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