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