Sensor reporting over USB CDC

Dependencies:   MAG3110 MMA8451Q SLCD- TSI USBDevice mbed

Committer:
wue
Date:
Wed Apr 16 12:20:12 2014 +0000
Revision:
0:7b58cdacf811
Sensor reporting over USB CDC

Who changed what in which revision?

UserRevisionLine numberNew contents of line
wue 0:7b58cdacf811 1 /* Freescale Semiconductor Inc.
wue 0:7b58cdacf811 2 * (c) Copyright 2004-2005 Freescale Semiconductor, Inc.
wue 0:7b58cdacf811 3 * (c) Copyright 2001-2004 Motorola, Inc.
wue 0:7b58cdacf811 4 *
wue 0:7b58cdacf811 5 * mbed Microcontroller Library
wue 0:7b58cdacf811 6 * (c) Copyright 2009-2012 ARM Limited.
wue 0:7b58cdacf811 7 *
wue 0:7b58cdacf811 8 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
wue 0:7b58cdacf811 9 * and associated documentation files (the "Software"), to deal in the Software without
wue 0:7b58cdacf811 10 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
wue 0:7b58cdacf811 11 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
wue 0:7b58cdacf811 12 * Software is furnished to do so, subject to the following conditions:
wue 0:7b58cdacf811 13 *
wue 0:7b58cdacf811 14 * The above copyright notice and this permission notice shall be included in all copies or
wue 0:7b58cdacf811 15 * substantial portions of the Software.
wue 0:7b58cdacf811 16 *
wue 0:7b58cdacf811 17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
wue 0:7b58cdacf811 18 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
wue 0:7b58cdacf811 19 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
wue 0:7b58cdacf811 20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
wue 0:7b58cdacf811 21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
wue 0:7b58cdacf811 22 */
wue 0:7b58cdacf811 23
wue 0:7b58cdacf811 24 #ifndef TSISENSOR_H
wue 0:7b58cdacf811 25 #define TSISENSOR_H
wue 0:7b58cdacf811 26
wue 0:7b58cdacf811 27 /**
wue 0:7b58cdacf811 28 * TSISensor example
wue 0:7b58cdacf811 29 *
wue 0:7b58cdacf811 30 * @code
wue 0:7b58cdacf811 31 * #include "mbed.h"
wue 0:7b58cdacf811 32 * #include "TSISensor.h"
wue 0:7b58cdacf811 33 *
wue 0:7b58cdacf811 34 * int main(void) {
wue 0:7b58cdacf811 35 * PwmOut led(LED_GREEN);
wue 0:7b58cdacf811 36 * TSISensor tsi;
wue 0:7b58cdacf811 37 *
wue 0:7b58cdacf811 38 * while (true) {
wue 0:7b58cdacf811 39 * led = 1.0 - tsi.readPercentage();
wue 0:7b58cdacf811 40 * wait(0.1);
wue 0:7b58cdacf811 41 * }
wue 0:7b58cdacf811 42 * }
wue 0:7b58cdacf811 43 * @endcode
wue 0:7b58cdacf811 44 */
wue 0:7b58cdacf811 45 class TSISensor {
wue 0:7b58cdacf811 46 public:
wue 0:7b58cdacf811 47 /**
wue 0:7b58cdacf811 48 * Initialize the TSI Touch Sensor
wue 0:7b58cdacf811 49 */
wue 0:7b58cdacf811 50 TSISensor();
wue 0:7b58cdacf811 51
wue 0:7b58cdacf811 52 /**
wue 0:7b58cdacf811 53 * Read Touch Sensor percentage value
wue 0:7b58cdacf811 54 *
wue 0:7b58cdacf811 55 * @returns percentage value between [0 ... 1]
wue 0:7b58cdacf811 56 */
wue 0:7b58cdacf811 57 float readPercentage();
wue 0:7b58cdacf811 58
wue 0:7b58cdacf811 59 /**
wue 0:7b58cdacf811 60 * Read Touch Sensor distance
wue 0:7b58cdacf811 61 *
wue 0:7b58cdacf811 62 * @returns distance in mm. The value is between [0 ... 40]
wue 0:7b58cdacf811 63 */
wue 0:7b58cdacf811 64 uint8_t readDistance();
wue 0:7b58cdacf811 65 uint16_t readValue(uint8_t);
wue 0:7b58cdacf811 66 void TSISensor_reset(void);
wue 0:7b58cdacf811 67
wue 0:7b58cdacf811 68 private:
wue 0:7b58cdacf811 69 void sliderRead(void);
wue 0:7b58cdacf811 70 void selfCalibration(void);
wue 0:7b58cdacf811 71 };
wue 0:7b58cdacf811 72
wue 0:7b58cdacf811 73 #endif