mirror of
https://github.com/lvgl/lvgl.git
synced 2026-05-22 23:37:43 +08:00
feat(docs): migrate from .md to .rst (#4129)
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
.. _timer:
|
||||
|
||||
=============
|
||||
Timer Handler
|
||||
=============
|
||||
|
||||
To handle the tasks of LVGL you need to call :cpp:func:`lv_timer_handler`
|
||||
periodically in one of the following:
|
||||
|
||||
- *while(1)* of *main()* function
|
||||
- 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);
|
||||
}
|
||||
|
||||
If you want to use :cpp:func:`lv_timer_handler` in a super-loop, a helper
|
||||
function :cpp:func:`lv_timer_handler_run_in_period` is provided to simplify
|
||||
the porting:
|
||||
|
||||
.. code:: c
|
||||
|
||||
while(1) {
|
||||
...
|
||||
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
|
||||
**sleep** provided by OS to release CPU whenever possible:
|
||||
|
||||
.. 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 */
|
||||
}
|
||||
|
||||
To learn more about timers visit the `Timer </overview/timer>`__
|
||||
section.
|
||||
|
||||
API
|
||||
***
|
||||
Reference in New Issue
Block a user