firmware wip

This commit is contained in:
Marcus 2024-04-17 22:44:30 +02:00
parent e52a2fb4e0
commit 2d842b5996
1 changed files with 34 additions and 38 deletions

View File

@ -61,6 +61,8 @@ bool FirstRun;
// //
// WiFi // WiFi
// //
// if empty, CanGrow start in AccessPoint mode
char WIFIssid[32]; char WIFIssid[32];
char WIFIpassword[64]; char WIFIpassword[64];
// WIFIuseDHCP - if true, get IP by DHCP // WIFIuseDHCP - if true, get IP by DHCP
@ -75,7 +77,7 @@ char WebUiPassword[32] = "cangrow";
// //
// System // System
// //
// configured - if true, run setup assistant // configured - if false, let the user configure system settings first
bool configured = false; bool configured = false;
// NTP Offset // NTP Offset
int ntpOffset = 0; int ntpOffset = 0;
@ -88,7 +90,7 @@ byte SoilmoistureLow = 20;
// UsePump - is the pump used? bool // UsePump - is the pump used? bool
bool UsePump; bool UsePump;
// UseFan - is the fan used? bool // UseFan - is the fan used? bool
byte PumpOnTime; byte PumpOnTime = 3;
bool UseFan; bool UseFan;
// In case the user uses no 12V LED on the LED output and an relais instead // In case the user uses no 12V LED on the LED output and an relais instead
// we have to disable PWM. So we ask here for what kind of light user is going // we have to disable PWM. So we ask here for what kind of light user is going
@ -102,6 +104,7 @@ bool UseLEDrelais;
// //
// GrowName - contains the name of the grow/plant. Up to 32 byte // GrowName - contains the name of the grow/plant. Up to 32 byte
// if empty, let the user setup grow settings first
char GrowName[32]; char GrowName[32];
// GrowStart - contains unix timestamp from date where grow starts (00:00) // GrowStart - contains unix timestamp from date where grow starts (00:00)
// unsigned long is 8 byte // unsigned long is 8 byte
@ -682,34 +685,25 @@ bool loadEEPROM() {
/* /*
* System settings * System settings
*/ */
/*
* configured
*
* read var configured from address 511 - I put this to the end to
* prevent confusion with the 1 byte offset in the address when it
* would be at the beginning - more a cosmetic thing
*
* All boolean variables are at the end of the EEPROM
*/
// size is 1 byte // size is 1 byte
EEPROM.get(161, configured); EEPROM.get(161, configured);
// size is 1 byte if(configured == true) {
EEPROM.get(162, UseFan); // size is 1 byte
// size is 1 byte EEPROM.get(162, UseFan);
EEPROM.get(163, UsePump); // size is 1 byte
// size is 1 byte EEPROM.get(163, UsePump);
EEPROM.get(164, PumpOnTime); // size is 1 byte
// size is 1 byte EEPROM.get(164, PumpOnTime);
EEPROM.get(165, MoistureSensor_Type); // size is 1 byte
// size is 1 byte EEPROM.get(165, MoistureSensor_Type);
EEPROM.get(166, SoilmoistureLow); // size is 1 byte
// size is 2 byte EEPROM.get(166, SoilmoistureLow);
EEPROM.get(167, ntpOffset); // size is 2 byte
// size is 1 byte EEPROM.get(167, ntpOffset);
EEPROM.get(169, UseLEDrelais); // size is 1 byte
EEPROM.get(169, UseLEDrelais);
}
// TODO auth does not work atm // TODO auth does not work atm
// EEPROM.get(160, WebUiUsername); // EEPROM.get(160, WebUiUsername);
// EEPROM.get(176, WebUiPassword); // EEPROM.get(176, WebUiPassword);
@ -737,15 +731,17 @@ bool loadEEPROM() {
EEPROM.get(211, SunriseMinute); EEPROM.get(211, SunriseMinute);
// size is 1 byte // size is 1 byte
EEPROM.get(212, DayOfGrow); EEPROM.get(212, DayOfGrow);
// to ensure PINled_PWM always set to 255 when UseLEDrelais is true
// we set it here again, does not matter whats stored.
// size is 1 byte
if(UseLEDrelais == true) {
PINled_PWM = 255;
} else {
EEPROM.get(213, PINled_PWM);
}
} }
// to ensure PINled_PWM always set to 255 when UseLEDrelais is true
// we set it here again, does not matter whats stored.
// size is 1 byte
if(UseLEDrelais == true) {
PINled_PWM = 255;
} else {
EEPROM.get(213, PINled_PWM);
}
@ -1040,9 +1036,9 @@ void WebRestart() {
String body = FPSTR(HTMLheader); String body = FPSTR(HTMLheader);
if(NeedRestart == true) { if(NeedRestart == true) {
body += "<h1>Restarting</h1>"; body += "<h1>Restarting</h1>";
body += "<div class='infomsg'>After restart you will be connected to Wifi<br><b>"; body += "<div class='infomsg'>After restart CanGrow will be connected to WiFi SSID<br><b>";
body += WIFIssid; body += WIFIssid;
body += "</b><br>You get CanGrow's IP-Address from the display or serial console.</div>"; body += "</b><br>You get its IP-Address from the display or serial console.</div>";
body += returnHTMLfooter(); body += returnHTMLfooter();
webserver.send(200, "text/html", body); webserver.send(200, "text/html", body);
Serial.println("Restarting... see you soon space cowboy!"); Serial.println("Restarting... see you soon space cowboy!");