Compare commits

...

2 Commits

Author SHA1 Message Date
Marcus d5695f8926 firmware wip 2024-04-17 23:16:44 +02:00
Marcus 8bc3e9ca62 firmware wip 2024-04-17 22:45:50 +02:00
1 changed files with 55 additions and 4 deletions

View File

@ -95,6 +95,8 @@ 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
bool UseLEDrelais;
// Which temperature sensor to use?
byte TemperatureSensor_Type;
@ -703,6 +705,11 @@ bool loadEEPROM() {
EEPROM.get(167, ntpOffset);
// size is 1 byte
EEPROM.get(169, UseLEDrelais);
// size is 1 byte
// I forgot to add TemperatureSensor_Type to EEPROM and noticed it
// quite late in the process of programming. So this value residents
// in 214 and not directly after UseLEDrelais
EEPROM.get(214, TemperatureSensor_Type);
}
// TODO auth does not work atm
// EEPROM.get(160, WebUiUsername);
@ -889,9 +896,10 @@ void setup() {
// Start Serial
Serial.begin(115200);
// Write an empty line, because before there is some garbage in serial
// Write a line before doing serious output, because before there is some garbage in serial
// whats get the cursor somewhere over the place
// output
Serial.println("");
Serial.println("420");
Serial.println(".:: CanGrow Start ::.");
// initialise Wire for I2C
@ -1203,9 +1211,40 @@ void WEBroot() {
} else {
String body = FPSTR(HTMLheader);
body += "<h1>configured!</h1>";
body += "<h1>&#x1F331;";
body += GrowName;
body += "</h1>";
body += "<p>";
body += timeClient.getFormattedTime();
body += "Grow started: ";
body += returnStrDateFromEpoch(GrowStart);
body += "<br>";
body += "Day of Grow: ";
body += DayOfGrow;
body += "<br><br>";
body += "Soil Moisture: ";
body += getSoilmoisture(MoistureSensor_Type);
body += " %<br>";
body += "Humidity: ";
body += getHumidity();
body += " ?<br>";
body += "Temperature: ";
body += getTemperature(TemperatureSensor_Type);
body += " °C<br>";
if(UsePump == true) {
body += "Pump water level: ";
switch(getWaterlevel()) {
case 0:
body += "OK";
break;
case 1:
body += "Warning";
break;
case 2:
body += "Critical";
break;
}
}
body += "</p>";
body += returnHTMLfooter();
@ -1330,6 +1369,15 @@ void WEBsystemSettings() {
body += SoilmoistureLow;
body += "' required><br>\n";
// TemperatureSensor_Type byte
body += "Temperature sensor type: <select id='TemperatureSensor_Type' name='TemperatureSensor_Type' required>\n";
if(configured == false) {
body += "<option disabled value='' selected hidden>---</option>\n";
}
body += "<option value='1'" + returnStrSelected(TemperatureSensor_Type, 1) + ">DHT11/22</option>\n";
body += "<option value='2'" + returnStrSelected(TemperatureSensor_Type, 2) + ">I2C chirp</option>\n";
body += "</select><br>\n";
// ntpOffset int
body += "NTP offset: <input type='number' name='ntpOffset' min='0' value='";
body += ntpOffset;
@ -1517,6 +1565,7 @@ void POSTsystemSettings() {
PumpOnTime = webserver.arg("PumpOnTime").toInt();
UseFan = webserver.arg("UseFan").toInt();
UseLEDrelais = webserver.arg("UseLEDrelais").toInt();
TemperatureSensor_Type = webserver.arg("TemperatureSensor_Type").toInt();
configured = true;
@ -1536,6 +1585,8 @@ void POSTsystemSettings() {
EEPROM.put(167, ntpOffset);
// size is 1 byte
EEPROM.put(169, UseLEDrelais);
// size is 1 byte
EEPROM.put(214, TemperatureSensor_Type);
EEPROM.commit();