neu-rah / ArduinoMenu

Arduino generic menu/interactivity system
GNU Lesser General Public License v2.1
934 stars 189 forks source link

btnNav example not working with HW buttons #282

Open jiritusla opened 4 years ago

jiritusla commented 4 years ago

Found with btnNav.ino commit 989951e7d51e036a156a0d7f0f042369b85f8bcc ArduinoMenu version: 4.19.0 Tested with Arduino Nano

Steps to reproduce:

  1. Copy btnNav.ino of given revision to Arduino IDE
  2. Compile and Upload to Arduino
  3. Open serial monitor -> you should see menu printed 3.1 if menu is not visible in serial monitor, just reset arduino
  4. press any of three buttons connected between pins 6,7 or 8 and GND.
  5. nothing happens in serial monitor

Proposed example change:

diff --git a/examples/btnNav/btnNav/btnNav.ino b/examples/btnNav/btnNav/btnNav.ino
index 70d5653..18f048b 100644
--- a/examples/btnNav/btnNav/btnNav.ino
+++ b/examples/btnNav/btnNav/btnNav.ino
@@ -8,7 +8,7 @@ Digital keypad (3 buttons) using the menu keyIn driver
 #include <menu.h>
 #include <menuIO/serialIn.h>
 #include <menuIO/serialOut.h>
-#include <menuIO/altKeyIn.h>
+#include <menuIO/keyIn.h>
 #include <menuIO/chainStream.h>

 using namespace Menu;
@@ -109,9 +109,9 @@ MENU(mainMenu,"Main menu",doNothing,noEvent,wrapStyle
 );

 keyMap joystickBtn_map[]={
- {-BTN_SEL, defaultNavCodes[enterCmd].ch,INPUT_PULLUP} ,
- {-BTN_UP, defaultNavCodes[upCmd].ch,INPUT_PULLUP} ,
- {-BTN_DOWN, defaultNavCodes[downCmd].ch,INPUT_PULLUP}  ,
+ {-BTN_SEL, defaultNavCodes[enterCmd].ch} ,
+ {-BTN_UP, defaultNavCodes[upCmd].ch} ,
+ {-BTN_DOWN, defaultNavCodes[downCmd].ch}  ,
 };
 keyIn<3> joystickBtns(joystickBtn_map);

After applying this change it works as expected.