From 3409b73d2b7d0a7aa333a4c7e01941e32a07254a Mon Sep 17 00:00:00 2001 From: Stephan Hadinger Date: Fri, 7 May 2021 18:25:55 +0200 Subject: [PATCH] Fix press detection --- tasmota/xdrv_52_3_berry_lvgl.ino | 16 +++++++++++----- tasmota/xdsp_17_universal.ino | 2 +- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/tasmota/xdrv_52_3_berry_lvgl.ino b/tasmota/xdrv_52_3_berry_lvgl.ino index 9cd0da91a..45404392c 100644 --- a/tasmota/xdrv_52_3_berry_lvgl.ino +++ b/tasmota/xdrv_52_3_berry_lvgl.ino @@ -727,13 +727,19 @@ extern "C" { } bool lvbe_touch_screen_read(lv_indev_drv_t * drv, lv_indev_data_t*data){ + static int16_t prev_x = 0; + static int16_t prev_y = 0; int16_t touchpad_x, touchpad_y; - int32_t touched; + int32_t touchpad_press; - if (udisp_ReadTouch(&touchpad_x, &touchpad_y, &touched)) { - data->point.x = touchpad_x; - data->point.y = touchpad_y; - data->state = touched ? LV_INDEV_STATE_PR : LV_INDEV_STATE_REL; + if (udisp_ReadTouch(&touchpad_x, &touchpad_y, &touchpad_press)) { + if (touchpad_press) { + prev_x = touchpad_x; + prev_y = touchpad_y; + } + data->point.x = prev_x; + data->point.y = prev_y; + data->state = touchpad_press ? LV_INDEV_STATE_PR : LV_INDEV_STATE_REL; } return false; // no more event in buffer } diff --git a/tasmota/xdsp_17_universal.ino b/tasmota/xdsp_17_universal.ino index 828d56628..7bc758a48 100644 --- a/tasmota/xdsp_17_universal.ino +++ b/tasmota/xdsp_17_universal.ino @@ -384,7 +384,7 @@ bool udisp_ReadTouch(int16_t * _x, int16_t * _y, int32_t * _touched) { // read from xdrv_55_touch.ino if (_x) { *_x = touch_xp; } if (_y) { *_y = touch_yp; } - if (touched) { *_touched = touched; } + if (_touched) { *_touched = touched ? 1 : 0; } return true; #else return false;