Scroll a page to the bottom in a task?


Hi, I have a stream of text coming from the serial port and I have a task to update the text periodically. Some of the text streams are larger than the page size so I would like it to be scrolled to the bottom of the page.

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

ESP-32 nodeMCU-32s

What LVGL version are you using?


What do you want to achieve?

scroll the page to bottom in a task.

What have you tried so far?

I have tried adding lv_page_scroll_ver(page, -10000); in my refresh task but it seems to freeze my whole program.

Code to reproduce

my refresh function:

void refr_func(lv_task_t * task)
    lv_label_set_text(label, testStr2);
    lv_page_scroll_ver(page, -10000);//scroll to the bottom, program freezes if this line is present 

You should probably check whether or not you are at the bottom before you call lv_page_scroll_ver using if( lv_page_on_edge( page, LV_PAGE_EDGE_BOTTOM ) == false)
Also, be aware that if you have animations enabled a call to lv_page_scroll_ver will construct an animation. To keep animations enabled, i.e. to use them elsewhere, you can circumvent this by using

lv_obj_t* scrl = lv_page_get_scrollable( page );
lv_obj_set_y( scrl, lv_obj_get_y( scrl ) - 10000 );

in place of lv_page_scroll_ver

1 Like

That is an excellent suggestion many thanks!