diff options
| author | FintasticMan <finlay.neon.kid@gmail.com> | 2024-02-20 11:25:02 +0100 |
|---|---|---|
| committer | JF <JF002@users.noreply.github.com> | 2024-11-04 21:22:38 +0100 |
| commit | 29ad09f4ef54126831d36fe1b99e794059fc5421 (patch) | |
| tree | 4699e2008850c8f99297abcf549844317ab0cdb2 /src/displayapp/screens/WatchFacePineTimeStyle.cpp | |
| parent | afeded0126ff3bb30bdd5b1ed55f5dddca8b92d5 (diff) | |
weather: Refactor temperature type for type safety
There is now a Temperature struct in the weather service, which holds
the internal representation. There is also a temperature struct in the
Applications namespace, which holds the temperature in either Celsius or
Fahrenheit.
Diffstat (limited to 'src/displayapp/screens/WatchFacePineTimeStyle.cpp')
| -rw-r--r-- | src/displayapp/screens/WatchFacePineTimeStyle.cpp | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/src/displayapp/screens/WatchFacePineTimeStyle.cpp b/src/displayapp/screens/WatchFacePineTimeStyle.cpp index e56031f7..c5946111 100644 --- a/src/displayapp/screens/WatchFacePineTimeStyle.cpp +++ b/src/displayapp/screens/WatchFacePineTimeStyle.cpp @@ -22,7 +22,8 @@ #include "displayapp/screens/WatchFacePineTimeStyle.h" #include <lvgl/lvgl.h> #include <cstdio> -#include <displayapp/Colors.h> +#include "displayapp/Colors.h" +#include "displayapp/Weather.h" #include "displayapp/screens/BatteryIcon.h" #include "displayapp/screens/BleIcon.h" #include "displayapp/screens/NotificationIcon.h" @@ -543,11 +544,7 @@ void WatchFacePineTimeStyle::Refresh() { if (currentWeather.IsUpdated()) { auto optCurrentWeather = currentWeather.Get(); if (optCurrentWeather) { - int16_t temp = optCurrentWeather->temperature; - if (settingsController.GetWeatherFormat() == Controllers::Settings::WeatherFormat::Imperial) { - temp = Controllers::SimpleWeatherService::CelsiusToFahrenheit(temp); - } - temp = temp / 100 + (temp % 100 >= 50 ? 1 : 0); + Applications::Temperature temp = Applications::Convert(optCurrentWeather->temperature, settingsController.GetWeatherFormat()); lv_label_set_text_fmt(temperature, "%d°", temp); lv_label_set_text(weatherIcon, Symbols::GetSymbol(optCurrentWeather->iconId)); } else { |
