I did a search and it seems like a lot of people are using this menu that I am posting, possible because its not too difficult. Like others I am going to give it a shot. The one question I have is how to add a bool selection for the second entry. Everything the author has are int values, but I would like to add one int and one bool value that allows a Yes or No entry.
On this line below I have an int, the other entry "Auto Run" how can I get that selection to toggle to either Yes or No? Or even have both Yes and No on the same line and toggle over to select which one I want. Appreicate some help, thanks.
i.e
Auto Run (toggle to yes/no)
No
or
Auto Run (move over to select entry)
Yes No
I have no clue on what to change to make this happen or if its even possible. Appreciate any help as menus are not easy to understand.
String screens[numOfScreens][2] = {{"Motor Voltage","Volts"}, {"Auto Run", ""}};
#include <LiquidCrystal.h>
LiquidCrystal lcd(6, 7, 5, 4, 3, 2);
//Input & Button Logic
const int numOfInputs = 2;
const int inputPins[numOfInputs] = {2,3};
int inputState[numOfInputs];
int lastInputState[numOfInputs] = {LOW,LOW};
bool inputFlags[numOfInputs] = {LOW,LOW};
long lastDebounceTime[numOfInputs] = {0,0};
long debounceDelay = 5;
//LCD Menu Logic
const int numOfScreens = ;
int currentScreen = 0;
String screens[numOfScreens][2] = {{"Motor Voltage","Volts"}, {"Auto Run", ""}};
int parameters[numOfScreens];
void setup() {
for(int i = 0; i < numOfInputs; i++) {
pinMode(inputPins[i], INPUT);
digitalWrite(inputPins[i], HIGH); // pull-up 20k
}
//Serial.begin(9600);
lcd.begin(16, 2);
}
void loop() {
setInputFlags();
resolveInputFlags();
}
void setInputFlags() {
for(int i = 0; i < numOfInputs; i++) {
int reading = digitalRead(inputPins[i]);
if (reading != lastInputState[i]) {
lastDebounceTime[i] = millis();
}
if ((millis() - lastDebounceTime[i]) > debounceDelay) {
if (reading != inputState[i]) {
inputState[i] = reading;
if (inputState[i] == HIGH) {
inputFlags[i] = HIGH;
}
}
}
lastInputState[i] = reading;
}
}
void resolveInputFlags() {
for(int i = 0; i < numOfInputs; i++) {
if(inputFlags[i] == HIGH) {
inputAction(i);
inputFlags[i] = LOW;
printScreen();
}
}
}
void inputAction(int input) {
if(input == 0) {
if (currentScreen == 0) {
currentScreen = numOfScreens-1;
}else{
currentScreen--;
}
}else if(input == 1) {
if (currentScreen == numOfScreens-1) {
currentScreen = 0;
}else{
currentScreen++;
}
}else if(input == 2) {
parameterChange(0);
}else if(input == 3) {
parameterChange(1);
}
}
void parameterChange(int key) {
if(key == 0) {
parameters[currentScreen]++;
}else if(key == 1) {
parameters[currentScreen]--;
}
}
void printScreen() {
lcd.clear();
lcd.print(screens[currentScreen][0]);
lcd.setCursor(0,1);
lcd.print(parameters[currentScreen]);
lcd.print(" ");
lcd.print(screens[currentScreen][1]);
}