Scrolling down lists in a menu is not smooth


I am trying to create a list in a menu and traverse through it using a rotary encoder. Whenever I try to scroll to the item beyond the end of the screen, the whole screen refreshes and the transition doesn’t look smooth.

What MCU/Processor/Board and compiler are you using?

STM32L4 series custom board, GNU ARM compiler.

The display is interfaced with STM using SPI.

What LVGL version are you using?

LVGL 9.0

What do you want to achieve?

Smoother transition among list items

What have you tried so far?

Changed the refresh period.
Increased the frame buffer size
Increased SPI baud rate

Code to reproduce

    lv_obj_t *menu = lv_menu_create(lv_scr_act());
lv_obj_set_size(menu, lv_disp_get_hor_res(NULL), lv_disp_get_ver_res(NULL));

lv_obj_t *cont;
lv_obj_t *label;
lv_obj_t *menuProgListBtn1;
lv_obj_t *menuProgListBtn2;
lv_obj_t *menuProgListBtn3;
lv_obj_t *menuProgListBtn4;
lv_obj_t *menuProgListBtn5;
lv_obj_t *menuProgListBtn6;
lv_group_t *menuProgListGrp;

/*Create a sub page*/
lv_obj_t *sub_page = lv_menu_page_create(menu, NULL);

cont = lv_menu_cont_create(sub_page);
label = lv_label_create(cont);
lv_label_set_text(label, "Hello, I am hiding here");

/*Create a main page*/
lv_obj_t *main_page = lv_menu_page_create(menu, NULL);

cont = lv_menu_cont_create(main_page);
menuProgListBtn1 = lv_list_add_btn(cont, NULL, "Item1");
lv_obj_set_height(menuProgListBtn1, 30);

cont = lv_menu_cont_create(main_page);
menuProgListBtn2 = lv_list_add_btn(cont, NULL, "Item2");
lv_obj_set_height(menuProgListBtn2, 30);

cont = lv_menu_cont_create(main_page);
menuProgListBtn3 = lv_list_add_btn(cont, NULL, "Item3");
lv_obj_set_height(menuProgListBtn3, 30);

cont = lv_menu_cont_create(main_page);
menuProgListBtn4 = lv_list_add_btn(cont, NULL, "Item4");
lv_obj_set_height(menuProgListBtn4, 30);

cont = lv_menu_cont_create(main_page);
menuProgListBtn5 = lv_list_add_btn(cont, NULL, "Item5");
lv_obj_set_height(menuProgListBtn5, 30);

cont = lv_menu_cont_create(main_page);
menuProgListBtn6 = lv_list_add_btn(cont, NULL, "Item6");
lv_obj_set_height(menuProgListBtn6, 30);

lv_menu_set_load_page_event(menu, cont, sub_page);

lv_menu_set_page(menu, main_page);

menuProgListGrp = lv_group_create();

lv_group_add_obj(menuProgListGrp, menuProgListBtn1);
lv_group_add_obj(menuProgListGrp, menuProgListBtn2);
lv_group_add_obj(menuProgListGrp, menuProgListBtn3);
lv_group_add_obj(menuProgListGrp, menuProgListBtn4);
lv_group_add_obj(menuProgListGrp, menuProgListBtn5);
lv_group_add_obj(menuProgListGrp, menuProgListBtn6);

lv_indev_set_group(encoder_indev, menuProgListGrp);
encoder_indev->proc.wait_until_release = 1;

lv_obj_add_event_cb(menuProgListBtn1, menuEventHandler, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(menuProgListBtn2, menuEventHandler, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(menuProgListBtn3, menuEventHandler, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(menuProgListBtn4, menuEventHandler, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(menuProgListBtn5, menuEventHandler, LV_EVENT_ALL, NULL);
lv_obj_add_event_cb(menuProgListBtn6, menuEventHandler, LV_EVENT_ALL, NULL);

Attaching a zipped video of the same. (3.4 MB)


SPI baud?
And SPI is worse type of lcd connection…

I know modifying lvlg source really should be the last step, and is possibly another root cause of your issue.

BUT I have myself the same “issue” on a less powerful MCU and the patch I found for lvgl 8, probably is similar to lvgl 9 is to change that line to LV_ANIM_OFF. It will remove the animation when scrolling making it looks smoother.

1 Like

Thanks jakkra! It works. Looks a lot better now.

Can I have a look at your source code?I have the same needs.How to implement menuEventHandler?