firmware wip - add display stuff
This commit is contained in:
parent
eb45412a6e
commit
ffae349878
1 changed files with 96 additions and 6 deletions
|
@ -66,8 +66,11 @@ byte valWaterlevel;
|
|||
// do we need a restart? (e.g. after wifi settings change)
|
||||
bool NeedRestart;
|
||||
bool FirstRun;
|
||||
|
||||
|
||||
// which screen should be actually displayed
|
||||
byte ScreenToDisplay = 0;
|
||||
byte DisplayScreenDuration = 3;
|
||||
// how many seconds actual screen got displayed
|
||||
byte ScreenIterationPassed = 0;
|
||||
/*
|
||||
*
|
||||
* EEPROM saved variables
|
||||
|
@ -599,7 +602,10 @@ void wipeEEPROM() {
|
|||
Serial.println("Please release PinWIPE to erase all data saved in EEPROM");
|
||||
Serial.println("LAST CHANCE TO KEEP THE DATA BY RESETTING NOW!!");
|
||||
|
||||
display.setCursor(0,36);
|
||||
display.clearDisplay();
|
||||
display.setCursor(0,0);
|
||||
display.println("!!!!!!!!!!!!!!!!!!!!!");
|
||||
display.println("");
|
||||
display.println("RELEASE PinWIPE");
|
||||
display.println("TO WIPE EEPROM");
|
||||
display.display();
|
||||
|
@ -612,7 +618,6 @@ void wipeEEPROM() {
|
|||
|
||||
// write a 0 to all 512 bytes of the EEPROM
|
||||
Serial.print("wiping EEPROM... ");
|
||||
display.setCursor(0,36);
|
||||
display.println("Wiping EEPROM...");
|
||||
display.println("Will restart in 3s");
|
||||
display.display();
|
||||
|
@ -1030,7 +1035,89 @@ void refreshSensors() {
|
|||
valWaterlevel = getWaterlevel();
|
||||
}
|
||||
|
||||
void displayScreens() {
|
||||
/*
|
||||
* which screen to display
|
||||
* interate through different screens
|
||||
*
|
||||
*/
|
||||
if(ScreenIterationPassed > DisplayScreenDuration){
|
||||
ScreenIterationPassed = 0;
|
||||
// helper variable, maybe i find a better way in future
|
||||
byte LastScreen = 2;
|
||||
// when the next screen gets displayed, clear display
|
||||
display.clearDisplay();
|
||||
display.display();
|
||||
// when ScreenToDisplay has reach last number of screens, reset to first (0)
|
||||
if(ScreenToDisplay >= LastScreen) {
|
||||
ScreenToDisplay = 0;
|
||||
} else {
|
||||
ScreenToDisplay++;
|
||||
}
|
||||
}
|
||||
|
||||
display.setCursor(0,0);
|
||||
// in this switch case the single screens gets defined
|
||||
switch(ScreenToDisplay) {
|
||||
case 0:
|
||||
display.print("Humidity: ");
|
||||
display.print(valHumidity);
|
||||
display.println(" %");
|
||||
display.print("Temperature: ");
|
||||
display.print(valTemperature);
|
||||
display.println(" C");
|
||||
display.print("Moisture: ");
|
||||
display.print(valSoilmoisture);
|
||||
display.println(" %");
|
||||
if(UsePump == true) {
|
||||
display.print("Pump Waterlvl: ");
|
||||
switch(valWaterlevel) {
|
||||
case 0:
|
||||
display.println("OK");
|
||||
break;
|
||||
case 1:
|
||||
display.println("Warn");
|
||||
break;
|
||||
case 2:
|
||||
display.println("Crit");
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
display.print("LED: ");
|
||||
display.print(PinLEDPWM * 100 / 255);
|
||||
display.println(" %");
|
||||
display.print("State: ");
|
||||
display.println(digitalRead(PinLED));
|
||||
display.println("");
|
||||
display.print("FAN: ");
|
||||
display.print(PinFANPWM * 100 / 255);
|
||||
display.println(" %");
|
||||
display.print("State: ");
|
||||
display.println(digitalRead(PinFAN));
|
||||
display.println("");
|
||||
display.print("Pump state: ");
|
||||
display.println(digitalRead(PinPUMP));
|
||||
break;
|
||||
case 2:
|
||||
// display Logo
|
||||
display.drawBitmap(0, 0, bmpCanGrow_Logo, 128, 32, WHITE);
|
||||
display.display();
|
||||
display.setCursor(0,32);
|
||||
display.println(GrowName);
|
||||
display.print("DoG: ");
|
||||
display.print(DayOfGrow);
|
||||
display.print(", ");
|
||||
display.println(timeClient.getFormattedTime());
|
||||
display.print("IP: ");
|
||||
display.println(WiFi.localIP());
|
||||
break;
|
||||
}
|
||||
ScreenIterationPassed++;
|
||||
display.display();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
@ -1154,6 +1241,9 @@ void setup() {
|
|||
webserver.begin();
|
||||
|
||||
Serial.println(".:: CanGrow Ready ::.");
|
||||
delay(1000);
|
||||
display.clearDisplay();
|
||||
display.display();
|
||||
}
|
||||
|
||||
|
||||
|
@ -1186,7 +1276,7 @@ void loop() {
|
|||
|
||||
// set the actual state of the Grow LED
|
||||
controlLED();
|
||||
|
||||
displayScreens();
|
||||
|
||||
// current time gets previous time for new interval
|
||||
outputPrevTime = currentRuntime;
|
||||
|
|
Loading…
Reference in a new issue