summaryrefslogtreecommitdiff
path: root/lib/lvgl/docs/porting/timer_handler.rst
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2024-06-12 17:54:40 +1000
committerjacqueline <me@jacqueline.id.au>2024-06-12 17:54:40 +1000
commit64bd9053a25297f7a442ca831c7da5b44bd33f84 (patch)
treea90c6cad25a12028302ab1a5334510fba0229bae /lib/lvgl/docs/porting/timer_handler.rst
parent611176ed667c4ed7ee9f609e958f9404f4aee91d (diff)
downloadtangara-fw-64bd9053a25297f7a442ca831c7da5b44bd33f84.tar.gz
Update LVGL to v9.1.0
Diffstat (limited to 'lib/lvgl/docs/porting/timer_handler.rst')
-rw-r--r--lib/lvgl/docs/porting/timer_handler.rst59
1 files changed, 59 insertions, 0 deletions
diff --git a/lib/lvgl/docs/porting/timer_handler.rst b/lib/lvgl/docs/porting/timer_handler.rst
new file mode 100644
index 00000000..1a40a62f
--- /dev/null
+++ b/lib/lvgl/docs/porting/timer_handler.rst
@@ -0,0 +1,59 @@
+.. _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
+
+Example:
+
+.. code:: c
+
+ while(1) {
+ 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
+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 */
+ ...
+ }
+
+Or use the sleep time automatically calculated by LVGL:
+
+.. code:: c
+
+ while(1) {
+ ...
+ lv_timer_periodic_handler();
+ ...
+ }
+
+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) {
+ 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 :ref:`timer`
+section.
+
+API
+***