55#include " displayapp/screens/BleIcon.h"
66#include " displayapp/screens/Symbols.h"
77#include " displayapp/screens/NotificationIcon.h"
8+ #include " displayapp/screens/WeatherSymbols.h"
9+ #include " components/ble/SimpleWeatherService.h"
810#include " components/heartrate/HeartRateController.h"
911#include " components/motion/MotionController.h"
1012#include " components/settings/Settings.h"
@@ -49,7 +51,8 @@ WatchFaceAnalog::WatchFaceAnalog(Controllers::DateTime& dateTimeController,
4951 Controllers::NotificationManager& notificationManager,
5052 Controllers::Settings& settingsController,
5153 Controllers::HeartRateController& heartRateController,
52- Controllers::MotionController& motionController)
54+ Controllers::MotionController& motionController,
55+ Controllers::SimpleWeatherService& weatherService)
5356 : currentDateTime {{}},
5457 batteryIcon (true ),
5558 dateTimeController {dateTimeController},
@@ -58,7 +61,8 @@ WatchFaceAnalog::WatchFaceAnalog(Controllers::DateTime& dateTimeController,
5861 notificationManager {notificationManager},
5962 settingsController {settingsController},
6063 heartRateController {heartRateController},
61- motionController {motionController} {
64+ motionController {motionController},
65+ weatherService {weatherService} {
6266
6367 sHour = 99 ;
6468 sMinute = 99 ;
@@ -117,13 +121,25 @@ WatchFaceAnalog::WatchFaceAnalog(Controllers::DateTime& dateTimeController,
117121 lv_obj_align (notificationIcon, nullptr , LV_ALIGN_IN_TOP_LEFT, 0 , 0 );
118122
119123 // Date - Day / Week day
120-
121124 label_date_day = lv_label_create (lv_scr_act (), nullptr );
122125 lv_obj_set_style_local_text_color (label_date_day, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::orange);
123126 lv_label_set_text_fmt (label_date_day, " %s\n %02i" , dateTimeController.DayOfWeekShortToString (), dateTimeController.Day ());
124127 lv_label_set_align (label_date_day, LV_LABEL_ALIGN_CENTER);
125128 lv_obj_align (label_date_day, nullptr , LV_ALIGN_CENTER, 50 , 0 );
126129
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+
127143 minute_body = lv_line_create (lv_scr_act (), nullptr );
128144 minute_body_trace = lv_line_create (lv_scr_act (), nullptr );
129145 hour_body = lv_line_create (lv_scr_act (), nullptr );
@@ -317,4 +333,27 @@ void WatchFaceAnalog::Refresh() {
317333 lv_obj_realign (stepIcon);
318334 }
319335 }
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+ }
320359}
0 commit comments