diff --git a/src/WifiManager.cpp b/src/WifiManager.cpp index 12b57e7..d845f83 100644 --- a/src/WifiManager.cpp +++ b/src/WifiManager.cpp @@ -45,14 +45,11 @@ void WifiManager::handleRoot() { " Wastinfoboard-ConfigurationPage\n" " \n" " \n" - "
Aktuelle Zeit: "+ String(value) +" Minuten
\n" + "
Aktuelle Zeit: "+ String(value / 60) +" Minuten
\n" "
\n" " Zeit setzen: \n" " \n" "

\n" - " \n" - " " - " \n" ""; server.send(200, "text/html", index_html); @@ -75,22 +72,29 @@ void WifiManager::handleGet() { Serial.println(server.arg("time")); if (server.arg("time") != "") { - int time = atoi(server.arg("time").c_str()); //Gets the value of the query parameter + // should be hours + int time = (int) (server.arg("time").toFloat() * 3600.0 + 0.5); //manager.setSSID(message); - + if (time == 0) { + time = 7200; + } EEPROM.begin(4096); // init the eeprom EEPROM.put(0, time); EEPROM.commit(); // write the changes to the eeprom EEPROM.end(); // stop the eeprom communication - } else if (server.arg("reset") != "") { - Serial.println("Reset ..."); - ESP.reset(); } -// manager.storeVars(); - Serial.println("send get back"); + server.send(200, "text/html", s); //Send web page } void WifiManager::holdAlive() { server.handleClient(); } + +int WifiManager::getWaitTime() { + int value = 0; + EEPROM.begin(4096); // init the eeprom + EEPROM.get(0, value); + EEPROM.end(); // stop the eeprom communication + return value; +} diff --git a/src/WifiManager.h b/src/WifiManager.h index 00218b7..47a9140 100644 --- a/src/WifiManager.h +++ b/src/WifiManager.h @@ -15,6 +15,8 @@ public: void init(); void holdAlive(); + + int getWaitTime(); private: ESP8266WebServer server; diff --git a/src/main.cpp b/src/main.cpp index 78a155a..ebb278c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -15,7 +15,6 @@ static const uint8_t DruckSensorPin = 12; static const uint8_t SchuetzPin = 13; /** time config */ -static int abschaltzeit = 7200; //sek static const int maxpumpdauer = 600; //sek // ticker fuer kein-wasser abschaltung @@ -77,7 +76,7 @@ ICACHE_RAM_ATTR void DruckschalterInt() { } } -int i = abschaltzeit; //todo better +int i = mang.getWaitTime(); //todo better void WasserSensorCheck() { if (digitalRead(WasserSensorPin) == LOW) { Serial.println("Wasser Sensor AUS"); @@ -91,7 +90,7 @@ void WasserSensorCheck() { status.detach(); - i = abschaltzeit; + i = mang.getWaitTime(); status.attach(5, []() { i -= 5; Serial.print("noch "); @@ -144,13 +143,9 @@ void setup() { //allow = digitalRead(WasserSensorPin); allow = true; - int value = 0; - EEPROM.begin(4096); // init the eeprom - EEPROM.get(0, value); - EEPROM.end(); // stop the eeprom communication + int value = mang.getWaitTime(); Serial.print("read value from eeprom: "); Serial.println(value); - abschaltzeit = value; WasserSensorCheck(); DruckschalterInt();