KL25Z TSI library

Dependents:   AirMouse FRDM_Deco KL25Z_DCF77_HY-1_8LCD FRDM_TSI ... more

Committer:
samux
Date:
Thu Oct 11 14:00:48 2012 +0000
Revision:
1:4dd9262cac47
Child:
2:507b1f67804b
add license - rename files/methods

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"
samux 1:4dd9262cac47 33 *
samux 1:4dd9262cac47 34 * int main(void) {
samux 1:4dd9262cac47 35 * DigitalOut led(LED_GREEN);
samux 1:4dd9262cac47 36 * TSISensor tsi;
samux 1:4dd9262cac47 37 *
samux 1:4dd9262cac47 38 * while (true) {
samux 1:4dd9262cac47 39 * printf("slider percentage: %f%\r\n", tsi.readPercentage());
samux 1:4dd9262cac47 40 * printf("slider distance: %dmm\r\n", tsi.readDistance());
samux 1:4dd9262cac47 41 * wait(1);
samux 1:4dd9262cac47 42 * led = !led;
samux 1:4dd9262cac47 43 * }
samux 1:4dd9262cac47 44 * }
samux 1:4dd9262cac47 45 * @endcode
samux 1:4dd9262cac47 46 */
samux 1:4dd9262cac47 47 class TSISensor {
samux 1:4dd9262cac47 48 public:
samux 1:4dd9262cac47 49 /**
samux 1:4dd9262cac47 50 * Initialize the TSI Touch Sensor
samux 1:4dd9262cac47 51 */
samux 1:4dd9262cac47 52 TSISensor();
samux 1:4dd9262cac47 53
samux 1:4dd9262cac47 54 /**
samux 1:4dd9262cac47 55 * Read Touch Sensor percentage value
samux 1:4dd9262cac47 56 *
samux 1:4dd9262cac47 57 * @returns percentage value between [0 ... 1]
samux 1:4dd9262cac47 58 */
samux 1:4dd9262cac47 59 float readPercentage();
samux 1:4dd9262cac47 60
samux 1:4dd9262cac47 61 /**
samux 1:4dd9262cac47 62 * Read Touch Sensor distance
samux 1:4dd9262cac47 63 *
samux 1:4dd9262cac47 64 * @returns distance in mm. The value is between [0 ... 40]
samux 1:4dd9262cac47 65 */
samux 1:4dd9262cac47 66 uint8_t readDistance();
samux 1:4dd9262cac47 67
samux 1:4dd9262cac47 68 private:
samux 1:4dd9262cac47 69 void sliderRead(void);
samux 1:4dd9262cac47 70 void selfCalibration(void);
samux 1:4dd9262cac47 71 };
samux 1:4dd9262cac47 72
samux 1:4dd9262cac47 73 #endif