diff options
| -rw-r--r-- | src/displayapp/screens/Clock.cpp | 10 | ||||
| -rw-r--r-- | src/displayapp/screens/WatchFaceAnalog24.cpp | 108 | ||||
| -rw-r--r-- | src/displayapp/screens/WatchFaceAnalog24.h | 34 | ||||
| m--------- | src/libs/lvgl | 0 |
4 files changed, 93 insertions, 59 deletions
diff --git a/src/displayapp/screens/Clock.cpp b/src/displayapp/screens/Clock.cpp index 04c1348..67598c0 100644 --- a/src/displayapp/screens/Clock.cpp +++ b/src/displayapp/screens/Clock.cpp @@ -84,8 +84,14 @@ std::unique_ptr<Screen> Clock::WatchFaceAnalogScreen() { } std::unique_ptr<Screen> Clock::WatchFaceAnalog24Screen() { - return std::make_unique<Screens::WatchFaceAnalog24>( - app, dateTimeController, batteryController, bleController, notificatioManager, settingsController); + return std::make_unique<Screens::WatchFaceAnalog24>(app, + dateTimeController, + batteryController, + bleController, + notificatioManager, + settingsController, + heartRateController, + motionController); } std::unique_ptr<Screen> Clock::PineTimeStyleScreen() { 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()); + } + } diff --git a/src/displayapp/screens/WatchFaceAnalog24.h b/src/displayapp/screens/WatchFaceAnalog24.h index 25233af..0653bcf 100644 --- a/src/displayapp/screens/WatchFaceAnalog24.h +++ b/src/displayapp/screens/WatchFaceAnalog24.h @@ -9,6 +9,8 @@ #include "components/battery/BatteryController.h" #include "components/ble/BleController.h" #include "components/ble/NotificationManager.h" +#include "components/heartrate/HeartRateController.h" +#include "components/motion/MotionController.h" namespace Pinetime { namespace Controllers { @@ -27,7 +29,9 @@ namespace Pinetime { Controllers::Battery& batteryController, Controllers::Ble& bleController, Controllers::NotificationManager& notificationManager, - Controllers::Settings& settingsController); + Controllers::Settings& settingsController, + Controllers::HeartRateController& heartRateController, + Controllers::MotionController& motionController); ~WatchFaceAnalog24() override; @@ -35,9 +39,6 @@ namespace Pinetime { private: uint8_t sHour, sMinute; // , sSecond; - uint8_t hour; - uint8_t minute; - // uint8_t second; Pinetime::Controllers::DateTime::Months month; uint8_t day; @@ -49,29 +50,28 @@ namespace Pinetime { DirtyValue<uint8_t> batteryPercentRemaining {0}; DirtyValue<bool> isCharging {}; + DirtyValue<bool> bleState {}; + DirtyValue<bool> bleRadioEnabled {}; DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds>> currentDateTime; + DirtyValue<bool> motionSensorOk {}; + DirtyValue<uint32_t> stepCount {}; + DirtyValue<uint8_t> heartbeat {}; + DirtyValue<bool> heartbeatRunning {}; DirtyValue<bool> notificationState {false}; - // lv_obj_t* hour_body; lv_obj_t* hour_body_trace; - // lv_obj_t* minute_body; - // lv_obj_t* minute_body_trace; - // lv_obj_t* second_body; - // lv_point_t hour_point[2]; lv_point_t hour_point_trace[2]; - // lv_point_t minute_point[2]; - // lv_point_t minute_point_trace[2]; - // lv_point_t second_point[2]; - // lv_style_t hour_line_style; lv_style_t hour_line_style_trace; - // lv_style_t minute_line_style; - // lv_style_t minute_line_style_trace; - // lv_style_t second_line_style; // lv_obj_t* label_date_day; lv_obj_t* batteryIcon; + lv_obj_t* bleIcon; + lv_obj_t* heartbeatIcon; + lv_obj_t* heartbeatValue; + lv_obj_t* stepIcon; + lv_obj_t* stepValue; lv_obj_t* notificationIcon; Controllers::DateTime& dateTimeController; @@ -79,6 +79,8 @@ namespace Pinetime { Controllers::Ble& bleController; Controllers::NotificationManager& notificationManager; Controllers::Settings& settingsController; + Controllers::HeartRateController& heartRateController; + Controllers::MotionController& motionController; void UpdateClock(); void SetBatteryIcon(); diff --git a/src/libs/lvgl b/src/libs/lvgl -Subproject 23430cf20e32294549fff9b2879a9466dacc19b +Subproject e100d920f823e4308b8b43d7eb4130afa74f272 |
