Sunrise/sunset re-calculated after saving time settings.

This commit is contained in:
Blaz Kristan 2021-03-08 19:52:43 +01:00
parent 09e51c2399
commit 142740f080
4 changed files with 5 additions and 3 deletions

View File

@ -264,7 +264,7 @@ void checkTimers()
lastTimerMinute = minute(localTime); lastTimerMinute = minute(localTime);
// calculate sunrise and sunset at midnight (if longitude and latitude are set) // calculate sunrise and sunset at midnight (if longitude and latitude are set)
if (((int)longitude || (int)latitude) /*&& ((!hour(localTime) && !minute(localTime)) || (!sunrise && !sunset))*/) { if (((int)longitude || (int)latitude) && ((!hour(localTime) && !minute(localTime)) || (!sunrise && !sunset))) {
struct tm tim_0; struct tm tim_0;
tim_0.tm_year = year(localTime)-1900; tim_0.tm_year = year(localTime)-1900;
tim_0.tm_mon = month(localTime)-1; tim_0.tm_mon = month(localTime)-1;

View File

@ -296,6 +296,8 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
if (ntpEnabled && WLED_CONNECTED && !ntpConnected) ntpConnected = ntpUdp.begin(ntpLocalPort); if (ntpEnabled && WLED_CONNECTED && !ntpConnected) ntpConnected = ntpUdp.begin(ntpLocalPort);
longitude = request->arg(F("LN")).toFloat(); longitude = request->arg(F("LN")).toFloat();
latitude = request->arg(F("LT")).toFloat(); latitude = request->arg(F("LT")).toFloat();
// force a sunrise/sunset re-calculation
sunrise = sunset =0;
if (request->hasArg(F("OL"))) { if (request->hasArg(F("OL"))) {
overlayDefault = request->arg(F("OL")).toInt(); overlayDefault = request->arg(F("OL")).toInt();

View File

@ -8,7 +8,7 @@
*/ */
// version code in format yymmddb (b = daily build) // version code in format yymmddb (b = daily build)
#define VERSION 2103081 #define VERSION 2103082
//uncomment this if you have a "my_config.h" file you'd like to use //uncomment this if you have a "my_config.h" file you'd like to use
//#define WLED_USE_MY_CONFIG //#define WLED_USE_MY_CONFIG

View File

@ -451,7 +451,7 @@ void getSettingsJS(byte subPage, char* dest)
sappends('s',SET_F("LT"),tm); sappends('s',SET_F("LT"),tm);
getTimeString(tm); getTimeString(tm);
sappends('m',SET_F("(\"times\")[0]"),tm); sappends('m',SET_F("(\"times\")[0]"),tm);
if ((int)longitude || (int)latitude) { if ((int)(longitude*10) || (int)(latitude*10)) {
sprintf_P(tm, PSTR("Sunrise: %02d:%02d Sunset: %02d:%02d"), hour(sunrise), minute(sunrise), hour(sunset), minute(sunset)); sprintf_P(tm, PSTR("Sunrise: %02d:%02d Sunset: %02d:%02d"), hour(sunrise), minute(sunrise), hour(sunset), minute(sunset));
sappends('m',SET_F("(\"times\")[1]"),tm); sappends('m',SET_F("(\"times\")[1]"),tm);
} }