diff --git a/src/displayapp/screens/WatchFaceDigital.cpp b/src/displayapp/screens/WatchFaceDigital.cpp index ca53691b12..566a116199 100644 --- a/src/displayapp/screens/WatchFaceDigital.cpp +++ b/src/displayapp/screens/WatchFaceDigital.cpp @@ -19,13 +19,15 @@ WatchFaceDigital::WatchFaceDigital(Controllers::DateTime& dateTimeController, Controllers::NotificationManager& notificationManager, Controllers::Settings& settingsController, Controllers::HeartRateController& heartRateController, - Controllers::MotionController& motionController) + Controllers::MotionController& motionController, + Controllers::Timer& timer) : currentDateTime {{}}, dateTimeController {dateTimeController}, notificationManager {notificationManager}, settingsController {settingsController}, heartRateController {heartRateController}, motionController {motionController}, + timer {timer}, statusIcons(batteryController, bleController) { statusIcons.Create(); @@ -35,6 +37,16 @@ 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); + timerIcon = lv_label_create(lv_scr_act(), nullptr); + lv_label_set_text_static(timerIcon, Symbols::hourGlass); + lv_obj_set_style_local_text_color(timerIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x999999)); + lv_obj_align(timerIcon, lv_scr_act(), LV_ALIGN_IN_TOP_MID, -32, 60); + + timeRemaining = lv_label_create(lv_scr_act(), nullptr); + lv_obj_set_style_local_text_color(timeRemaining, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x999999)); + lv_label_set_text(timeRemaining, "00:00"); + lv_obj_align(timeRemaining, nullptr, LV_ALIGN_IN_TOP_MID, 10, 60); + 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)); @@ -85,6 +97,20 @@ void WatchFaceDigital::Refresh() { lv_label_set_text_static(notificationIcon, NotificationIcon::GetIcon(notificationState.Get())); } + if (timer.IsRunning()) { + auto secondsRemaining = std::chrono::duration_cast(timer.GetTimeRemaining()); + + int minutes = secondsRemaining.count() / 60; + int seconds = secondsRemaining.count() % 60; + lv_label_set_text_fmt(timeRemaining, "%02d:%02d", minutes, seconds); + + lv_obj_set_hidden(timeRemaining, false); + lv_obj_set_hidden(timerIcon, false); + } else { + lv_obj_set_hidden(timeRemaining, true); + lv_obj_set_hidden(timerIcon, true); + } + currentDateTime = std::chrono::time_point_cast(dateTimeController.CurrentDateTime()); if (currentDateTime.IsUpdated()) { diff --git a/src/displayapp/screens/WatchFaceDigital.h b/src/displayapp/screens/WatchFaceDigital.h index a4664792c0..85a5e00ca1 100644 --- a/src/displayapp/screens/WatchFaceDigital.h +++ b/src/displayapp/screens/WatchFaceDigital.h @@ -19,6 +19,7 @@ namespace Pinetime { class NotificationManager; class HeartRateController; class MotionController; + class Timer; } namespace Applications { @@ -32,7 +33,8 @@ namespace Pinetime { Controllers::NotificationManager& notificationManager, Controllers::Settings& settingsController, Controllers::HeartRateController& heartRateController, - Controllers::MotionController& motionController); + Controllers::MotionController& motionController, + Controllers::Timer& timer); ~WatchFaceDigital() override; void Refresh() override; @@ -53,6 +55,8 @@ namespace Pinetime { using days = std::chrono::duration>; // TODO: days is standard in c++20 Utility::DirtyValue> currentDate; + lv_obj_t* timerIcon; + lv_obj_t* timeRemaining; lv_obj_t* label_time; lv_obj_t* label_time_ampm; lv_obj_t* label_date; @@ -67,6 +71,7 @@ namespace Pinetime { Controllers::Settings& settingsController; Controllers::HeartRateController& heartRateController; Controllers::MotionController& motionController; + Controllers::Timer& timer; lv_task_t* taskRefresh; Widgets::StatusIcons statusIcons; @@ -85,7 +90,8 @@ namespace Pinetime { controllers.notificationManager, controllers.settingsController, controllers.heartRateController, - controllers.motionController); + controllers.motionController, + controllers.timer); }; static bool IsAvailable(Pinetime::Controllers::FS& /*filesystem*/) {