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