From d1c146e2fbad5ae01adfb9c2c67dc1eb61a4e298 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Milants?= Date: Sun, 17 Sep 2023 20:19:11 +0200 Subject: [PATCH] Improve and fix WeatherService Ensure that PTS will update the weather info if temperature and cloud info were received. Assume 0 precipitation if no precipitation event were received. --- .../screens/WatchFacePineTimeStyle.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/displayapp/screens/WatchFacePineTimeStyle.cpp b/src/displayapp/screens/WatchFacePineTimeStyle.cpp index 250a745c..c5b5fe19 100644 --- a/src/displayapp/screens/WatchFacePineTimeStyle.cpp +++ b/src/displayapp/screens/WatchFacePineTimeStyle.cpp @@ -537,11 +537,22 @@ void WatchFacePineTimeStyle::Refresh() { } } - if (weatherService.GetCurrentTemperature()->timestamp != 0 && weatherService.GetCurrentClouds()->timestamp != 0 && - weatherService.GetCurrentPrecipitation()->timestamp != 0) { + const auto& newTemperatureEvent = weatherService.GetCurrentTemperature(); + const auto& newCloudsEvent = weatherService.GetCurrentClouds(); + const auto& newPrecipitationEvent = weatherService.GetCurrentPrecipitation(); + + if(newTemperatureEvent->timestamp == 0 && newCloudsEvent->timestamp == 0 && newPrecipitationEvent == 0) { + lv_label_set_text_static(temperature, "--"); + lv_label_set_text(weatherIcon, Symbols::ban); + lv_obj_realign(temperature); + lv_obj_realign(weatherIcon); + } + + // Assume 0 precipitation if no precipitation event were received + if (newTemperatureEvent->timestamp != 0 && newCloudsEvent->timestamp != 0 /*&& newPrecipitationEvent->timestamp !=0*/) { nowTemp = (weatherService.GetCurrentTemperature()->temperature / 100); clouds = (weatherService.GetCurrentClouds()->amount); - precip = (weatherService.GetCurrentPrecipitation()->amount); + precip = (newPrecipitationEvent->timestamp != 0) ? weatherService.GetCurrentPrecipitation()->amount : 0; if (nowTemp.IsUpdated()) { lv_label_set_text_fmt(temperature, "%d°", nowTemp.Get()); if ((clouds <= 30) && (precip == 0)) {