Revert STMPE610 touch driver

This commit is contained in:
fvanroie 2021-11-05 00:59:23 +01:00
parent ff8566c1a6
commit e625dc1e55
2 changed files with 27 additions and 50 deletions

View File

@ -23,67 +23,44 @@ extern uint8_t hasp_sleep_state;
#define TS_MINY 100 #define TS_MINY 100
#define TS_MAXY 3750 #define TS_MAXY 3750
// bool touch_read(lv_indev_drv_t* indev_driver, lv_indev_data_t* data) static Adafruit_STMPE610 stmpe610_touchpanel = Adafruit_STMPE610(TOUCH_CS);
// {
// data->state = LV_INDEV_STATE_REL;
// // while touched, but the state is released => read next point bool touch_read(lv_indev_drv_t* indev_driver, lv_indev_data_t* data)
// while(data->state == LV_INDEV_STATE_REL && stmpe610_touchpanel.touched()) { {
data->state = LV_INDEV_STATE_REL;
// TS_Point point = stmpe610_touchpanel.getPoint(); // while touched, but the state is released => read next point
// Log.trace(TAG_DRVR, F("STMPE610: x=%i y=%i z=%i"), point.x, point.y, point.z); while(data->state == LV_INDEV_STATE_REL && stmpe610_touchpanel.touched()) {
// if(point.z && point.x < 4096 && point.y < 4096) { // valid reading TS_Point point = stmpe610_touchpanel.getPoint();
// if(hasp_sleep_state != HASP_SLEEP_OFF) hasp_update_sleep_state(); // update Idle Log.trace(TAG_DRVR, F("STMPE610: x=%i y=%i z=%i"), point.x, point.y, point.z);
// data->state = LV_INDEV_STATE_PR;
// #if HX8357D_DRIVER == 1 if(point.z && point.x < 4096 && point.y < 4096) { // valid reading
// data->point.x = map(point.x, TS_MINX, TS_MAXX, TFT_WIDTH, 0); if(hasp_sleep_state != HASP_SLEEP_OFF) hasp_update_sleep_state(); // update Idle
// data->point.y = map(point.y, TS_MINY, TS_MAXY, 0, TFT_HEIGHT); data->state = LV_INDEV_STATE_PR;
// #else
// data->point.x = map(point.x, TS_MINX, TS_MAXX, 0, TFT_WIDTH);
// data->point.y = map(point.y, TS_MINY, TS_MAXY, 0, TFT_HEIGHT);
// #endif
// }
// }
// /*Return `false` because we are not buffering and no more data to read*/ #if HX8357D_DRIVER == 1
// return false; data->point.x = map(point.x, TS_MINX, TS_MAXX, TFT_WIDTH, 0);
// } data->point.y = map(point.y, TS_MINY, TS_MAXY, 0, TFT_HEIGHT);
#else
data->point.x = map(point.x, TS_MINX, TS_MAXX, 0, TFT_WIDTH);
data->point.y = map(point.y, TS_MINY, TS_MAXY, 0, TFT_HEIGHT);
#endif
}
}
/*Return `false` because we are not buffering and no more data to read*/
return false;
}
namespace dev { namespace dev {
class TouchStmpe610 : public BaseTouch { class TouchStmpe610 : public BaseTouch {
public: public:
Adafruit_STMPE610 stmpe610_touchpanel = Adafruit_STMPE610(TOUCH_CS);
IRAM_ATTR bool read(lv_indev_drv_t* indev_driver, lv_indev_data_t* data) IRAM_ATTR bool read(lv_indev_drv_t* indev_driver, lv_indev_data_t* data)
{ {
data->state = LV_INDEV_STATE_REL; return touch_read(indev_driver, data);
// while touched, but the state is released => read next point
while(data->state == LV_INDEV_STATE_REL && stmpe610_touchpanel.touched()) {
TS_Point point = stmpe610_touchpanel.getPoint();
Log.trace(TAG_DRVR, F("STMPE610: x=%i y=%i z=%i"), point.x, point.y, point.z);
if(point.z && point.x < 4096 && point.y < 4096) { // valid reading
if(hasp_sleep_state != HASP_SLEEP_OFF) hasp_update_sleep_state(); // update Idle
data->state = LV_INDEV_STATE_PR;
#if HX8357D_DRIVER == 1
data->point.x = map(point.x, TS_MINX, TS_MAXX, TFT_WIDTH, 0);
data->point.y = map(point.y, TS_MINY, TS_MAXY, 0, TFT_HEIGHT);
#else
data->point.x = map(point.x, TS_MINX, TS_MAXX, 0, TFT_WIDTH);
data->point.y = map(point.y, TS_MINY, TS_MAXY, 0, TFT_HEIGHT);
#endif
}
}
/*Return `false` because we are not buffering and no more data to read*/
return false;
} }
void init(int w, int h) void init(int w, int h)
@ -100,7 +77,7 @@ class TouchStmpe610 : public BaseTouch {
} // namespace dev } // namespace dev
using dev::TouchStmpe610; using dev::TouchStmpe610;
dev::TouchStmpe610 haspTouch; extern dev::TouchStmpe610 haspTouch;
#endif // ARDUINO #endif // ARDUINO

View File

@ -66,7 +66,7 @@ class TouchTftEspi : public BaseTouch {
} // namespace dev } // namespace dev
using dev::TouchTftEspi; using dev::TouchTftEspi;
extern dev::TouchTftEspi haspTouch; dev::TouchTftEspi haspTouch;
#endif // ARDUINO #endif // ARDUINO