@@ -246,6 +246,39 @@ void setup()
246
246
}
247
247
248
248
void loop ()
249
+ {
250
+ /* Execute every 10 ms. */
251
+ {
252
+ static auto prev = millis ();
253
+ auto const now = millis ();
254
+ if ((now - prev) > 10 )
255
+ {
256
+ prev = now;
257
+ handle_ButtonPressedReleased ();
258
+ }
259
+ }
260
+
261
+ /* Execute every 100 ms. */
262
+ {
263
+ static auto prev = millis ();
264
+ auto const now = millis ();
265
+ if ((now - prev) > 100 )
266
+ {
267
+ prev = now;
268
+
269
+ if (Braccio.isJoystickPressed_UP ())
270
+ app.update (Button::Up);
271
+ if (Braccio.isJoystickPressed_DOWN ())
272
+ app.update (Button::Down);
273
+ if (Braccio.isJoystickPressed_LEFT ())
274
+ app.update (Button::Left);
275
+ if (Braccio.isJoystickPressed_RIGHT ())
276
+ app.update (Button::Right);
277
+ }
278
+ }
279
+ }
280
+
281
+ void handle_ButtonPressedReleased ()
249
282
{
250
283
/* ENTER */
251
284
@@ -312,23 +345,6 @@ void loop()
312
345
handle_OnButtonRightReleased ();
313
346
}
314
347
prev_joystick_pressed_right = curr_joystick_pressed_right;
315
-
316
-
317
- static auto prev = millis ();
318
- auto const now = millis ();
319
- if ((now - prev) > 100 )
320
- {
321
- prev = now;
322
-
323
- if (Braccio.isJoystickPressed_UP ())
324
- app.update (Button::Up);
325
- if (Braccio.isJoystickPressed_DOWN ())
326
- app.update (Button::Down);
327
- if (Braccio.isJoystickPressed_LEFT ())
328
- app.update (Button::Left);
329
- if (Braccio.isJoystickPressed_RIGHT ())
330
- app.update (Button::Right);
331
- }
332
348
}
333
349
334
350
void handle_OnButtonDownPressed ()
0 commit comments