diff --git a/src/components/ble/SimpleWeatherService.h b/src/components/ble/SimpleWeatherService.h index 0f8c181bd3..61dc264c75 100644 --- a/src/components/ble/SimpleWeatherService.h +++ b/src/components/ble/SimpleWeatherService.h @@ -22,6 +22,9 @@ #include #include +#include +#include "displayapp/InfiniTimeTheme.h" + #define min // workaround: nimble's min/max macros conflict with libstdc++ #define max #include @@ -86,6 +89,17 @@ namespace Pinetime { return raw == other.raw; } + [[nodiscard]] lv_color_t Color() const { + if (Celsius() <= 0) { // freezing + return Colors::blue; + } else if (Celsius() <= 4) { // ice + return LV_COLOR_CYAN; + } else if (Celsius() >= 27) { // hot + return Colors::deepOrange; + } + return Colors::orange; // normal + } + private: int16_t raw; }; diff --git a/src/displayapp/screens/WatchFaceTerminal.cpp b/src/displayapp/screens/WatchFaceTerminal.cpp index 568c842131..6b850052e6 100644 --- a/src/displayapp/screens/WatchFaceTerminal.cpp +++ b/src/displayapp/screens/WatchFaceTerminal.cpp @@ -15,19 +15,6 @@ using namespace Pinetime::Applications::Screens; -namespace { - lv_color_t TemperatureColor(Pinetime::Controllers::SimpleWeatherService::Temperature temp) { - if (temp.Celsius() <= 0) { // freezing - return Colors::blue; - } else if (temp.Celsius() <= 4) { // ice - return LV_COLOR_CYAN; - } else if (temp.Celsius() >= 27) { // hot - return Colors::deepOrange; - } - return Colors::orange; // normal - } -} - WatchFaceTerminal::WatchFaceTerminal(Controllers::DateTime& dateTimeController, const Controllers::Battery& batteryController, const Controllers::Ble& bleController, @@ -177,7 +164,7 @@ void WatchFaceTerminal::Refresh() { if (optCurrentWeather) { int16_t temp = optCurrentWeather->temperature.Celsius(); char tempUnit = 'C'; - lv_obj_set_style_local_text_color(weather, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, TemperatureColor(optCurrentWeather->temperature)); + lv_obj_set_style_local_text_color(weather, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, optCurrentWeather->temperature.Color()); if (settingsController.GetWeatherFormat() == Controllers::Settings::WeatherFormat::Imperial) { temp = optCurrentWeather->temperature.Fahrenheit(); tempUnit = 'F';