diff --git a/src/api/weather_api.cpp b/src/api/weather_api.cpp index 20e147c..d69d8cd 100644 --- a/src/api/weather_api.cpp +++ b/src/api/weather_api.cpp @@ -28,17 +28,7 @@ WeatherData fetchWeather() { fe.precipitationType = precip["type"] | ""; data.forecast.push_back(fe); } + data.willRainSoon = doc["willRainSoon"] | false; data.valid = true; return data; } - -bool willRainSoon(const WeatherData &data, int hours) { - if (!data.valid) return false; - int checked = 0; - for (const auto &entry : data.forecast) { - if (checked >= hours) break; - if (entry.precipitationType == "rain" && entry.precipitationProbability > 0.0f) return true; - checked++; - } - return false; -} diff --git a/src/api/weather_api.h b/src/api/weather_api.h index 73cf32e..464b5db 100644 --- a/src/api/weather_api.h +++ b/src/api/weather_api.h @@ -19,9 +19,9 @@ struct ForecastEntry { struct WeatherData { bool valid = false; + bool willRainSoon = false; WeatherCurrent current; std::vector forecast; }; WeatherData fetchWeather(); -bool willRainSoon(const WeatherData &data, int hours = 8); diff --git a/src/ui/home_screen.cpp b/src/ui/home_screen.cpp index 1f86494..8971ce3 100644 --- a/src/ui/home_screen.cpp +++ b/src/ui/home_screen.cpp @@ -35,7 +35,7 @@ void updateRainWarning(const WeatherData &w, bool ok) { lv_obj_del(rainWarningIcon); rainWarningIcon = nullptr; } - if (ok && willRainSoon(w, 8)) { + if (ok && w.willRainSoon) { rainWarningIcon = Icons::createRainWarning(weatherTile.btn, 28); lv_obj_align(rainWarningIcon, LV_ALIGN_TOP_RIGHT, -4, 4); }