Fix WiFi reconnect bugs, negative-temp rounding, and stale docs
- Clear WIFI_CONNECTED_BIT on disconnect so wifi_is_connected() stops reporting a link that is gone; the weather task's reconnect path was dead code without it. - After the 8 fast retries are spent, retry every 30s via an esp_timer forever instead of giving up until power cycle. FAIL_BIT now only unblocks the boot-time wait and is cleared on reconnect. - Start the weather task even when the boot-time connect times out -- the background retries may still bring WiFi up later. Only an empty SSID skips it. - Round temperatures with lroundf(): the old +0.5f-and-truncate rounded toward zero below 0degF (-10.6 displayed as -10). - Drop the stale single-framebuffer "Partial-mode flush" comment in display_rgb.c, fix the README paragraph claiming the bounce buffer is disabled (it is enabled and load-bearing), and correct the sdkconfig.defaults header to N16R8/16MB. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0ef2017d18
commit
dd2d4283e2
5 files changed
+59
-26
No files matched your search
+18
-8
@@ -1,3 +1,4 @@
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -54,7 +55,9 @@ static void weather_update_task(void *arg)
|
||||
snprintf(detail, sizeof(detail), "%.0f%% humidity",
|
||||
weather.has_humidity ? weather.humidity : 0.0f);
|
||||
|
||||
ui_update_weather((int16_t)(weather.temp_f + 0.5f),
|
||||
/* lroundf, not +0.5f-and-truncate: the latter rounds toward zero
|
||||
* below 0°F, turning -10.6 into -10. */
|
||||
ui_update_weather((int16_t)lroundf(weather.temp_f),
|
||||
weather.has_humidity ? detail : "Outdoor");
|
||||
|
||||
wifi_get_status(line, sizeof(line));
|
||||
@@ -83,7 +86,7 @@ void app_main(void)
|
||||
*/
|
||||
const esp_err_t wifi_err = wifi_init_sta();
|
||||
if (wifi_err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "WiFi failed -- continuing, weather will be disabled");
|
||||
ESP_LOGE(TAG, "WiFi not up yet -- weather starts when it connects");
|
||||
}
|
||||
|
||||
/* LVGL core must exist before the display and touch drivers register
|
||||
@@ -114,15 +117,22 @@ void app_main(void)
|
||||
vTaskDelay(pdMS_TO_TICKS(100));
|
||||
ESP_ERROR_CHECK(backlight_set(255));
|
||||
|
||||
if (wifi_err != ESP_OK) {
|
||||
ui_set_status("WiFi: failed");
|
||||
if (wifi_err == ESP_OK) {
|
||||
char status[96];
|
||||
wifi_get_status(status, sizeof(status));
|
||||
ui_set_status(status);
|
||||
} else if (wifi_err == ESP_FAIL || wifi_err == ESP_ERR_TIMEOUT) {
|
||||
/* The event handler keeps retrying in the background; the weather
|
||||
* task polls wifi_is_connected(), so start it anyway rather than
|
||||
* permanently disabling weather because boot raced a slow AP. */
|
||||
ui_set_status("WiFi: connecting...");
|
||||
} else {
|
||||
/* No SSID configured (or setup failed outright) -- nothing will ever
|
||||
* connect, so there is no point starting the weather task. */
|
||||
ui_set_status("WiFi: not configured");
|
||||
return;
|
||||
}
|
||||
|
||||
char status[96];
|
||||
wifi_get_status(status, sizeof(status));
|
||||
ui_set_status(status);
|
||||
|
||||
if (weather_init() != ESP_OK) {
|
||||
ui_set_status("Weather: no API credentials");
|
||||
return;
|
||||
|
||||
Reference in new issue
Block a user