A 5-wire resistive touch screen controller.
ResistiveTouchController.hpp
- Committer:
- Generic
- Date:
- 2016-10-08
- Revision:
- 2:a4ebeb3ba49c
- Parent:
- 1:51bde7ae4a65
- Child:
- 3:3e240b27bd4a
File content as of revision 2:a4ebeb3ba49c:
#ifndef RESISTIVE_TOUCH_CONTROLLER_HPP #define RESISTIVE_TOUCH_CONTROLLER_HPP //-- Macros for calibration function #define X_T1 t[0][0] #define X_T2 t[1][0] #define X_T3 t[2][0] #define Y_T1 t[0][1] #define Y_T2 t[1][1] #define Y_T3 t[2][1] #define X_D1 d[0][0] #define X_D2 d[1][0] #define X_D3 d[2][0] #define Y_D1 d[0][1] #define Y_D2 d[1][1] #define Y_D3 d[2][1] #include "mbed.h" class ResistiveTouchController { public: ResistiveTouchController(PinName ur, PinName lr, PinName s, PinName ul, PinName ll, int num_of_samples = 5, float settle = 0.002); int TouchDetected(); void Measure(); float RawX(); float RawY(); float X(); float Y(); void Calibrate(float t[3][2], float d[3][2]); void SetSettleTime(float settle); private: DigitalInOut _UR; DigitalInOut _LR; PinName _S; DigitalInOut _UL; DigitalInOut _LL; Timer _delayTimer; float _settle; static const char DETECT_MODE = 1; static const char X_MODE = 2; static const char Y_MODE = 3; float A,B,C,D,E,F; float _xt, _yt; int _samples; void ConfigPins(char mode); float MeasureS(); void Delay(float time); }; #endif