@@ -178,26 +178,7 @@ void loop()
178
178
179
179
if (state == State::RECORD)
180
180
{
181
- /* Check if we still have space for samples. */
182
- if (sample_cnt >= MAX_SAMPLES)
183
- {
184
- state = State::ZERO_POSITION;
185
- replay_cnt = 0 ;
186
- Braccio.lvgl_lock ();
187
- btnm_map[0 ] = " RECORD" ; // reset the label of the first button back to "RECORD"
188
- lv_btnmatrix_set_btn_ctrl (btnm, 0 , LV_BTNMATRIX_CTRL_CHECKABLE);
189
- Braccio.lvgl_unlock ();
190
- }
191
- else
192
- {
193
- /* Capture those samples. */
194
- Braccio.positions (values + sample_cnt);
195
- sample_cnt += 6 ;
196
- }
197
-
198
- Braccio.lvgl_lock ();
199
- lv_label_set_text_fmt (counter, " Counter: %d" , (sample_cnt / 6 ));
200
- Braccio.lvgl_unlock ();
181
+ state = handle_RECORD ();
201
182
}
202
183
203
184
if (state == State::REPLAY)
@@ -226,3 +207,36 @@ void loop()
226
207
}
227
208
}
228
209
}
210
+
211
+ /* *************************************************************************************
212
+ * FUNCTION DEFINITIONS
213
+ **************************************************************************************/
214
+
215
+ State handle_RECORD ()
216
+ {
217
+ /* Check if we still have space for samples. */
218
+ if (sample_cnt >= MAX_SAMPLES)
219
+ {
220
+ replay_cnt = 0 ;
221
+
222
+ Braccio.lvgl_lock ();
223
+ btnm_map[0 ] = " RECORD" ; // reset the label of the first button back to "RECORD"
224
+ lv_btnmatrix_set_btn_ctrl (btnm, 0 , LV_BTNMATRIX_CTRL_CHECKABLE);
225
+ Braccio.lvgl_unlock ();
226
+
227
+ return State::ZERO_POSITION;
228
+ }
229
+ else
230
+ {
231
+ /* Capture those samples. */
232
+ Braccio.positions (values + sample_cnt);
233
+ sample_cnt += 6 ;
234
+
235
+ /* Update sample counter. */
236
+ Braccio.lvgl_lock ();
237
+ lv_label_set_text_fmt (counter, " Counter: %d" , (sample_cnt / 6 ));
238
+ Braccio.lvgl_unlock ();
239
+
240
+ return State::RECORD;
241
+ }
242
+ }
0 commit comments