@@ -28,10 +28,12 @@ static const char * btnm_map[] = { "RECORD", "\n", "REPLAY", "\n", "ZERO_POSITIO
28
28
29
29
30
30
static void eventHandlerMenu (lv_event_t * e) {
31
+ Braccio.lvgl_lock ();
31
32
lv_event_code_t code = lv_event_get_code (e);
32
33
lv_obj_t * obj = lv_event_get_target (e);
33
34
34
35
if (code == LV_EVENT_KEY && lv_indev_get_key (lv_indev_get_act ()) == LV_KEY_HOME) {
36
+ Braccio.lvgl_unlock ();
35
37
state = ZERO_POSITION;
36
38
return ;
37
39
}
@@ -94,9 +96,12 @@ static void eventHandlerMenu(lv_event_t * e) {
94
96
break ;
95
97
}
96
98
}
99
+ Braccio.lvgl_unlock ();
97
100
}
98
101
99
- void mainMenu () {
102
+ void mainMenu ()
103
+ {
104
+ Braccio.lvgl_lock ();
100
105
static lv_style_t style_focus;
101
106
lv_style_init (&style_focus);
102
107
lv_style_set_outline_color (&style_focus, lv_color_hex (COLOR_ORANGE));
@@ -128,6 +133,7 @@ void mainMenu() {
128
133
lv_obj_align (counter, LV_ALIGN_CENTER, 0 , 80 );
129
134
130
135
lv_obj_add_event_cb (btnm, eventHandlerMenu, LV_EVENT_ALL, NULL );
136
+ Braccio.lvgl_unlock ();
131
137
132
138
Braccio.connectJoystickTo (btnm);
133
139
}
@@ -150,8 +156,10 @@ void loop() {
150
156
if (sample_cnt >= MAX_SAMPLES) {
151
157
state = ZERO_POSITION;
152
158
Serial.println (" ZERO_POSITION" );
159
+ Braccio.lvgl_lock ();
153
160
btnm_map[0 ] = " RECORD" ; // reset the label of the first button back to "RECORD"
154
161
lv_btnmatrix_set_btn_ctrl (btnm, 0 , LV_BTNMATRIX_CTRL_CHECKABLE);
162
+ Braccio.lvgl_unlock ();
155
163
}
156
164
/* Capture those samples. */
157
165
Braccio.positions (idx);
@@ -165,12 +173,16 @@ void loop() {
165
173
if (idx >= final_idx) {
166
174
Serial.println (" REPLAY done" );
167
175
state = ZERO_POSITION;
176
+ Braccio.lvgl_lock ();
168
177
btnm_map[2 ] = " REPLAY" ; // reset the label of the first button back to "REPLAY"
169
178
lv_btnmatrix_set_btn_ctrl (btnm, 2 , LV_BTNMATRIX_CTRL_CHECKED);
179
+ Braccio.lvgl_unlock ();
170
180
}
171
181
}
172
182
delay (100 );
173
183
if (state != ZERO_POSITION) {
184
+ Braccio.lvgl_lock ();
174
185
lv_label_set_text_fmt (counter, " Counter: %d" , (sample_cnt / 6 ));
186
+ Braccio.lvgl_unlock ();
175
187
}
176
188
}
0 commit comments