diff --git a/zisterne/display.ino b/zisterne/display.ino index e61b595..00eaf30 100644 --- a/zisterne/display.ino +++ b/zisterne/display.ino @@ -2,12 +2,13 @@ //LCD Setup //*********************** void ladeLCDdisplay() { - Wire.begin(12, 13); //SDA-D6, SCL-D7 // LCD Setup (bei beiden LCD Displays gleich) + // Wire.begin(12, 13); //SDA-D6, SCL-D7 // LCD Setup (bei beiden LCD Displays gleich) // *******************Boot mit LAN-Info für 1602 Display************************** if (cfg.data_display ==1) { timer.setInterval(1000); - lcd.begin(); + // lcd.begin(); + lcd.init(); lcd.backlight(); lcd.print(cfg.SSID); lcd.setCursor(0, 1); @@ -27,7 +28,7 @@ // *******************Boot mit LAN-Info für 1604 Display************************** if (cfg.data_display ==2) { timer.setInterval(1000); - lcd.begin(); + lcd.init(); lcd.backlight(); lcd.setCursor(0, 0); lcd.print("Ihre SSID:"); @@ -47,7 +48,8 @@ delay (5000); lcd.noBacklight(); } - } + } + void ladeOLEDdisplay() { //*******************************Initialisierung und DEBUG OLED************************************ @@ -97,101 +99,140 @@ //LCD mit Tastersteuerung für 1602 Display //*********************** void loop1602() { - if ( millis() - displayMicros >= 5000 ) { - displayMicros = millis(); - lcd.clear(); - lcd.setCursor(0,0); - lcd.print(volumen); - lcd.print( " Liter,"); - lcd.setCursor(0,1); - lcd.print(fuellstand); - lcd.print( " % voll"); + if (millis() - displayMicros >= 5000 ) { + displayMicros = millis(); + lcd.clear(); + lcd.setCursor(0,0); + lcd.print(volumen); + lcd.print( " Liter,"); + lcd.setCursor(0,1); + lcd.print(fuellstand); + lcd.print( " % voll"); } - if ((backlstatus == 0) && (digitalRead(taster) == HIGH)) { - lcd.backlight(); - backlstatus = 1; - delay (300); //gegen Tastenprellen - } unsigned long tasterMicros = millis(); - if (tasterMicros - previousMicros >= 90000 ) { - previousMicros = tasterMicros; - lcd.noBacklight(); + if ((tasterMicros - previousMicros >= 90000) && backlstatus) { + lcd.noBacklight(); + backlstatus = false; + return; } - if ((backlstatus == 1) && (digitalRead(taster) == HIGH)) { - lcd.noBacklight(); - backlstatus = 0; - delay (300); //gegen Tastenprellen + + if ((backlstatus == false) && (tasterHigh)) { + resetBacklightTaster(); + lcd.backlight(); + backlstatus = true; + previousMicros = millis(); + return; + } + + if (backlstatus && tasterHigh) { + resetBacklightTaster(); + lcd.noBacklight(); + backlstatus = false; + return; } - } + +} //*********************** //LCD mit Tastersteuerung für 1604 Display //*********************** - void loop1604() { +void loop1604() { if ( millis() - displayMicros >= 5000 ) { - displayMicros = millis(); - lcd.clear(); - lcd.setCursor(0,0); - lcd.print( "F\365llstand:"); // Ueberschrift - lcd.setCursor(0,1); - lcd.print(volumen); - lcd.print( " Liter,"); - lcd.setCursor(0,3); - lcd.print(fuellstand); - lcd.print( " % voll"); + displayMicros = millis(); + lcd.clear(); + lcd.setCursor(0,0); + lcd.print( "F\365llstand:"); // Ueberschrift + lcd.setCursor(0,1); + lcd.print(volumen); + lcd.print( " Liter,"); + lcd.setCursor(0,3); + lcd.print(fuellstand); + lcd.print( " % voll"); } - if ((backlstatus == 0) && (digitalRead(taster) == HIGH)) { - lcd.backlight(); - backlstatus = 1; - delay (300); //gegen Tastenprellen - } - unsigned long tasterMicros = millis(); - if (tasterMicros - previousMicros >= 180000 ) { - previousMicros = tasterMicros; - lcd.noBacklight(); - } - if ((backlstatus == 1) && (digitalRead(taster) == HIGH)) { - lcd.noBacklight(); - backlstatus = 0; - delay (300); //gegen Tastenprellen - } - } + unsigned long tasterMicros = millis(); + if ((tasterMicros - previousMicros >= 90000) && backlstatus) { + lcd.noBacklight(); + backlstatus = false; + return; + } + + if ((backlstatus == false) && (tasterHigh)) { + resetBacklightTaster(); + lcd.backlight(); + backlstatus = true; + previousMicros = millis(); + return; + } + + if (backlstatus && tasterHigh) { + resetBacklightTaster(); + lcd.noBacklight(); + backlstatus = false; + return; + } +} //*********************** // OLED Display //*********************** + void loopOLED() { - if (((backlstatus == 0) && (digitalRead(taster) == HIGH)) || (backlstatus == 1)){ - backlstatus = 1; - delay (300); - if ( millis() - displayMicros >= 5000 ) { - displayMicros = millis(); + + // setze Display-Timout zu 30 Sekunden + // prüfe wenn Display an ist, ob das letzte Einschalten mehr als 30sek in der Vergangenheit liegt + unsigned long oledTimeout = millis(); + if ((oledTimeout - previousMicros >= 30000) && backlstatus ) { oledFill(&ssoled, 0, 1); - char Volumen[10]; - sprintf(Volumen,"%.2f l", volumen); - char Fuellstand[10]; - sprintf(Fuellstand,"%.2f%%", fuellstand); - oledWriteString(&ssoled, 0,0,0,(char *)"Fuellstand:" , FONT_NORMAL, 0, 1); - oledWriteString(&ssoled, 0,60,3,Volumen, FONT_SMALL, 0, 1); - oledWriteString(&ssoled, 0,60,5,Fuellstand, FONT_SMALL, 0, 1); - //*********************Grafik ********************** - rest = map(fuellstand, 0, 100, 62, 13); // Hoehe des Balkens ermitteln - oledRectangle(&ssoled, (1), (13), (45), (62), 1, 0); // aeussere Linie zeichnen - oledRectangle(&ssoled, (1), (rest), (45), (62), 1, 1); // Fuellbalken - oledDumpBuffer(&ssoled, NULL); - } + backlstatus = false; + return; + } - unsigned long tasterMicros = millis(); - if (tasterMicros - previousMicros >= 180000 ) { - previousMicros = tasterMicros; - oledFill(&ssoled, 0, 1); - backlstatus = 0; - } - if ((backlstatus == 1) && (digitalRead(taster) == HIGH)) { + + //if ((backlstatus == 1) && (digitalRead(taster) == HIGH)) { + + // Schalte das Display aus, falls es an ist + // setze das Flag für den GPIO-Pin zurück + if (backlstatus && tasterHigh) { + resetBacklightTaster(); oledFill(&ssoled, 0, 1); - backlstatus = 0; - delay (300); + //delay (300); //gegen Tastenprellen + backlstatus = false; + return; } + + //if (((backlstatus == 0) && (digitalRead(taster) == HIGH)) || (backlstatus == 1)){ + // if ((backlstatus == 0) && (digitalRead(taster) == HIGH)) { + + // schalte Display ein, falls aus + // aktualisiere Display nach 5 sek falls an + // setze Flag für GPIO-Pin zurück und speichere Zeitpunkt des letzten Taster-Drucks in previousMicros + if (!backlstatus && tasterHigh) { + if (tasterHigh) { + previousMicros = millis(); + } + // delay (300); //gegen Tastenprellen + backlstatus = true; + resetBacklightTaster(); + } + + if (backlstatus) { + // aktualisiere Display + if ( millis() - displayMicros >= 5000 ) { + displayMicros = millis(); + oledFill(&ssoled, 0, 1); + char Volumen[10]; + sprintf(Volumen,"%.2f l", volumen); + char Fuellstand[10]; + sprintf(Fuellstand,"%.2f%%", fuellstand); + oledWriteString(&ssoled, 0,0,0,(char *)"Fuellstand:" , FONT_NORMAL, 0, 1); + oledWriteString(&ssoled, 0,60,3,Volumen, FONT_SMALL, 0, 1); + oledWriteString(&ssoled, 0,60,5,Fuellstand, FONT_SMALL, 0, 1); + //*********************Grafik ********************** + rest = map(fuellstand, 0, 100, 62, 13); // Hoehe des Balkens ermitteln + oledRectangle(&ssoled, (1), (13), (45), (62), 1, 0); // aeussere Linie zeichnen + oledRectangle(&ssoled, (1), (rest), (45), (62), 1, 1); // Fuellbalken + oledDumpBuffer(&ssoled, NULL); + } } } diff --git a/zisterne/myTypes.h b/zisterne/myTypes.h index 35d6783..259fb66 100644 --- a/zisterne/myTypes.h +++ b/zisterne/myTypes.h @@ -47,7 +47,8 @@ typedef struct { //Sonstiges int data_dezstellen_anzeige; int data_anzeige_liter_check; - + int data_height_over_NN; + //weitere MQTT char data_mqtt_abstand_topic[51]; int data_mqtt_port; diff --git a/zisterne/ota.ino b/zisterne/ota.ino index f87a7c9..1a90c6e 100644 --- a/zisterne/ota.ino +++ b/zisterne/ota.ino @@ -20,7 +20,7 @@ void checkForUpdates() { Serial.println( fwVersionURL ); HTTPClient httpClient; - httpClient.begin( fwVersionURL ); + // httpClient.begin( fwVersionURL ); int httpCode = httpClient.GET(); if( httpCode == 200 ) { String newFWVersion = httpClient.getString(); @@ -37,7 +37,7 @@ void checkForUpdates() { String fwImageURL = fwURL; fwImageURL.concat( ".bin" ); - t_httpUpdate_return ret = ESPhttpUpdate.update( fwImageURL ); + t_httpUpdate_return ret = ESPhttpUpdate.update(httpClient, fwImageURL ); switch(ret) { case HTTP_UPDATE_FAILED: diff --git a/zisterne/rechnen.ino b/zisterne/rechnen.ino index 32e564b..2945b73 100644 --- a/zisterne/rechnen.ino +++ b/zisterne/rechnen.ino @@ -52,6 +52,17 @@ void looprechnen() { delay(100); } + //**************************************************** + // Druck Sensor ADS1115 + //**************************************************** + if (cfg.data_zisterne_sensor == 4) { + adc0 = ads.getLastConversionResults(); + //Serial.print("AIN0: "); Serial.println(adc0*0.02); + abstand=(cfg.data_abst_sen_boden-(adc0*0.02)); + fuellhoehe=(adc0*0.02); + delay(100); + } + //abstand = 100; //nur testweise wenn kein Sensor dran haengt //Fuellstand prozentual berechnen diff --git a/zisterne/relais.ino b/zisterne/relais.ino index d7d184a..94477cc 100644 --- a/zisterne/relais.ino +++ b/zisterne/relais.ino @@ -1,5 +1,5 @@ //******************************************************** -// Schaltet ein externes Relais an Ausgang D4 / Pin 2 +// Schaltet ein externes Relais an Ausgang D3 / Pin 0 // in Abhaengigkeit von zwei Werten //******************************************************** void relais() { diff --git a/zisterne/relais2.ino b/zisterne/relais2.ino index 5dbe3f8..176c938 100644 --- a/zisterne/relais2.ino +++ b/zisterne/relais2.ino @@ -1,5 +1,5 @@ //*********************************************************** -// Schaltet ein zweites externes Relais an Ausgang D3 / Pin 2 +// Schaltet ein zweites externes Relais an Ausgang D4 / Pin 2 // in Abhaengigkeit von zwei Werten // NOCH NICHT IMPLEMENTIERT //*********************************************************** diff --git a/zisterne/webserver.ino b/zisterne/webserver.ino index 284a2e3..5faa7ab 100644 --- a/zisterne/webserver.ino +++ b/zisterne/webserver.ino @@ -1,14 +1,16 @@ void webHandleRoot() { String inhalt; float vcc = ESP.getVcc() / 1000.0; - inhalt = ""; - inhalt += "
";
- inhalt += "" + anwendungsname + " v" + fw_version + "
Startseite
"; - inhalt += " "
+ ""+anwendungsname+" v"+fw_version+"
Startseite
" + "| BME280 | BME280 | (noch nicht implementiert) | |
| DS18B20 | (an I²C) | ||
| BMP280 | (an I²C) | ||
| DS18B20 | (noch nicht implementiert) | ||
| VL53L1X TOF-Sensor (D1->SCL, D2->SDA, I²C 0x29) | Long (4m) | ||
| ADS1115 Druck-Sensor (D1->SCL, D2->SDA, I²C 0x48) | |||
| Abstand Sensor/Boden | m | ||
| Abstand Sensor/Boden (Eintauchtiefe bei Drucksensor) | cm | ||
| Abstand Sensor/Max. Wasserstand |