KL25Z TSI library
Dependents: AccelerometerLedTsiDemo NRF24L01_sender TouchButton Wi-Go_IOT_Demo ... more
Fork of TSI by
TSISensor.h
00001 /* Freescale Semiconductor Inc. 00002 * (c) Copyright 2004-2005 Freescale Semiconductor, Inc. 00003 * (c) Copyright 2001-2004 Motorola, Inc. 00004 * 00005 * mbed Microcontroller Library 00006 * (c) Copyright 2009-2012 ARM Limited. 00007 * 00008 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 00009 * and associated documentation files (the "Software"), to deal in the Software without 00010 * restriction, including without limitation the rights to use, copy, modify, merge, publish, 00011 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the 00012 * Software is furnished to do so, subject to the following conditions: 00013 * 00014 * The above copyright notice and this permission notice shall be included in all copies or 00015 * substantial portions of the Software. 00016 * 00017 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 00018 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00019 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 00020 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00021 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00022 */ 00023 00024 #ifndef TSISENSOR_H 00025 #define TSISENSOR_H 00026 00027 /** 00028 * TSISensor example 00029 * 00030 * @code 00031 * #include "mbed.h" 00032 * #include "TSISensor.h" 00033 * 00034 * int main(void) { 00035 * PwmOut led(LED_GREEN); 00036 * TSISensor tsi; 00037 * 00038 * while (true) { 00039 * led = 1.0 - tsi.readPercentage(); 00040 * wait(0.1); 00041 * } 00042 * } 00043 * @endcode 00044 */ 00045 class TSISensor { 00046 public: 00047 /** 00048 * Initialize the TSI Touch Sensor 00049 */ 00050 TSISensor(); 00051 00052 /** 00053 * Read Touch Sensor percentage value 00054 * 00055 * @returns percentage value between [0 ... 1] 00056 */ 00057 float readPercentage(); 00058 00059 /** 00060 * Read Touch Sensor distance 00061 * 00062 * @returns distance in mm. The value is between [0 ... 40] 00063 */ 00064 uint8_t readDistance(); 00065 00066 private: 00067 void sliderRead(void); 00068 void selfCalibration(void); 00069 }; 00070 00071 #endif
Generated on Wed Jul 13 2022 10:20:22 by 1.7.2