From 292b7e3fb1b46cc526607a2d377260de6a322041 Mon Sep 17 00:00:00 2001 From: josh Date: Thu, 21 Sep 2023 21:01:37 -0400 Subject: [PATCH 1/3] Replaced am/pm with seconds on digital watchface --- src/displayapp/screens/WatchFaceDigital.cpp | 17 ++++++++++++----- src/displayapp/screens/WatchFaceDigital.h | 5 +++-- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/displayapp/screens/WatchFaceDigital.cpp b/src/displayapp/screens/WatchFaceDigital.cpp index ca53691b..1fbfc15a 100644 --- a/src/displayapp/screens/WatchFaceDigital.cpp +++ b/src/displayapp/screens/WatchFaceDigital.cpp @@ -35,6 +35,10 @@ WatchFaceDigital::WatchFaceDigital(Controllers::DateTime& dateTimeController, lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(false)); lv_obj_align(notificationIcon, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 0); + label_seconds = lv_label_create(lv_scr_act(), nullptr); // for secs + lv_obj_align(label_seconds, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, 0, -55); + lv_obj_set_style_local_text_color(label_seconds, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x999999)); + label_date = lv_label_create(lv_scr_act(), nullptr); lv_obj_align(label_date, lv_scr_act(), LV_ALIGN_CENTER, 0, 60); lv_obj_set_style_local_text_color(label_date, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x999999)); @@ -44,9 +48,9 @@ WatchFaceDigital::WatchFaceDigital(Controllers::DateTime& dateTimeController, lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, 0, 0); - label_time_ampm = lv_label_create(lv_scr_act(), nullptr); + /*label_time_ampm = lv_label_create(lv_scr_act(), nullptr); lv_label_set_text_static(label_time_ampm, ""); - lv_obj_align(label_time_ampm, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, -30, -55); + lv_obj_align(label_time_ampm, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, -30, -55);*/ heartbeatIcon = lv_label_create(lv_scr_act(), nullptr); lv_label_set_text_static(heartbeatIcon, Symbols::heartBeat); @@ -85,14 +89,15 @@ void WatchFaceDigital::Refresh() { lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(notificationState.Get())); } - currentDateTime = std::chrono::time_point_cast(dateTimeController.CurrentDateTime()); + currentDateTime = std::chrono::time_point_cast(dateTimeController.CurrentDateTime()); if (currentDateTime.IsUpdated()) { uint8_t hour = dateTimeController.Hours(); uint8_t minute = dateTimeController.Minutes(); + uint8_t second = dateTimeController.Seconds(); if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) { - char ampmChar[3] = "AM"; + /*char ampmChar[3] = "AM"; if (hour == 0) { hour = 12; } else if (hour == 12) { @@ -101,13 +106,15 @@ void WatchFaceDigital::Refresh() { hour = hour - 12; ampmChar[0] = 'P'; } - lv_label_set_text(label_time_ampm, ampmChar); + lv_label_set_text(label_time_ampm, ampmChar);*/ lv_label_set_text_fmt(label_time, "%2d:%02d", hour, minute); lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, 0, 0); } else { lv_label_set_text_fmt(label_time, "%02d:%02d", hour, minute); lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_CENTER, 0, 0); } + + lv_label_set_text_fmt(label_seconds, "%02d", second); // for secs currentDate = std::chrono::time_point_cast(currentDateTime.Get()); if (currentDate.IsUpdated()) { diff --git a/src/displayapp/screens/WatchFaceDigital.h b/src/displayapp/screens/WatchFaceDigital.h index f2409880..5b0ce672 100644 --- a/src/displayapp/screens/WatchFaceDigital.h +++ b/src/displayapp/screens/WatchFaceDigital.h @@ -44,7 +44,7 @@ namespace Pinetime { Utility::DirtyValue powerPresent {}; Utility::DirtyValue bleState {}; Utility::DirtyValue bleRadioEnabled {}; - Utility::DirtyValue> currentDateTime {}; + Utility::DirtyValue> currentDateTime {}; Utility::DirtyValue stepCount {}; Utility::DirtyValue heartbeat {}; Utility::DirtyValue heartbeatRunning {}; @@ -53,7 +53,8 @@ namespace Pinetime { Utility::DirtyValue> currentDate; lv_obj_t* label_time; - lv_obj_t* label_time_ampm; + lv_obj_t* label_seconds; //for secs + //lv_obj_t* label_time_ampm; lv_obj_t* label_date; lv_obj_t* heartbeatIcon; lv_obj_t* heartbeatValue; From b95823e745a08a47c56c803ed7eabe794131a9a5 Mon Sep 17 00:00:00 2001 From: josh Date: Sat, 23 Sep 2023 19:32:01 -0400 Subject: [PATCH 2/3] Fixed second $ in terminal watch face --- src/displayapp/screens/WatchFaceTerminal.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/displayapp/screens/WatchFaceTerminal.cpp b/src/displayapp/screens/WatchFaceTerminal.cpp index ac00f5a3..bd0a9f17 100644 --- a/src/displayapp/screens/WatchFaceTerminal.cpp +++ b/src/displayapp/screens/WatchFaceTerminal.cpp @@ -51,7 +51,7 @@ WatchFaceTerminal::WatchFaceTerminal(Controllers::DateTime& dateTimeController, lv_label_set_text_static(label_prompt_1, "user@watch:~ #00ff00 $# now"); label_prompt_2 = lv_label_create(lv_scr_act(), nullptr); - lv_label_set_recolor(label_prompt_1, true); + lv_label_set_recolor(label_prompt_2, true); lv_obj_align(label_prompt_2, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 60); lv_label_set_text_static(label_prompt_2, "user@watch:~ #00ff00 $#"); From cdd97b387113aa04fe5a241676487f86621e9d20 Mon Sep 17 00:00:00 2001 From: josh Date: Fri, 29 Sep 2023 23:15:07 -0400 Subject: [PATCH 3/3] Added battery percent to digital watch face --- src/displayapp/screens/WatchFaceDigital.cpp | 11 +++++++++++ src/displayapp/screens/WatchFaceDigital.h | 2 ++ 2 files changed, 13 insertions(+) diff --git a/src/displayapp/screens/WatchFaceDigital.cpp b/src/displayapp/screens/WatchFaceDigital.cpp index 1fbfc15a..df481806 100644 --- a/src/displayapp/screens/WatchFaceDigital.cpp +++ b/src/displayapp/screens/WatchFaceDigital.cpp @@ -23,6 +23,7 @@ WatchFaceDigital::WatchFaceDigital(Controllers::DateTime& dateTimeController, : currentDateTime {{}}, dateTimeController {dateTimeController}, notificationManager {notificationManager}, + batteryController {batteryController}, settingsController {settingsController}, heartRateController {heartRateController}, motionController {motionController}, @@ -34,6 +35,11 @@ WatchFaceDigital::WatchFaceDigital(Controllers::DateTime& dateTimeController, lv_obj_set_style_local_text_color(notificationIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_LIME); lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(false)); lv_obj_align(notificationIcon, nullptr, LV_ALIGN_IN_TOP_LEFT, 0, 0); + + + batteryValue = lv_label_create(lv_scr_act(), nullptr); + //lv_label_set_recolor(batteryValue, true); + lv_obj_align(batteryValue, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, -3, -110); label_seconds = lv_label_create(lv_scr_act(), nullptr); // for secs lv_obj_align(label_seconds, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, 0, -55); @@ -83,6 +89,11 @@ WatchFaceDigital::~WatchFaceDigital() { void WatchFaceDigital::Refresh() { statusIcons.Update(); + + batteryPercentRemaining = batteryController.PercentRemaining(); + if (batteryPercentRemaining.IsUpdated()) { + lv_label_set_text_fmt(batteryValue, "%d%%", batteryPercentRemaining.Get()); + } notificationState = notificationManager.AreNewNotificationsAvailable(); if (notificationState.IsUpdated()) { diff --git a/src/displayapp/screens/WatchFaceDigital.h b/src/displayapp/screens/WatchFaceDigital.h index 5b0ce672..4b66ae0b 100644 --- a/src/displayapp/screens/WatchFaceDigital.h +++ b/src/displayapp/screens/WatchFaceDigital.h @@ -55,6 +55,7 @@ namespace Pinetime { lv_obj_t* label_time; lv_obj_t* label_seconds; //for secs //lv_obj_t* label_time_ampm; + lv_obj_t* batteryValue; lv_obj_t* label_date; lv_obj_t* heartbeatIcon; lv_obj_t* heartbeatValue; @@ -63,6 +64,7 @@ namespace Pinetime { lv_obj_t* notificationIcon; Controllers::DateTime& dateTimeController; + const Controllers::Battery& batteryController; Controllers::NotificationManager& notificationManager; Controllers::Settings& settingsController; Controllers::HeartRateController& heartRateController;