From 2fd51c80eac749ed581c9cd2639637caac5e3544 Mon Sep 17 00:00:00 2001 From: Thomas Ballmann Date: Sun, 29 Nov 2020 10:57:30 +0100 Subject: [PATCH] move missing settings to config --- lib/app/app.cpp | 7 ++++--- lib/datetime/datetime.cpp | 7 ++++--- lib/face/faceCalendar.cpp | 9 +++++++++ lib/face/faceWeather.cpp | 1 - 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/lib/app/app.cpp b/lib/app/app.cpp index a60fcd7..c74d442 100644 --- a/lib/app/app.cpp +++ b/lib/app/app.cpp @@ -3,6 +3,8 @@ #include "app.h" #include "ESPAsyncWebServer.h" #include +#define ARDUINOJSON_DECODE_UNICODE 1 +#define ARDUINOJSON_USE_LONG_LONG 1 #include "ArduinoJson.h" #include "settings.h" #include "device.h" @@ -180,14 +182,12 @@ void setupApiSettings() root["system"]["dst"] = NVS.getInt("system.dst"); root["system"]["wifi"] = NVS.getString("wifi.ssid"); - // gmtOffset_sec - // daylightOffset_sec - //root["device"]["angle"] = NVS.getInt("device.angle"); root["device"]["theme"] = NVS.getString("device.theme"); root["device"]["name"] = NVS.getString("device.name"); root["playlist"]["timer"] = NVS.getInt("playlist.timer"); + root["playlist"]["images"] = NVS.getString("playlist.images"); root["weather"]["api"] = NVS.getString("weather.api"); root["weather"]["location"] = NVS.getInt("weather.loc"); @@ -234,6 +234,7 @@ void setupApiSettings() JsonVariant playlist = doc["playlist"]; if (!playlist.isNull()) { NVS.setInt("playlist.timer", playlist["timer"].as()); + NVS.setString("playlist.images", playlist["images"]); } JsonVariant weather = doc["weather"]; diff --git a/lib/datetime/datetime.cpp b/lib/datetime/datetime.cpp index fece5fb..f0b7d2b 100644 --- a/lib/datetime/datetime.cpp +++ b/lib/datetime/datetime.cpp @@ -2,13 +2,11 @@ #include #include #include "datetime.h" +#include "settings.h" RTC_DATA_ATTR struct datetime_struct now; -// TODO offset const char *ntpServer = "pool.ntp.org"; -const long gmtOffset_sec = 3600; -const int daylightOffset_sec = 3600; unsigned long lastUpdate = 0; @@ -54,6 +52,9 @@ bool updateDateTime() void setupDateTime() { + int gmtOffset_sec = NVS.getInt("system.utc"); + int daylightOffset_sec = NVS.getInt("system.dst"); + configTime(gmtOffset_sec, daylightOffset_sec, ntpServer); if (!updateDateTime()) diff --git a/lib/face/faceCalendar.cpp b/lib/face/faceCalendar.cpp index 69730ef..f7e91ef 100644 --- a/lib/face/faceCalendar.cpp +++ b/lib/face/faceCalendar.cpp @@ -65,6 +65,15 @@ void showFaceCalendar() */ bool updateCalendarData() { + String url = NVS.getString("service.image"); + + // TODO + if (url) { + url += "390x384.jpg" + } + // url += "APPID=" + NVS.getString("service.image"); + // char faceCalendarPictureUrl[] = NVS.getString("service.image"); + return downloadFile(faceCalendarPictureUrl, faceCalendarPicture); } diff --git a/lib/face/faceWeather.cpp b/lib/face/faceWeather.cpp index 0954e5f..849c6b7 100644 --- a/lib/face/faceWeather.cpp +++ b/lib/face/faceWeather.cpp @@ -160,7 +160,6 @@ void render_forecast() } } -// @todo load params from settings // @see https://openweathermap.org/appid#work // @note no more than one time every 10 minutes for one location bool downloadWeatherData()