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