Skip to content

Commit 85daef7

Browse files
committed
Adding lvgl_lock/lvgl_unlock to the Braccio example sketches.
1 parent 702770b commit 85daef7

File tree

4 files changed

+25
-4
lines changed

4 files changed

+25
-4
lines changed

examples/Braccio_Basic/Braccio_Basic.ino

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ bool move_joint = false;
3333

3434
static void event_handler(lv_event_t * e)
3535
{
36+
Braccio.lvgl_lock();
3637
lv_event_code_t code = lv_event_get_code(e);
3738
lv_obj_t * obj = lv_event_get_target(e);
3839
if (code == LV_EVENT_CLICKED)
@@ -46,15 +47,19 @@ static void event_handler(lv_event_t * e)
4647
if (strcmp(txt, "Move") == 0)
4748
move_joint = !move_joint;
4849
}
50+
Braccio.lvgl_unlock();
4951
}
5052

5153
void customMenu()
5254
{
55+
Braccio.lvgl_lock();
5356
lv_obj_t * btnm1 = lv_btnmatrix_create(lv_scr_act());
5457
lv_btnmatrix_set_map(btnm1, btnm_map);
5558
lv_btnmatrix_set_btn_ctrl(btnm1, 0, LV_BTNMATRIX_CTRL_CHECKABLE);
5659
lv_obj_align(btnm1, LV_ALIGN_CENTER, 0, 0);
5760
lv_obj_add_event_cb(btnm1, event_handler, LV_EVENT_ALL, NULL);
61+
Braccio.lvgl_unlock();
62+
5863
Braccio.connectJoystickTo(btnm1);
5964
}
6065

examples/LCD_Custom_Menu/LCD_Custom_Menu.ino

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,13 @@ static const char * btnm_map[] = {"Option 1", "\n",
2828
* FUNCTIONS
2929
**************************************************************************************/
3030

31-
void customMenu(){
31+
void customMenu()
32+
{
33+
Braccio.lvgl_lock();
3234
lv_obj_t * btnm1 = lv_btnmatrix_create(lv_scr_act());
3335
lv_btnmatrix_set_map(btnm1, btnm_map);
3436
lv_obj_align(btnm1, LV_ALIGN_CENTER, MARGIN_LEFT, MARGIN_TOP);
37+
Braccio.lvgl_unlock();
3538
}
3639

3740
/**************************************************************************************

examples/LCD_Menu_Joystick/LCD_Menu_Joystick.ino

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ static const char * btnm_map[] = {"Option 1", "Option 2", "\n",
3030
* FUNCTIONS
3131
**************************************************************************************/
3232

33-
static void event_handler(lv_event_t * e){
33+
static void event_handler(lv_event_t * e)
34+
{
35+
Braccio.lvgl_lock();
3436
lv_event_code_t code = lv_event_get_code(e);
3537
lv_obj_t * obj = lv_event_get_target(e);
3638
if (code == LV_EVENT_CLICKED) {
@@ -40,9 +42,12 @@ static void event_handler(lv_event_t * e){
4042
LV_LOG_USER("%s was pressed\n", txt);
4143
Serial.println(String(txt) + " was pressed.");
4244
}
45+
Braccio.lvgl_unlock();
4346
}
4447

45-
void customMenu(){
48+
void customMenu()
49+
{
50+
Braccio.lvgl_lock();
4651
lv_obj_t * btnm1 = lv_btnmatrix_create(lv_scr_act());
4752
lv_btnmatrix_set_map(btnm1, btnm_map);
4853
lv_btnmatrix_set_btn_ctrl(btnm1, 0, LV_BTNMATRIX_CTRL_CHECKABLE);
@@ -53,6 +58,8 @@ void customMenu(){
5358
lv_btnmatrix_set_btn_ctrl(btnm1, 5, LV_BTNMATRIX_CTRL_CHECKABLE);
5459
lv_obj_align(btnm1, LV_ALIGN_CENTER, MARGIN_LEFT, MARGIN_TOP);
5560
lv_obj_add_event_cb(btnm1, event_handler, LV_EVENT_ALL, NULL);
61+
Braccio.lvgl_unlock();
62+
5663
Braccio.connectJoystickTo(btnm1);
5764
}
5865

examples/LCD_Motors/LCD_Motors.ino

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ static const char * btnm_map[] = {"Motor 1", "Motor 2", "\n",
3232

3333
static void event_handler(lv_event_t * e)
3434
{
35+
Braccio.lvgl_lock();
3536
lv_event_code_t code = lv_event_get_code(e);
3637
lv_obj_t * obj = lv_event_get_target(e);
3738
if (code == LV_EVENT_CLICKED) {
@@ -63,9 +64,12 @@ static void event_handler(lv_event_t * e)
6364
selected_motor = 0;
6465
}
6566
}
67+
Braccio.lvgl_unlock();
6668
}
6769

68-
void customMenu() {
70+
void customMenu()
71+
{
72+
Braccio.lvgl_lock();
6973
lv_obj_t * btnm1 = lv_btnmatrix_create(lv_scr_act());
7074
lv_btnmatrix_set_map(btnm1, btnm_map);
7175
lv_btnmatrix_set_btn_ctrl(btnm1, 0, LV_BTNMATRIX_CTRL_CHECKABLE);
@@ -76,6 +80,8 @@ void customMenu() {
7680
lv_btnmatrix_set_btn_ctrl(btnm1, 5, LV_BTNMATRIX_CTRL_CHECKABLE);
7781
lv_obj_align(btnm1, LV_ALIGN_CENTER, 0, 0);
7882
lv_obj_add_event_cb(btnm1, event_handler, LV_EVENT_ALL, NULL);
83+
Braccio.lvgl_unlock();
84+
7985
Braccio.connectJoystickTo(btnm1);
8086
}
8187

0 commit comments

Comments
 (0)