for pymite

Dependents:   pymite pymite

Fork of TSI by Emilio Monti

Committer:
va009039
Date:
Sat Mar 16 13:26:46 2013 +0000
Revision:
3:b867dca5f810
Parent:
2:507b1f67804b
add TSI for KL25Z

Who changed what in which revision?

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