A compilation of some hardware sensors and their shared programming interfaces.

Committer:
mgottscho
Date:
Wed Mar 19 00:35:31 2014 +0000
Revision:
1:15396cab58d1
Parent:
0:8d34cc2ff388
Updated for most recent UtilityLib.

Who changed what in which revision?

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