firmware wip
This commit is contained in:
parent
56ce028b38
commit
ce55c874ec
1 changed files with 63 additions and 3 deletions
|
@ -80,7 +80,7 @@ char WebUiPassword[32] = "cangrow";
|
||||||
// configured - if false, let the user configure system settings first
|
// 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;
|
||||||
// MoistureSensor_Type - contains which moisture sensor to use
|
// MoistureSensor_Type - contains which moisture sensor to use
|
||||||
// 1: analog capacitive sensor
|
// 1: analog capacitive sensor
|
||||||
// 2: I2C chirp sensor from catnip electronics
|
// 2: I2C chirp sensor from catnip electronics
|
||||||
|
@ -1038,6 +1038,9 @@ void WebHandler() {
|
||||||
webserver.on("/favicon.ico", [](){ webserver.send(404, "text/html", "404 - not found"); });
|
webserver.on("/favicon.ico", [](){ webserver.send(404, "text/html", "404 - not found"); });
|
||||||
webserver.onNotFound(WEB404);
|
webserver.onNotFound(WEB404);
|
||||||
|
|
||||||
|
// switching MOSFETs
|
||||||
|
webserver.on("/switch", HTTP_POST, POSTswitchMOSFET);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebRestart() {
|
void WebRestart() {
|
||||||
|
@ -1245,7 +1248,28 @@ void WEBroot() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
body += "<form method='post' action='/switch'>";
|
||||||
|
body += "MOSFET<select id='output' name='output' required>\n";
|
||||||
|
body += "<option disabled value='' selected hidden>---</option>\n";
|
||||||
|
body += "<option value='1'>LED</option>\n";
|
||||||
|
body += "<option value='2'>PUMP</option>\n";
|
||||||
|
body += "<option value='3'>FAN</option>\n";
|
||||||
|
body += "</select><br>";
|
||||||
|
|
||||||
|
body += "On/Off: <select id='state' name='state' required>\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>";
|
||||||
|
|
||||||
|
|
||||||
body += "</p>";
|
body += "</p>";
|
||||||
|
|
||||||
|
|
||||||
body += returnHTMLfooter();
|
body += returnHTMLfooter();
|
||||||
|
|
||||||
webserver.send(200, "text/html", body);
|
webserver.send(200, "text/html", body);
|
||||||
|
@ -1529,7 +1553,7 @@ void POSTgrowSettings() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
analogWrite(PINled, PINled_PWM);
|
//analogWrite(PINled, PINled_PWM);
|
||||||
|
|
||||||
Serial.println(":: POSTgrowSettings ::");
|
Serial.println(":: POSTgrowSettings ::");
|
||||||
|
|
||||||
|
@ -1679,6 +1703,42 @@ void POSTwifiSettings() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void POSTswitchMOSFET() {
|
||||||
|
byte MosfetState = webserver.arg("state").toInt();
|
||||||
|
byte MosfetNr = webserver.arg("output").toInt();
|
||||||
|
|
||||||
|
Serial.println(":: GETswitchMOSFET ::");
|
||||||
|
Serial.print("MosfetState: ");
|
||||||
|
Serial.println(MosfetState);
|
||||||
|
Serial.print("MosfetNr: ");
|
||||||
|
Serial.println(MosfetNr);
|
||||||
|
|
||||||
|
if((MosfetState > 1) || (MosfetState < 0)) {
|
||||||
|
webserver.send(400, "text/plain", "not valid\n");
|
||||||
|
} else {
|
||||||
|
switch(MosfetNr) {
|
||||||
|
case 1:
|
||||||
|
if( MosfetState == 1) {
|
||||||
|
analogWrite(PINled, PINled_PWM);
|
||||||
|
} else {
|
||||||
|
digitalWrite(PINled, MosfetState);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
digitalWrite(PINpump, MosfetState);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
digitalWrite(PINfan, MosfetState);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
webserver.send(400, "text/plain", "not valid\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
webserver.sendHeader("Location", String("/?success"), true);
|
||||||
|
webserver.send(302, "text/plain", "wifiSettings/save: success!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
String JSreplaceStr(String elementID, String content) {
|
String JSreplaceStr(String elementID, String content) {
|
||||||
String jsReturn = "<script>document.getElementById('" + elementID + "').innerHTML='" + content + "';</script>";
|
String jsReturn = "<script>document.getElementById('" + elementID + "').innerHTML='" + content + "';</script>";
|
||||||
|
|
Loading…
Reference in a new issue