mirror of
https://github.com/lvgl/lvgl.git
synced 2024-11-30 13:14:37 +08:00
docs(timer): use precise delay description in Timer Handler (#4235)
This commit is contained in:
parent
091141885a
commit
5f42ff115b
@ -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 */
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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 </overview/timer>`__
|
||||
|
Loading…
Reference in New Issue
Block a user