Skip to content

Commit

Permalink
ESP_Gaszaehler_V1_95_Core302_LittleFS
Browse files Browse the repository at this point in the history
LittleFS.setTimeCallback (LittleFS filesystems file timestamp hinzugefügt)
Websites.ino void SiteSetup diverse Logausausgaben optimiert
  • Loading branch information
elektron-bbs committed Oct 9, 2022
1 parent 3d79072 commit 8c8facd
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 47 deletions.
9 changes: 3 additions & 6 deletions ESP-Gaszaehler-GZ16.ino
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,19 @@
#include <PubSubClient.h>
#include <Wire.h>
#include <SPI.h>
extern "C" {
#include "user_interface.h"
}
// #include <detail\RequestHandlersImpl.h>

#define HW_VERSION_1 // Version 1: ESP-12E, auskommentieren für Version 2 (MR) mit NodeMCU

#ifdef HW_VERSION_1
ADC_MODE(ADC_VCC); // vcc read
#else
const float ADC_DIV = 190.0; // Divisor für Batteriespannung bei HW-Version 2
const float ADC_DIV = 190.0; // Divisor für Batteriespannung bei HW-Version 2 (MR)
#endif

#define HOSTNAME "GZ16-ESP-" // Hostname, 3 Byte Chip-ID werden angehangen

#define VERSION 1
#define BUILD 93
#define BUILD 95
#define DEBUG_OUTPUT_SERIAL false
//#define DEBUG_OUTPUT_SERIAL true

