48 lines
1 KiB
C++
48 lines
1 KiB
C++
#include <FS.h>
|
|
|
|
#ifndef _TOUCH_CONTROLLERWSH_
|
|
#define _TOUCH_CONTROLLERWSH_
|
|
|
|
#ifdef TOUCH_CS
|
|
#include <Adafruit_STMPE610.h>
|
|
#else // use I2C
|
|
#include <Adafruit_TSC2007.h>
|
|
#endif
|
|
|
|
typedef void (*CalibrationCallback)(int16_t x, int16_t y);
|
|
|
|
class TouchControllerWS {
|
|
public:
|
|
#if defined(TOUCH_CS)
|
|
TouchControllerWS(Adafruit_STMPE610 *touchScreen);
|
|
#else
|
|
TouchControllerWS(Adafruit_TSC2007 *touchScreen);
|
|
#endif
|
|
bool loadCalibration();
|
|
bool saveCalibration();
|
|
void startCalibration(CalibrationCallback *callback);
|
|
void continueCalibration();
|
|
bool isCalibrationFinished();
|
|
bool isTouched();
|
|
bool isTouched(int16_t debounceMillis);
|
|
TS_Point getPoint();
|
|
|
|
private:
|
|
#if defined(TOUCH_CS)
|
|
Adafruit_STMPE610 *touchScreen;
|
|
#else
|
|
Adafruit_TSC2007 *touchScreen;
|
|
#endif
|
|
float dx = 0.0;
|
|
float dy = 0.0;
|
|
int ax = 0;
|
|
int ay = 0;
|
|
int state = 0;
|
|
long lastStateChange = 0;
|
|
long lastTouched = 0;
|
|
CalibrationCallback *calibrationCallback;
|
|
TS_Point p1, p2;
|
|
|
|
};
|
|
|
|
#endif
|