Merge branch 'detach' into 'master'
detach before call See merge request lukas/pumpensteuerung!11
This commit is contained in:
commit
aee4725379
@ -16,6 +16,6 @@
|
|||||||
#define TempSensorPin D4
|
#define TempSensorPin D4
|
||||||
|
|
||||||
// version info
|
// version info
|
||||||
#define VERSION "v1.2.4-Alpa1"
|
#define VERSION "v1.2.4-Alpha2"
|
||||||
|
|
||||||
#endif //PUMPENSTEUERUNG_PINS_H
|
#endif //PUMPENSTEUERUNG_PINS_H
|
||||||
|
17
src/main.cpp
17
src/main.cpp
@ -15,7 +15,7 @@ bool error = false;
|
|||||||
Ticker status;
|
Ticker status;
|
||||||
|
|
||||||
//pumpendauer maximum ticker
|
//pumpendauer maximum ticker
|
||||||
Ticker pumpendauer;
|
Ticker pumpendauer, wasserSensorDoubleCheck;
|
||||||
|
|
||||||
//WifiManager mang;
|
//WifiManager mang;
|
||||||
Heating mHeat;
|
Heating mHeat;
|
||||||
@ -47,7 +47,8 @@ void pumpeSchalten(bool on) {
|
|||||||
|
|
||||||
pumpendauer.once((float) settingsservice.getSettings()->maxpumpduration + 1, []() {
|
pumpendauer.once((float) settingsservice.getSettings()->maxpumpduration + 1, []() {
|
||||||
//erlaube keine einschaltung von mehr als 60 sek
|
//erlaube keine einschaltung von mehr als 60 sek
|
||||||
if (Timer::getSystemSeconds() - turnontime >= (unsigned)settingsservice.getSettings()->maxpumpduration && turnontime != 0) {
|
if (Timer::getSystemSeconds() - turnontime >=
|
||||||
|
(unsigned) settingsservice.getSettings()->maxpumpduration && turnontime != 0) {
|
||||||
//error zu lange
|
//error zu lange
|
||||||
Serial.println("\n\npumpe lief mehr als 10 Minuten durchgaengig");
|
Serial.println("\n\npumpe lief mehr als 10 Minuten durchgaengig");
|
||||||
pumpeSchalten(false);
|
pumpeSchalten(false);
|
||||||
@ -64,7 +65,8 @@ void pumpeSchalten(bool on) {
|
|||||||
digitalWrite(SchuetzPin, on);
|
digitalWrite(SchuetzPin, on);
|
||||||
Serial.println("[Erfolg] pumpe wird geschalten");
|
Serial.println("[Erfolg] pumpe wird geschalten");
|
||||||
} else {
|
} else {
|
||||||
Serial.println("[FEHLGESCHLAGEN] Schalten des Schütz gesperrt durch Timeout oder Fehler-- sofortiges ausschalten der pumpe\n");
|
Serial.println(
|
||||||
|
"[FEHLGESCHLAGEN] Schalten des Schütz gesperrt durch Timeout oder Fehler-- sofortiges ausschalten der pumpe\n");
|
||||||
turnontime = -1;
|
turnontime = -1;
|
||||||
digitalWrite(SchuetzPin, LOW);
|
digitalWrite(SchuetzPin, LOW);
|
||||||
}
|
}
|
||||||
@ -92,6 +94,9 @@ ICACHE_RAM_ATTR void DruckschalterInt() {
|
|||||||
int wateroutagewaitduration;
|
int wateroutagewaitduration;
|
||||||
|
|
||||||
void WasserSensorCheck() {
|
void WasserSensorCheck() {
|
||||||
|
if (digitalRead(WasserSensorPin) == LOW) {
|
||||||
|
// check if water sensor is also low after 500ms and lock it then
|
||||||
|
wasserSensorDoubleCheck.once_ms(500, []() {
|
||||||
if (digitalRead(WasserSensorPin) == LOW) {
|
if (digitalRead(WasserSensorPin) == LOW) {
|
||||||
Serial.println("Wasser Sensor AUS");
|
Serial.println("Wasser Sensor AUS");
|
||||||
//kein Wasser dh timer auf 10min stellen
|
//kein Wasser dh timer auf 10min stellen
|
||||||
@ -108,6 +113,8 @@ void WasserSensorCheck() {
|
|||||||
status.detach();
|
status.detach();
|
||||||
|
|
||||||
wateroutagewaitduration = settingsservice.getSettings()->waterOutageWaitDuration;
|
wateroutagewaitduration = settingsservice.getSettings()->waterOutageWaitDuration;
|
||||||
|
|
||||||
|
status.detach();
|
||||||
status.attach(5, []() {
|
status.attach(5, []() {
|
||||||
wateroutagewaitduration -= 5;
|
wateroutagewaitduration -= 5;
|
||||||
Serial.print("noch ");
|
Serial.print("noch ");
|
||||||
@ -115,6 +122,7 @@ void WasserSensorCheck() {
|
|||||||
Serial.println(" Sekunden verbleibend");
|
Serial.println(" Sekunden verbleibend");
|
||||||
|
|
||||||
if (wateroutagewaitduration <= 0) {
|
if (wateroutagewaitduration <= 0) {
|
||||||
|
status.detach();
|
||||||
if (digitalRead(WasserSensorPin)) {
|
if (digitalRead(WasserSensorPin)) {
|
||||||
allow = true;
|
allow = true;
|
||||||
Serial.println("Einschalten der Pumpe wieder erlaubt.");
|
Serial.println("Einschalten der Pumpe wieder erlaubt.");
|
||||||
@ -125,7 +133,8 @@ void WasserSensorCheck() {
|
|||||||
Serial.print("wassersensor immer noch kein Wasser --> verlaengern um 120min\n\n");
|
Serial.print("wassersensor immer noch kein Wasser --> verlaengern um 120min\n\n");
|
||||||
WasserSensorCheck();
|
WasserSensorCheck();
|
||||||
}
|
}
|
||||||
status.detach();
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user