diff options
| author | Michele Bini <michele.bini@gmail.com> | 2022-03-30 07:44:51 (GMT) |
|---|---|---|
| committer | Michele Bini <michele.bini@gmail.com> | 2022-03-30 09:59:15 (GMT) |
| commit | 1db07ae196b02bb7e656161555980ffc93203ba4 (patch) | |
| tree | 567c3d8eda19c070d0738cf15ce71c41601a5d6a /src/displayapp/screens/WatchFaceAnalog24.cpp | |
| parent | 1b6e0ea9f1e9d4ed7b22362588acd83ce3cd4644 (diff) | |
Steps and heartbeat for analog24 watchface
Diffstat (limited to 'src/displayapp/screens/WatchFaceAnalog24.cpp')
| -rw-r--r-- | src/displayapp/screens/WatchFaceAnalog24.cpp | 108 |
1 files changed, 67 insertions, 41 deletions
diff --git a/src/displayapp/screens/WatchFaceAnalog24.cpp b/src/displayapp/screens/WatchFaceAnalog24.cpp index cc29eb3..29c1095 100644 --- a/src/displayapp/screens/WatchFaceAnalog24.cpp +++ b/src/displayapp/screens/WatchFaceAnalog24.cpp @@ -49,14 +49,18 @@ WatchFaceAnalog24::WatchFaceAnalog24(Pinetime::Applications::DisplayApp* app, Controllers::Battery& batteryController, Controllers::Ble& bleController, Controllers::NotificationManager& notificationManager, - Controllers::Settings& settingsController) + Controllers::Settings& settingsController, + Controllers::HeartRateController& heartRateController, + Controllers::MotionController& motionController) : Screen(app), currentDateTime {{}}, dateTimeController {dateTimeController}, batteryController {batteryController}, bleController {bleController}, notificationManager {notificationManager}, - settingsController {settingsController} { + settingsController {settingsController}, + heartRateController {heartRateController}, + motionController {motionController} { sHour = 99; sMinute = 99; @@ -64,55 +68,27 @@ WatchFaceAnalog24::WatchFaceAnalog24(Pinetime::Applications::DisplayApp* app, lv_obj_t* bg_clock_img = lv_img_create(lv_scr_act(), NULL); lv_img_set_src(bg_clock_img, &bg_analog24); - lv_obj_align(bg_clock_img, NULL, LV_ALIGN_CENTER, 0, 0); + lv_obj_align(bg_clock_img, nullptr, LV_ALIGN_CENTER, 0, 0); batteryIcon = lv_label_create(lv_scr_act(), nullptr); lv_label_set_text(batteryIcon, Symbols::batteryHalf); lv_obj_align(batteryIcon, NULL, LV_ALIGN_IN_TOP_RIGHT, 0, 0); lv_obj_set_auto_realign(batteryIcon, true); + bleIcon = lv_label_create(lv_scr_act(), nullptr); + lv_obj_set_style_local_text_color(bleIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x0082FC)); + lv_label_set_text_static(bleIcon, Symbols::bluetooth); + lv_obj_align(bleIcon, batteryIcon, LV_ALIGN_OUT_BOTTOM_RIGHT, 0, 0); + lv_obj_set_auto_realign(bleIcon, true); + notificationIcon = lv_label_create(lv_scr_act(), NULL); lv_obj_set_style_local_text_color(notificationIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00FF00)); lv_label_set_text(notificationIcon, NotificationIcon::GetIcon(false)); - lv_obj_align(notificationIcon, NULL, LV_ALIGN_IN_TOP_LEFT, 0, 0); + lv_obj_align(notificationIcon, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 0); // Date - Day / Week day - // label_date_day = lv_label_create(lv_scr_act(), NULL); - // lv_obj_set_style_local_text_color(label_date_day, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xf0a500)); - // lv_label_set_text_fmt(label_date_day, "%s\n%02i", dateTimeController.DayOfWeekShortToString(), dateTimeController.Day()); - // lv_label_set_align(label_date_day, LV_LABEL_ALIGN_CENTER); - // lv_obj_align(label_date_day, NULL, LV_ALIGN_CENTER, 50, 0); - - // minute_body = lv_line_create(lv_scr_act(), NULL); - // minute_body_trace = lv_line_create(lv_scr_act(), NULL); - // hour_body = lv_line_create(lv_scr_act(), NULL); hour_body_trace = lv_line_create(lv_scr_act(), NULL); - // second_body = lv_line_create(lv_scr_act(), NULL); - - // lv_style_init(&second_line_style); - // lv_style_set_line_width(&second_line_style, LV_STATE_DEFAULT, 3); - // lv_style_set_line_color(&second_line_style, LV_STATE_DEFAULT, LV_COLOR_GREEN); - // lv_style_set_line_rounded(&second_line_style, LV_STATE_DEFAULT, true); - // lv_obj_add_style(second_body, LV_LINE_PART_MAIN, &second_line_style); - - // lv_style_init(&minute_line_style); - // lv_style_set_line_width(&minute_line_style, LV_STATE_DEFAULT, 7); - // lv_style_set_line_color(&minute_line_style, LV_STATE_DEFAULT, LV_COLOR_WHITE); - // lv_style_set_line_rounded(&minute_line_style, LV_STATE_DEFAULT, true); - // lv_obj_add_style(minute_body, LV_LINE_PART_MAIN, &minute_line_style); - - // lv_style_init(&minute_line_style_trace); - // lv_style_set_line_width(&minute_line_style_trace, LV_STATE_DEFAULT, 3); - // lv_style_set_line_color(&minute_line_style_trace, LV_STATE_DEFAULT, LV_COLOR_WHITE); - // lv_style_set_line_rounded(&minute_line_style_trace, LV_STATE_DEFAULT, false); - // lv_obj_add_style(minute_body_trace, LV_LINE_PART_MAIN, &minute_line_style_trace); - - // lv_style_init(&hour_line_style); - // lv_style_set_line_width(&hour_line_style, LV_STATE_DEFAULT, 7); - // lv_style_set_line_color(&hour_line_style, LV_STATE_DEFAULT, LV_COLOR_WHITE); - // lv_style_set_line_rounded(&hour_line_style, LV_STATE_DEFAULT, true); - // lv_obj_add_style(hour_body, LV_LINE_PART_MAIN, &hour_line_style); lv_style_init(&hour_line_style_trace); lv_style_set_line_width(&hour_line_style_trace, LV_STATE_DEFAULT, 3); @@ -120,8 +96,32 @@ WatchFaceAnalog24::WatchFaceAnalog24(Pinetime::Applications::DisplayApp* app, lv_style_set_line_rounded(&hour_line_style_trace, LV_STATE_DEFAULT, false); lv_obj_add_style(hour_body_trace, LV_LINE_PART_MAIN, &hour_line_style_trace); + heartbeatValue = lv_label_create(lv_scr_act(), nullptr); + lv_obj_set_style_local_text_color(heartbeatValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xAA1111)); + lv_label_set_text_static(heartbeatValue, ""); + lv_obj_align(heartbeatValue, nullptr, LV_ALIGN_IN_BOTTOM_LEFT, 0, 0); + lv_obj_set_auto_realign(heartbeatValue, true); + + heartbeatIcon = lv_label_create(lv_scr_act(), nullptr); + lv_label_set_text_static(heartbeatIcon, Symbols::heartBeat); + lv_obj_set_style_local_text_color(heartbeatIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x111111)); + lv_obj_align(heartbeatIcon, heartbeatValue, LV_ALIGN_OUT_TOP_LEFT, 0, 0); + lv_obj_set_auto_realign(heartbeatIcon, true); + + stepValue = lv_label_create(lv_scr_act(), nullptr); + lv_obj_set_style_local_text_color(stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00AAA8)); + lv_label_set_text_static(stepValue, "0"); + lv_obj_align(stepValue, nullptr, LV_ALIGN_IN_BOTTOM_RIGHT, 0, 0); + lv_obj_set_auto_realign(stepValue, true); + + stepIcon = lv_label_create(lv_scr_act(), nullptr); + lv_obj_set_style_local_text_color(stepIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x007775)); + lv_label_set_text_static(stepIcon, Symbols::shoe); + lv_obj_align(stepIcon, stepValue, LV_ALIGN_OUT_TOP_RIGHT, 0, 0); + lv_obj_set_auto_realign(stepIcon, true); + taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this); - UpdateClock(); + Refresh(); } WatchFaceAnalog24::~WatchFaceAnalog24() { @@ -137,8 +137,8 @@ WatchFaceAnalog24::~WatchFaceAnalog24() { } void WatchFaceAnalog24::UpdateClock() { - hour = dateTimeController.Hours(); - minute = dateTimeController.Minutes(); + uint8_t hour = dateTimeController.Hours(); + uint8_t minute = dateTimeController.Minutes(); // second = dateTimeController.Seconds(); // if (sMinute != minute) { @@ -205,6 +205,12 @@ void WatchFaceAnalog24::Refresh() { } } + bleState = bleController.IsConnected(); + bleRadioEnabled = bleController.IsRadioEnabled(); + if (bleState.IsUpdated() || bleRadioEnabled.IsUpdated()) { + lv_label_set_text(bleIcon, BleIcon::GetIcon(bleRadioEnabled.Get(), bleState.Get())); + } + notificationState = notificationManager.AreNewNotificationsAvailable(); if (notificationState.IsUpdated()) { @@ -230,4 +236,24 @@ void WatchFaceAnalog24::Refresh() { } #endif } + + heartbeat = heartRateController.HeartRate(); + heartbeatRunning = heartRateController.State() != Controllers::HeartRateController::States::Stopped; + if (heartbeat.IsUpdated() || heartbeatRunning.IsUpdated()) { + if (heartbeatRunning.Get()) { + lv_obj_set_style_local_text_color(heartbeatIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x770505)); + lv_label_set_text_fmt(heartbeatValue, "%d", heartbeat.Get()); + } else { + lv_obj_set_style_local_text_color(heartbeatIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x111111)); + lv_label_set_text_static(heartbeatValue, ""); + } + + } + + stepCount = motionController.NbSteps(); + motionSensorOk = motionController.IsSensorOk(); + if (stepCount.IsUpdated() || motionSensorOk.IsUpdated()) { + lv_label_set_text_fmt(stepValue, "%lu", stepCount.Get()); + } + } |
