From dc45d845c2267e3d1b182d693ddd39ea17733394 Mon Sep 17 00:00:00 2001 From: Josh Date: Thu, 9 May 2024 11:24:05 -0400 Subject: [PATCH] Horizon watch face compiles --- src/displayapp/screens/WatchFaceHorizon.cpp | 32 ++++++------------- src/displayapp/screens/WatchFaceHorizon.h | 11 ++++--- .../screens/settings/SettingWatchFace.h | 1 + 3 files changed, 17 insertions(+), 27 deletions(-) diff --git a/src/displayapp/screens/WatchFaceHorizon.cpp b/src/displayapp/screens/WatchFaceHorizon.cpp index 639cbcd5..fc9904c1 100644 --- a/src/displayapp/screens/WatchFaceHorizon.cpp +++ b/src/displayapp/screens/WatchFaceHorizon.cpp @@ -10,11 +10,11 @@ using namespace Pinetime::Applications::Screens; WatchFaceHorizon::WatchFaceHorizon(Controllers::DateTime& dateTimeController, - Controllers::Battery& batteryController, + const Controllers::Battery& batteryController, Controllers::Settings& settingsController, Controllers::MotionController& motionController, Controllers::FS& filesystem) - currentDateTime {{}}, + : currentDateTime {{}}, dateTimeController {dateTimeController}, batteryController {batteryController}, settingsController {settingsController}, @@ -144,21 +144,12 @@ WatchFaceHorizon::~WatchFaceHorizon() { } void WatchFaceHorizon::Refresh() { - currentDateTime = dateTimeController.CurrentDateTime(); + currentDateTime = std::chrono::time_point_cast(dateTimeController.CurrentDateTime()); if (currentDateTime.IsUpdated()) { - auto newDateTime = currentDateTime.Get(); - - auto dp = date::floor(newDateTime); - auto time = date::make_time(newDateTime - dp); - auto yearMonthDay = date::year_month_day(dp); - - auto month = static_cast(static_cast(yearMonthDay.month())); - auto day = static_cast(yearMonthDay.day()); - auto dayOfWeek = static_cast(date::weekday(yearMonthDay).iso_encoding()); - - int64_t hour = time.hours().count(); - int64_t minute = time.minutes().count(); + uint8_t hour = dateTimeController.Hours(); + uint8_t minute = dateTimeController.Minutes(); + uint8_t day = dateTimeController.Day(); char minutesChar[3]; sprintf(minutesChar, "%02d", static_cast(minute)); @@ -167,6 +158,7 @@ void WatchFaceHorizon::Refresh() { int displayHour = hour; // Account for 12-hour time + if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) { if (hour < 12) { if (hour == 0) { @@ -214,7 +206,8 @@ void WatchFaceHorizon::Refresh() { } // Date has updated - if ((month != currentMonth) || (dayOfWeek != currentDayOfWeek) || (day != currentDay)) { + currentDate = std::chrono::time_point_cast(currentDateTime.Get()); + if (currentDate.IsUpdated()) { lv_label_set_text_fmt(labelDayOfWeek, "%s", dateTimeController.DayOfWeekShortToString()); lv_label_set_text_fmt(labelMonth, "%s", dateTimeController.MonthShortToString()); lv_label_set_text_fmt(labelDate, "%d", day); @@ -222,10 +215,6 @@ void WatchFaceHorizon::Refresh() { lv_obj_realign(labelDayOfWeek); lv_obj_realign(labelMonth); lv_obj_realign(labelDate); - - currentMonth = month; - currentDayOfWeek = dayOfWeek; - currentDay = day; } } @@ -238,8 +227,7 @@ void WatchFaceHorizon::Refresh() { // Set step count stepCount = motionController.NbSteps(); - motionSensorOk = motionController.IsSensorOk(); - if (stepCount.IsUpdated() || motionSensorOk.IsUpdated()) { + if (stepCount.IsUpdated()) { lv_label_set_text_fmt(stepValue, "%lu", stepCount.Get()); lv_obj_realign(stepValue); } diff --git a/src/displayapp/screens/WatchFaceHorizon.h b/src/displayapp/screens/WatchFaceHorizon.h index a2ef6511..c909255a 100644 --- a/src/displayapp/screens/WatchFaceHorizon.h +++ b/src/displayapp/screens/WatchFaceHorizon.h @@ -23,7 +23,7 @@ namespace Pinetime { class WatchFaceHorizon : public Screen { public: WatchFaceHorizon(Controllers::DateTime& dateTimeController, - Controllers::Battery& batteryController, + const Controllers::Battery& batteryController, Controllers::Settings& settingsController, Controllers::MotionController& motionController, Controllers::FS& fs); @@ -41,6 +41,7 @@ namespace Pinetime { Pinetime::Controllers::DateTime::Months currentMonth = Pinetime::Controllers::DateTime::Months::Unknown; Pinetime::Controllers::DateTime::Days currentDayOfWeek = Pinetime::Controllers::DateTime::Days::Unknown; uint8_t currentDay = 0; + Utility::DirtyValue> currentDate; Utility::DirtyValue batteryPercentRemaining {}; Utility::DirtyValue> currentDateTime {}; @@ -73,7 +74,7 @@ namespace Pinetime { lv_obj_t* stepValue; Controllers::DateTime& dateTimeController; - Controllers::Battery& batteryController; + const Controllers::Battery& batteryController; Controllers::Settings& settingsController; Controllers::MotionController& motionController; @@ -92,16 +93,16 @@ namespace Pinetime { static constexpr WatchFace watchFace = WatchFace::Horizon; static constexpr const char* name = "Horizon"; - static Screens::Screen* Create(AppControllers& controllers) { + static Screens::Screen* Create;/*(AppControllers& controllers) { return new Screens::WatchFaceHorizon(controllers.dateTimeController, controllers.batteryController, controllers.settingsController, controllers.motionController, controllers.filesystem); - }; + };*/ static bool IsAvailable(Pinetime::Controllers::FS& filesystem) { - return Screens::WatchFaceInfineat::IsAvailable(filesystem); + return Screens::WatchFaceHorizon::IsAvailable(filesystem); } }; } diff --git a/src/displayapp/screens/settings/SettingWatchFace.h b/src/displayapp/screens/settings/SettingWatchFace.h index 4c75b0ab..8acb65b3 100644 --- a/src/displayapp/screens/settings/SettingWatchFace.h +++ b/src/displayapp/screens/settings/SettingWatchFace.h @@ -11,6 +11,7 @@ #include "displayapp/screens/CheckboxList.h" #include "displayapp/screens/WatchFaceInfineat.h" #include "displayapp/screens/WatchFaceCasioStyleG7710.h" +#include "displayapp/screens/WatchFaceHorizon.h" namespace Pinetime {