diff options
| author | Scott <development@justscott.me> | 2025-11-08 12:53:04 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-11-08 18:53:04 +0000 |
| commit | 9093d18efc1df0be5366444fd72129dae19b2f20 (patch) | |
| tree | b7db53d54eea54e875548e8431101b2bf0dbde5a /src | |
| parent | 075e02a33e7a362197f279edc015b596c4f9cd4e (diff) | |
Move TemperatureColor to SimpleWeatherService for reusability
Diffstat (limited to 'src')
| -rw-r--r-- | src/components/ble/SimpleWeatherService.h | 14 | ||||
| -rw-r--r-- | src/displayapp/screens/Weather.cpp | 16 |
2 files changed, 15 insertions, 15 deletions
diff --git a/src/components/ble/SimpleWeatherService.h b/src/components/ble/SimpleWeatherService.h index 0f8c181b..469b571a 100644 --- a/src/components/ble/SimpleWeatherService.h +++ b/src/components/ble/SimpleWeatherService.h @@ -32,6 +32,8 @@ #undef min #include "components/datetime/DateTimeController.h" +#include <lvgl/lvgl.h> +#include "displayapp/InfiniTimeTheme.h" int WeatherCallback(uint16_t connHandle, uint16_t attrHandle, struct ble_gatt_access_ctxt* ctxt, void* arg); @@ -82,6 +84,18 @@ namespace Pinetime { return (PreciseFahrenheit() + 50) / 100; } + [[nodiscard]] lv_color_t Color() const { + int16_t celsius = Celsius(); + 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 + } + bool operator==(const Temperature& other) const { return raw == other.raw; } diff --git a/src/displayapp/screens/Weather.cpp b/src/displayapp/screens/Weather.cpp index 25464c70..0e44df03 100644 --- a/src/displayapp/screens/Weather.cpp +++ b/src/displayapp/screens/Weather.cpp @@ -12,17 +12,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 - } - uint8_t TemperatureStyle(Pinetime::Controllers::SimpleWeatherService::Temperature temp) { if (temp.Celsius() <= 0) { // freezing return LV_TABLE_PART_CELL3; @@ -128,10 +117,7 @@ void Weather::Refresh() { maxTemp = optCurrentWeather->maxTemperature.Fahrenheit(); tempUnit = 'F'; } - lv_obj_set_style_local_text_color(temperature, - LV_LABEL_PART_MAIN, - LV_STATE_DEFAULT, - TemperatureColor(optCurrentWeather->temperature)); + lv_obj_set_style_local_text_color(temperature, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, optCurrentWeather->temperature.Color()); lv_label_set_text(icon, Symbols::GetSymbol(optCurrentWeather->iconId)); lv_label_set_text(condition, Symbols::GetCondition(optCurrentWeather->iconId)); lv_label_set_text_fmt(temperature, "%d°%c", temp, tempUnit); |
