From f6796fa4481c389151b1ac3394255ec9e3609f14 Mon Sep 17 00:00:00 2001 From: Djuri Baars Date: Fri, 8 Sep 2023 22:25:24 +0200 Subject: [PATCH] Fix for negative timezone offsets --- src/lib/functions.cpp | 4 ++-- src/lib/webserver.cpp | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/lib/functions.cpp b/src/lib/functions.cpp index 32be979..dfdf56a 100644 --- a/src/lib/functions.cpp +++ b/src/lib/functions.cpp @@ -93,12 +93,12 @@ void setupComponents() void synchronizeTime() { - configTime(preferences.getUInt("gmtOffset", TIME_OFFSET_SECONDS), 0, NTP_SERVER); + configTime(preferences.getInt("gmtOffset", TIME_OFFSET_SECONDS), 0, NTP_SERVER); struct tm timeinfo; while (!getLocalTime(&timeinfo)) { - configTime(preferences.getUInt("gmtOffset", TIME_OFFSET_SECONDS), 0, NTP_SERVER); + configTime(preferences.getInt("gmtOffset", TIME_OFFSET_SECONDS), 0, NTP_SERVER); delay(500); Serial.println("Retry set time"); } diff --git a/src/lib/webserver.cpp b/src/lib/webserver.cpp index 59edbf7..94cdd22 100644 --- a/src/lib/webserver.cpp +++ b/src/lib/webserver.cpp @@ -9,6 +9,9 @@ void setupWebserver() // Initialize SPIFFS if (!SPIFFS.begin(true)) { + pinMode(47, OUTPUT); + digitalWrite(47, HIGH); + Serial.println("An Error has occurred while mounting SPIFFS"); return; } @@ -142,7 +145,7 @@ void onApiSettingsGet(AsyncWebServerRequest *request) root["bgColor"] = getBgColor(); root["timerSeconds"] = timerSeconds; root["timerRunning"] = timerRunning; - root["tzOffset"] = preferences.getUInt("gmtOffset", TIME_OFFSET_SECONDS) / 60; + root["tzOffset"] = preferences.getInt("gmtOffset", TIME_OFFSET_SECONDS) / 60; root["useBitcoinNode"] = preferences.getBool("useNode", false); root["rpcPort"] = preferences.getUInt("rpcPort", BITCOIND_PORT); root["rpcUser"] = preferences.getString("rpcUser", BITCOIND_RPC_USER); @@ -245,7 +248,9 @@ void onApiSettingsPost(AsyncWebServerRequest *request) { AsyncWebParameter *p = request->getParam("tzOffset", true); int tzOffsetSeconds = p->value().toInt() * 60; - preferences.putUInt("tzOffset", tzOffsetSeconds); + preferences.putInt("gmtOffset", tzOffsetSeconds); + Serial.print("Setting tz offset to "); + Serial.println(tzOffsetSeconds); settingsChanged = true; }