Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/components/ble/SimpleWeatherService.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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;
}
Expand Down
16 changes: 1 addition & 15 deletions src/displayapp/screens/Weather.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down