Added Uptime library and showing of uptime values.

master
Holger Wirtz 4 years ago
parent d6c3f4e5d8
commit 17ff2e905e
  1. 11
      WLAN_Thermometer.ino

@ -13,6 +13,7 @@
#include <Time.h> #include <Time.h>
#include <DHT.h> #include <DHT.h>
#include <esp_task_wdt.h> #include <esp_task_wdt.h>
#include <uptime.h>
#define MDNS_NAME "wlanthermometer" #define MDNS_NAME "wlanthermometer"
#define AP_SSID_CONFIG_NAME "WLANTHERMOMETER-Config" #define AP_SSID_CONFIG_NAME "WLANTHERMOMETER-Config"
@ -50,6 +51,7 @@ uint8_t add_summertime = 0;
bool last_reset_ap_check = false; bool last_reset_ap_check = false;
//bool minmax_enabled = false; //bool minmax_enabled = false;
char date_string_old[9]; char date_string_old[9];
char uptime_string[23];
enum { enum {
ACT, ACT,
@ -337,6 +339,10 @@ void loop()
client.println("</h4>"); client.println("</h4>");
} }
client.print("<h5 style=\"color:black;\">");
client.print(uptime_string);
client.println("</h5>");
client.println("</center>"); client.println("</center>");
client.println("</body>"); client.println("</body>");
client.println("</html>"); client.println("</html>");
@ -388,6 +394,8 @@ void show_time(void)
char date_string[11]; char date_string[11];
char time_string[9]; char time_string[9];
uptime::calculateUptime();
if (DateTime.isTimeValid()) if (DateTime.isTimeValid())
{ {
DateTimeParts p = DateTime.getParts(); DateTimeParts p = DateTime.getParts();
@ -405,12 +413,15 @@ void show_time(void)
sprintf(date_string, "%02d.%02d.%4d", p.getMonthDay(), p.getMonth() + 1, p.getYear()); sprintf(date_string, "%02d.%02d.%4d", p.getMonthDay(), p.getMonth() + 1, p.getYear());
sprintf(time_string, "%02d:%02d:%02d", p.getHours() + add_summertime, p.getMinutes(), p.getSeconds()); sprintf(time_string, "%02d:%02d:%02d", p.getHours() + add_summertime, p.getMinutes(), p.getSeconds());
sprintf(uptime_string, "Uptime: %4dd %02d:%02d:%02d", uptime::getDays(), uptime::getHours(), uptime::getMinutes(), uptime::getSeconds());
DEBUG_MSG("%s %s", date_string, time_string); DEBUG_MSG("%s %s", date_string, time_string);
if (add_summertime > 0) if (add_summertime > 0)
DEBUG_MSG(" Summertime\n"); DEBUG_MSG(" Summertime\n");
else else
DEBUG_MSG(" Wintertime\n"); DEBUG_MSG(" Wintertime\n");
DEBUG_MSG("%s\n", uptime_string);
} }
else else
{ {

Loading…
Cancel
Save