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