File tree Expand file tree Collapse file tree 2 files changed +13
-6
lines changed Expand file tree Collapse file tree 2 files changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -272,22 +272,22 @@ void BraccioClass::motors_connected_thread() {
272
272
}
273
273
274
274
int BraccioClass::getKey () {
275
- if (digitalRead (BTN_LEFT) == LOW ) {
275
+ if (isJoystickPressed_LEFT () ) {
276
276
return 1 ;
277
277
}
278
- if (digitalRead (BTN_RIGHT) == LOW ) {
278
+ if (isJoystickPressed_RIGHT () ) {
279
279
return 2 ;
280
280
}
281
- if (digitalRead (BTN_SEL) == LOW ) {
281
+ if (isJoystickPressed_SELECT () ) {
282
282
return 3 ;
283
283
}
284
- if (digitalRead (BTN_UP) == LOW ) {
284
+ if (isJoystickPressed_UP () ) {
285
285
return 4 ;
286
286
}
287
- if (digitalRead (BTN_DOWN) == LOW ) {
287
+ if (isJoystickPressed_DOWN () ) {
288
288
return 5 ;
289
289
}
290
- if (digitalRead (BTN_ENTER) == LOW ) {
290
+ if (isButtonPressed_ENTER () ) {
291
291
return 6 ;
292
292
}
293
293
return 0 ;
Original file line number Diff line number Diff line change @@ -146,6 +146,13 @@ class BraccioClass
146
146
int getKey ();
147
147
void connectJoystickTo (lv_obj_t * obj);
148
148
149
+ inline bool isJoystickPressed_LEFT () { return (digitalRead (BTN_LEFT) == LOW); }
150
+ inline bool isJoystickPressed_RIGHT () { return (digitalRead (BTN_RIGHT) == LOW); }
151
+ inline bool isJoystickPressed_SELECT () { return (digitalRead (BTN_SEL) == LOW); }
152
+ inline bool isJoystickPressed_UP () { return (digitalRead (BTN_UP) == LOW); }
153
+ inline bool isJoystickPressed_DOWN () { return (digitalRead (BTN_DOWN) == LOW); }
154
+ inline bool isButtonPressed_ENTER () { return (digitalRead (BTN_ENTER) == LOW); }
155
+
149
156
TFT_eSPI gfx = TFT_eSPI();
150
157
151
158
bool ping_allowed = true ;
You can’t perform that action at this time.
0 commit comments