A question about the basic main loop, again

Hi. I am new to lvgl.

The included examples, even the “get started” ones, do not include the main loop. There was a question here about the main loop, but it does not seem to work in v9.

I have read somewhere that LVGL needs to know the time, and so I wrote the basic main loop as follows:

uint32_t now_ms = to_ms_since_boot(get_absolute_time());

while(1) {
    uint32_t new_ms = to_ms_since_boot(get_absolute_time());
    lv_tick_inc(new_ms - now_ms);
    now_ms = new_ms;        
    lv_timer_handler();
    sleep_ms(5);
}

but it makes the touch events queue up and lag if there is about twenty of them or more per second, even with sleep_ms(1) (Pico 2, only one button on the screen).

This doc page contains a broken link to what could possibly be useful here.

Note: I use the RTOS-specific yielding sleep and I know that for precision, lv_tick_inc should be in an interupt, but I wanted to keep the code minimal here.

Hi,
use timer interrupt to generate interrupt every 1ms to handle lv_tick_inc()
Also, make sure not to use blocking delay for lv_timer_handler(). Each 3 ms will give your decent performance.