Introduce touch offset (#69)

This commit is contained in:
Ken Van Hoeylandt 2024-11-03 22:51:02 +01:00 committed by GitHub
parent 28c456e2d9
commit c11d63ef2d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -8,12 +8,18 @@
extern "C" {
#endif
/**
* Touch seems to be offset by a certain amount.
* The docs don't mention it, so this is the estimated value.
*/
#define TOUCH_Y_OFFSET 16
static void read_touch(TT_UNUSED lv_indev_t* indev, lv_indev_data_t* data) {
lgfx::touch_point_t point; // Making it static makes it unreliable
bool touched = M5.Lcd.getTouch(&point) > 0;
if (touched) {
data->point.x = point.x;
data->point.y = point.y;
data->point.y = point.y - TOUCH_Y_OFFSET;
data->state = LV_INDEV_STATE_PRESSED;
} else {
data->state = LV_INDEV_STATE_RELEASED;