8
8
9
9
using namespace Pinetime ::Applications::Screens;
10
10
11
+ namespace {
12
+ uint8_t temperatureStyle (int16_t temperature) {
13
+ if (temperature <= 0 ) { // freezing
14
+ return LV_TABLE_PART_CELL3;
15
+ } else if (temperature <= 400 ) { // ice danger
16
+ return LV_TABLE_PART_CELL4;
17
+ } else if (temperature >= 2700 ) { // hot
18
+ return LV_TABLE_PART_CELL6;
19
+ }
20
+ return LV_TABLE_PART_CELL5;
21
+ }
22
+ }
23
+
11
24
Weather::Weather (Controllers::Settings& settingsController, Controllers::SimpleWeatherService& weatherService)
12
25
: settingsController {settingsController}, weatherService {weatherService} {
13
26
@@ -54,6 +67,19 @@ Weather::Weather(Controllers::Settings& settingsController, Controllers::SimpleW
54
67
lv_obj_set_style_local_text_color (forecast, LV_TABLE_PART_CELL2, LV_STATE_DEFAULT, LV_COLOR_WHITE);
55
68
lv_obj_set_style_local_text_font (forecast, LV_TABLE_PART_CELL2, LV_STATE_DEFAULT, &fontawesome_weathericons);
56
69
70
+ // LV_TABLE_PART_CELL3: Freezing
71
+ lv_obj_set_style_local_border_color (forecast, LV_TABLE_PART_CELL3, LV_STATE_DEFAULT, LV_COLOR_BLACK);
72
+ lv_obj_set_style_local_text_color (forecast, LV_TABLE_PART_CELL3, LV_STATE_DEFAULT, Colors::blue);
73
+ // LV_TABLE_PART_CELL4: Ice
74
+ lv_obj_set_style_local_border_color (forecast, LV_TABLE_PART_CELL4, LV_STATE_DEFAULT, LV_COLOR_BLACK);
75
+ lv_obj_set_style_local_text_color (forecast, LV_TABLE_PART_CELL4, LV_STATE_DEFAULT, LV_COLOR_CYAN);
76
+ // LV_TABLE_PART_CELL5: Normal
77
+ lv_obj_set_style_local_border_color (forecast, LV_TABLE_PART_CELL5, LV_STATE_DEFAULT, LV_COLOR_BLACK);
78
+ lv_obj_set_style_local_text_color (forecast, LV_TABLE_PART_CELL5, LV_STATE_DEFAULT, Colors::orange);
79
+ // LV_TABLE_PART_CELL6: Hot
80
+ lv_obj_set_style_local_border_color (forecast, LV_TABLE_PART_CELL6, LV_STATE_DEFAULT, LV_COLOR_BLACK);
81
+ lv_obj_set_style_local_text_color (forecast, LV_TABLE_PART_CELL6, LV_STATE_DEFAULT, Colors::deepOrange);
82
+
57
83
lv_obj_align (forecast, nullptr , LV_ALIGN_IN_BOTTOM_LEFT, 0 , 0 );
58
84
59
85
for (int i = 0 ; i < Controllers::SimpleWeatherService::MaxNbForecastDays; i++) {
@@ -124,6 +150,8 @@ void Weather::Refresh() {
124
150
for (int i = 0 ; i < Controllers::SimpleWeatherService::MaxNbForecastDays; i++) {
125
151
int16_t maxTemp = optCurrentForecast->days [i].maxTemperature ;
126
152
int16_t minTemp = optCurrentForecast->days [i].minTemperature ;
153
+ uint8_t maxStyle = temperatureStyle (maxTemp);
154
+ uint8_t minStyle = temperatureStyle (minTemp);
127
155
if (settingsController.GetWeatherFormat () == Controllers::Settings::WeatherFormat::Imperial) {
128
156
maxTemp = Controllers::SimpleWeatherService::CelsiusToFahrenheit (maxTemp);
129
157
minTemp = Controllers::SimpleWeatherService::CelsiusToFahrenheit (minTemp);
@@ -137,7 +165,9 @@ void Weather::Refresh() {
137
165
lv_table_set_cell_value (forecast, 0 , i, WeekDays[wday]);
138
166
lv_table_set_cell_value (forecast, 1 , i, Symbols::GetSymbol (optCurrentForecast->days [i].iconId ));
139
167
lv_table_set_cell_value_fmt (forecast, 2 , i, " %d" , maxTemp);
168
+ lv_table_set_cell_type (forecast, 2 , i, maxStyle);
140
169
lv_table_set_cell_value_fmt (forecast, 3 , i, " %d" , minTemp);
170
+ lv_table_set_cell_type (forecast, 3 , i, minStyle);
141
171
}
142
172
} else {
143
173
for (int i = 0 ; i < Controllers::SimpleWeatherService::MaxNbForecastDays; i++) {
0 commit comments