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