diff --git a/docs/porting/os.rst b/docs/porting/os.rst index 3948617b6..0fb95b0d4 100644 --- a/docs/porting/os.rst +++ b/docs/porting/os.rst @@ -29,10 +29,11 @@ Here is some pseudocode to illustrate the concept: void lvgl_thread(void) { while(1) { + uint32_t time_till_next; mutex_lock(&lvgl_mutex); - lv_task_handler(); + time_till_next = lv_task_handler(); mutex_unlock(&lvgl_mutex); - thread_sleep(10); /* sleep for 10 ms */ + thread_sleep(time_till_next); /* sleep for a while */ } } diff --git a/docs/porting/timer_handler.rst b/docs/porting/timer_handler.rst index b65b2d3ad..db0a4a907 100644 --- a/docs/porting/timer_handler.rst +++ b/docs/porting/timer_handler.rst @@ -11,16 +11,13 @@ periodically in one of the following: - timer interrupt periodically (lower priority than :cpp:func:`lv_tick_inc`) - an OS task periodically -The timing is not critical but it should be about 5 milliseconds to keep -the system responsive. - Example: .. code:: c while(1) { - lv_timer_handler(); - my_delay_ms(5); + uint32_t time_till_next = lv_timer_handler(); + my_delay_ms(time_till_next); } If you want to use :cpp:func:`lv_timer_handler` in a super-loop, a helper @@ -30,9 +27,9 @@ the porting: .. code:: c while(1) { - ... - lv_timer_handler_run_in_period(5); /* run lv_timer_handler() every 5ms */ - ... + ... + lv_timer_handler_run_in_period(5); /* run lv_timer_handler() every 5ms */ + ... } In an OS environment, you can use it together with the **delay** or @@ -41,8 +38,8 @@ In an OS environment, you can use it together with the **delay** or .. code:: c while (1) { - lv_timer_handler_run_in_period(5); /* run lv_timer_handler() every 5ms */ - my_delay_ms(5); /* delay 5ms to avoid unnecessary polling */ + uint32_t time_till_next = lv_timer_handler(); + os_delay_ms(time_till_next); /* delay to avoid unnecessary polling */ } To learn more about timers visit the `Timer `__