|
6 | 6 | #include "displayapp/screens/BleIcon.h" |
7 | 7 | #include "displayapp/screens/Symbols.h" |
8 | 8 | #include "displayapp/screens/NotificationIcon.h" |
| 9 | +#include "displayapp/screens/WeatherSymbols.h" |
| 10 | +#include "components/ble/SimpleWeatherService.h" |
| 11 | +#include "components/heartrate/HeartRateController.h" |
| 12 | +#include "components/motion/MotionController.h" |
9 | 13 | #include "components/settings/Settings.h" |
10 | 14 | #include "displayapp/InfiniTimeTheme.h" |
11 | 15 |
|
@@ -48,14 +52,20 @@ WatchFaceAnalog::WatchFaceAnalog(Controllers::DateTime& dateTimeController, |
48 | 52 | const Controllers::Battery& batteryController, |
49 | 53 | const Controllers::Ble& bleController, |
50 | 54 | Controllers::NotificationManager& notificationManager, |
51 | | - Controllers::Settings& settingsController) |
| 55 | + Controllers::Settings& settingsController, |
| 56 | + Controllers::HeartRateController& heartRateController, |
| 57 | + Controllers::MotionController& motionController, |
| 58 | + Controllers::SimpleWeatherService& weatherService) |
52 | 59 | : currentDateTime {{}}, |
53 | 60 | batteryIcon(true), |
54 | 61 | dateTimeController {dateTimeController}, |
55 | 62 | batteryController {batteryController}, |
56 | 63 | bleController {bleController}, |
57 | 64 | notificationManager {notificationManager}, |
58 | | - settingsController {settingsController} { |
| 65 | + settingsController {settingsController}, |
| 66 | + heartRateController {heartRateController}, |
| 67 | + motionController {motionController}, |
| 68 | + weatherService {weatherService} { |
59 | 69 |
|
60 | 70 | sHour = 99; |
61 | 71 | sMinute = 99; |
@@ -114,13 +124,25 @@ WatchFaceAnalog::WatchFaceAnalog(Controllers::DateTime& dateTimeController, |
114 | 124 | lv_obj_align(notificationIcon, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 0); |
115 | 125 |
|
116 | 126 | // Date - Day / Week day |
117 | | - |
118 | 127 | label_date_day = lv_label_create(lv_scr_act(), nullptr); |
119 | 128 | lv_obj_set_style_local_text_color(label_date_day, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, Colors::orange); |
120 | 129 | lv_label_set_text_fmt(label_date_day, "%s\n%02i", dateTimeController.DayOfWeekShortToString(), dateTimeController.Day()); |
121 | 130 | lv_label_set_align(label_date_day, LV_LABEL_ALIGN_CENTER); |
122 | 131 | lv_obj_align(label_date_day, nullptr, LV_ALIGN_CENTER, 50, 0); |
123 | 132 |
|
| 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 | + |
124 | 146 | minute_body = lv_line_create(lv_scr_act(), nullptr); |
125 | 147 | minute_body_trace = lv_line_create(lv_scr_act(), nullptr); |
126 | 148 | hour_body = lv_line_create(lv_scr_act(), nullptr); |
@@ -157,6 +179,30 @@ WatchFaceAnalog::WatchFaceAnalog(Controllers::DateTime& dateTimeController, |
157 | 179 | lv_style_set_line_rounded(&hour_line_style_trace, LV_STATE_DEFAULT, false); |
158 | 180 | lv_obj_add_style(hour_body_trace, LV_LINE_PART_MAIN, &hour_line_style_trace); |
159 | 181 |
|
| 182 | + if (settingsController.IsWidgetOn(Pinetime::Controllers::Settings::Widget::HeartRate)) { |
| 183 | + heartbeatIcon = lv_label_create(lv_scr_act(), nullptr); |
| 184 | + lv_label_set_text_static(heartbeatIcon, Symbols::heartBeat); |
| 185 | + lv_obj_set_style_local_text_color(heartbeatIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xCE1B1B)); |
| 186 | + lv_obj_align(heartbeatIcon, lv_scr_act(), LV_ALIGN_IN_BOTTOM_LEFT, 0, 0); |
| 187 | + |
| 188 | + heartbeatValue = lv_label_create(lv_scr_act(), nullptr); |
| 189 | + lv_obj_set_style_local_text_color(heartbeatValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xCE1B1B)); |
| 190 | + lv_label_set_text_static(heartbeatValue, ""); |
| 191 | + lv_obj_align(heartbeatValue, heartbeatIcon, LV_ALIGN_OUT_RIGHT_MID, 5, 0); |
| 192 | + } |
| 193 | + |
| 194 | + if (settingsController.IsWidgetOn(Pinetime::Controllers::Settings::Widget::Steps)) { |
| 195 | + stepValue = lv_label_create(lv_scr_act(), nullptr); |
| 196 | + lv_obj_set_style_local_text_color(stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FFE7)); |
| 197 | + lv_label_set_text_static(stepValue, "0"); |
| 198 | + lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0); |
| 199 | + |
| 200 | + stepIcon = lv_label_create(lv_scr_act(), nullptr); |
| 201 | + lv_obj_set_style_local_text_color(stepIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FFE7)); |
| 202 | + lv_label_set_text_static(stepIcon, Symbols::shoe); |
| 203 | + lv_obj_align(stepIcon, stepValue, LV_ALIGN_OUT_LEFT_MID, -5, 0); |
| 204 | + } |
| 205 | + |
160 | 206 | taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this); |
161 | 207 |
|
162 | 208 | Refresh(); |
@@ -264,4 +310,50 @@ void WatchFaceAnalog::Refresh() { |
264 | 310 | lv_label_set_text_fmt(label_date_day, "%s\n%02i", dateTimeController.DayOfWeekShortToString(), dateTimeController.Day()); |
265 | 311 | } |
266 | 312 | } |
| 313 | + |
| 314 | + if (settingsController.IsWidgetOn(Pinetime::Controllers::Settings::Widget::HeartRate)) { |
| 315 | + heartbeat = heartRateController.HeartRate(); |
| 316 | + heartbeatRunning = heartRateController.State() != Controllers::HeartRateController::States::Stopped; |
| 317 | + if (heartbeat.IsUpdated() || heartbeatRunning.IsUpdated()) { |
| 318 | + if (heartbeatRunning.Get()) { |
| 319 | + lv_obj_set_style_local_text_color(heartbeatIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xCE1B1B)); |
| 320 | + lv_label_set_text_fmt(heartbeatValue, "%d", heartbeat.Get()); |
| 321 | + } else { |
| 322 | + lv_obj_set_style_local_text_color(heartbeatIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x1B1B1B)); |
| 323 | + lv_label_set_text_static(heartbeatValue, ""); |
| 324 | + } |
| 325 | + |
| 326 | + lv_obj_realign(heartbeatIcon); |
| 327 | + lv_obj_realign(heartbeatValue); |
| 328 | + } |
| 329 | + } |
| 330 | + |
| 331 | + if (settingsController.IsWidgetOn(Pinetime::Controllers::Settings::Widget::Steps)) { |
| 332 | + stepCount = motionController.NbSteps(); |
| 333 | + if (stepCount.IsUpdated()) { |
| 334 | + lv_label_set_text_fmt(stepValue, "%lu", stepCount.Get()); |
| 335 | + lv_obj_realign(stepValue); |
| 336 | + lv_obj_realign(stepIcon); |
| 337 | + } |
| 338 | + } |
| 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 | + } |
267 | 359 | } |
0 commit comments