44#include < cstdio>
55#include " displayapp/screens/NotificationIcon.h"
66#include " displayapp/screens/Symbols.h"
7+ #include " displayapp/screens/WeatherSymbols.h"
78#include " components/battery/BatteryController.h"
89#include " components/ble/BleController.h"
910#include " components/ble/NotificationManager.h"
1011#include " components/heartrate/HeartRateController.h"
1112#include " components/motion/MotionController.h"
13+ #include " components/ble/SimpleWeatherService.h"
1214#include " components/settings/Settings.h"
1315
1416using namespace Pinetime ::Applications::Screens;
@@ -19,13 +21,15 @@ WatchFaceDigital::WatchFaceDigital(Controllers::DateTime& dateTimeController,
1921 Controllers::NotificationManager& notificationManager,
2022 Controllers::Settings& settingsController,
2123 Controllers::HeartRateController& heartRateController,
22- Controllers::MotionController& motionController)
24+ Controllers::MotionController& motionController,
25+ Controllers::SimpleWeatherService& weatherService)
2326 : currentDateTime {{}},
2427 dateTimeController {dateTimeController},
2528 notificationManager {notificationManager},
2629 settingsController {settingsController},
2730 heartRateController {heartRateController},
2831 motionController {motionController},
32+ weatherService {weatherService},
2933 statusIcons (batteryController, bleController) {
3034
3135 statusIcons.Create ();
@@ -35,6 +39,18 @@ WatchFaceDigital::WatchFaceDigital(Controllers::DateTime& dateTimeController,
3539 lv_label_set_text_static (notificationIcon, NotificationIcon::GetIcon (false ));
3640 lv_obj_align (notificationIcon, nullptr , LV_ALIGN_IN_TOP_LEFT, 0 , 0 );
3741
42+ weatherIcon = lv_label_create (lv_scr_act (), nullptr );
43+ lv_obj_set_style_local_text_color (weatherIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
44+ lv_obj_set_style_local_text_font (weatherIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &fontawesome_weathericons);
45+ lv_label_set_text (weatherIcon, " " );
46+ lv_obj_align (weatherIcon, nullptr , LV_ALIGN_IN_TOP_MID, -20 , 0 );
47+ lv_obj_set_auto_realign (weatherIcon, true );
48+
49+ temperature = lv_label_create (lv_scr_act (), nullptr );
50+ lv_obj_set_style_local_text_color (temperature, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE);
51+ lv_label_set_text (temperature, " " );
52+ lv_obj_align (temperature, nullptr , LV_ALIGN_IN_TOP_MID, 20 , 0 );
53+
3854 label_date = lv_label_create (lv_scr_act (), nullptr );
3955 lv_obj_align (label_date, lv_scr_act (), LV_ALIGN_CENTER, 0 , 60 );
4056 lv_obj_set_style_local_text_color (label_date, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex (0x999999 ));
@@ -153,4 +169,25 @@ void WatchFaceDigital::Refresh() {
153169 lv_obj_realign (stepValue);
154170 lv_obj_realign (stepIcon);
155171 }
172+
173+ currentWeather = weatherService.Current ();
174+ if (currentWeather.IsUpdated ()) {
175+ auto optCurrentWeather = currentWeather.Get ();
176+ if (optCurrentWeather) {
177+ int16_t temp = optCurrentWeather->temperature ;
178+ char tempUnit = ' C' ;
179+ if (settingsController.GetWeatherFormat () == Controllers::Settings::WeatherFormat::Imperial) {
180+ temp = Controllers::SimpleWeatherService::CelsiusToFahrenheit (temp);
181+ tempUnit = ' F' ;
182+ }
183+ temp = temp / 100 + (temp % 100 >= 50 ? 1 : 0 );
184+ lv_label_set_text_fmt (temperature, " %d°%c" , temp, tempUnit);
185+ lv_label_set_text (weatherIcon, Symbols::GetSymbol (optCurrentWeather->iconId ));
186+ } else {
187+ lv_label_set_text_static (temperature, " " );
188+ lv_label_set_text (weatherIcon, " " );
189+ }
190+ lv_obj_realign (temperature);
191+ lv_obj_realign (weatherIcon);
192+ }
156193}
0 commit comments