neu-rah / ArduinoMenu

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

Problem with keyIn #399

Closed behi88 closed 1 year ago

behi88 commented 1 year ago

Hello friends, I have problem with simple Key Input and LCD program

CPU: ESP32 Dev Module Display: Nokia 5110 LCD with U8G2 library Inputs: Push button switches with external 10K pullup resistors compiler: Arduino IDE 1.8.13

the Menu Displays Fine But the keys are all wrong and the menus jump randomly and one the keys is not working at all I try to de-bounce the keys by hardware but the result was the same I also connect an alternative pins but no luck I test the pins with a test program and the they are working fine and there is no hardware problem I change the input to serial mode and in serial mode the inputs works fine!

any ideas? this id my code: `#include

include

include <menuIO/u8g2Out.h>

include <menuIO/chainStream.h>

include <menuIO/serialOut.h>

include <menuIO/serialIn.h>

include <menuIO/keyIn.h>

include

using namespace Menu;

define LCD_CS 13

define LCD_DC 27

define LCD_RS 14

define LCD_CL 25

define LCD_DA 26

define LCD_BL 15

define BTN_SEL 23

define BTN_UP 0

define BTN_DOWN 5

define fontName u8g2_font_6x13_tf

define fontX 6

define fontY 13

define offsetX 1

define offsetY 1

define LCD_Width 84

define LCD_Height 48

define MAX_DEPTH 2

const colorDef colors[6] MEMMODE={ {{0,0},{0,1,1}},//bgColor {{1,1},{1,0,0}},//fgColor {{1,1},{1,0,0}},//valColor {{1,1},{1,0,0}},//unitColor {{0,1},{0,0,1}},//cursorColor {{1,1},{1,0,0}},//titleColor };

U8G2_PCD8544_84X48_F_4W_HW_SPI u8g2(U8G2_R0,LCD_CS,LCD_DC,LCD_RS); //U8G2_PCD8544_84X48_F_4W_SW_SPI u8g2(U8G2_R2,LCD_CL,LCD_DA,LCD_CS,LCD_DC,LCD_RS);

keyMap joystickBtn_map[]= { {-BTN_SEL, defaultNavCodes[enterCmd].ch} , {-BTN_UP, defaultNavCodes[upCmd].ch} , {-BTN_DOWN, defaultNavCodes[downCmd].ch} };

keyIn<3> joystickBtns(joystickBtn_map);

menuIn* inputsList[]={&joystickBtns}; chainStream<1> in(inputsList); MENU_OUTPUTS(out,MAX_DEPTH,U8G2_OUT(u8g2,colors,fontX,fontY,offsetX,offsetY,{0,0,LCD_Width/fontX,LCD_Height/fontY}),NONE);

int chooseTest=1; CHOOSE(chooseTest,chooseMenu,"Number",doNothing,noEvent,noStyle ,VALUE("1",1,doNothing,noEvent) ,VALUE("2",2,doNothing,noEvent) ,VALUE("3",3,doNothing,noEvent) ,VALUE("4",4,doNothing,noEvent) ,VALUE("5",5,doNothing,noEvent) ,VALUE("6",6,doNothing,noEvent) ,VALUE("7",7,doNothing,noEvent) ,VALUE("8",8,doNothing,noEvent) ,VALUE("9",9,doNothing,noEvent) );

int chooseTest2=1; CHOOSE(chooseTest2,chooseMenu2,"Alph",doNothing,noEvent,noStyle ,VALUE("A",1,doNothing,noEvent) ,VALUE("B",2,doNothing,noEvent) ,VALUE("C",3,doNothing,noEvent) ,VALUE("D",4,doNothing,noEvent) ,VALUE("E",5,doNothing,noEvent) ,VALUE("F",6,doNothing,noEvent) ,VALUE("G",7,doNothing,noEvent) );

MENU(mainMenu,"Main menu",doNothing,noEvent,wrapStyle ,SUBMENU(chooseMenu) ,SUBMENU(chooseMenu2) ,EXIT("<Exit") );

NAVROOT(nav,mainMenu,MAX_DEPTH,in,out);

//when menu is suspended result idle(menuOut& o,idleEvent e) { o.clear(); switch(e) { case idleStart:o.println("suspending menu!");break; case idling:o.println("suspended...");break; case idleEnd:o.println("resuming menu.");break; } return proceed; } void setup() { Serial.begin(115200); SPI.begin(LCD_CL,-1,LCD_DA,-1); u8g2.begin(); u8g2.setFont(fontName); joystickBtns.begin(); nav.idleTask=idle; } void loop() { while(true) { nav.doInput(); if (nav.changed(0)) { u8g2.firstPage(); do nav.doOutput(); while(u8g2.nextPage()); } delay(100); } } `

UPDATE: sorry I find the problem! the problem id GPIO0 that could have a problem with used as INPUT. I am closing the issue :)