「App:Library:LVGL:docs:Porting:Operating system and interrupts」の版間の差分
59行目: | 59行目: | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
+ | | | ||
+ | |} | ||
+ | :[[App:Library:LVGL:docs:Porting|戻る : Previous]] | ||
+ | |||
== Interrupts == | == Interrupts == | ||
+ | {| class="wikitable" | ||
+ | !英文 | ||
+ | !自動翻訳 | ||
+ | |- | ||
+ | | | ||
Try to avoid calling LVGL functions from interrupt handlers (except <code style="color: #bb0000;">lv_tick_inc()</code> and <code style="color: #bb0000;">lv_disp_flush_ready()</code>). But if you need to do this you have to disable the interrupt which uses LVGL functions while <code style="color: #bb0000;">lv_timer_handler</code> is running. | Try to avoid calling LVGL functions from interrupt handlers (except <code style="color: #bb0000;">lv_tick_inc()</code> and <code style="color: #bb0000;">lv_disp_flush_ready()</code>). But if you need to do this you have to disable the interrupt which uses LVGL functions while <code style="color: #bb0000;">lv_timer_handler</code> is running. | ||
It's a better approach to simply set a flag or some value in the interrupt, and periodically check it in an LVGL timer (which is run by <code style="color: #bb0000;">lv_timer_handler</code>). | It's a better approach to simply set a flag or some value in the interrupt, and periodically check it in an LVGL timer (which is run by <code style="color: #bb0000;">lv_timer_handler</code>). | ||
− | + | | | |
− | + | |} | |
− | + | :[[App:Library:LVGL:docs:Porting|戻る : Previous]] | |
− | |||
− | |||
− | |||
− | |||
− | [[App:Library:LVGL:docs:Porting|戻る : Previous]] |
2022年6月22日 (水) 14:37時点における版
https://docs.lvgl.io/8.2/porting/os.html
英文 | 自動翻訳 |
---|---|
Operating system and interrupts
LVGL is not thread-safe by default.
However, in the following conditions it's valid to call LVGL related functions:
- In events. Learn more in Events.
- In lv_timer. Learn more in Timers.
Tasks and threads
英文 | 自動翻訳 |
---|---|
If you need to use real tasks or threads, you need a mutex which should be invoked before the call of Here is some pseudocode to illustrate the concept: static mutex_t lvgl_mutex;
void lvgl_thread(void)
{
while(1) {
mutex_lock(&lvgl_mutex);
lv_task_handler();
mutex_unlock(&lvgl_mutex);
thread_sleep(10); /* sleep for 10 ms */
}
}
void other_thread(void)
{
/* You must always hold the mutex while using LVGL APIs */
mutex_lock(&lvgl_mutex);
lv_obj_t *img = lv_img_create(lv_scr_act());
mutex_unlock(&lvgl_mutex);
while(1) {
mutex_lock(&lvgl_mutex);
/* change to the next image */
lv_img_set_src(img, next_image);
mutex_unlock(&lvgl_mutex);
thread_sleep(2000);
}
}
|
Interrupts
英文 | 自動翻訳 |
---|---|
Try to avoid calling LVGL functions from interrupt handlers (except It's a better approach to simply set a flag or some value in the interrupt, and periodically check it in an LVGL timer (which is run by |