From c25623ae7993485ebb61664d93eb413af35535fb Mon Sep 17 00:00:00 2001 From: Josh Date: Thu, 9 May 2024 13:50:02 -0400 Subject: [PATCH] Progress with Accurate words face, but not working yet --- src/displayapp/apps/Apps.h.in | 3 +- .../screens/WatchFaceAccurateWords.cpp | 38 +++++--------- .../screens/WatchFaceAccurateWords.h | 51 ++++++++++++++----- 3 files changed, 51 insertions(+), 41 deletions(-) diff --git a/src/displayapp/apps/Apps.h.in b/src/displayapp/apps/Apps.h.in index 64ad2572..c05fb834 100644 --- a/src/displayapp/apps/Apps.h.in +++ b/src/displayapp/apps/Apps.h.in @@ -57,7 +57,8 @@ namespace Pinetime { Terminal, Infineat, CasioStyleG7710, - Horizon + Horizon, + AccurateWords, }; template diff --git a/src/displayapp/screens/WatchFaceAccurateWords.cpp b/src/displayapp/screens/WatchFaceAccurateWords.cpp index a7319301..4eaf65e3 100644 --- a/src/displayapp/screens/WatchFaceAccurateWords.cpp +++ b/src/displayapp/screens/WatchFaceAccurateWords.cpp @@ -1,6 +1,5 @@ #include "displayapp/screens/WatchFaceAccurateWords.h" -#include #include #include #include "displayapp/screens/NotificationIcon.h" @@ -14,16 +13,14 @@ using namespace Pinetime::Applications::Screens; -WatchFaceAccurateWords::WatchFaceAccurateWords(DisplayApp* app, - Controllers::DateTime& dateTimeController, - Controllers::Battery& batteryController, - Controllers::Ble& bleController, +WatchFaceAccurateWords::WatchFaceAccurateWords(Controllers::DateTime& dateTimeController, + const Controllers::Battery& batteryController, + const Controllers::Ble& bleController, Controllers::NotificationManager& notificatioManager, Controllers::Settings& settingsController, Controllers::HeartRateController& heartRateController, Controllers::MotionController& motionController) - : Screen(app), - currentDateTime {{}}, + : currentDateTime {{}}, dateTimeController {dateTimeController}, notificatioManager {notificatioManager}, settingsController {settingsController}, @@ -92,19 +89,13 @@ void WatchFaceAccurateWords::Refresh() { currentDateTime = dateTimeController.CurrentDateTime(); if (currentDateTime.IsUpdated()) { - auto newDateTime = currentDateTime.Get(); + auto year = dateTimeController.Year(); + auto month = dateTimeController.Month(); + auto day = dateTimeController.Day(); + auto dayOfWeek = dateTimeController.DayOfWeek(); - auto dp = date::floor(newDateTime); - auto time = date::make_time(newDateTime - dp); - auto yearMonthDay = date::year_month_day(dp); - - auto year = static_cast(yearMonthDay.year()); - auto month = static_cast(static_cast(yearMonthDay.month())); - auto day = static_cast(yearMonthDay.day()); - auto dayOfWeek = static_cast(date::weekday(yearMonthDay).iso_encoding()); - - uint8_t hour = time.hours().count(); - uint8_t minute = time.minutes().count(); + uint8_t hour = dateTimeController.Hours(); + uint8_t minute = dateTimeController.Minutes(); uint8_t monthInt = static_cast(month); uint8_t dayInt = static_cast(day); @@ -198,7 +189,8 @@ void WatchFaceAccurateWords::Refresh() { lv_label_set_text_fmt(label_time, "%s", words); lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_CENTER, 0, -40); - if ((year != currentYear) || (month != currentMonth) || (dayOfWeek != currentDayOfWeek) || (day != currentDay)) { + currentDate = std::chrono::time_point_cast(currentDateTime.Get()); + if (currentDate.IsUpdated()) { // Specific dates have specific names if (year == 1970) { lv_label_set_text_fmt(label_date, "New Firmware"); @@ -228,11 +220,6 @@ void WatchFaceAccurateWords::Refresh() { months_array[monthInt]); } lv_obj_align(label_date, lv_scr_act(), LV_ALIGN_CENTER, 0, 60); - - currentYear = year; - currentMonth = month; - currentDayOfWeek = dayOfWeek; - currentDay = day; } } } @@ -253,7 +240,6 @@ void WatchFaceAccurateWords::Refresh() { } stepCount = motionController.NbSteps(); - motionSensorOk = motionController.IsSensorOk(); if (stepCount.IsUpdated() || motionSensorOk.IsUpdated()) { lv_label_set_text_fmt(stepValue, "%lu", stepCount.Get()); lv_obj_realign(stepValue); diff --git a/src/displayapp/screens/WatchFaceAccurateWords.h b/src/displayapp/screens/WatchFaceAccurateWords.h index c3eee38c..90ef03ba 100644 --- a/src/displayapp/screens/WatchFaceAccurateWords.h +++ b/src/displayapp/screens/WatchFaceAccurateWords.h @@ -8,6 +8,8 @@ #include "components/datetime/DateTimeController.h" #include "components/ble/BleController.h" #include "displayapp/widgets/StatusIcons.h" +#include "displayapp/apps/Apps.h" +#include "utility/DirtyValue.h" namespace Pinetime { namespace Controllers { @@ -24,10 +26,9 @@ namespace Pinetime { class WatchFaceAccurateWords : public Screen { public: - WatchFaceAccurateWords(DisplayApp* app, - Controllers::DateTime& dateTimeController, - Controllers::Battery& batteryController, - Controllers::Ble& bleController, + WatchFaceAccurateWords(Controllers::DateTime& dateTimeController, + const Controllers::Battery& batteryController, + const Controllers::Ble& bleController, Controllers::NotificationManager& notificatioManager, Controllers::Settings& settingsController, Controllers::HeartRateController& heartRateController, @@ -45,17 +46,19 @@ namespace Pinetime { Controllers::DateTime::Days currentDayOfWeek = Pinetime::Controllers::DateTime::Days::Unknown; uint8_t currentDay = 0; - DirtyValue batteryPercentRemaining {}; - DirtyValue powerPresent {}; - DirtyValue bleState {}; - DirtyValue bleRadioEnabled {}; - DirtyValue> currentDateTime {}; - DirtyValue motionSensorOk {}; - DirtyValue stepCount {}; - DirtyValue heartbeat {}; - DirtyValue heartbeatRunning {}; - DirtyValue notificationState {}; + Utility::DirtyValue batteryPercentRemaining {}; + Utility::DirtyValue powerPresent {}; + Utility::DirtyValue bleState {}; + Utility::DirtyValue bleRadioEnabled {}; + Utility::DirtyValue> currentDateTime {}; + Utility::DirtyValue motionSensorOk {}; + Utility::DirtyValue stepCount {}; + Utility::DirtyValue heartbeat {}; + Utility::DirtyValue heartbeatRunning {}; + Utility::DirtyValue notificationState {}; + Utility::DirtyValue> currentDate; + lv_obj_t* label_time; lv_obj_t* label_time_ampm; lv_obj_t* label_date; @@ -75,5 +78,25 @@ namespace Pinetime { Widgets::StatusIcons statusIcons; }; } + + template <> + struct WatchFaceTraits { + static constexpr WatchFace watchFace = WatchFace::AccurateWords; + static constexpr const char* name = "AccurateWords"; + + static Screens::Screen* Create(AppControllers& controllers) { + return new Screens::WatchFaceAccurateWords (controllers.dateTimeController, + controllers.batteryController, + controllers.bleController, + controllers.notificationManager, + controllers.settingsController, + controllers.heartRateController, + controllers.motionController); + }; + + static bool IsAvailable(Pinetime::Controllers::FS& ) { + return true; + } + }; } }