From 6c7427c8033c3c848123882c97ef0018f9588730 Mon Sep 17 00:00:00 2001 From: ajs123 Date: Mon, 15 Apr 2024 01:04:00 -0400 Subject: [PATCH] Improve pulldown selection reliability (#77) --- lv_touch_calibration/lv_tc.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/lv_touch_calibration/lv_tc.c b/lv_touch_calibration/lv_tc.c index cde010d..82e4101 100644 --- a/lv_touch_calibration/lv_tc.c +++ b/lv_touch_calibration/lv_tc.c @@ -140,14 +140,22 @@ void lv_tc_compute_coeff(lv_point_t *scrP, lv_point_t *tchP, bool save) { //Th #endif } +static lv_point_t last_pressed_point = {0,0}; +static lv_indev_state_t last_state = 0; lv_point_t _lv_tc_transform_point_indev(lv_indev_data_t *data) { - if(data->state == LV_INDEV_STATE_PRESSED || data->state == LV_INDEV_STATE_RELEASED) { + if(data->state == LV_INDEV_STATE_PRESSED) { + // Pressed - just return coordinates + last_pressed_point = data->point; + last_state = data->state; return lv_tc_transform_point(data->point); - } else { - //Reject invalid points if the touch panel is in released state - lv_point_t point = {0, 0}; - return point; + } else if(data->state == LV_INDEV_STATE_RELEASED && last_state == LV_INDEV_STATE_PRESSED) { + // Released - ensure reporting of coordinates where the touch was last seen + last_state = data->state; + return lv_tc_transform_point(last_pressed_point); } + // Invalid state + lv_point_t point = {0, 0}; + return point; } lv_point_t lv_tc_transform_point(lv_point_t point) { @@ -196,4 +204,4 @@ static void lv_tc_indev_drv_read_cb(lv_indev_drv_t *indevDrv, lv_indev_data_t *d } data->point = _lv_tc_transform_point_indev(data); -} \ No newline at end of file +}