@@ -81,6 +81,7 @@ BraccioClass::BraccioClass()
81
81
, _lvgl_draw_buf{}
82
82
, _lvgl_p_obj_group{nullptr }
83
83
, _lvgl_kb_indev{nullptr }
84
+ , _display_mtx{}
84
85
, _display_thd{}
85
86
, _pd_events{}
86
87
, _pd_timer{}
@@ -238,6 +239,7 @@ int BraccioClass::getKey() {
238
239
239
240
void BraccioClass::connectJoystickTo (lv_obj_t * obj)
240
241
{
242
+ mbed::ScopedLock<rtos::Mutex> lock (_display_mtx);
241
243
lv_group_add_obj (_lvgl_p_obj_group, obj);
242
244
lv_indev_set_group (_lvgl_kb_indev, _lvgl_p_obj_group);
243
245
}
@@ -409,31 +411,40 @@ void BraccioClass::lvgl_init()
409
411
410
412
void BraccioClass::display_thread_func ()
411
413
{
412
- for (;;)
414
+ for (;; delay (LV_DISP_DEF_REFR_PERIOD) )
413
415
{
416
+ mbed::ScopedLock<rtos::Mutex> lock (_display_mtx);
414
417
lv_task_handler ();
415
418
lv_tick_inc (LV_DISP_DEF_REFR_PERIOD);
416
- delay (LV_DISP_DEF_REFR_PERIOD);
417
419
}
418
420
}
419
421
420
422
void BraccioClass::lvgl_splashScreen (unsigned long const duration_ms)
421
423
{
422
424
extern const lv_img_dsc_t img_bulb_gif;
425
+ lv_obj_t * img = nullptr ;
423
426
424
- LV_IMG_DECLARE (img_bulb_gif);
425
- lv_obj_t * img = lv_gif_create (lv_scr_act ());
426
- lv_gif_set_src (img, &img_bulb_gif);
427
- lv_obj_align (img, LV_ALIGN_CENTER, 0 , 0 );
427
+ {
428
+ mbed::ScopedLock<rtos::Mutex> lock (_display_mtx);
429
+ LV_IMG_DECLARE (img_bulb_gif);
430
+ img = lv_gif_create (lv_scr_act ());
431
+ lv_gif_set_src (img, &img_bulb_gif);
432
+ lv_obj_align (img, LV_ALIGN_CENTER, 0 , 0 );
433
+ }
428
434
429
435
/* Wait until the splash screen duration is over. */
430
436
for (unsigned long const start = millis (); millis () - start < duration_ms; delay (10 )) { }
431
437
432
- lv_obj_del (img);
438
+ {
439
+ mbed::ScopedLock<rtos::Mutex> lock (_display_mtx);
440
+ lv_obj_del (img);
441
+ }
433
442
}
434
443
435
444
void BraccioClass::lvgl_pleaseConnectPower ()
436
445
{
446
+ mbed::ScopedLock<rtos::Mutex> lock (_display_mtx);
447
+
437
448
lv_style_set_text_font (&_lv_style, &lv_font_montserrat_32);
438
449
lv_obj_t * label1 = lv_label_create (lv_scr_act ());
439
450
lv_obj_add_style (label1, &_lv_style, 0 );
@@ -445,7 +456,8 @@ void BraccioClass::lvgl_pleaseConnectPower()
445
456
446
457
void BraccioClass::lvgl_defaultMenu ()
447
458
{
448
- // TODO: create a meaningful default menu
459
+ mbed::ScopedLock<rtos::Mutex> lock (_display_mtx);
460
+
449
461
lv_style_set_text_font (&_lv_style, &lv_font_montserrat_32);
450
462
lv_obj_t * label1 = lv_label_create (lv_scr_act ());
451
463
lv_obj_add_style (label1, &_lv_style, 0 );
0 commit comments