Deleted .idea/.gitignore, .idea/clion.iml, .idea/misc.xml, .idea/modules.xml, .idea/platformio.iml, .idea/serialmonitor_settings.xml, .idea/vcs.xml, .idea/watcherTasks.xml files
This commit is contained in:
69
src/main.cpp
69
src/main.cpp
@@ -1,47 +1,46 @@
|
||||
#include <Arduino.h>
|
||||
#include <Ticker.h>
|
||||
|
||||
#include "WifiManager.h"
|
||||
#include <ESP8266React.h>
|
||||
#include "Heating.h"
|
||||
|
||||
#include "Pins.h"
|
||||
|
||||
#define VERSION "v1.1.1"
|
||||
#include "GeneralInfoService.h"
|
||||
#include "SettingsService.h"
|
||||
|
||||
bool allow;
|
||||
bool error = false;
|
||||
|
||||
|
||||
|
||||
/** time config */
|
||||
static const int maxpumpdauer = 600; //sek
|
||||
|
||||
// ticker fuer kein-wasser abschaltung
|
||||
Ticker status;
|
||||
|
||||
//pumpendauer maximum ticker
|
||||
Ticker pumpendauer;
|
||||
|
||||
WifiManager mang;
|
||||
//WifiManager mang;
|
||||
Heating mHeat;
|
||||
|
||||
long turnontime = -1;
|
||||
unsigned long turnontime = 0;
|
||||
|
||||
AsyncWebServer server(80);
|
||||
ESP8266React esp8266React(&server);
|
||||
|
||||
GeneralInfoService generalinfo = GeneralInfoService(&server, mHeat.getLastHum(), mHeat.getLastTemp());
|
||||
SettingsService settingsservice = SettingsService(&server, esp8266React.getSecurityManager());
|
||||
|
||||
void pumpeSchalten(bool on) {
|
||||
// digitalWrite(4,on);
|
||||
if (on) {
|
||||
Serial.println("versuche Pumpe EIN zuschalten");
|
||||
// refresh last pump counter
|
||||
mang.setlastPumpTime(millis());
|
||||
generalinfo.setlastPumpTime(millis());
|
||||
} else {
|
||||
Serial.println("versuche Pumpe AUS zuschalten");
|
||||
}
|
||||
|
||||
if (allow && !error) {
|
||||
if (on) {
|
||||
pumpendauer.once(maxpumpdauer + 1, []() {
|
||||
pumpendauer.once((float)settingsservice.getSettings()->maxpumpduration + 1, []() {
|
||||
//erlaube keine einschaltung von mehr als 60 sek
|
||||
if (millis() - turnontime >= maxpumpdauer * 1000 && turnontime != -1) {
|
||||
if (millis() - turnontime >= (unsigned)settingsservice.getSettings()->maxpumpduration * 1000 && turnontime != 0) {
|
||||
//error zu lange
|
||||
Serial.println("\n\npumpe lief mehr als 10 Minuten durchgaengig");
|
||||
pumpeSchalten(false);
|
||||
@@ -49,7 +48,7 @@ void pumpeSchalten(bool on) {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
mang.setPumpDuration(millis() - turnontime);
|
||||
generalinfo.setPumpDuration(millis() - turnontime);
|
||||
}
|
||||
|
||||
// save pump start time
|
||||
@@ -62,8 +61,6 @@ void pumpeSchalten(bool on) {
|
||||
turnontime = -1;
|
||||
digitalWrite(SchuetzPin, LOW);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
ICACHE_RAM_ATTR void DruckschalterInt() {
|
||||
@@ -84,14 +81,16 @@ ICACHE_RAM_ATTR void DruckschalterInt() {
|
||||
}
|
||||
}
|
||||
|
||||
int i = mang.getWaitTime(); //todo better
|
||||
// time counter to wait
|
||||
int wateroutagewaitduration;
|
||||
|
||||
void WasserSensorCheck() {
|
||||
if (digitalRead(WasserSensorPin) == LOW) {
|
||||
Serial.println("Wasser Sensor AUS");
|
||||
//kein Wasser dh timer auf 10min stellen
|
||||
|
||||
// refresh wateroutage counter
|
||||
mang.setlastWaterOutage(millis());
|
||||
generalinfo.setlastWaterOutage(millis());
|
||||
|
||||
allow = false;
|
||||
Serial.println("Schalte pumpe aus");
|
||||
@@ -101,14 +100,14 @@ void WasserSensorCheck() {
|
||||
|
||||
status.detach();
|
||||
|
||||
i = mang.getWaitTime();
|
||||
wateroutagewaitduration = settingsservice.getSettings()->waterOutageWaitDuration;
|
||||
status.attach(5, []() {
|
||||
i -= 5;
|
||||
wateroutagewaitduration -= 5;
|
||||
Serial.print("noch ");
|
||||
Serial.print(i);
|
||||
Serial.print(wateroutagewaitduration);
|
||||
Serial.println(" Sekunden verbleibend");
|
||||
|
||||
if (i <= 0) {
|
||||
if (wateroutagewaitduration <= 0) {
|
||||
if (digitalRead(WasserSensorPin)) {
|
||||
allow = true;
|
||||
Serial.println("Einschalten der Pumpe wieder erlaubt.");
|
||||
@@ -142,7 +141,7 @@ void setup() {
|
||||
pinMode(DruckSensorPin, INPUT);
|
||||
|
||||
// initialize pins
|
||||
digitalWrite(LED_BUILTIN, LOW);
|
||||
digitalWrite(LED_BUILTIN, HIGH);
|
||||
digitalWrite(SchuetzPin, LOW); //pumpe anfangs sofort abschalten
|
||||
digitalWrite(LuefterPin, LOW);
|
||||
digitalWrite(HeizungPin, LOW);
|
||||
@@ -159,12 +158,11 @@ void setup() {
|
||||
//allow = digitalRead(WasserSensorPin);
|
||||
allow = true;
|
||||
|
||||
int value = mang.getWaitTime();
|
||||
Serial.print("read value from eeprom: ");
|
||||
Serial.println(value);
|
||||
|
||||
WasserSensorCheck();
|
||||
DruckschalterInt();
|
||||
// reset the pumpduration settings maybe set by pressureint function above if pressure pin not high...
|
||||
generalinfo.setPumpDuration(0);
|
||||
|
||||
|
||||
|
||||
@@ -173,19 +171,20 @@ void setup() {
|
||||
attachInterrupt(digitalPinToInterrupt(WasserSensorPin), WasserSensorInt, CHANGE);
|
||||
|
||||
|
||||
// initialize heating control
|
||||
Serial.println("initializing heating service");
|
||||
mHeat.init(Heating::HUMIDITY);
|
||||
|
||||
// initialize wifi
|
||||
Serial.println("Initializing wifi");
|
||||
mang.init(mHeat.getLastHum(), mHeat.getLastTemp());
|
||||
esp8266React.begin();
|
||||
settingsservice.begin();
|
||||
server.begin();
|
||||
|
||||
// initialize heating control
|
||||
Serial.println("initializing heating service");
|
||||
mHeat.init(Heating::HUMIDITY, settingsservice.getSettings());
|
||||
|
||||
Serial.println("startup sequence complete!\n");
|
||||
digitalWrite(LED_BUILTIN, HIGH);
|
||||
}
|
||||
|
||||
|
||||
void loop() {
|
||||
mang.holdAlive();
|
||||
esp8266React.loop();
|
||||
}
|
||||
Reference in New Issue
Block a user