Introduce touch offset (#69)
This commit is contained in:
parent
28c456e2d9
commit
c11d63ef2d
@ -8,12 +8,18 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#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) {
|
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
|
lgfx::touch_point_t point; // Making it static makes it unreliable
|
||||||
bool touched = M5.Lcd.getTouch(&point) > 0;
|
bool touched = M5.Lcd.getTouch(&point) > 0;
|
||||||
if (touched) {
|
if (touched) {
|
||||||
data->point.x = point.x;
|
data->point.x = point.x;
|
||||||
data->point.y = point.y;
|
data->point.y = point.y - TOUCH_Y_OFFSET;
|
||||||
data->state = LV_INDEV_STATE_PRESSED;
|
data->state = LV_INDEV_STATE_PRESSED;
|
||||||
} else {
|
} else {
|
||||||
data->state = LV_INDEV_STATE_RELEASED;
|
data->state = LV_INDEV_STATE_RELEASED;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user