acid-drop- Hacking the planet from a LilyGo T-Deck using custom firmware |
git clone git://git.acid.vegas/acid-drop.git |
Log | Files | Refs | Archive | README | LICENSE |
timer-handler.md (1169B)
1 ```eval_rst 2 .. include:: /header.rst 3 :github_url: |github_link_base|/porting/timer-handler.md 4 ``` 5 # Timer Handler 6 7 To handle the tasks of LVGL you need to call `lv_timer_handler()` periodically in one of the following: 8 - *while(1)* of *main()* function 9 - timer interrupt periodically (lower priority than `lv_tick_inc()`) 10 - an OS task periodically 11 12 The timing is not critical but it should be about 5 milliseconds to keep the system responsive. 13 14 Example: 15 ```c 16 while(1) { 17 lv_timer_handler(); 18 my_delay_ms(5); 19 } 20 ``` 21 22 If you want to use `lv_timer_handler()` in a super-loop, a helper function`lv_timer_handler_run_in_period()` is provided to simplify the porting: 23 24 ```c 25 while(1) { 26 ... 27 lv_timer_handler_run_in_period(5); /* run lv_timer_handler() every 5ms */ 28 ... 29 } 30 ``` 31 32 In an OS environment, you can use it together with the **delay** or **sleep** provided by OS to release CPU whenever possible: 33 34 ```c 35 while (1) { 36 lv_timer_handler_run_in_period(5); /* run lv_timer_handler() every 5ms */ 37 my_delay_ms(5); /* delay 5ms to avoid unnecessary polling */ 38 } 39 ``` 40 41 To learn more about timers visit the [Timer](/overview/timer) section. 42