From 2d842b59965b32a911de4345acbef89202d7461d Mon Sep 17 00:00:00 2001 From: Marcus Date: Wed, 17 Apr 2024 22:44:30 +0200 Subject: [PATCH] firmware wip --- Arduino/CanGrow/CanGrow.ino | 72 ++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 38 deletions(-) diff --git a/Arduino/CanGrow/CanGrow.ino b/Arduino/CanGrow/CanGrow.ino index 0d80016..08db330 100644 --- a/Arduino/CanGrow/CanGrow.ino +++ b/Arduino/CanGrow/CanGrow.ino @@ -61,6 +61,8 @@ bool FirstRun; // // WiFi // + +// if empty, CanGrow start in AccessPoint mode char WIFIssid[32]; char WIFIpassword[64]; // WIFIuseDHCP - if true, get IP by DHCP @@ -75,7 +77,7 @@ char WebUiPassword[32] = "cangrow"; // // System // -// configured - if true, run setup assistant +// configured - if false, let the user configure system settings first bool configured = false; // NTP Offset int ntpOffset = 0; @@ -88,7 +90,7 @@ byte SoilmoistureLow = 20; // UsePump - is the pump used? bool bool UsePump; // UseFan - is the fan used? bool -byte PumpOnTime; +byte PumpOnTime = 3; bool UseFan; // 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 @@ -102,6 +104,7 @@ bool UseLEDrelais; // // GrowName - contains the name of the grow/plant. Up to 32 byte +// if empty, let the user setup grow settings first char GrowName[32]; // GrowStart - contains unix timestamp from date where grow starts (00:00) // unsigned long is 8 byte @@ -682,34 +685,25 @@ bool loadEEPROM() { /* * 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 EEPROM.get(161, configured); - // size is 1 byte - EEPROM.get(162, UseFan); - // size is 1 byte - EEPROM.get(163, UsePump); - // size is 1 byte - EEPROM.get(164, PumpOnTime); - // size is 1 byte - EEPROM.get(165, MoistureSensor_Type); - // size is 1 byte - EEPROM.get(166, SoilmoistureLow); - // size is 2 byte - EEPROM.get(167, ntpOffset); - // size is 1 byte - EEPROM.get(169, UseLEDrelais); - + if(configured == true) { + // size is 1 byte + EEPROM.get(162, UseFan); + // size is 1 byte + EEPROM.get(163, UsePump); + // size is 1 byte + EEPROM.get(164, PumpOnTime); + // size is 1 byte + EEPROM.get(165, MoistureSensor_Type); + // size is 1 byte + EEPROM.get(166, SoilmoistureLow); + // size is 2 byte + EEPROM.get(167, ntpOffset); + // size is 1 byte + EEPROM.get(169, UseLEDrelais); + } // TODO auth does not work atm // EEPROM.get(160, WebUiUsername); // EEPROM.get(176, WebUiPassword); @@ -737,15 +731,17 @@ bool loadEEPROM() { EEPROM.get(211, SunriseMinute); // size is 1 byte 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); if(NeedRestart == true) { body += "

Restarting

"; - body += "
After restart you will be connected to Wifi
"; + body += "
After restart CanGrow will be connected to WiFi SSID
"; body += WIFIssid; - body += "
You get CanGrow's IP-Address from the display or serial console.
"; + body += "

You get its IP-Address from the display or serial console.
"; body += returnHTMLfooter(); webserver.send(200, "text/html", body); Serial.println("Restarting... see you soon space cowboy!");