4
4
#include < cstdio>
5
5
#include " displayapp/screens/NotificationIcon.h"
6
6
#include " displayapp/screens/Symbols.h"
7
+ #include " displayapp/screens/WeatherSymbols.h"
7
8
#include " components/battery/BatteryController.h"
8
9
#include " components/ble/BleController.h"
9
10
#include " components/ble/NotificationManager.h"
10
11
#include " components/heartrate/HeartRateController.h"
11
12
#include " components/motion/MotionController.h"
13
+ #include " components/ble/SimpleWeatherService.h"
12
14
#include " components/settings/Settings.h"
13
15
14
16
using namespace Pinetime ::Applications::Screens;
@@ -19,13 +21,15 @@ WatchFaceDigital::WatchFaceDigital(Controllers::DateTime& dateTimeController,
19
21
Controllers::NotificationManager& notificationManager,
20
22
Controllers::Settings& settingsController,
21
23
Controllers::HeartRateController& heartRateController,
22
- Controllers::MotionController& motionController)
24
+ Controllers::MotionController& motionController,
25
+ Controllers::SimpleWeatherService& weatherService)
23
26
: currentDateTime {{}},
24
27
dateTimeController {dateTimeController},
25
28
notificationManager {notificationManager},
26
29
settingsController {settingsController},
27
30
heartRateController {heartRateController},
28
31
motionController {motionController},
32
+ weatherService {weatherService},
29
33
statusIcons (batteryController, bleController) {
30
34
31
35
statusIcons.Create ();
@@ -35,6 +39,18 @@ WatchFaceDigital::WatchFaceDigital(Controllers::DateTime& dateTimeController,
35
39
lv_label_set_text_static (notificationIcon, NotificationIcon::GetIcon (false ));
36
40
lv_obj_align (notificationIcon, nullptr , LV_ALIGN_IN_TOP_LEFT, 0 , 0 );
37
41
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
+
38
54
label_date = lv_label_create (lv_scr_act (), nullptr );
39
55
lv_obj_align (label_date, lv_scr_act (), LV_ALIGN_CENTER, 0 , 60 );
40
56
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() {
153
169
lv_obj_realign (stepValue);
154
170
lv_obj_realign (stepIcon);
155
171
}
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
+ }
156
193
}
0 commit comments