66#include " displayapp/screens/BleIcon.h"
77#include " displayapp/screens/Symbols.h"
88#include " displayapp/screens/NotificationIcon.h"
9+ #include " displayapp/screens/WeatherSymbols.h"
10+ #include " components/ble/SimpleWeatherService.h"
911#include " components/heartrate/HeartRateController.h"
1012#include " components/motion/MotionController.h"
1113#include " components/settings/Settings.h"
@@ -52,7 +54,8 @@ WatchFaceAnalog::WatchFaceAnalog(Controllers::DateTime& dateTimeController,
5254 Controllers::NotificationManager& notificationManager,
5355 Controllers::Settings& settingsController,
5456 Controllers::HeartRateController& heartRateController,
55- Controllers::MotionController& motionController)
57+ Controllers::MotionController& motionController,
58+ Controllers::SimpleWeatherService& weatherService)
5659 : currentDateTime {{}},
5760 batteryIcon (true ),
5861 dateTimeController {dateTimeController},
@@ -61,7 +64,8 @@ WatchFaceAnalog::WatchFaceAnalog(Controllers::DateTime& dateTimeController,
6164 notificationManager {notificationManager},
6265 settingsController {settingsController},
6366 heartRateController {heartRateController},
64- motionController {motionController} {
67+ motionController {motionController},
68+ weatherService {weatherService} {
6569
6670 sHour = 99 ;
6771 sMinute = 99 ;
@@ -120,13 +124,25 @@ WatchFaceAnalog::WatchFaceAnalog(Controllers::DateTime& dateTimeController,
120124 lv_obj_align (notificationIcon, nullptr , LV_ALIGN_IN_TOP_LEFT, 0 , 0 );
121125
122126 // Date - Day / Week day
123-
124127 label_date_day = lv_label_create (lv_scr_act (), nullptr );
125128 lv_obj_set_style_local_text_color (label_date_day, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::orange);
126129 lv_label_set_text_fmt (label_date_day, " %s\n %02i" , dateTimeController.DayOfWeekShortToString (), dateTimeController.Day ());
127130 lv_label_set_align (label_date_day, LV_LABEL_ALIGN_CENTER);
128131 lv_obj_align (label_date_day, nullptr , LV_ALIGN_CENTER, 50 , 0 );
129132
133+ if (settingsController.IsWidgetOn (Pinetime::Controllers::Settings::Widget::Weather)) {
134+ weatherIcon = lv_label_create (lv_scr_act (), nullptr );
135+ lv_obj_set_style_local_text_color (weatherIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::lightGray);
136+ lv_obj_set_style_local_text_font (weatherIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &fontawesome_weathericons);
137+ lv_label_set_text (weatherIcon, " " );
138+ lv_obj_align (weatherIcon, nullptr , LV_ALIGN_CENTER, -50 , -12 );
139+
140+ temperature = lv_label_create (lv_scr_act (), nullptr );
141+ lv_obj_set_style_local_text_color (temperature, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::lightGray);
142+ lv_label_set_text (temperature, " " );
143+ lv_obj_align (temperature, nullptr , LV_ALIGN_CENTER, -50 , 12 );
144+ }
145+
130146 minute_body = lv_line_create (lv_scr_act (), nullptr );
131147 minute_body_trace = lv_line_create (lv_scr_act (), nullptr );
132148 hour_body = lv_line_create (lv_scr_act (), nullptr );
@@ -320,4 +336,24 @@ void WatchFaceAnalog::Refresh() {
320336 lv_obj_realign (stepIcon);
321337 }
322338 }
339+
340+ if (settingsController.IsWidgetOn (Pinetime::Controllers::Settings::Widget::Weather)) {
341+ currentWeather = weatherService.Current ();
342+ if (currentWeather.IsUpdated ()) {
343+ auto optCurrentWeather = currentWeather.Get ();
344+ if (optCurrentWeather) {
345+ int16_t temp = optCurrentWeather->temperature .Celsius ();
346+ char tempUnit = ' C' ;
347+ if (settingsController.GetWeatherFormat () == Controllers::Settings::WeatherFormat::Imperial) {
348+ temp = optCurrentWeather->temperature .Fahrenheit ();
349+ tempUnit = ' F' ;
350+ }
351+ lv_label_set_text_fmt (temperature, " %d°%c" , temp, tempUnit);
352+ lv_label_set_text (weatherIcon, Symbols::GetSymbol (optCurrentWeather->iconId , weatherService.IsNight ()));
353+ } else {
354+ lv_label_set_text_static (temperature, " " );
355+ lv_label_set_text (weatherIcon, " " );
356+ }
357+ }
358+ }
323359}
0 commit comments