firmware wip - add basic maintenance mode, which dimms the led for a minute

This commit is contained in:
Marcus 2024-05-08 17:08:39 +02:00
parent d879b209bd
commit 12fdd869c4
2 changed files with 47 additions and 5 deletions

View file

@ -71,6 +71,10 @@ byte ScreenToDisplay = 0;
byte DisplayScreenDuration = 3;
// how many seconds actual screen got displayed
byte ScreenIterationPassed = 0;
bool MaintenanceMode = false;
unsigned long MaintenanceStarted = 0;
/*
*
* EEPROM saved variables
@ -117,6 +121,7 @@ bool UseLEDrelais;
bool UseFANrelais;
// Which temperature sensor to use?
byte TemperatureSensor_Type;
unsigned short MaintenanceDuration = 60000;
//
// Grow Stuff
@ -1568,7 +1573,18 @@ void loop() {
// when DayOfGrow is larger then DaysVeg we must be in Bloom
// set the actual state of the Grow LED
// when being in Maintenance Mode and UseRelaisLED not true,
// dimm the light
if(MaintenanceMode == true) {
if((currentRuntime - MaintenanceStarted <= MaintenanceDuration) && (UseLEDrelais == false)) {
// in case of being in Maintenance Mode , dimm the grow light when not a relais is used
setOutput(1, 20);
} else {
MaintenanceMode = false;
}
} else {
controlLED();
}
displayScreens();
// current time gets previous time for new interval
@ -1720,6 +1736,11 @@ String returnHTMLheader(String MenuEntry = "") {
header += CanGrowVer;
header += "</a></li>\n";
if(MaintenanceMode == true) {
// status icons
header += "<li><span>&#x1F1F2;</span></li>\n";
}
// close <ul> and start <div>
header += "</ul><div class='center'>";
@ -1961,20 +1982,25 @@ void WEBroot() {
body += ((PinLEDPWM * 100) / 255);
body += " %<br>\n";
body += "<form method='post' action='/switch'>\n";
body += "MOSFET<select id='output' name='output' required>\n";
body += "MOSFET<select id='output' name='output' >\n";
body += "<option disabled value='' selected hidden>---</option>\n";
body += "<option value='1'>LED</option>\n";
body += "<option value='2'>FAN</option>\n";
body += "<option value='3'>PUMP</option>\n";
body += "</select><br>";
body += "On/Off: <select id='state' name='state' required>\n";
body += "On/Off: <select id='state' name='state' >\n";
body += "<option disabled value='' selected hidden>---</option>\n";
body += "<option value='1'>On</option>\n";
body += "<option value='0'>Off</option>\n";
body += "</select><br>\n";
body += "Intensity: <input type='range' id='OutputPWM' name='OutputPWM' min='1' max='255' value='255'/><br>\n";
body += "Maintenance: <select id='EnableMaintenance' name='EnableMaintenance'>\n";
body += "<option disabled value='' selected hidden>---</option>\n";
body += "<option value='1'>On</option>\n";
body += "<option value='0'>Off</option>\n";
body += "</select><br>\n";
body += "<input type='submit' value='Save'>\n";
body += "</form>";
@ -2516,12 +2542,15 @@ void POSTsetOutput() {
byte OutputNr = webserver.arg("output").toInt();
//PinLEDPWM = webserver.arg("PinLEDPWM").toInt();
byte OutputPWM = webserver.arg("OutputPWM").toInt();
byte EnableMaintenance = webserver.arg("EnableMaintenance").toInt();
Serial.println(":: POSTsetOutput ::");
Serial.print("OutputState: ");
Serial.println(OutputState);
Serial.print("OutputNr: ");
Serial.println(OutputNr);
Serial.print("EnableMaintenance: ");
Serial.println(EnableMaintenance);
if((OutputNr > 3) || (OutputNr < 1) || (OutputState > 255) || (OutputState < 0)) {
webserver.send(400, "text/plain", "not valid\n");
@ -2533,9 +2562,18 @@ void POSTsetOutput() {
setOutput(OutputNr, 0);
}
webserver.sendHeader("Location", String("/?success"), true);
webserver.send(302, "text/plain", "switch: success!\n");
}
if(EnableMaintenance > 0 ) {
MaintenanceMode = true;
MaintenanceStarted = millis();
} else {
MaintenanceMode = false;
}
}

View file

@ -103,8 +103,12 @@ a:active {
<li><a href='/wifiSettings' >&#128225; WiFi settings</a></li>
<li><a href='/help' >&#x2753; Help</a></li>
<li><span class='MenuTime'>23:57:31</span></li>
<li><span>Ⓜ️</span></li>
<li><a href='https://git.la10cy.net/DeltaLima/CanGrow' target='_blank'>CanGrow v0.1</a></li>
</ul><div class='center'><h2>&#x1F331; Ruderalis Indica</h2>
</ul>
<div class='center'><h2>&#x1F331; Ruderalis Indica</h2>
<div class='gaugeWrapper'>