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() {
272272}
273273
274274int BraccioClass::getKey () {
275- if (digitalRead (BTN_LEFT) == LOW ) {
275+ if (isJoystickPressed_LEFT () ) {
276276 return 1 ;
277277 }
278- if (digitalRead (BTN_RIGHT) == LOW ) {
278+ if (isJoystickPressed_RIGHT () ) {
279279 return 2 ;
280280 }
281- if (digitalRead (BTN_SEL) == LOW ) {
281+ if (isJoystickPressed_SELECT () ) {
282282 return 3 ;
283283 }
284- if (digitalRead (BTN_UP) == LOW ) {
284+ if (isJoystickPressed_UP () ) {
285285 return 4 ;
286286 }
287- if (digitalRead (BTN_DOWN) == LOW ) {
287+ if (isJoystickPressed_DOWN () ) {
288288 return 5 ;
289289 }
290- if (digitalRead (BTN_ENTER) == LOW ) {
290+ if (isButtonPressed_ENTER () ) {
291291 return 6 ;
292292 }
293293 return 0 ;
Original file line number Diff line number Diff line change @@ -146,6 +146,13 @@ class BraccioClass
146146 int getKey ();
147147 void connectJoystickTo (lv_obj_t * obj);
148148
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+
149156 TFT_eSPI gfx = TFT_eSPI();
150157
151158 bool ping_allowed = true ;
You can’t perform that action at this time.
0 commit comments