good

Dependencies:   mbed

Fork of BX-car by Clark Lin

Committer:
even
Date:
Wed Jun 25 05:59:29 2014 +0000
Revision:
11:ffd762ae141b
Parent:
9:33b99cb45e99
1st PID complete

Who changed what in which revision?

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