m5paper: clear-night icon for sunny hours without UV, center hourly temperature without precipitation

This commit is contained in:
randy committed 2026-09-28 23:13:31 +02:00
1 parent b523963944
commit e13be73596
2 files changed
+7 -2

No files matched your search

+3
View File
@@ -123,6 +123,9 @@ inline bool parse(ArduinoJson::JsonObjectConst response, const char *entity, uin
} }
Hour &hour = out.hours[out.count++]; Hour &hour = out.hours[out.count++];
hour.cond = condition_code(item["condition"] | ""); hour.cond = condition_code(item["condition"] | "");
// OpenWeatherMap reports "sunny" for clear nights too; no UV means the sun is down
if (hour.cond == condition_code("sunny") && (item["uv_index"] | 1.0f) == 0.0f)
hour.cond = condition_code("clear-night");
float temp = item["temperature"] | NAN; float temp = item["temperature"] | NAN;
hour.temp2 = std::isnan(temp) ? NO_TEMP : int8_t(std::max(-127L, std::min(127L, lroundf(temp * 2)))); hour.temp2 = std::isnan(temp) ? NO_TEMP : int8_t(std::max(-127L, std::min(127L, lroundf(temp * 2))));
float wind = item["wind_speed"] | NAN; float wind = item["wind_speed"] | NAN;
+4 -2
View File
@@ -616,9 +616,11 @@ display:
it.printf(x, y + 14, id(font_hour), id(ink), "%02d", t.hour); it.printf(x, y + 14, id(font_hour), id(ink), "%02d", t.hour);
if (h->cond < NUM_CONDITIONS) if (h->cond < NUM_CONDITIONS)
it.image(x + 42, y + 8, small[h->cond], id(ink)); it.image(x + 42, y + 8, small[h->cond], id(ink));
// temperature in line with the hour, lifted only to make room for the precipitation below
const bool show_pop = h->pop != NO_VALUE && h->pop >= 10;
if (h->temp2 != NO_TEMP) if (h->temp2 != NO_TEMP)
it.printf(x + 94, y + 6, id(font_hour), id(ink), "%.0f°", h->temp2 / 2.0f); it.printf(x + 94, show_pop ? y + 6 : y + 14, id(font_hour), id(ink), "%.0f°", h->temp2 / 2.0f);
if (h->pop != NO_VALUE && h->pop >= 10) if (show_pop)
it.printf(x + 94, y + 38, id(font_tiny), id(ink), "%u %%", h->pop); it.printf(x + 94, y + 38, id(font_tiny), id(ink), "%u %%", h->pop);
} }
for (int c = 1; c < 3; c++) for (int c = 1; c < 3; c++)