docs(timer): use precise delay description in Timer Handler (#4235)
This commit is contained in:
@@ -29,10 +29,11 @@ Here is some pseudocode to illustrate the concept:
|
|||||||
void lvgl_thread(void)
|
void lvgl_thread(void)
|
||||||
{
|
{
|
||||||
while(1) {
|
while(1) {
|
||||||
|
uint32_t time_till_next;
|
||||||
mutex_lock(&lvgl_mutex);
|
mutex_lock(&lvgl_mutex);
|
||||||
lv_task_handler();
|
time_till_next = lv_task_handler();
|
||||||
mutex_unlock(&lvgl_mutex);
|
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`)
|
- timer interrupt periodically (lower priority than :cpp:func:`lv_tick_inc`)
|
||||||
- an OS task periodically
|
- an OS task periodically
|
||||||
|
|
||||||
The timing is not critical but it should be about 5 milliseconds to keep
|
|
||||||
the system responsive.
|
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
.. code:: c
|
.. code:: c
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
lv_timer_handler();
|
uint32_t time_till_next = lv_timer_handler();
|
||||||
my_delay_ms(5);
|
my_delay_ms(time_till_next);
|
||||||
}
|
}
|
||||||
|
|
||||||
If you want to use :cpp:func:`lv_timer_handler` in a super-loop, a helper
|
If you want to use :cpp:func:`lv_timer_handler` in a super-loop, a helper
|
||||||
@@ -30,9 +27,9 @@ the porting:
|
|||||||
.. code:: c
|
.. code:: c
|
||||||
|
|
||||||
while(1) {
|
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
|
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
|
.. code:: c
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
lv_timer_handler_run_in_period(5); /* run lv_timer_handler() every 5ms */
|
uint32_t time_till_next = lv_timer_handler();
|
||||||
my_delay_ms(5); /* delay 5ms to avoid unnecessary polling */
|
os_delay_ms(time_till_next); /* delay to avoid unnecessary polling */
|
||||||
}
|
}
|
||||||
|
|
||||||
To learn more about timers visit the `Timer </overview/timer>`__
|
To learn more about timers visit the `Timer </overview/timer>`__
|
||||||
|
|||||||
Reference in New Issue
Block a user