Use `lv_refr_now` instead of `lv_task_handler`

Hello LVGL Team,

In my project, I use LVGL v7.11 with ZephyrRTOS.
I only update the screen when needed, I don’t use animation nor lv_tasks.

So roughly here is how things are connected:

void some_app_function()
{
   refresh_statusbar(BATTERY, 50);
}

void refresh_statusbar(refresh_type, data)
{
    switch(refresh_type)
   {
   case BATTERY:
      /* some lvgl obj calls */
      break;
   case CHARGER:
      /* some lvgl obj calls */
      break;
   case TIME:
      /* some lvgl obj calls */
      break;
   }

   lv_task_handler();
}

refresh_statusbar() is called from different other contexts, sometimes this function could be called in less than 5ms to 10ms and in this case lv_task_handler() just return LV_NO_TASK_READYand screen is not updated.

Replacing lv_task_handler() with lv_refr_now(NULL) make things work flawlessly.

My question is would it be okay to use lv_refr_now(NULL) instead of lv_task_handler() in my use case ?
or better to change LV_DISP_DEF_REFR_PERIOD to be like 1ms ?

If you use lv_refr_now(NULL) directly you might have refresh calls e.g. 100 times per second (realistically probably much less as the rendering time limits how often you can call a new lv_refr_now(NULL)).

If it’s not a problem, that using lv_refr_now(NULL) is fine. If it’s a problem, you need to implement a timer-like mechanism to refresh the screen only e.g. after 30ms, but it’s the same as what lv_task_handler does. :slight_smile:

Thanks for your answer.
to give you more insights
On boot up lv_refr_now(NULL) could be called like 10 times but then it will be only when screen requires update which may happen at seconds interval. so it is far away from getting called even every 10ms.

It seems fine for me!