feat(porting): add a macro lv_run_timer_handler_in_period to simplify porting (#3063)

* feat(porting): add a macro lv_run_timer_handler_in_period to simplify porting

* feat: update helper function and doc

* doc(porting): update function names

* revise to the original os.md

* fix: fix typo

* fix: mitigate warnings
This commit is contained in:
Gabriel Wang
2022-02-07 20:10:12 +00:00
committed by GitHub
parent 9e1b789fb3
commit 796f0c0b4e
2 changed files with 38 additions and 0 deletions

View File

@@ -19,5 +19,24 @@ while(1) {
}
```
If you intend to use `lv_timer_handler()` in a super-loop, a helper function`lv_run_timer_handler_in_period(__ms)` is provided to simplify the porting:
```c
while(1) {
...
lv_timer_handler_run_period(5); /* run lv_timer_handler() every 5ms */
...
}
```
In OS environment, you can use it together with the delay or sleep provided by OS:
```c
while (1) {
lv_timer_handler_run_in_period(5); /* run lv_timer_handler() every 5ms */
sleep(5); /* sleep 5ms */
}
```
To learn more about timers visit the [Timer](/overview/timer) section.