Skip to content

Commit

Permalink
Improve pulldown selection reliability (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajs123 authored Apr 15, 2024
1 parent b53c308 commit 6c7427c
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions lv_touch_calibration/lv_tc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}
}

0 comments on commit 6c7427c

Please sign in to comment.