- Use localTime instead of epochTime when formatting date string, so date rolls over at local midnight, not UTC midnight (fixes #5) - Remove WEATHER_SUCCESS state assignment that blocked periodic refresh; state correctly stays WEATHER_IDLE after successful fetch (fixes #7) - Fix weather debug page "Last update" to show elapsed seconds (millis() - lastUpdate) instead of raw timestamp Applied from PR #6 by @Mysteoa with a compilation fix in web_server.cpp (missing closing parenthesis in snprintf_P call). Co-authored-by: Mysteoa <mysteoa@users.noreply.github.com> Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Mysteoa
Claude Sonnet 4.6
parent
9c0f269ee5
commit
441c61676b
@@ -54,7 +54,7 @@ void ICACHE_FLASH_ATTR updateDisplay() {
|
|||||||
|
|
||||||
// === YELLOW ZONE (Y: 48-63): Date (size 2 = 16px height) ===
|
// === YELLOW ZONE (Y: 48-63): Date (size 2 = 16px height) ===
|
||||||
display.setTextSize(2);
|
display.setTextSize(2);
|
||||||
time_t t = epochTime;
|
time_t t = localTime;
|
||||||
struct tm *ptm = gmtime(&t);
|
struct tm *ptm = gmtime(&t);
|
||||||
|
|
||||||
// Format: "Thu 02.01" or "! Thu 02.01" if no WiFi
|
// Format: "Thu 02.01" or "! Thu 02.01" if no WiFi
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ void ICACHE_FLASH_ATTR onWeatherResponse(void* optParm, AsyncHTTPRequest* reques
|
|||||||
sunTimes.lastDay = ptm->tm_yday;
|
sunTimes.lastDay = ptm->tm_yday;
|
||||||
}
|
}
|
||||||
|
|
||||||
weatherState = WEATHER_SUCCESS;
|
// weatherState stays WEATHER_IDLE (set at readyState==4 entry) — allows periodic refresh
|
||||||
weatherRetry.reset();
|
weatherRetry.reset();
|
||||||
Serial.printf("Weather: %.1f C, code %d, wind %.1f km/h\n",
|
Serial.printf("Weather: %.1f C, code %d, wind %.1f km/h\n",
|
||||||
weather.temperature, weather.weathercode, weather.windspeed);
|
weather.temperature, weather.weathercode, weather.windspeed);
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ void ICACHE_FLASH_ATTR handleDebug() {
|
|||||||
|
|
||||||
if (weather.valid) {
|
if (weather.valid) {
|
||||||
snprintf_P(buf, sizeof(buf), PSTR("Temperature: %.1f C\nWeather code: %d\nWind speed: %.1f km/h\nLast update: %lu sec ago\n"),
|
snprintf_P(buf, sizeof(buf), PSTR("Temperature: %.1f C\nWeather code: %d\nWind speed: %.1f km/h\nLast update: %lu sec ago\n"),
|
||||||
weather.temperature, weather.weathercode, weather.windspeed, weather.lastUpdate/1000);
|
weather.temperature, weather.weathercode, weather.windspeed, (millis() - weather.lastUpdate)/1000);
|
||||||
server.sendContent(buf);
|
server.sendContent(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -988,7 +988,7 @@ void updateDisplay() {
|
|||||||
|
|
||||||
// === YELLOW ZONE (Y: 48-63): Date (size 2 = 16px height) ===
|
// === YELLOW ZONE (Y: 48-63): Date (size 2 = 16px height) ===
|
||||||
display.setTextSize(2);
|
display.setTextSize(2);
|
||||||
time_t t = epochTime;
|
time_t t = localTime;
|
||||||
struct tm *ptm = gmtime(&t);
|
struct tm *ptm = gmtime(&t);
|
||||||
|
|
||||||
// Format: "Thu 02.01" or "! Thu 02.01" if no WiFi
|
// Format: "Thu 02.01" or "! Thu 02.01" if no WiFi
|
||||||
@@ -1453,7 +1453,7 @@ void ICACHE_FLASH_ATTR handleDebug() {
|
|||||||
|
|
||||||
if (weather.valid) {
|
if (weather.valid) {
|
||||||
snprintf_P(buf, sizeof(buf), PSTR("Temperature: %.1f°C\nWeather code: %d\nWind speed: %.1f km/h\nLast update: %lu sec ago\n"),
|
snprintf_P(buf, sizeof(buf), PSTR("Temperature: %.1f°C\nWeather code: %d\nWind speed: %.1f km/h\nLast update: %lu sec ago\n"),
|
||||||
weather.temperature, weather.weathercode, weather.windspeed, weather.lastUpdate/1000);
|
weather.temperature, weather.weathercode, weather.windspeed, (millis() - weather.lastUpdate)/1000);
|
||||||
server.sendContent(buf);
|
server.sendContent(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2081,7 +2081,7 @@ void onWeatherResponse(void* optParm, AsyncHTTPRequest* request, int readyState)
|
|||||||
sunTimes.lastDay = ptm->tm_yday;
|
sunTimes.lastDay = ptm->tm_yday;
|
||||||
}
|
}
|
||||||
|
|
||||||
weatherState = WEATHER_SUCCESS;
|
// weatherState stays WEATHER_IDLE (set at readyState==4 entry) — allows periodic refresh
|
||||||
weatherRetry.reset(); // Success! Reset retry counter
|
weatherRetry.reset(); // Success! Reset retry counter
|
||||||
Serial.printf("✓ Weather: %.1f°C, code %d, wind %.1f km/h\n",
|
Serial.printf("✓ Weather: %.1f°C, code %d, wind %.1f km/h\n",
|
||||||
weather.temperature, weather.weathercode, weather.windspeed);
|
weather.temperature, weather.weathercode, weather.windspeed);
|
||||||
|
|||||||
Reference in New Issue
Block a user