Scroll debouncing


I’m working on a small project using an ESP32 and an ILI9341 display with touchscreen. I encountered the fact that when I press the screen for a long time on an object that can scroll, I sometimes get a reaction in the form of content twitching. This is even more noticeable if LV_OBJ_FLAG_SCROLL_ELASTIC is enabled. I sometimes get the same effect with a short touch.

Investigation of this problem revealed that the touchpad, when pressed, may return coordinates with some bounce. This leads to scrolling starting even if the coordinate has changed by 1 pixel.

To solve this problem, I added a small threshold of 5 pixels to the lv_indev_scroll module. If the change in coordinates is less than this threshold, then scrolling does not begin.

void _lv_indev_scroll_handler(_lv_indev_proc_t * proc)
    if(proc->types.pointer.vect.x == 0 && proc->types.pointer.vect.y == 0) {
    lv_obj_t * scroll_obj = proc->types.pointer.scroll_obj;
    /*If there is no scroll object yet try to find one*/
    if(scroll_obj == NULL) {
    	// debouncing treshold for start scroll
    	if(abs(proc->types.pointer.vect.x) <= 5 && abs(proc->types.pointer.vect.y) <= 5) {

Perhaps there is some other solution in LVGL, but I did not find it. It will be interesting to know if anyone has encountered such a problem and how they solved it.