Expand Down Expand Up @@ -272,6 +268,7 @@ void setup (void) {

// Initialize file system.
SerialPrintLine(); // Trennlinie seriell ausgeben
LittleFS.setTimeCallback(LittleFsTimeCallback); // for LittleFS filesystems file timestamp
if (!LittleFS.begin()) {
//filesystem = false;
Serial.println(F("LittleFS Failed to mount file system"));
Expand Down
56 changes: 16 additions & 40 deletions Websites.ino
Original file line number Diff line number Diff line change
Expand Up @@ -199,22 +199,21 @@ nocheinmal: // Sprungmarke für 2. Durchlauf bei 2 Jahren
// ############################## Einstellungen diverse anzeigen ##############################
void SiteSetup() {
String sResponse = ""; // Response HTML
String qs0count = server.arg("s0count"); // S0-Count
String submit = server.arg("submit"); // welcher Button wurde betätigt
String logtext = "";
int countargs = server.args(); // Anzahl Argumente
if (countargs != 0) {
if (SerialOutput == 1) { // serielle Ausgabe eingeschaltet
SerialPrintLine(); // Trennlinie seriell ausgeben
if (SerialOutput == 1) { // serielle Ausgabe eingeschaltet
SerialPrintLine(); // Trennlinie seriell ausgeben
}
#if DEBUG_OUTPUT_SERIAL == true
Serial.print(F("S0-Count: "));
Serial.println(qs0count);
Serial.print(F("Button wurde betaetigt(submit): "));
Serial.println(submit);
Serial.print(F("Anzahl Argumente(countargs): "));
Serial.println(countargs);
#endif
if (submit == "saves0count") { // Button "Zählerstand speichern" betätigt
String qs0count = server.arg("s0count"); // S0-Count
// Prüfung auf Zahl einfügen
qs0count.replace(",", "."); // Komma durch Punkt ersetzen
if (SerialOutput == 1) { // serielle Ausgabe eingeschaltet
Expand All @@ -223,81 +222,58 @@ void SiteSetup() {
}
s0_count_abs = round(qs0count.toFloat() * 100.0); // "toFloat" funktioniert nicht richtig, deshalb runden
DS1307_write_long(DS1307_ADDR_S0COUNTABS, s0_count_abs); // save S0-Counter to DS1307 RAM
String logtext = F("Set Counter to: ");
logtext = F("Set Counter to: ");
logtext += longToStr(s0_count_abs);
logtext += F("");
appendLogFile(logtext);
if (SerialOutput == 1) { // serielle Ausgabe eingeschaltet
Serial.println(logtext);
}
}
if (submit == "resetMaxDay") { // Button "Rückstellen" betätigt
s0_count_max_day = 0; // Maximum pro Tag löschen
DS1307_write_long(DS1307_ADDR_MAXS0DAY, s0_count_max_day); // Maximum pro Tag speichern
DS1307_write_long(DS1307_ADDR_MAXS0DAYTIME, now()); // aktuelle Uhrzeit speichern
String logtext = F("Reset max consumption per day");
appendLogFile(logtext);
if (SerialOutput == 1) { // serielle Ausgabe eingeschaltet
Serial.println(logtext);
}
logtext = F("Reset max consumption per day");
}
if (submit == "resetMaxMonth") { // Button "Rückstellen" betätigt
s0_count_max_month = 0; // Maximum pro Monat löschen
DS1307_write_long(DS1307_ADDR_MAXS0MONTH, s0_count_max_month); // Maximum Monat speichern
DS1307_write_long(DS1307_ADDR_MAXS0MONTHTIME, now()); // aktuelle Uhrzeit speichern
String logtext = F("Reset max consumption per month");
appendLogFile(logtext);
if (SerialOutput == 1) { // serielle Ausgabe eingeschaltet
Serial.println(logtext);
}
logtext = F("Reset max consumption per month");
}
if (submit == "resetMaxYear") { // Button "Rückstellen" betätigt
s0_count_max_year = 0; // Maximum pro Jahr löschen
DS1307_write_long(DS1307_ADDR_MAXS0YEAR, s0_count_max_year); // Maximum Jahr speichern
DS1307_write_long(DS1307_ADDR_MAXS0YEARTIME, now()); // aktuelle Uhrzeit speichern
String logtext = F("Reset max consumption per year");
appendLogFile(logtext);
if (SerialOutput == 1) { // serielle Ausgabe eingeschaltet
Serial.println(logtext);
}
logtext += F("Reset max consumption per year");
}
if (submit == "sets0trip1") { // Button "Rückstellen" betätigt
EEPROM_write_long(EEPROM_ADDR_S0TRIP1, s0_count_abs); // S0-Count Trip begin set to S0-Count
EEPROM_write_long(EEPROM_ADDR_S0TRIP1TIME, now()); // S0-Count Trip time set
String logtext = F("Reset Counter 1 to: ");
logtext = F("Reset Counter 1 to: ");
logtext += longToStr(s0_count_abs);
logtext += F("");
appendLogFile(logtext);
if (SerialOutput == 1) { // serielle Ausgabe eingeschaltet
Serial.println(logtext);
}
}
if (submit == "sets0trip2") { // Button "Rückstellen" betätigt
EEPROM_write_long(EEPROM_ADDR_S0TRIP2, s0_count_abs); // S0-Count Trip begin set to S0-Count
EEPROM_write_long(EEPROM_ADDR_S0TRIP2TIME, now()); // S0-Count Trip time set
String logtext = F("Reset Counter 2 to: ");
logtext = F("Reset Counter 2 to: ");
logtext += longToStr(s0_count_abs);
logtext += F("");
appendLogFile(logtext);
if (SerialOutput == 1) { // serielle Ausgabe eingeschaltet
Serial.println(logtext);
}
}
if (submit == "setser") {
SerialOutput = !SerialOutput;// toggle boolean
EEPROM_write_byte(EEPROM_ADDR_SERIALOUTPUT, SerialOutput); // write byte at address
String logtext = F("Serial Output: ");
logtext = F("Serial Output: ");
if (SerialOutput == 1) { // serielle Ausgabe eingeschaltet
logtext += F("on");
} else { // serielle Ausgabe ausgeschaltet
logtext += F("off");
}
appendLogFile(logtext);
if (SerialOutput == 1) { // serielle Ausgabe eingeschaltet
Serial.println(logtext);
}
}
appendLogFile(logtext);
if (SerialOutput == 1) { // serielle Ausgabe eingeschaltet
Serial.println(logtext);
}
}

// Beginn HTML
insertHeaderCSS(sResponse); // Header und CCS einfügen
sResponse += F("<link rel=\"stylesheet\" type=\"text/css\" href=\"static/button.css\">");
Expand Down
15 changes: 14 additions & 1 deletion ZLog.ino
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
https://github.com/esp8266/arduino-esp8266fs-plugin
https://github.com/esp8266/arduino-esp8266fs-plugin/releases/
kopieren nach:
D:\Eigene Dateien\Eigene Dokumente\Arduino\tools\ESP8266FS\tool\esp8266fs.jar
E:\Eigene Dateien\Eigene Dokumente\Arduino\tools\ESP8266FS\tool\esp8266fs.jar
für ESP8266 Little Data-Upload-Tool installieren:
https://github.com/earlephilhower/arduino-esp8266littlefs-plugin
Expand Down Expand Up @@ -69,6 +69,19 @@
If you know all this and you knew how to do it, then you should have told me ...
---------------------------------------------------------------------------------------------------------------------
2022-06-04
- in Websites.ino void SiteSetup diverse Logausausgaben aus submit ans Ende verschoben
Der Sketch verwendet 479541 Bytes (45%) des Programmspeicherplatzes. Das Maximum sind 1044464 Bytes.
Globale Variablen verwenden 37584 Bytes (45%) des dynamischen Speichers, 44336 Bytes für lokale Variablen verbleiben. Das Maximum sind 81920 Bytes.
2022-06-02
- LittleFS.setTimeCallback (LittleFS filesystems file timestamp hinzugefügt), entfernt:
- extern "C" {
- #include "user_interface.h"
- }
Der Sketch verwendet 479733 Bytes (45%) des Programmspeicherplatzes. Das Maximum sind 1044464 Bytes.
Globale Variablen verwenden 37584 Bytes (45%) des dynamischen Speichers, 44336 Bytes für lokale Variablen verbleiben. Das Maximum sind 81920 Bytes.
2022-01-27
- add command restart
- F-Macro in server.on...
Expand Down

0 comments on commit 8c8facd

Please sign in to comment.