From bf66e640216c68d03657f183d4dec62afd3c9892 Mon Sep 17 00:00:00 2001 From: Josh Date: Thu, 9 May 2024 15:52:57 -0400 Subject: [PATCH] Gravel watchface compiles --- src/displayapp/UserApps.h | 1 + src/displayapp/apps/Apps.h.in | 1 + src/displayapp/apps/CMakeLists.txt | 1 + src/displayapp/screens/WatchFaceGravel.cpp | 100 +++++++++------------ src/displayapp/screens/WatchFaceGravel.h | 39 +++++--- src/resources/fonts/SquareRegular.ttf | Bin 0 -> 17180 bytes 6 files changed, 76 insertions(+), 66 deletions(-) create mode 100644 src/resources/fonts/SquareRegular.ttf diff --git a/src/displayapp/UserApps.h b/src/displayapp/UserApps.h index 3f05ebdd..c7a719d8 100644 --- a/src/displayapp/UserApps.h +++ b/src/displayapp/UserApps.h @@ -17,6 +17,7 @@ #include "displayapp/screens/WatchFaceTerminal.h" #include "displayapp/screens/WatchFaceHorizon.h" #include "displayapp/screens/WatchFaceAccurateWords.h" +#include "displayapp/screens/WatchFaceGravel.h" namespace Pinetime { namespace Applications { diff --git a/src/displayapp/apps/Apps.h.in b/src/displayapp/apps/Apps.h.in index c05fb834..8cc34943 100644 --- a/src/displayapp/apps/Apps.h.in +++ b/src/displayapp/apps/Apps.h.in @@ -59,6 +59,7 @@ namespace Pinetime { CasioStyleG7710, Horizon, AccurateWords, + Gravel }; template diff --git a/src/displayapp/apps/CMakeLists.txt b/src/displayapp/apps/CMakeLists.txt index 379605bd..85281926 100644 --- a/src/displayapp/apps/CMakeLists.txt +++ b/src/displayapp/apps/CMakeLists.txt @@ -32,6 +32,7 @@ else() set(DEFAULT_WATCHFACE_TYPES "${DEFAULT_WATCHFACE_TYPES}, WatchFace::CasioStyleG7710") set(DEFAULT_WATCHFACE_TYPES "${DEFAULT_WATCHFACE_TYPES}, WatchFace::Horizon") set(DEFAULT_WATCHFACE_TYPES "${DEFAULT_WATCHFACE_TYPES}, WatchFace::AccurateWords") + set(DEFAULT_WATCHFACE_TYPES "${DEFAULT_WATCHFACE_TYPES}, WatchFace::Gravel") set(WATCHFACE_TYPES "${DEFAULT_WATCHFACE_TYPES}" CACHE STRING "List of watch faces to build into the firmware") endif() diff --git a/src/displayapp/screens/WatchFaceGravel.cpp b/src/displayapp/screens/WatchFaceGravel.cpp index 05a1c07f..2bb4c47b 100644 --- a/src/displayapp/screens/WatchFaceGravel.cpp +++ b/src/displayapp/screens/WatchFaceGravel.cpp @@ -1,6 +1,5 @@ #include "displayapp/screens/WatchFaceGravel.h" -#include #include #include "components/battery/BatteryController.h" #include "components/ble/BleController.h" @@ -26,18 +25,16 @@ namespace Style { static constexpr lv_color_t barBackground = LV_COLOR_MAKE(0x38, 0x38, 0x38); } -WatchFaceGravel::WatchFaceGravel(DisplayApp* app, - Controllers::DateTime& dateTimeController, - Controllers::Battery& batteryController, +WatchFaceGravel::WatchFaceGravel(Controllers::DateTime& dateTimeController, + const Controllers::Battery& batteryController, Controllers::Settings& settingsController, Controllers::MotionController& motionController, Controllers::FS& filesystem) - : Screen(app), - currentDateTime {{}}, + : currentDateTime {{}}, dateTimeController {dateTimeController}, batteryController {batteryController}, settingsController {settingsController}, - motionController(motionController) { + motionController {motionController} { lfs_file f = {}; if (filesystem.FileOpen(&f, "/fonts/SquareRegular_72.bin", LFS_O_RDONLY) >= 0) { @@ -116,47 +113,36 @@ void WatchFaceGravel::Refresh() { currentDateTime = dateTimeController.CurrentDateTime(); if (currentDateTime.IsUpdated()) { - auto newDateTime = currentDateTime.Get(); + uint8_t hour = dateTimeController.Hours(); + uint8_t minute = dateTimeController.Minutes(); - auto dp = date::floor(newDateTime); - auto time = date::make_time(newDateTime - dp); - uint8_t hour = time.hours().count(); - uint8_t minute = time.minutes().count(); - - if (displayedHour != hour || displayedMinute != minute) { - displayedHour = hour; - displayedMinute = minute; - - if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) { - char ampmChar[3] = "AM"; - if (hour == 0) { - hour = 12; - } else if (hour == 12) { - ampmChar[0] = 'P'; - } else if (hour > 12) { - hour = hour - 12; - ampmChar[0] = 'P'; - } - lv_label_set_text(labelTimeAMPM, ampmChar); + if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) { + char ampmChar[3] = "AM"; + if (hour == 0) { + hour = 12; + } else if (hour == 12) { + ampmChar[0] = 'P'; + } else if (hour > 12) { + hour = hour - 12; + ampmChar[0] = 'P'; } - - lv_label_set_text_fmt(labelTime, "%02d:%02d", hour, minute); - lv_obj_align_origo(labelTime, lv_scr_act(), LV_ALIGN_CENTER, 0, 0); + lv_label_set_text(labelTimeAMPM, ampmChar); } - auto yearMonthDay = date::year_month_day(dp); - auto month = static_cast(static_cast(yearMonthDay.month())); - auto day = static_cast(yearMonthDay.day()); - if ((day != currentDay) || (month != currentMonth)) { - lv_label_set_text_fmt(labelDate, "%d %s", day, Pinetime::Controllers::DateTime::MonthShortToStringLow(month)); + lv_label_set_text_fmt(labelTime, "%02d:%02d", hour, minute); + lv_obj_align_origo(labelTime, lv_scr_act(), LV_ALIGN_CENTER, 0, 0); + + + currentDate = std::chrono::time_point_cast(currentDateTime.Get()); + if (currentDate.IsUpdated()) { + lv_label_set_text_fmt(labelDate, "%d %s", dateTimeController.DayOfWeekShortToString(), dateTimeController.MonthShortToString()); } lv_obj_realign(labelDate); } stepCount = motionController.NbSteps(); - motionSensorOk = motionController.IsSensorOk(); - if (stepCount.IsUpdated() || motionSensorOk.IsUpdated()) { + if (stepCount.IsUpdated()) { uint16_t pointCount = refreshStepLinePoints(std::min(stepCount.Get(), settingsController.GetStepsGoal())); lv_line_set_points(stepLine, stepLinePoints.data(), pointCount); } @@ -177,6 +163,21 @@ void WatchFaceGravel::Refresh() { } } +bool WatchFaceGravel::IsAvailable(Pinetime::Controllers::FS& filesystem) { + lfs_file file = {}; + + if (filesystem.FileOpen(&file, "/fonts/SquareRegular_72.bin", LFS_O_RDONLY) < 0) { + return false; + } + filesystem.FileClose(&file); + + if (filesystem.FileOpen(&file, "/fonts/SquareRegular_20.bin", LFS_O_RDONLY) < 0) { + return false; + } + filesystem.FileClose(&file); + return true; +} + void WatchFaceGravel::updateBatteryBar(uint8_t percent) { lv_bar_set_value(batteryBar, percent, LV_ANIM_ON); if (percent >= 70) { @@ -188,8 +189,9 @@ void WatchFaceGravel::updateBatteryBar(uint8_t percent) { } } -void WatchFaceGravel::toggleBatteryChargingAnimation(bool enabled, uint8_t percent) { - if (enabled) { +void WatchFaceGravel::toggleBatteryChargingAnimation(bool, uint8_t) { +//void WatchFaceGravel::toggleBatteryChargingAnimation(bool enabled, uint8_t percent) { + /*if (enabled) { lv_obj_set_style_local_bg_color(batteryBar, LV_BAR_PART_INDIC, LV_STATE_DEFAULT, Style::green); lv_anim_del(batteryBar, (lv_anim_exec_xcb_t) lv_bar_set_value); lv_anim_set_exec_cb(&animationBatteryCharging, (lv_anim_exec_xcb_t) lv_bar_set_value); @@ -200,7 +202,8 @@ void WatchFaceGravel::toggleBatteryChargingAnimation(bool enabled, uint8_t perce } else { lv_anim_del(batteryBar, (lv_anim_exec_xcb_t) lv_bar_set_value); updateBatteryBar(batteryPercentRemaining.Get()); - } + }*/ + } WatchFaceGravel::DrawStop WatchFaceGravel::getDrawEnd(float percent, uint16_t width, uint16_t height) { @@ -317,18 +320,3 @@ uint16_t WatchFaceGravel::refreshStepLinePoints(uint32_t stepCount) { return currentPointIndex; } - -bool WatchFaceGravel::IsAvailable(Pinetime::Controllers::FS& filesystem) { - lfs_file file = {}; - - if (filesystem.FileOpen(&file, "/fonts/SquareRegular_72.bin", LFS_O_RDONLY) < 0) { - return false; - } - filesystem.FileClose(&file); - - if (filesystem.FileOpen(&file, "/fonts/SquareRegular_20.bin", LFS_O_RDONLY) < 0) { - return false; - } - filesystem.FileClose(&file); - return true; -} diff --git a/src/displayapp/screens/WatchFaceGravel.h b/src/displayapp/screens/WatchFaceGravel.h index 7faf7fae..480985e4 100644 --- a/src/displayapp/screens/WatchFaceGravel.h +++ b/src/displayapp/screens/WatchFaceGravel.h @@ -5,9 +5,11 @@ #include #include #include +#include "displayapp/Controllers.h" #include "components/ble/BleController.h" #include "components/datetime/DateTimeController.h" #include "displayapp/screens/Screen.h" +#include "utility/DirtyValue.h" namespace Pinetime { namespace Controllers { @@ -21,12 +23,10 @@ namespace Pinetime { namespace Applications { namespace Screens { - class WatchFaceGravel : public Screen { public: - WatchFaceGravel(DisplayApp* app, - Controllers::DateTime& dateTimeController, - Controllers::Battery& batteryController, + WatchFaceGravel(Controllers::DateTime& dateTimeController, + const Controllers::Battery& batteryController, Controllers::Settings& settingsController, Controllers::MotionController& motionController, Controllers::FS& filesystem); @@ -43,11 +43,12 @@ namespace Pinetime { uint8_t currentDay = 0; std::array stepLinePoints = {0}; - DirtyValue> currentDateTime {}; - DirtyValue motionSensorOk {}; - DirtyValue stepCount {}; - DirtyValue batteryPercentRemaining {}; - DirtyValue isCharging {}; + Utility::DirtyValue> currentDateTime {}; + Utility::DirtyValue motionSensorOk {}; + Utility::DirtyValue stepCount {}; + Utility::DirtyValue batteryPercentRemaining {}; + Utility::DirtyValue isCharging {}; + Utility::DirtyValue> currentDate; lv_obj_t* labelTime; lv_obj_t* labelTimeAMPM; @@ -62,9 +63,9 @@ namespace Pinetime { lv_font_t* font_SquareRegular20 = nullptr; Controllers::DateTime& dateTimeController; + const Controllers::Battery& batteryController; Controllers::Settings& settingsController; Controllers::MotionController& motionController; - Controllers::Battery& batteryController; lv_task_t* taskRefresh; @@ -80,5 +81,23 @@ namespace Pinetime { void toggleBatteryChargingAnimation(bool enabled, uint8_t percent); }; } + + template <> + struct WatchFaceTraits { + static constexpr WatchFace watchFace = WatchFace::Gravel; + static constexpr const char* name = "Pebble face"; + + static Screens::Screen* Create(AppControllers& controllers) { + return new Screens::WatchFaceGravel(controllers.dateTimeController, + controllers.batteryController, + controllers.settingsController, + controllers.motionController, + controllers.filesystem); + }; + + static bool IsAvailable(Pinetime::Controllers::FS& filesystem) { + return Screens::WatchFaceGravel::IsAvailable(filesystem); + } + }; } } diff --git a/src/resources/fonts/SquareRegular.ttf b/src/resources/fonts/SquareRegular.ttf new file mode 100644 index 0000000000000000000000000000000000000000..9243923e229dce2989f863e1810b26705c06327f GIT binary patch literal 17180 zcmeI4f2?I!Rmayo_sx&aOlLYjXooU|(^4sgGCxXNno?vpV1Gyv(m^09;k}u8o%hSqLDu!Q6qm4cVdm2@CPbUqDUVF6Nn}y1|yo8Iexxt z?{n|DKi)tTLQFWf>+H4nUhBJl>~;3p_r7MVXJ$JrTHoq-96xe<|E?_`G24BV(bRRnf=LU&B90NfBfv++WF@9?B~t4-;8{HZtm>-jjw&< z8|l9loqs*Qw6bbda|wIcuo|kMK6HRPo>%X*nd)Bp_b@wS*V|2Yv)yX9* z?*si8>@V&4nVFfLGdIoLJriagn0edonY~x--MM$~-UBcHWc||mhNc0dM)y^&d(?j1 z?n8I3==RXPX698h_n`ZeyL)>L-93BvqkFJE)HKc4nira{HqSR-Y5uwSa`R8kKQ{l+ z{C)GQ%?B_3^u>2veA~qbFFtVbzKd`E_m92!>o5M=i@);X$6n}de01ZN6~T|LA7Tc6 zR69S!)BqNIVreOf`O_4MRUGKE7G{n(MVPsq*IvAxAMJ&e4$FREm=puj7hE% zAG1zhyod-!S}WsuZi5Inq|;IxkL$FurF9$Pq3mPE7GH@Nu0m`?U=h2LR6ReiPaJMD1)Na1(ciT?Wvf3@A*|FgmqOaE(y-*1n!Jh2>{x$`Yc=bv0& zJiV}5udO}y*wWI<{JGO>uU}iMZ$EnM&f_0=Vs3f?k17}Y>xUjl<{+=U89>wH}n>>7S>FlV3FT`iEofqQo)EDMf>Jv{ao>{Fg zEUqqOWY^nKkS<)faM;nXC#B^Vm>jDkrMOoRPDP%DXX2ssa$eZ|B)%#rU zY2E}gmA?p@_1yAOc)fjIoBoV$T%XA=l-%Kd|M7P{V!`VA2F?wE$7f4`&EGT|jb^SPs>JNc zGXIf@c8OWz3*Ph1-(5Z+*-Jqq`Arz{UA_#w(3C|KAhr2UFZGhy<$!xqjfBd7a=n$w zheVwYHPeJjjj&%aL>~>c(~D@N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