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