diff --git a/src/html.cpp b/src/html.cpp index 8bbff7d..e24fa76 100644 --- a/src/html.cpp +++ b/src/html.cpp @@ -2,23 +2,6 @@ #include void reload_home() { - char time_current[3][3] = {"", "", ""}; - if (myTime.hour() < 10) { - sprintf(time_current[0], "0%d", myTime.hour()); - } else { - sprintf(time_current[0], "%d", myTime.hour()); - } - if (myTime.minute() < 10) { - sprintf(time_current[1], "0%d", myTime.minute()); - } else { - sprintf(time_current[1], "%d", myTime.minute()); - } - if (myTime.second() < 10) { - sprintf(time_current[2], "0%d", myTime.second()); - } else { - sprintf(time_current[2], "%d", myTime.second()); - } - sprintf(home_html, "\ \ \ @@ -79,7 +62,7 @@ void reload_home() { \
\

Übersicht

\ -

Uhrzeit: %s:%s:%s

\ +

Uhrzeit: %02d:%02d:%02d

\
\
\ Ventil 1: \ @@ -120,7 +103,7 @@ void reload_home() {
\ \ ", - time_current[0], time_current[1], time_current[2], stat[0], stat[1], + myTime.hour(), myTime.minute(), myTime.second(), stat[0], stat[1], stat[2], stat[3], stat[4], stat[5], stat[6], stat[7]); } diff --git a/src/main.cpp b/src/main.cpp index 53a532a..0d8b5d0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -159,11 +159,7 @@ void load_EEPROM() { unsigned int EEPROM_Addr = 0; for (unsigned int i0 = 0; i0 < 8; i0++) { for (unsigned int i = 0; i < 8; i++) { - if (EEPROM.read(EEPROM_Addr) < 10) { - sprintf(time_all[i0][i], "0%d", EEPROM.read(EEPROM_Addr)); - } else { - sprintf(time_all[i0][i], "%d", EEPROM.read(EEPROM_Addr)); - } + sprintf(time_all[i0][i], "%02d", EEPROM.read(EEPROM_Addr)); EEPROM_Addr += 4; yield(); } @@ -193,10 +189,10 @@ void handleTime() { server.arg(args[arg])[1]}; char buff_m[2][2] = {server.arg(args[arg])[3], server.arg(args[arg])[4]}; - sprintf(time_all[arg * 2][server.arg("rule").toInt()], "%s", - buff_h); - sprintf(time_all[arg * 2 + 1][server.arg("rule").toInt()], "%s", - buff_m); + sprintf(time_all[arg * 2][server.arg("rule").toInt()], "%s%s", + buff_h[0], buff_h[1]); + sprintf(time_all[arg * 2 + 1][server.arg("rule").toInt()], "%s%s", + buff_m[0], buff_m[1]); EEPROM.put(server.arg("rule").toInt() * 4 + arg * 64, atoi(time_all[arg * 2][server.arg("rule").toInt()]));