I have a display with 4 pages;
- = start-up page
- = data display page 1
- = data display page 2
- = data display page 3
So far I have it working by it's self by using a variable ans a switch to check what page to display, once the page is displayed the variable is set to display the next page and there is a delay, then the switch reads the variable and repeats.
My problem is how do I add a manual button to advance the display and change the delay (longer so it does not change on the user) The issue I am having a problem getting around is the delay, since it is in delay it is not reading the pin that advances the screen.
The IF statements are where I need the help.
Any suggestion would be appropriated.
void loop() {
// decide what to put on the display
switch (page) {
case 0:
//do something when var equals 1
vfd.clear();
vfd.print("Starting up...");
vfd.setCursor(0, 1);
vfd.print("System Monitior");
vfd.setCursor(0, 2);
vfd.print("Version 1.0");
vfd.setCursor(0, 3);
vfd.print("Bla Bla Bla");
page = 1; // set the next page to display
break;case 1:
//Show page 1
vfd.clear();
vfd.print("Page #1");
vfd.setCursor(0, 1);
vfd.print("Time On -");
vfd.setCursor(0, 2);
vfd.print("VFD is WORKING");
vfd.setCursor(0, 3);
vfd.print("Zone 1 = ON");
vfd.setCursor(11, 1);
vfd.print(millis()/1000); // print the number of seconds since reset:
page = 2; // set the next page to display
break;case 2:
//do something
vfd.clear();
vfd.print("Page #2");
vfd.setCursor(0, 1);
vfd.print("Header Temp = 181");
vfd.setCursor(0, 2);
vfd.print("Return Temp = 162");
vfd.setCursor(0, 3);
vfd.print("Burner is ON");
page = 3; // set the next page to display
break;case 3:
//do something
vfd.clear();
vfd.print("Page #3");
vfd.setCursor(0, 2);
vfd.print(pin22);
page = 1; // set the next page to display
break;default:
// if nothing else matches, do the default
vfd.clear();
vfd.setCursor(0, 1);
vfd.print("ERROR, No page Ref.");
}// check for user selection of screens
if (pin22 == 1){
// the user has pushed the scroll button, advance the display page and set the delay to one min.
if (page == 1){
// make it 2
page = 2;
}
if (page == 2){
// make it 3
page = 3;
}
if (page == 3){
// make it 1, since we only have 3 pages
page = 1;
}
// now set the delay longer so the user can read the display
//delay(10000);
}else{
// set the default auto scrole delay
delay(8000);
}}