5
5
#include " displayapp/screens/BleIcon.h"
6
6
#include " displayapp/screens/Symbols.h"
7
7
#include " displayapp/screens/NotificationIcon.h"
8
+ #include " displayapp/screens/WeatherSymbols.h"
9
+ #include " components/ble/SimpleWeatherService.h"
8
10
#include " components/heartrate/HeartRateController.h"
9
11
#include " components/motion/MotionController.h"
10
12
#include " components/settings/Settings.h"
@@ -49,7 +51,8 @@ WatchFaceAnalog::WatchFaceAnalog(Controllers::DateTime& dateTimeController,
49
51
Controllers::NotificationManager& notificationManager,
50
52
Controllers::Settings& settingsController,
51
53
Controllers::HeartRateController& heartRateController,
52
- Controllers::MotionController& motionController)
54
+ Controllers::MotionController& motionController,
55
+ Controllers::SimpleWeatherService& weatherService)
53
56
: currentDateTime {{}},
54
57
batteryIcon (true ),
55
58
dateTimeController {dateTimeController},
@@ -58,7 +61,8 @@ WatchFaceAnalog::WatchFaceAnalog(Controllers::DateTime& dateTimeController,
58
61
notificationManager {notificationManager},
59
62
settingsController {settingsController},
60
63
heartRateController {heartRateController},
61
- motionController {motionController} {
64
+ motionController {motionController},
65
+ weatherService {weatherService} {
62
66
63
67
sHour = 99 ;
64
68
sMinute = 99 ;
@@ -117,13 +121,25 @@ WatchFaceAnalog::WatchFaceAnalog(Controllers::DateTime& dateTimeController,
117
121
lv_obj_align (notificationIcon, nullptr , LV_ALIGN_IN_TOP_LEFT, 0 , 0 );
118
122
119
123
// Date - Day / Week day
120
-
121
124
label_date_day = lv_label_create (lv_scr_act (), nullptr );
122
125
lv_obj_set_style_local_text_color (label_date_day, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::orange);
123
126
lv_label_set_text_fmt (label_date_day, " %s\n %02i" , dateTimeController.DayOfWeekShortToString (), dateTimeController.Day ());
124
127
lv_label_set_align (label_date_day, LV_LABEL_ALIGN_CENTER);
125
128
lv_obj_align (label_date_day, nullptr , LV_ALIGN_CENTER, 50 , 0 );
126
129
130
+ if (settingsController.IsWidgetOn (Pinetime::Controllers::Settings::Widget::Weather)) {
131
+ weatherIcon = lv_label_create (lv_scr_act (), nullptr );
132
+ lv_obj_set_style_local_text_color (weatherIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::lightGray);
133
+ lv_obj_set_style_local_text_font (weatherIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &fontawesome_weathericons);
134
+ lv_label_set_text (weatherIcon, " " );
135
+ lv_obj_align (weatherIcon, nullptr , LV_ALIGN_CENTER, -50 , -12 );
136
+
137
+ temperature = lv_label_create (lv_scr_act (), nullptr );
138
+ lv_obj_set_style_local_text_color (temperature, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::lightGray);
139
+ lv_label_set_text (temperature, " " );
140
+ lv_obj_align (temperature, nullptr , LV_ALIGN_CENTER, -50 , 12 );
141
+ }
142
+
127
143
minute_body = lv_line_create (lv_scr_act (), nullptr );
128
144
minute_body_trace = lv_line_create (lv_scr_act (), nullptr );
129
145
hour_body = lv_line_create (lv_scr_act (), nullptr );
@@ -317,4 +333,27 @@ void WatchFaceAnalog::Refresh() {
317
333
lv_obj_realign (stepIcon);
318
334
}
319
335
}
336
+
337
+ if (settingsController.IsWidgetOn (Pinetime::Controllers::Settings::Widget::Weather)) {
338
+ currentWeather = weatherService.Current ();
339
+ if (currentWeather.IsUpdated ()) {
340
+ auto optCurrentWeather = currentWeather.Get ();
341
+ if (optCurrentWeather) {
342
+ int16_t temp = optCurrentWeather->temperature ;
343
+ char tempUnit = ' C' ;
344
+ if (settingsController.GetWeatherFormat () == Controllers::Settings::WeatherFormat::Imperial) {
345
+ temp = Controllers::SimpleWeatherService::CelsiusToFahrenheit (temp);
346
+ tempUnit = ' F' ;
347
+ }
348
+ temp = temp / 100 + (temp % 100 >= 50 ? 1 : 0 );
349
+ lv_label_set_text_fmt (temperature, " %d°%c" , temp, tempUnit);
350
+ lv_label_set_text (weatherIcon, Symbols::GetSymbol (optCurrentWeather->iconId ));
351
+ } else {
352
+ lv_label_set_text_static (temperature, " " );
353
+ lv_label_set_text (weatherIcon, " " );
354
+ }
355
+ lv_obj_realign (temperature);
356
+ lv_obj_realign (weatherIcon);
357
+ }
358
+ }
320
359
}
0 commit comments