Ok so heres some rough coding i knocket together this evening, Its not pretty, its probably not effiecent but its what first came to mind for me that worked.
its just the various "menu" screens or cases, i need to somehow interface the button pad coding into this exisiting coding.
oh and if your wondering why theres 2 of everything its because one has an asterix "*" at the end, this is the way i decided to show which option is "selected".
i looked at the Display blink tutorial in the arduino folders and would like to have a blinking cursor at the end instead of using a asterix but i figured if i used the delay method it used then i could see problems with how the program runs.
its not much but you get the idea.
next step is implimenting the actual keypad. i wrote psudo code in each method sawing what i want to happen when each butten is pressed.
#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);//delares the LCD Pins for the liquidCrystal library methods.
int x = 0;//Used for testing purposes to show the LED strength
int menuOption = 3;//used for the Switch statement, each menu has its own value,
int tankTemp = 25;//used for testing purposes, in real build this value with come from a temp probe
int timeHour = 12;//used for testing purposes, in real build RTC wil give this value
int timeMinute = 30;//used for testing purposes, in real build RTC wil give this value
//-----------------------------------------------------
void setup() {//ran once AKA welcome screen
lcd.begin(16, 2);//sets the LCD screen dimentions up
lcd.print(" Reef Minder ");
lcd.setCursor(0,1);
lcd.print("by Luke V1.00");
delay(5000);
lcd.clear();
}
//-----------------------------------------------------
void loop() {
switch(menuOption){//loads each menu depending on what value "menuOption" has at the start of the loop.
case 1: mainMenuOneOne();break;
case 2: mainMenuOneTwo();break;
case 3: mainMenuTwoOne();break;
case 4: mainMenuTwoTwo();break;
case 5: setIntensityOne();break;
case 6: setIntensityTwo();break;
case 7: setIntensityThree();break;
case 8: setLightsOne();break;
case 9: setLightsTwo();break;
case 10: setTimePeriodOne();break;
case 11: setTimePeriodTwo();break;
default: idleMenu();break;
}
}
//-----------------------------------------------------
void idleMenu(){//case 0
//this is the idle screen which will be the ran as default, when the user hasnt pressed anything, after X amount of time if the user hasnt pressed anything load this menuOption
lcd.setCursor(0,0);
lcd.print("Temp:"); lcd.print(tankTemp); lcd.print("*C ");//temp half, top line
lcd.print(timeHour); lcd.print(":"); lcd.print(timeMinute);// time half, top line
lcd.setCursor(0,1);
lcd.print("WHT:");lcd.print(x);lcd.print(" BLU:");lcd.print(x);
if(x <100){//used in testing, real value will come from the led's/set by the user in the SET intensity menu option
x++;
delay(5000);
lcd.clear();
}
//If any button pressed, load mainMenuOne()/ menuOption = 1;
}
//-----------------------------------------------------
void mainMenuOneOne(){ //case 1
//main menu,
lcd.setCursor(0,0);
lcd.print("1.SET LIGHTS *");
lcd.setCursor(0,1);
lcd.print("2.VIEW PERAMS");
lcd.setCursor(0,0);
/*if V pressed load menuOptionOneTwo();
if ^ pressed do nothing
if < pressed load idleMenu()/ menuOption = 0;
if > pressed load setLightsOne();/ menuOption = 8;
if * pressed load setLightsOne();/ menuOption = 9;
*/
}
void mainMenuOneTwo(){ //case 2
//main menu,
lcd.setCursor(0,0);
lcd.print("1.SET LIGHTS");
lcd.setCursor(0,1);
lcd.print("2.VIEW PERAMS *");
lcd.setCursor(0,0);
/*if V pressed load menuOptionTwoOne()/menuOption = 3;
if ^ pressed load menuOptionOneOne()/menuOption = 2;
if < pressed load idleMenu()/menuOption = 0;
if > pressed load viewPerams(); not coded yet
if * pressed load viewPerams(); not coded yet
*/
}
void mainMenuTwoOne(){// case 3
lcd.setCursor(0,0);
lcd.print("3.BLANK *");
//flashing pixel
lcd.setCursor(0,1);
lcd.print("4.BLANK");
lcd.setCursor(0,0);
/*if V pressed load menuOptionTwoTwo()/menuOption = 4;
if ^ pressed load menuOptionOneTwo()/menuOption = 2;
if < pressed load idleMenu()/menuOption = 0;
if > pressed load 3rd menu;/not coded yet
if * pressed load 3rd menu()/not coded yet
*/
}
void mainMenuTwoTwo(){// case 4
lcd.setCursor(0,0);
lcd.print("3.BLANK");
lcd.setCursor(0,1);
lcd.print("4.BLANK *");
//flashing pixel
lcd.setCursor(0,0);
/*if V pressed do nothing;
if ^ pressed load menuOptionTwoOne()/menuOption = 3;
if < pressed load idleMenu()/menuOption = 0;
if > pressed load 4rd menu;/not coded yet
if * pressed load 4th menu();/not coded yet
*/
}
//----------------------------------------------------
void setLightsOne(){// case 8
lcd.setCursor(0,0);
lcd.print("1.SET INTENSITY*");
lcd.setCursor(0,1);
lcd.print("2.SET TIMES");
lcd.setCursor(0,0);
/*if V pressed load setLightsTwo()/menuOption = 9;
if ^ pressed do nothing
if < pressed load idleMenu()//menuOption = 0;
if > pressed load setintensityOne()/menuOption = 5;
if * pressed load setLightsTwo()/menuOption = 9;
*/
}
void setLightsTwo(){//case 9
lcd.setCursor(0,0);
lcd.print("1.SET INTENSITY");
lcd.setCursor(0,1);
lcd.print("2.SET TIMES *");
//flash pixel
lcd.setCursor(0,0);
/*if V pressed do nothing;
if ^ pressed load setLightsOne()/menuOption = 8;
if < pressed load mainMenuOneOne()/menuOption = 1;
if > pressed load setTimeOne()/menuOption = 10;
if * pressed load setTimeOne()/menuOption = 10;
*/
}
//----------------------------------------------------
void setIntensityOne(){// case 5
lcd.setCursor(0,0);
lcd.print("1. SET BLUE MAX");
lcd.setCursor(0,1);
lcd.print(" 100%");
lcd.setCursor(0,0);
/*if V pressed value-- While => 0;
if ^ pressed value++ while <= 100;
if < pressed do nothing;
if > pressed load setIntenistyTwo()//menuOption = 6;
if * pressed load setIntenistyTwo()/menuOption = 6;
*/
}
void setIntensityTwo(){//case 6
lcd.setCursor(0,0);
lcd.print("1. SET WHITE MAX");
lcd.setCursor(0,1);
lcd.print(" 100%");
lcd.setCursor(0,0);
/*if V pressed value-- While => 0;
if ^ pressed value++ while <= 100;
if < pressed do nothing;
if > pressed load setIntenistyThree()/menuOption = 7;
if * pressed load setIntenistyThree()//menuOption = 7;
*/
}
void setIntensityThree(){//case 7
lcd.setCursor(0,0);
lcd.print("LIGHTS SET");
lcd.setCursor(0,1);
delay(5000);
lcd.setCursor(0,0);
menuOption = 1;
/*if V pressed do nothing;
if ^ pressed do nothing;
if < pressed do nothing;
if > pressed load mainMenuOne()/menuOption = 1;
if * pressed load mainMenuOne()/menuOption = 1;
*/
}
//-------------------------------------------------
void setTimePeriodOne(){//case 10
lcd.setCursor(0,0);
lcd.print("1.SET START *");
lcd.setCursor(0,1);
lcd.print("2.SET END");
lcd.setCursor(0,0);
/*if V pressed load setTimePeriodTwo()/menuOption = 11;
if ^ pressed do nothing;
if < pressed load setLightsTwo()/menuOption = 9;
if > pressed load setStartTime/not coded yet;
if * pressed load setStartTime)/not coded yet
*/
}
void setTimePeriodTwo(){//case 11
lcd.setCursor(0,0);
lcd.print("1.SET START");
lcd.setCursor(0,1);
lcd.print("2.SET END *");
lcd.setCursor(0,0);
/*if V pressed do nothing;
if ^ pressed load setTimePeriodOne/menuOption = 10;
if < pressed load setLightsTwo()/menuOption = 9;
if > pressed load setEndTime/not coded yet
if * pressed load setEndTime)/not coded yet
*/
}
//-------------------------------------------------