Hi everyone,
I'm creating a menu for my project to help my it look more intuitive. I'm using a GLCD with a u8g2 library, the menu is as seen in the picture attached.
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
char key;
void setup(){
Serial.begin(9600);
u8g2.begin();
startup();
}
void loop(){
key = keypad.getKey();// Read the key
if(key)
Serial.print(key);
// Print if key pressed
switch(key)
{
case 'A' :
InHouse();
break;
case 'B':
refGUI();
break;
}
}
void startup(){
u8g2.clearBuffer(); // clear the internal memory
u8g2.setFont(u8g2_font_6x10_tf); // choose a suitable font
u8g2.drawStr(30,7,"STARTING..."); // write something to the internal memory
u8g2.sendBuffer(); // transfer internal memory to the display
/*
* Put the SYSRESET* code here so the addresses will load in the background
*/
delay(1500);
u8g2.clearBuffer();
u8g2.setFont(u8g2_font_6x10_tf); // choose a suitable font
u8g2.drawStr(0,7,"Select Mode:"); // write something to the internal memory
u8g2.drawStr(0,24,"(A) GUI"); // write something to the internal memory
u8g2.drawStr(0,32,"(B) Project Mode"); // write something to the internal memory
u8g2.sendBuffer(); // transfer internal memory to the display
return;
}
void InHouse(){
u8g2.clearBuffer(); // clear the internal memory
u8g2.setFont(u8g2_font_6x10_tf); // choose a suitable font
u8g2.drawStr(0,7,"Project Selcted."); // write something to the internal memory
u8g2.sendBuffer();
delay(1500);
u8g2.clearBuffer();
u8g2.setFont(u8g2_font_6x10_tf); // choose a suitable font
u8g2.drawStr(0,7,"Select Mode:"); // write something to the internal memory
u8g2.drawStr(0,24,"(A) Automatic"); // write something to the internal memory
u8g2.drawStr(0,32,"(B) Manual"); // write something to the internal memory
u8g2.drawStr(0,40,"(C) Back"); // write something to the internal memory
u8g2.sendBuffer(); // transfer internal memory to the display
delay(250);
while(key = keypad.getKey())
switch(key){
case 'A':
AutoRefer();
break;
case 'B':
ManualRefer();
break;
}
}
void refGUI(){
u8g2.clearBuffer(); // clear the internal memory
u8g2.setFont(u8g2_font_6x10_tf); // choose a suitable font
u8g2.drawStr(0,7,"Continue On PC "); // write something to the internal memory
u8g2.sendBuffer();
//Put the required code to transfer data to the GUI application
}
The problem is that once the Arduino starts and the program is loaded, the only part that works in the menu is the first part in the void loop, that selects between the Arduino mode or GUI. I tried to make another loop inside of the "InHouse" function, that will wait until a key is presses in the keypad and then will go to the switch case statement.
I tried using "if... else.." method but it faced the same problem; Stucked in the first selection choice.
Can anyone help me get in to the second selection choice? (also i'm quit new so go easy on me
)

