|
6 | 6 | #include "displayapp/screens/BleIcon.h" |
7 | 7 | #include "displayapp/screens/Symbols.h" |
8 | 8 | #include "displayapp/screens/NotificationIcon.h" |
| 9 | +#include "components/heartrate/HeartRateController.h" |
| 10 | +#include "components/motion/MotionController.h" |
9 | 11 | #include "components/settings/Settings.h" |
10 | 12 | #include "displayapp/InfiniTimeTheme.h" |
11 | 13 |
|
@@ -48,14 +50,18 @@ WatchFaceAnalog::WatchFaceAnalog(Controllers::DateTime& dateTimeController, |
48 | 50 | const Controllers::Battery& batteryController, |
49 | 51 | const Controllers::Ble& bleController, |
50 | 52 | Controllers::NotificationManager& notificationManager, |
51 | | - Controllers::Settings& settingsController) |
| 53 | + Controllers::Settings& settingsController, |
| 54 | + Controllers::HeartRateController& heartRateController, |
| 55 | + Controllers::MotionController& motionController) |
52 | 56 | : currentDateTime {{}}, |
53 | 57 | batteryIcon(true), |
54 | 58 | dateTimeController {dateTimeController}, |
55 | 59 | batteryController {batteryController}, |
56 | 60 | bleController {bleController}, |
57 | 61 | notificationManager {notificationManager}, |
58 | | - settingsController {settingsController} { |
| 62 | + settingsController {settingsController}, |
| 63 | + heartRateController {heartRateController}, |
| 64 | + motionController {motionController} { |
59 | 65 |
|
60 | 66 | sHour = 99; |
61 | 67 | sMinute = 99; |
@@ -157,6 +163,30 @@ WatchFaceAnalog::WatchFaceAnalog(Controllers::DateTime& dateTimeController, |
157 | 163 | lv_style_set_line_rounded(&hour_line_style_trace, LV_STATE_DEFAULT, false); |
158 | 164 | lv_obj_add_style(hour_body_trace, LV_LINE_PART_MAIN, &hour_line_style_trace); |
159 | 165 |
|
| 166 | + if (settingsController.IsWidgetOn(Pinetime::Controllers::Settings::Widget::HeartRate)) { |
| 167 | + heartbeatIcon = lv_label_create(lv_scr_act(), nullptr); |
| 168 | + lv_label_set_text_static(heartbeatIcon, Symbols::heartBeat); |
| 169 | + lv_obj_set_style_local_text_color(heartbeatIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xCE1B1B)); |
| 170 | + lv_obj_align(heartbeatIcon, lv_scr_act(), LV_ALIGN_IN_BOTTOM_LEFT, 0, 0); |
| 171 | + |
| 172 | + heartbeatValue = lv_label_create(lv_scr_act(), nullptr); |
| 173 | + lv_obj_set_style_local_text_color(heartbeatValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xCE1B1B)); |
| 174 | + lv_label_set_text_static(heartbeatValue, ""); |
| 175 | + lv_obj_align(heartbeatValue, heartbeatIcon, LV_ALIGN_OUT_RIGHT_MID, 5, 0); |
| 176 | + } |
| 177 | + |
| 178 | + if (settingsController.IsWidgetOn(Pinetime::Controllers::Settings::Widget::Steps)) { |
| 179 | + stepValue = lv_label_create(lv_scr_act(), nullptr); |
| 180 | + lv_obj_set_style_local_text_color(stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FFE7)); |
| 181 | + lv_label_set_text_static(stepValue, "0"); |
| 182 | + lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0); |
| 183 | + |
| 184 | + stepIcon = lv_label_create(lv_scr_act(), nullptr); |
| 185 | + lv_obj_set_style_local_text_color(stepIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FFE7)); |
| 186 | + lv_label_set_text_static(stepIcon, Symbols::shoe); |
| 187 | + lv_obj_align(stepIcon, stepValue, LV_ALIGN_OUT_LEFT_MID, -5, 0); |
| 188 | + } |
| 189 | + |
160 | 190 | taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this); |
161 | 191 |
|
162 | 192 | Refresh(); |
@@ -264,4 +294,30 @@ void WatchFaceAnalog::Refresh() { |
264 | 294 | lv_label_set_text_fmt(label_date_day, "%s\n%02i", dateTimeController.DayOfWeekShortToString(), dateTimeController.Day()); |
265 | 295 | } |
266 | 296 | } |
| 297 | + |
| 298 | + if (settingsController.IsWidgetOn(Pinetime::Controllers::Settings::Widget::HeartRate)) { |
| 299 | + heartbeat = heartRateController.HeartRate(); |
| 300 | + heartbeatRunning = heartRateController.State() != Controllers::HeartRateController::States::Stopped; |
| 301 | + if (heartbeat.IsUpdated() || heartbeatRunning.IsUpdated()) { |
| 302 | + if (heartbeatRunning.Get()) { |
| 303 | + lv_obj_set_style_local_text_color(heartbeatIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xCE1B1B)); |
| 304 | + lv_label_set_text_fmt(heartbeatValue, "%d", heartbeat.Get()); |
| 305 | + } else { |
| 306 | + lv_obj_set_style_local_text_color(heartbeatIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x1B1B1B)); |
| 307 | + lv_label_set_text_static(heartbeatValue, ""); |
| 308 | + } |
| 309 | + |
| 310 | + lv_obj_realign(heartbeatIcon); |
| 311 | + lv_obj_realign(heartbeatValue); |
| 312 | + } |
| 313 | + } |
| 314 | + |
| 315 | + if (settingsController.IsWidgetOn(Pinetime::Controllers::Settings::Widget::Steps)) { |
| 316 | + stepCount = motionController.NbSteps(); |
| 317 | + if (stepCount.IsUpdated()) { |
| 318 | + lv_label_set_text_fmt(stepValue, "%lu", stepCount.Get()); |
| 319 | + lv_obj_realign(stepValue); |
| 320 | + lv_obj_realign(stepIcon); |
| 321 | + } |
| 322 | + } |
267 | 323 | } |
0 commit comments