From 0a48fbcd79d519d0c126d3eabdb8243877d51a25 Mon Sep 17 00:00:00 2001 From: Eshe Date: Mon, 16 Dec 2024 17:29:52 +0000 Subject: [PATCH 01/26] Added trans watch face --- src/CMakeLists.txt | 1 + src/displayapp/UserApps.h | 1 + src/displayapp/apps/Apps.h.in | 1 + src/displayapp/apps/CMakeLists.txt | 1 + src/displayapp/screens/WatchFaceTrans.cpp | 192 ++++++++++++++++++++++ src/displayapp/screens/WatchFaceTrans.h | 90 ++++++++++ 6 files changed, 286 insertions(+) create mode 100644 src/displayapp/screens/WatchFaceTrans.cpp create mode 100644 src/displayapp/screens/WatchFaceTrans.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e2b69b8b02..9b06347524 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -426,6 +426,7 @@ list(APPEND SOURCE_FILES displayapp/screens/WatchFaceTerminal.cpp displayapp/screens/WatchFacePineTimeStyle.cpp displayapp/screens/WatchFaceCasioStyleG7710.cpp + displayapp/screens/WatchFaceTrans.cpp ## diff --git a/src/displayapp/UserApps.h b/src/displayapp/UserApps.h index 67bbfa7d41..74573b1176 100644 --- a/src/displayapp/UserApps.h +++ b/src/displayapp/UserApps.h @@ -14,6 +14,7 @@ #include "displayapp/screens/WatchFaceInfineat.h" #include "displayapp/screens/WatchFacePineTimeStyle.h" #include "displayapp/screens/WatchFaceTerminal.h" +#include "displayapp/screens/WatchFaceTrans.h" namespace Pinetime { namespace Applications { diff --git a/src/displayapp/apps/Apps.h.in b/src/displayapp/apps/Apps.h.in index 2104a267c0..b64b6be8f8 100644 --- a/src/displayapp/apps/Apps.h.in +++ b/src/displayapp/apps/Apps.h.in @@ -52,6 +52,7 @@ namespace Pinetime { Terminal, Infineat, CasioStyleG7710, + Trans, }; template diff --git a/src/displayapp/apps/CMakeLists.txt b/src/displayapp/apps/CMakeLists.txt index d78587609e..5209431f5e 100644 --- a/src/displayapp/apps/CMakeLists.txt +++ b/src/displayapp/apps/CMakeLists.txt @@ -27,6 +27,7 @@ else() set(DEFAULT_WATCHFACE_TYPES "${DEFAULT_WATCHFACE_TYPES}, WatchFace::Terminal") set(DEFAULT_WATCHFACE_TYPES "${DEFAULT_WATCHFACE_TYPES}, WatchFace::Infineat") set(DEFAULT_WATCHFACE_TYPES "${DEFAULT_WATCHFACE_TYPES}, WatchFace::CasioStyleG7710") + set(DEFAULT_WATCHFACE_TYPES "${DEFAULT_WATCHFACE_TYPES}, WatchFace::Trans") set(WATCHFACE_TYPES "${DEFAULT_WATCHFACE_TYPES}" CACHE STRING "List of watch faces to build into the firmware") endif() diff --git a/src/displayapp/screens/WatchFaceTrans.cpp b/src/displayapp/screens/WatchFaceTrans.cpp new file mode 100644 index 0000000000..fe7a488e1d --- /dev/null +++ b/src/displayapp/screens/WatchFaceTrans.cpp @@ -0,0 +1,192 @@ +#include +#include "displayapp/screens/WatchFaceTrans.h" +#include "displayapp/screens/BatteryIcon.h" +#include "displayapp/screens/NotificationIcon.h" +#include "displayapp/screens/Symbols.h" +#include "components/battery/BatteryController.h" +#include "components/ble/BleController.h" +#include "components/motion/MotionController.h" +#include "components/settings/Settings.h" + +using namespace Pinetime::Applications::Screens; + +WatchFaceTrans::WatchFaceTrans(Controllers::DateTime& dateTimeController, + const Controllers::Battery& batteryController, + const Controllers::Ble& bleController, + Controllers::NotificationManager& notificationManager, + Controllers::Settings& settingsController, + Controllers::MotionController& motionController) + : currentDateTime {{}}, + dateTimeController {dateTimeController}, + batteryController {batteryController}, + bleController {bleController}, + notificationManager {notificationManager}, + settingsController {settingsController}, + motionController {motionController} { + + topBlueBackground = lv_obj_create(lv_scr_act(), nullptr); + lv_obj_set_size(topBlueBackground, LV_HOR_RES, LV_VER_RES / 5); + lv_obj_set_pos(topBlueBackground, 0, 0); + lv_obj_set_style_local_bg_color(topBlueBackground, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00bff3)); + lv_obj_set_style_local_radius(topBlueBackground, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, 0); + topPinkBackground = lv_obj_create(lv_scr_act(), nullptr); + lv_obj_set_size(topPinkBackground, LV_HOR_RES, LV_VER_RES / 5); + lv_obj_set_pos(topPinkBackground, 0, LV_VER_RES / 5); + lv_obj_set_style_local_bg_color(topPinkBackground, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xf49ac1)); + lv_obj_set_style_local_radius(topPinkBackground, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, 0); + whiteBackground = lv_obj_create(lv_scr_act(), nullptr); + lv_obj_set_size(whiteBackground, LV_HOR_RES, LV_VER_RES / 5); + lv_obj_set_pos(whiteBackground, 0, 2 * LV_VER_RES / 5); + lv_obj_set_style_local_bg_color(whiteBackground, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xffffff)); + lv_obj_set_style_local_radius(whiteBackground, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, 0); + bottomPinkBackground = lv_obj_create(lv_scr_act(), nullptr); + lv_obj_set_size(bottomPinkBackground, LV_HOR_RES, LV_VER_RES / 5); + lv_obj_set_pos(bottomPinkBackground, 0, 3 * LV_VER_RES / 5); + lv_obj_set_style_local_bg_color(bottomPinkBackground, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xf49ac1)); + lv_obj_set_style_local_radius(bottomPinkBackground, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, 0); + bottomBlueBackground = lv_obj_create(lv_scr_act(), nullptr); + lv_obj_set_size(bottomBlueBackground, LV_HOR_RES, LV_VER_RES / 5); + lv_obj_set_pos(bottomBlueBackground, 0, 4 * LV_VER_RES / 5); + lv_obj_set_style_local_bg_color(bottomBlueBackground, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00bff3)); + lv_obj_set_style_local_radius(bottomBlueBackground, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, 0); + + bluetoothStatus = lv_label_create(lv_scr_act(), nullptr); + lv_label_set_text_static(bluetoothStatus, ""); + lv_obj_align(bluetoothStatus, nullptr, LV_ALIGN_IN_TOP_RIGHT, -16, 0); + + batteryValue = lv_label_create(lv_scr_act(), nullptr); + lv_label_set_recolor(batteryValue, true); + lv_obj_align(batteryValue, lv_scr_act(), LV_ALIGN_CENTER, 0, -96); + lv_label_set_align(batteryValue, LV_LABEL_ALIGN_CENTER); + lv_obj_set_auto_realign(batteryValue, true); + + notificationIcon = lv_label_create(lv_scr_act(), nullptr); + lv_obj_align(notificationIcon, nullptr, LV_ALIGN_IN_LEFT_MID, 0, -100); + lv_obj_set_style_local_text_color(notificationIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); + + label_date = lv_label_create(lv_scr_act(), nullptr); + lv_label_set_recolor(label_date, true); + lv_obj_align(label_date, lv_scr_act(), LV_ALIGN_CENTER, 0, -48); + lv_label_set_align(label_date, LV_LABEL_ALIGN_CENTER); + lv_obj_set_auto_realign(label_date, true); + + label_time = lv_label_create(lv_scr_act(), nullptr); + lv_label_set_recolor(label_time, true); + lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_CENTER, 0, 0); + lv_label_set_align(label_time, LV_LABEL_ALIGN_CENTER); + lv_obj_set_style_local_text_font(label_time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42); + lv_obj_set_auto_realign(label_time, true); + + label_day = lv_label_create(lv_scr_act(), nullptr); + lv_label_set_recolor(label_day, true); + lv_obj_align(label_day, lv_scr_act(), LV_ALIGN_CENTER, 0, 48); + lv_label_set_align(label_day, LV_LABEL_ALIGN_CENTER); + lv_obj_set_auto_realign(label_day, true); + + stepValue = lv_label_create(lv_scr_act(), nullptr); + lv_label_set_recolor(stepValue, true); + lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_CENTER, 0, 96); + lv_label_set_align(stepValue, LV_LABEL_ALIGN_CENTER); + lv_obj_set_auto_realign(stepValue, true); + + taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this); + Refresh(); +} + +WatchFaceTrans::~WatchFaceTrans() { + lv_task_del(taskRefresh); + lv_obj_clean(lv_scr_act()); +} + +void WatchFaceTrans::Refresh() { + powerPresent = batteryController.IsPowerPresent(); + bleState = bleController.IsConnected(); + batteryPercentRemaining = batteryController.PercentRemaining(); + if (batteryPercentRemaining.IsUpdated() || powerPresent.IsUpdated()) { + lv_label_set_text_fmt(batteryValue, "#ffffff %d%%", batteryPercentRemaining.Get()); + if (batteryController.IsPowerPresent()) { + lv_label_ins_text(batteryValue, LV_LABEL_POS_LAST, " Charging"); + } + } + if (bleState.IsUpdated()) { + if (bleState.Get()) { + lv_label_set_text_static(bluetoothStatus, Symbols::bluetooth); + } + else { + lv_label_set_text_static(bluetoothStatus, ""); + } + } + + notificationState = notificationManager.AreNewNotificationsAvailable(); + if (notificationState.IsUpdated()) { + if (notificationState.Get()) { + lv_label_set_text_static(notificationIcon, "You have mail."); + } else { + lv_label_set_text_static(notificationIcon, ""); + } + } + + 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"; + 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(label_time, "#000000 %02d:%02d:%02d %s#", hour, minute, second, ampmChar); + } else { + lv_label_set_text_fmt(label_time, "#000000 %02d:%02d:%02d", hour, minute, second); + } + + currentDate = std::chrono::time_point_cast(currentDateTime.Get()); + if (currentDate.IsUpdated()) { + uint16_t year = dateTimeController.Year(); + Controllers::DateTime::Months month = dateTimeController.Month(); + uint8_t day = dateTimeController.Day(); + Controllers::DateTime::Days dayOfWeek = dateTimeController.DayOfWeek(); + lv_label_set_text_fmt(label_date, "#ffffff %02d-%02d-%04d#", short(day), char(month), year); + const char* dayString; + switch (dayOfWeek) { + case Controllers::DateTime::Days::Monday: + dayString = "Monday"; + break; + case Controllers::DateTime::Days::Tuesday: + dayString = "Tuesday"; + break; + case Controllers::DateTime::Days::Wednesday: + dayString = "Wednesday"; + break; + case Controllers::DateTime::Days::Thursday: + dayString = "Thursday"; + break; + case Controllers::DateTime::Days::Friday: + dayString = "Friday"; + break; + case Controllers::DateTime::Days::Saturday: + dayString = "Saturday"; + break; + case Controllers::DateTime::Days::Sunday: + dayString = "Sunday"; + break; + default: + dayString = "?"; + break; + } + lv_label_set_text_fmt(label_day, "#ffffff %s", dayString); + } + } + + stepCount = motionController.NbSteps(); + if (stepCount.IsUpdated()) { + lv_label_set_text_fmt(stepValue, "#ffffff %lu steps#", stepCount.Get()); + } +} diff --git a/src/displayapp/screens/WatchFaceTrans.h b/src/displayapp/screens/WatchFaceTrans.h new file mode 100644 index 0000000000..3fea31340f --- /dev/null +++ b/src/displayapp/screens/WatchFaceTrans.h @@ -0,0 +1,90 @@ +#pragma once + +#include +#include +#include +#include +#include +#include "displayapp/screens/Screen.h" +#include "displayapp/widgets/StatusIcons.h" +#include "components/datetime/DateTimeController.h" +#include "components/ble/BleController.h" +#include "utility/DirtyValue.h" + +namespace Pinetime { + namespace Controllers { + class Settings; + class Battery; + class Ble; + class NotificationManager; + class MotionController; + } + + namespace Applications { + namespace Screens { + + class WatchFaceTrans : public Screen { + public: + WatchFaceTrans(Controllers::DateTime& dateTimeController, + const Controllers::Battery& batteryController, + const Controllers::Ble& bleController, + Controllers::NotificationManager& notificationManager, + Controllers::Settings& settingsController, + Controllers::MotionController& motionController); + ~WatchFaceTrans() override; + + void Refresh() override; + + private: + Utility::DirtyValue batteryPercentRemaining {}; + Utility::DirtyValue powerPresent {}; + Utility::DirtyValue bleState {}; + Utility::DirtyValue> currentDateTime {}; + Utility::DirtyValue stepCount {}; + Utility::DirtyValue notificationState {}; + Utility::DirtyValue> currentDate; + + lv_obj_t* topBlueBackground; + lv_obj_t* topPinkBackground; + lv_obj_t* whiteBackground; + lv_obj_t* bottomPinkBackground; + lv_obj_t* bottomBlueBackground; + lv_obj_t* bluetoothStatus; + lv_obj_t* label_time; + lv_obj_t* label_date; + lv_obj_t* label_day; + lv_obj_t* batteryValue; + lv_obj_t* stepValue; + lv_obj_t* notificationIcon; + + Controllers::DateTime& dateTimeController; + const Controllers::Battery& batteryController; + const Controllers::Ble bleController; + Controllers::NotificationManager& notificationManager; + Controllers::Settings& settingsController; + Controllers::MotionController& motionController; + + lv_task_t* taskRefresh; + }; + } + + template <> + struct WatchFaceTraits { + static constexpr WatchFace watchFace = WatchFace::Trans; + static constexpr const char* name = "Trans"; + + static Screens::Screen* Create(AppControllers& controllers) { + return new Screens::WatchFaceTrans(controllers.dateTimeController, + controllers.batteryController, + controllers.bleController, + controllers.notificationManager, + controllers.settingsController, + controllers.motionController); + }; + + static bool IsAvailable(Pinetime::Controllers::FS& /*filesystem*/) { + return true; + } + }; + } +} From 7e2f2a19a7bad61bc56f5656885f635f3bcfc541 Mon Sep 17 00:00:00 2001 From: Eshe Date: Thu, 19 Dec 2024 17:08:10 +0000 Subject: [PATCH 02/26] Patched source files with fixed formatting --- src/displayapp/screens/WatchFaceTrans.cpp | 13 ++++++------- src/displayapp/screens/WatchFaceTrans.h | 20 ++++++++++---------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/displayapp/screens/WatchFaceTrans.cpp b/src/displayapp/screens/WatchFaceTrans.cpp index fe7a488e1d..0c93a60668 100644 --- a/src/displayapp/screens/WatchFaceTrans.cpp +++ b/src/displayapp/screens/WatchFaceTrans.cpp @@ -11,11 +11,11 @@ using namespace Pinetime::Applications::Screens; WatchFaceTrans::WatchFaceTrans(Controllers::DateTime& dateTimeController, - const Controllers::Battery& batteryController, - const Controllers::Ble& bleController, - Controllers::NotificationManager& notificationManager, - Controllers::Settings& settingsController, - Controllers::MotionController& motionController) + const Controllers::Battery& batteryController, + const Controllers::Ble& bleController, + Controllers::NotificationManager& notificationManager, + Controllers::Settings& settingsController, + Controllers::MotionController& motionController) : currentDateTime {{}}, dateTimeController {dateTimeController}, batteryController {batteryController}, @@ -111,8 +111,7 @@ void WatchFaceTrans::Refresh() { if (bleState.IsUpdated()) { if (bleState.Get()) { lv_label_set_text_static(bluetoothStatus, Symbols::bluetooth); - } - else { + } else { lv_label_set_text_static(bluetoothStatus, ""); } } diff --git a/src/displayapp/screens/WatchFaceTrans.h b/src/displayapp/screens/WatchFaceTrans.h index 3fea31340f..8aff5661fe 100644 --- a/src/displayapp/screens/WatchFaceTrans.h +++ b/src/displayapp/screens/WatchFaceTrans.h @@ -26,11 +26,11 @@ namespace Pinetime { class WatchFaceTrans : public Screen { public: WatchFaceTrans(Controllers::DateTime& dateTimeController, - const Controllers::Battery& batteryController, - const Controllers::Ble& bleController, - Controllers::NotificationManager& notificationManager, - Controllers::Settings& settingsController, - Controllers::MotionController& motionController); + const Controllers::Battery& batteryController, + const Controllers::Ble& bleController, + Controllers::NotificationManager& notificationManager, + Controllers::Settings& settingsController, + Controllers::MotionController& motionController); ~WatchFaceTrans() override; void Refresh() override; @@ -75,11 +75,11 @@ namespace Pinetime { static Screens::Screen* Create(AppControllers& controllers) { return new Screens::WatchFaceTrans(controllers.dateTimeController, - controllers.batteryController, - controllers.bleController, - controllers.notificationManager, - controllers.settingsController, - controllers.motionController); + controllers.batteryController, + controllers.bleController, + controllers.notificationManager, + controllers.settingsController, + controllers.motionController); }; static bool IsAvailable(Pinetime::Controllers::FS& /*filesystem*/) { From ee2e8681c4b24145787a11dcb5793ac41e1b58d5 Mon Sep 17 00:00:00 2001 From: Eshe Date: Mon, 30 Dec 2024 18:45:31 +0000 Subject: [PATCH 03/26] Implemented suggested changes --- .../datetime/DateTimeController.cpp | 10 +++ src/components/datetime/DateTimeController.h | 2 + src/displayapp/screens/WatchFaceTrans.cpp | 87 +++++++------------ src/displayapp/screens/WatchFaceTrans.h | 11 ++- 4 files changed, 49 insertions(+), 61 deletions(-) diff --git a/src/components/datetime/DateTimeController.cpp b/src/components/datetime/DateTimeController.cpp index d439821b90..2ef0ef22f1 100644 --- a/src/components/datetime/DateTimeController.cpp +++ b/src/components/datetime/DateTimeController.cpp @@ -9,6 +9,8 @@ using namespace Pinetime::Controllers; namespace { constexpr const char* const DaysStringShort[] = {"--", "MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"}; constexpr const char* const DaysStringShortLow[] = {"--", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"}; + constexpr const char* const DaysString[] = {"--", "MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", "FRIDAY", "SATURDAY", "SUNDAY"}; + constexpr const char* const DaysStringLow[] = {"--", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"}; constexpr const char* const MonthsString[] = {"--", "JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"}; constexpr const char* const MonthsStringLow[] = {"--", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; @@ -144,6 +146,10 @@ const char* DateTime::DayOfWeekShortToString() const { return DaysStringShort[static_cast(DayOfWeek())]; } +const char* DateTime::DayOfWeekToString() const { + return DaysString[static_cast(DayOfWeek())]; +} + const char* DateTime::MonthShortToStringLow(Months month) { return MonthsStringLow[static_cast(month)]; } @@ -152,6 +158,10 @@ const char* DateTime::DayOfWeekShortToStringLow(Days day) { return DaysStringShortLow[static_cast(day)]; } +const char* DateTime::DayOfWeekToStringLow(Days day) { + return DaysStringLow[static_cast(day)]; +} + void DateTime::Register(Pinetime::System::SystemTask* systemTask) { this->systemTask = systemTask; } diff --git a/src/components/datetime/DateTimeController.h b/src/components/datetime/DateTimeController.h index a005f9ac43..33fef6be09 100644 --- a/src/components/datetime/DateTimeController.h +++ b/src/components/datetime/DateTimeController.h @@ -121,8 +121,10 @@ namespace Pinetime { const char* MonthShortToString() const; const char* DayOfWeekShortToString() const; + const char* DayOfWeekToString() const; static const char* MonthShortToStringLow(Months month); static const char* DayOfWeekShortToStringLow(Days day); + static const char* DayOfWeekToStringLow(Days day); std::chrono::time_point CurrentDateTime(); diff --git a/src/displayapp/screens/WatchFaceTrans.cpp b/src/displayapp/screens/WatchFaceTrans.cpp index 0c93a60668..92e6ddd8a9 100644 --- a/src/displayapp/screens/WatchFaceTrans.cpp +++ b/src/displayapp/screens/WatchFaceTrans.cpp @@ -27,27 +27,27 @@ WatchFaceTrans::WatchFaceTrans(Controllers::DateTime& dateTimeController, topBlueBackground = lv_obj_create(lv_scr_act(), nullptr); lv_obj_set_size(topBlueBackground, LV_HOR_RES, LV_VER_RES / 5); lv_obj_set_pos(topBlueBackground, 0, 0); - lv_obj_set_style_local_bg_color(topBlueBackground, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00bff3)); + lv_obj_set_style_local_bg_color(topBlueBackground, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lightBlue); lv_obj_set_style_local_radius(topBlueBackground, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, 0); topPinkBackground = lv_obj_create(lv_scr_act(), nullptr); lv_obj_set_size(topPinkBackground, LV_HOR_RES, LV_VER_RES / 5); lv_obj_set_pos(topPinkBackground, 0, LV_VER_RES / 5); - lv_obj_set_style_local_bg_color(topPinkBackground, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xf49ac1)); + lv_obj_set_style_local_bg_color(topPinkBackground, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lightPink); lv_obj_set_style_local_radius(topPinkBackground, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, 0); whiteBackground = lv_obj_create(lv_scr_act(), nullptr); lv_obj_set_size(whiteBackground, LV_HOR_RES, LV_VER_RES / 5); lv_obj_set_pos(whiteBackground, 0, 2 * LV_VER_RES / 5); - lv_obj_set_style_local_bg_color(whiteBackground, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xffffff)); + lv_obj_set_style_local_bg_color(whiteBackground, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE); lv_obj_set_style_local_radius(whiteBackground, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, 0); bottomPinkBackground = lv_obj_create(lv_scr_act(), nullptr); lv_obj_set_size(bottomPinkBackground, LV_HOR_RES, LV_VER_RES / 5); lv_obj_set_pos(bottomPinkBackground, 0, 3 * LV_VER_RES / 5); - lv_obj_set_style_local_bg_color(bottomPinkBackground, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0xf49ac1)); + lv_obj_set_style_local_bg_color(bottomPinkBackground, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lightPink); lv_obj_set_style_local_radius(bottomPinkBackground, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, 0); bottomBlueBackground = lv_obj_create(lv_scr_act(), nullptr); lv_obj_set_size(bottomBlueBackground, LV_HOR_RES, LV_VER_RES / 5); lv_obj_set_pos(bottomBlueBackground, 0, 4 * LV_VER_RES / 5); - lv_obj_set_style_local_bg_color(bottomBlueBackground, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x00bff3)); + lv_obj_set_style_local_bg_color(bottomBlueBackground, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lightBlue); lv_obj_set_style_local_radius(bottomBlueBackground, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, 0); bluetoothStatus = lv_label_create(lv_scr_act(), nullptr); @@ -62,26 +62,26 @@ WatchFaceTrans::WatchFaceTrans(Controllers::DateTime& dateTimeController, notificationIcon = lv_label_create(lv_scr_act(), nullptr); lv_obj_align(notificationIcon, nullptr, LV_ALIGN_IN_LEFT_MID, 0, -100); - lv_obj_set_style_local_text_color(notificationIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, lv_color_hex(0x000000)); - - label_date = lv_label_create(lv_scr_act(), nullptr); - lv_label_set_recolor(label_date, true); - lv_obj_align(label_date, lv_scr_act(), LV_ALIGN_CENTER, 0, -48); - lv_label_set_align(label_date, LV_LABEL_ALIGN_CENTER); - lv_obj_set_auto_realign(label_date, true); - - label_time = lv_label_create(lv_scr_act(), nullptr); - lv_label_set_recolor(label_time, true); - lv_obj_align(label_time, lv_scr_act(), LV_ALIGN_CENTER, 0, 0); - lv_label_set_align(label_time, LV_LABEL_ALIGN_CENTER); - lv_obj_set_style_local_text_font(label_time, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42); - lv_obj_set_auto_realign(label_time, true); - - label_day = lv_label_create(lv_scr_act(), nullptr); - lv_label_set_recolor(label_day, true); - lv_obj_align(label_day, lv_scr_act(), LV_ALIGN_CENTER, 0, 48); - lv_label_set_align(label_day, LV_LABEL_ALIGN_CENTER); - lv_obj_set_auto_realign(label_day, true); + lv_obj_set_style_local_text_color(notificationIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK); + + labelDate = lv_label_create(lv_scr_act(), nullptr); + lv_label_set_recolor(labelDate, true); + lv_obj_align(labelDate, lv_scr_act(), LV_ALIGN_CENTER, 0, -48); + lv_label_set_align(labelDate, LV_LABEL_ALIGN_CENTER); + lv_obj_set_auto_realign(labelDate, true); + + labelTime = lv_label_create(lv_scr_act(), nullptr); + lv_label_set_recolor(labelTime, true); + lv_obj_align(labelTime, lv_scr_act(), LV_ALIGN_CENTER, 0, 0); + lv_label_set_align(labelTime, LV_LABEL_ALIGN_CENTER); + lv_obj_set_style_local_text_font(labelTime, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42); + lv_obj_set_auto_realign(labelTime, true); + + labelDay = lv_label_create(lv_scr_act(), nullptr); + lv_label_set_recolor(labelDay, true); + lv_obj_align(labelDay, lv_scr_act(), LV_ALIGN_CENTER, 0, 48); + lv_label_set_align(labelDay, LV_LABEL_ALIGN_CENTER); + lv_obj_set_auto_realign(labelDay, true); stepValue = lv_label_create(lv_scr_act(), nullptr); lv_label_set_recolor(stepValue, true); @@ -103,7 +103,7 @@ void WatchFaceTrans::Refresh() { bleState = bleController.IsConnected(); batteryPercentRemaining = batteryController.PercentRemaining(); if (batteryPercentRemaining.IsUpdated() || powerPresent.IsUpdated()) { - lv_label_set_text_fmt(batteryValue, "#ffffff %d%%", batteryPercentRemaining.Get()); + lv_label_set_text_fmt(batteryValue, "#ffffff %d%%#", batteryPercentRemaining.Get()); if (batteryController.IsPowerPresent()) { lv_label_ins_text(batteryValue, LV_LABEL_POS_LAST, " Charging"); } @@ -141,9 +141,9 @@ void WatchFaceTrans::Refresh() { hour = hour - 12; ampmChar[0] = 'P'; } - lv_label_set_text_fmt(label_time, "#000000 %02d:%02d:%02d %s#", hour, minute, second, ampmChar); + lv_label_set_text_fmt(labelTime, "#000000 %02d:%02d:%02d %s#", hour, minute, second, ampmChar); } else { - lv_label_set_text_fmt(label_time, "#000000 %02d:%02d:%02d", hour, minute, second); + lv_label_set_text_fmt(labelTime, "#000000 %02d:%02d:%02d#", hour, minute, second); } currentDate = std::chrono::time_point_cast(currentDateTime.Get()); @@ -152,35 +152,8 @@ void WatchFaceTrans::Refresh() { Controllers::DateTime::Months month = dateTimeController.Month(); uint8_t day = dateTimeController.Day(); Controllers::DateTime::Days dayOfWeek = dateTimeController.DayOfWeek(); - lv_label_set_text_fmt(label_date, "#ffffff %02d-%02d-%04d#", short(day), char(month), year); - const char* dayString; - switch (dayOfWeek) { - case Controllers::DateTime::Days::Monday: - dayString = "Monday"; - break; - case Controllers::DateTime::Days::Tuesday: - dayString = "Tuesday"; - break; - case Controllers::DateTime::Days::Wednesday: - dayString = "Wednesday"; - break; - case Controllers::DateTime::Days::Thursday: - dayString = "Thursday"; - break; - case Controllers::DateTime::Days::Friday: - dayString = "Friday"; - break; - case Controllers::DateTime::Days::Saturday: - dayString = "Saturday"; - break; - case Controllers::DateTime::Days::Sunday: - dayString = "Sunday"; - break; - default: - dayString = "?"; - break; - } - lv_label_set_text_fmt(label_day, "#ffffff %s", dayString); + lv_label_set_text_fmt(labelDate, "#ffffff %02d-%02d-%04d#", day, static_cast(month), year); + lv_label_set_text_fmt(labelDay, "#ffffff %s#", dateTimeController.DayOfWeekToStringLow(dayOfWeek)); } } diff --git a/src/displayapp/screens/WatchFaceTrans.h b/src/displayapp/screens/WatchFaceTrans.h index 8aff5661fe..09ce2c47d5 100644 --- a/src/displayapp/screens/WatchFaceTrans.h +++ b/src/displayapp/screens/WatchFaceTrans.h @@ -36,7 +36,7 @@ namespace Pinetime { void Refresh() override; private: - Utility::DirtyValue batteryPercentRemaining {}; + Utility::DirtyValue batteryPercentRemaining {}; Utility::DirtyValue powerPresent {}; Utility::DirtyValue bleState {}; Utility::DirtyValue> currentDateTime {}; @@ -50,13 +50,16 @@ namespace Pinetime { lv_obj_t* bottomPinkBackground; lv_obj_t* bottomBlueBackground; lv_obj_t* bluetoothStatus; - lv_obj_t* label_time; - lv_obj_t* label_date; - lv_obj_t* label_day; + lv_obj_t* labelTime; + lv_obj_t* labelDate; + lv_obj_t* labelDay; lv_obj_t* batteryValue; lv_obj_t* stepValue; lv_obj_t* notificationIcon; + static constexpr lv_color_t lightBlue = LV_COLOR_MAKE(0x00, 0xbf, 0xf3); + static constexpr lv_color_t lightPink = LV_COLOR_MAKE(0xf4, 0x9a, 0xc1); + Controllers::DateTime& dateTimeController; const Controllers::Battery& batteryController; const Controllers::Ble bleController; From 9b8df1f801b6b08b34882ae7297dad504a90140c Mon Sep 17 00:00:00 2001 From: Eshe Date: Sat, 4 Jan 2025 11:46:56 +0000 Subject: [PATCH 04/26] Made notification display not overlap battery level; changed name from "Trans" to "Trans Flag" --- src/displayapp/screens/WatchFaceTrans.cpp | 4 ++-- src/displayapp/screens/WatchFaceTrans.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/displayapp/screens/WatchFaceTrans.cpp b/src/displayapp/screens/WatchFaceTrans.cpp index 92e6ddd8a9..ee6692ff9c 100644 --- a/src/displayapp/screens/WatchFaceTrans.cpp +++ b/src/displayapp/screens/WatchFaceTrans.cpp @@ -61,7 +61,7 @@ WatchFaceTrans::WatchFaceTrans(Controllers::DateTime& dateTimeController, lv_obj_set_auto_realign(batteryValue, true); notificationIcon = lv_label_create(lv_scr_act(), nullptr); - lv_obj_align(notificationIcon, nullptr, LV_ALIGN_IN_LEFT_MID, 0, -100); + lv_obj_align(notificationIcon, nullptr, LV_ALIGN_IN_LEFT_MID, 0, -110); lv_obj_set_style_local_text_color(notificationIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK); labelDate = lv_label_create(lv_scr_act(), nullptr); @@ -119,7 +119,7 @@ void WatchFaceTrans::Refresh() { notificationState = notificationManager.AreNewNotificationsAvailable(); if (notificationState.IsUpdated()) { if (notificationState.Get()) { - lv_label_set_text_static(notificationIcon, "You have mail."); + lv_label_set_text_static(notificationIcon, "You have\nMail!"); } else { lv_label_set_text_static(notificationIcon, ""); } diff --git a/src/displayapp/screens/WatchFaceTrans.h b/src/displayapp/screens/WatchFaceTrans.h index 09ce2c47d5..4cf82cd406 100644 --- a/src/displayapp/screens/WatchFaceTrans.h +++ b/src/displayapp/screens/WatchFaceTrans.h @@ -74,7 +74,7 @@ namespace Pinetime { template <> struct WatchFaceTraits { static constexpr WatchFace watchFace = WatchFace::Trans; - static constexpr const char* name = "Trans"; + static constexpr const char* name = "Trans Flag"; static Screens::Screen* Create(AppControllers& controllers) { return new Screens::WatchFaceTrans(controllers.dateTimeController, From bb388ef63b08abfbdedc79b9133906762f23cf17 Mon Sep 17 00:00:00 2001 From: Eshe Date: Sat, 4 Jan 2025 16:09:58 +0000 Subject: [PATCH 05/26] Changed Mail to mail in notification --- src/displayapp/screens/WatchFaceTrans.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/displayapp/screens/WatchFaceTrans.cpp b/src/displayapp/screens/WatchFaceTrans.cpp index ee6692ff9c..beee8e44ba 100644 --- a/src/displayapp/screens/WatchFaceTrans.cpp +++ b/src/displayapp/screens/WatchFaceTrans.cpp @@ -119,7 +119,7 @@ void WatchFaceTrans::Refresh() { notificationState = notificationManager.AreNewNotificationsAvailable(); if (notificationState.IsUpdated()) { if (notificationState.Get()) { - lv_label_set_text_static(notificationIcon, "You have\nMail!"); + lv_label_set_text_static(notificationIcon, "You have\nmail!"); } else { lv_label_set_text_static(notificationIcon, ""); } From e01e6161e50c6d532823378839a4621e590eaad9 Mon Sep 17 00:00:00 2001 From: Eshe Date: Sat, 18 Jan 2025 11:50:22 +0000 Subject: [PATCH 06/26] Moved AM/PM display to the day --- src/displayapp/screens/WatchFaceTrans.cpp | 30 +++++++++++------------ 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/displayapp/screens/WatchFaceTrans.cpp b/src/displayapp/screens/WatchFaceTrans.cpp index beee8e44ba..52008c8e64 100644 --- a/src/displayapp/screens/WatchFaceTrans.cpp +++ b/src/displayapp/screens/WatchFaceTrans.cpp @@ -131,20 +131,7 @@ void WatchFaceTrans::Refresh() { uint8_t minute = dateTimeController.Minutes(); uint8_t second = dateTimeController.Seconds(); - 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, "#000000 %02d:%02d:%02d %s#", hour, minute, second, ampmChar); - } else { - lv_label_set_text_fmt(labelTime, "#000000 %02d:%02d:%02d#", hour, minute, second); - } + lv_label_set_text_fmt(labelTime, "#000000 %02d:%02d:%02d#", hour, minute, second); currentDate = std::chrono::time_point_cast(currentDateTime.Get()); if (currentDate.IsUpdated()) { @@ -153,7 +140,20 @@ void WatchFaceTrans::Refresh() { uint8_t day = dateTimeController.Day(); Controllers::DateTime::Days dayOfWeek = dateTimeController.DayOfWeek(); lv_label_set_text_fmt(labelDate, "#ffffff %02d-%02d-%04d#", day, static_cast(month), year); - lv_label_set_text_fmt(labelDay, "#ffffff %s#", dateTimeController.DayOfWeekToStringLow(dayOfWeek)); + 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(labelDay, "#ffffff %s %s#", dateTimeController.DayOfWeekToStringLow(dayOfWeek), ampmChar); + } else { + lv_label_set_text_fmt(labelDay, "#ffffff %s#", dateTimeController.DayOfWeekToStringLow(dayOfWeek)); + } } } From 879fb48cfcac32e577804ed4908ac07f090ec362 Mon Sep 17 00:00:00 2001 From: Eshe Date: Mon, 20 Jan 2025 14:11:17 +0000 Subject: [PATCH 07/26] Fixed 12H mode displaying 24H times --- src/displayapp/screens/WatchFaceTrans.cpp | 23 +++++++++++++---------- src/displayapp/screens/WatchFaceTrans.h | 2 ++ 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/displayapp/screens/WatchFaceTrans.cpp b/src/displayapp/screens/WatchFaceTrans.cpp index 52008c8e64..ce032f9801 100644 --- a/src/displayapp/screens/WatchFaceTrans.cpp +++ b/src/displayapp/screens/WatchFaceTrans.cpp @@ -131,25 +131,28 @@ void WatchFaceTrans::Refresh() { uint8_t minute = dateTimeController.Minutes(); uint8_t second = dateTimeController.Seconds(); + if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) { + if (hour == 0) { + ampmChar = "AM"; + hour = 12; + } else if (hour == 12) { + ampmChar = "PM"; + } else if (hour > 12) { + hour = hour - 12; + ampmChar = "PM"; + } + } + lv_label_set_text_fmt(labelTime, "#000000 %02d:%02d:%02d#", hour, minute, second); currentDate = std::chrono::time_point_cast(currentDateTime.Get()); - if (currentDate.IsUpdated()) { + if (currentDate.IsUpdated() || ampmChar.IsUpdated()) { uint16_t year = dateTimeController.Year(); Controllers::DateTime::Months month = dateTimeController.Month(); uint8_t day = dateTimeController.Day(); Controllers::DateTime::Days dayOfWeek = dateTimeController.DayOfWeek(); lv_label_set_text_fmt(labelDate, "#ffffff %02d-%02d-%04d#", day, static_cast(month), year); 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(labelDay, "#ffffff %s %s#", dateTimeController.DayOfWeekToStringLow(dayOfWeek), ampmChar); } else { lv_label_set_text_fmt(labelDay, "#ffffff %s#", dateTimeController.DayOfWeekToStringLow(dayOfWeek)); diff --git a/src/displayapp/screens/WatchFaceTrans.h b/src/displayapp/screens/WatchFaceTrans.h index 4cf82cd406..04312c9efe 100644 --- a/src/displayapp/screens/WatchFaceTrans.h +++ b/src/displayapp/screens/WatchFaceTrans.h @@ -43,6 +43,8 @@ namespace Pinetime { Utility::DirtyValue stepCount {}; Utility::DirtyValue notificationState {}; Utility::DirtyValue> currentDate; + // Must be wrapped in a dirty value, since it is displayed in the day but is updated twice a day + Utility::DirtyValue ampmChar {"AM"}; lv_obj_t* topBlueBackground; lv_obj_t* topPinkBackground; From 285ba00fbad62a620f7669192512674c536bc103 Mon Sep 17 00:00:00 2001 From: Eshe Date: Sat, 15 Feb 2025 13:14:42 +0000 Subject: [PATCH 08/26] Renamed WatchFaceTrans to WatchFaceTransFlag --- src/CMakeLists.txt | 2 +- src/displayapp/UserApps.h | 2 +- src/displayapp/apps/Apps.h.in | 2 +- src/displayapp/apps/CMakeLists.txt | 2 +- .../{WatchFaceTrans.cpp => WatchFaceTransFlag.cpp} | 8 ++++---- .../{WatchFaceTrans.h => WatchFaceTransFlag.h} | 12 ++++++------ 6 files changed, 14 insertions(+), 14 deletions(-) rename src/displayapp/screens/{WatchFaceTrans.cpp => WatchFaceTransFlag.cpp} (97%) rename src/displayapp/screens/{WatchFaceTrans.h => WatchFaceTransFlag.h} (90%) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9b06347524..fbd8a04a8c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -426,7 +426,7 @@ list(APPEND SOURCE_FILES displayapp/screens/WatchFaceTerminal.cpp displayapp/screens/WatchFacePineTimeStyle.cpp displayapp/screens/WatchFaceCasioStyleG7710.cpp - displayapp/screens/WatchFaceTrans.cpp + displayapp/screens/WatchFaceTransFlag.cpp ## diff --git a/src/displayapp/UserApps.h b/src/displayapp/UserApps.h index 74573b1176..5dac0ba828 100644 --- a/src/displayapp/UserApps.h +++ b/src/displayapp/UserApps.h @@ -14,7 +14,7 @@ #include "displayapp/screens/WatchFaceInfineat.h" #include "displayapp/screens/WatchFacePineTimeStyle.h" #include "displayapp/screens/WatchFaceTerminal.h" -#include "displayapp/screens/WatchFaceTrans.h" +#include "displayapp/screens/WatchFaceTransFlag.h" namespace Pinetime { namespace Applications { diff --git a/src/displayapp/apps/Apps.h.in b/src/displayapp/apps/Apps.h.in index b64b6be8f8..e900cdcdc1 100644 --- a/src/displayapp/apps/Apps.h.in +++ b/src/displayapp/apps/Apps.h.in @@ -52,7 +52,7 @@ namespace Pinetime { Terminal, Infineat, CasioStyleG7710, - Trans, + TransFlag, }; template diff --git a/src/displayapp/apps/CMakeLists.txt b/src/displayapp/apps/CMakeLists.txt index 5209431f5e..1fbd8b876e 100644 --- a/src/displayapp/apps/CMakeLists.txt +++ b/src/displayapp/apps/CMakeLists.txt @@ -27,7 +27,7 @@ else() set(DEFAULT_WATCHFACE_TYPES "${DEFAULT_WATCHFACE_TYPES}, WatchFace::Terminal") set(DEFAULT_WATCHFACE_TYPES "${DEFAULT_WATCHFACE_TYPES}, WatchFace::Infineat") set(DEFAULT_WATCHFACE_TYPES "${DEFAULT_WATCHFACE_TYPES}, WatchFace::CasioStyleG7710") - set(DEFAULT_WATCHFACE_TYPES "${DEFAULT_WATCHFACE_TYPES}, WatchFace::Trans") + set(DEFAULT_WATCHFACE_TYPES "${DEFAULT_WATCHFACE_TYPES}, WatchFace::TransFlag") set(WATCHFACE_TYPES "${DEFAULT_WATCHFACE_TYPES}" CACHE STRING "List of watch faces to build into the firmware") endif() diff --git a/src/displayapp/screens/WatchFaceTrans.cpp b/src/displayapp/screens/WatchFaceTransFlag.cpp similarity index 97% rename from src/displayapp/screens/WatchFaceTrans.cpp rename to src/displayapp/screens/WatchFaceTransFlag.cpp index ce032f9801..97823b6e9c 100644 --- a/src/displayapp/screens/WatchFaceTrans.cpp +++ b/src/displayapp/screens/WatchFaceTransFlag.cpp @@ -1,5 +1,5 @@ #include -#include "displayapp/screens/WatchFaceTrans.h" +#include "displayapp/screens/WatchFaceTransFlag.h" #include "displayapp/screens/BatteryIcon.h" #include "displayapp/screens/NotificationIcon.h" #include "displayapp/screens/Symbols.h" @@ -10,7 +10,7 @@ using namespace Pinetime::Applications::Screens; -WatchFaceTrans::WatchFaceTrans(Controllers::DateTime& dateTimeController, +WatchFaceTransFlag::WatchFaceTransFlag(Controllers::DateTime& dateTimeController, const Controllers::Battery& batteryController, const Controllers::Ble& bleController, Controllers::NotificationManager& notificationManager, @@ -93,12 +93,12 @@ WatchFaceTrans::WatchFaceTrans(Controllers::DateTime& dateTimeController, Refresh(); } -WatchFaceTrans::~WatchFaceTrans() { +WatchFaceTransFlag::~WatchFaceTransFlag() { lv_task_del(taskRefresh); lv_obj_clean(lv_scr_act()); } -void WatchFaceTrans::Refresh() { +void WatchFaceTransFlag::Refresh() { powerPresent = batteryController.IsPowerPresent(); bleState = bleController.IsConnected(); batteryPercentRemaining = batteryController.PercentRemaining(); diff --git a/src/displayapp/screens/WatchFaceTrans.h b/src/displayapp/screens/WatchFaceTransFlag.h similarity index 90% rename from src/displayapp/screens/WatchFaceTrans.h rename to src/displayapp/screens/WatchFaceTransFlag.h index 04312c9efe..83c5e4f6b8 100644 --- a/src/displayapp/screens/WatchFaceTrans.h +++ b/src/displayapp/screens/WatchFaceTransFlag.h @@ -23,15 +23,15 @@ namespace Pinetime { namespace Applications { namespace Screens { - class WatchFaceTrans : public Screen { + class WatchFaceTransFlag : public Screen { public: - WatchFaceTrans(Controllers::DateTime& dateTimeController, + WatchFaceTransFlag(Controllers::DateTime& dateTimeController, const Controllers::Battery& batteryController, const Controllers::Ble& bleController, Controllers::NotificationManager& notificationManager, Controllers::Settings& settingsController, Controllers::MotionController& motionController); - ~WatchFaceTrans() override; + ~WatchFaceTransFlag() override; void Refresh() override; @@ -74,12 +74,12 @@ namespace Pinetime { } template <> - struct WatchFaceTraits { - static constexpr WatchFace watchFace = WatchFace::Trans; + struct WatchFaceTraits { + static constexpr WatchFace watchFace = WatchFace::TransFlag; static constexpr const char* name = "Trans Flag"; static Screens::Screen* Create(AppControllers& controllers) { - return new Screens::WatchFaceTrans(controllers.dateTimeController, + return new Screens::WatchFaceTransFlag(controllers.dateTimeController, controllers.batteryController, controllers.bleController, controllers.notificationManager, From 1d59a7ae1732b4be1685a43bf12a336b0dffe025 Mon Sep 17 00:00:00 2001 From: Eshe Date: Sun, 16 Feb 2025 09:41:47 +0000 Subject: [PATCH 09/26] Applied formatting patches --- src/displayapp/screens/WatchFaceTransFlag.cpp | 10 +++++----- src/displayapp/screens/WatchFaceTransFlag.h | 20 +++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/displayapp/screens/WatchFaceTransFlag.cpp b/src/displayapp/screens/WatchFaceTransFlag.cpp index 97823b6e9c..89304d1d3e 100644 --- a/src/displayapp/screens/WatchFaceTransFlag.cpp +++ b/src/displayapp/screens/WatchFaceTransFlag.cpp @@ -11,11 +11,11 @@ using namespace Pinetime::Applications::Screens; WatchFaceTransFlag::WatchFaceTransFlag(Controllers::DateTime& dateTimeController, - const Controllers::Battery& batteryController, - const Controllers::Ble& bleController, - Controllers::NotificationManager& notificationManager, - Controllers::Settings& settingsController, - Controllers::MotionController& motionController) + const Controllers::Battery& batteryController, + const Controllers::Ble& bleController, + Controllers::NotificationManager& notificationManager, + Controllers::Settings& settingsController, + Controllers::MotionController& motionController) : currentDateTime {{}}, dateTimeController {dateTimeController}, batteryController {batteryController}, diff --git a/src/displayapp/screens/WatchFaceTransFlag.h b/src/displayapp/screens/WatchFaceTransFlag.h index 83c5e4f6b8..bf458ed113 100644 --- a/src/displayapp/screens/WatchFaceTransFlag.h +++ b/src/displayapp/screens/WatchFaceTransFlag.h @@ -26,11 +26,11 @@ namespace Pinetime { class WatchFaceTransFlag : public Screen { public: WatchFaceTransFlag(Controllers::DateTime& dateTimeController, - const Controllers::Battery& batteryController, - const Controllers::Ble& bleController, - Controllers::NotificationManager& notificationManager, - Controllers::Settings& settingsController, - Controllers::MotionController& motionController); + const Controllers::Battery& batteryController, + const Controllers::Ble& bleController, + Controllers::NotificationManager& notificationManager, + Controllers::Settings& settingsController, + Controllers::MotionController& motionController); ~WatchFaceTransFlag() override; void Refresh() override; @@ -80,11 +80,11 @@ namespace Pinetime { static Screens::Screen* Create(AppControllers& controllers) { return new Screens::WatchFaceTransFlag(controllers.dateTimeController, - controllers.batteryController, - controllers.bleController, - controllers.notificationManager, - controllers.settingsController, - controllers.motionController); + controllers.batteryController, + controllers.bleController, + controllers.notificationManager, + controllers.settingsController, + controllers.motionController); }; static bool IsAvailable(Pinetime::Controllers::FS& /*filesystem*/) { From 5891adfdb064f71b6a69c680c67d603814a4601a Mon Sep 17 00:00:00 2001 From: Eshe Date: Sun, 23 Mar 2025 12:16:47 +0000 Subject: [PATCH 10/26] Added multiple pride flags --- src/CMakeLists.txt | 2 +- src/components/settings/Settings.h | 13 + src/displayapp/UserApps.h | 2 +- src/displayapp/apps/Apps.h.in | 2 +- src/displayapp/apps/CMakeLists.txt | 2 +- src/displayapp/screens/WatchFacePrideFlag.cpp | 346 ++++++++++++++++++ ...chFaceTransFlag.h => WatchFacePrideFlag.h} | 47 ++- src/displayapp/screens/WatchFaceTransFlag.cpp | 167 --------- 8 files changed, 398 insertions(+), 183 deletions(-) create mode 100644 src/displayapp/screens/WatchFacePrideFlag.cpp rename src/displayapp/screens/{WatchFaceTransFlag.h => WatchFacePrideFlag.h} (63%) delete mode 100644 src/displayapp/screens/WatchFaceTransFlag.cpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fbd8a04a8c..a4b7fc8b17 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -426,7 +426,7 @@ list(APPEND SOURCE_FILES displayapp/screens/WatchFaceTerminal.cpp displayapp/screens/WatchFacePineTimeStyle.cpp displayapp/screens/WatchFaceCasioStyleG7710.cpp - displayapp/screens/WatchFaceTransFlag.cpp + displayapp/screens/WatchFacePrideFlag.cpp ## diff --git a/src/components/settings/Settings.h b/src/components/settings/Settings.h index 602de3a585..c45777bfc9 100644 --- a/src/components/settings/Settings.h +++ b/src/components/settings/Settings.h @@ -36,6 +36,7 @@ namespace Pinetime { }; enum class PTSGaugeStyle : uint8_t { Full, Half, Numeric }; enum class PTSWeather : uint8_t { On, Off }; + enum class PrideFlag: uint8_t {Rainbow, Trans, Bi, Lesbian}; struct PineTimeStyle { Colors ColorTime = Colors::Teal; @@ -154,6 +155,16 @@ namespace Pinetime { return settings.PTS.weatherEnable; }; + void SetPrideFlag(PrideFlag prideFlag) { + if (prideFlag != settings.prideFlag) + settingsChanged = true; + settings.prideFlag = prideFlag; + }; + + PrideFlag GetPrideFlag() const { + return settings.prideFlag; + }; + void SetAppMenu(uint8_t menu) { appMenu = menu; }; @@ -319,6 +330,8 @@ namespace Pinetime { PineTimeStyle PTS; + PrideFlag prideFlag = PrideFlag::Rainbow; + WatchFaceInfineat watchFaceInfineat; std::bitset<5> wakeUpMode {0}; diff --git a/src/displayapp/UserApps.h b/src/displayapp/UserApps.h index 5dac0ba828..8dc114429f 100644 --- a/src/displayapp/UserApps.h +++ b/src/displayapp/UserApps.h @@ -14,7 +14,7 @@ #include "displayapp/screens/WatchFaceInfineat.h" #include "displayapp/screens/WatchFacePineTimeStyle.h" #include "displayapp/screens/WatchFaceTerminal.h" -#include "displayapp/screens/WatchFaceTransFlag.h" +#include "displayapp/screens/WatchFacePrideFlag.h" namespace Pinetime { namespace Applications { diff --git a/src/displayapp/apps/Apps.h.in b/src/displayapp/apps/Apps.h.in index e900cdcdc1..c1a91540f3 100644 --- a/src/displayapp/apps/Apps.h.in +++ b/src/displayapp/apps/Apps.h.in @@ -52,7 +52,7 @@ namespace Pinetime { Terminal, Infineat, CasioStyleG7710, - TransFlag, + PrideFlag, }; template diff --git a/src/displayapp/apps/CMakeLists.txt b/src/displayapp/apps/CMakeLists.txt index 1fbd8b876e..b67f39b9fb 100644 --- a/src/displayapp/apps/CMakeLists.txt +++ b/src/displayapp/apps/CMakeLists.txt @@ -27,7 +27,7 @@ else() set(DEFAULT_WATCHFACE_TYPES "${DEFAULT_WATCHFACE_TYPES}, WatchFace::Terminal") set(DEFAULT_WATCHFACE_TYPES "${DEFAULT_WATCHFACE_TYPES}, WatchFace::Infineat") set(DEFAULT_WATCHFACE_TYPES "${DEFAULT_WATCHFACE_TYPES}, WatchFace::CasioStyleG7710") - set(DEFAULT_WATCHFACE_TYPES "${DEFAULT_WATCHFACE_TYPES}, WatchFace::TransFlag") + set(DEFAULT_WATCHFACE_TYPES "${DEFAULT_WATCHFACE_TYPES}, WatchFace::PrideFlag") set(WATCHFACE_TYPES "${DEFAULT_WATCHFACE_TYPES}" CACHE STRING "List of watch faces to build into the firmware") endif() diff --git a/src/displayapp/screens/WatchFacePrideFlag.cpp b/src/displayapp/screens/WatchFacePrideFlag.cpp new file mode 100644 index 0000000000..1d548d8593 --- /dev/null +++ b/src/displayapp/screens/WatchFacePrideFlag.cpp @@ -0,0 +1,346 @@ +#include +#include "displayapp/screens/WatchFacePrideFlag.h" +#include "displayapp/screens/BatteryIcon.h" +#include "displayapp/screens/NotificationIcon.h" +#include "displayapp/screens/Symbols.h" +#include "components/battery/BatteryController.h" +#include "components/ble/BleController.h" +#include "components/motion/MotionController.h" +#include "components/settings/Settings.h" + +using namespace Pinetime::Applications::Screens; + +namespace { + void event_handler(lv_obj_t* obj, lv_event_t event) { + auto* screen = static_cast(obj->user_data); + screen->UpdateSelected(obj, event); + } +} + +WatchFacePrideFlag::WatchFacePrideFlag(Controllers::DateTime& dateTimeController, + const Controllers::Battery& batteryController, + const Controllers::Ble& bleController, + Controllers::NotificationManager& notificationManager, + Controllers::Settings& settingsController, + Controllers::MotionController& motionController) + : currentDateTime {{}}, + dateTimeController {dateTimeController}, + batteryController {batteryController}, + bleController {bleController}, + notificationManager {notificationManager}, + settingsController {settingsController}, + motionController {motionController} { + + + bluetoothStatus = lv_label_create(lv_scr_act(), nullptr); + lv_label_set_text_static(bluetoothStatus, ""); + lv_obj_align(bluetoothStatus, nullptr, LV_ALIGN_IN_TOP_RIGHT, -16, 0); + + batteryValue = lv_label_create(lv_scr_act(), nullptr); + lv_label_set_recolor(batteryValue, true); + lv_obj_align(batteryValue, lv_scr_act(), LV_ALIGN_CENTER, 0, -96); + lv_label_set_align(batteryValue, LV_LABEL_ALIGN_CENTER); + lv_obj_set_auto_realign(batteryValue, true); + + notificationIcon = lv_label_create(lv_scr_act(), nullptr); + lv_obj_align(notificationIcon, nullptr, LV_ALIGN_IN_LEFT_MID, 0, -110); + lv_obj_set_style_local_text_color(notificationIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK); + + btnClose = lv_btn_create(lv_scr_act(), nullptr); + btnClose->user_data = this; + lv_obj_set_size(btnClose, 60, 60); + lv_obj_align(btnClose, lv_scr_act(), LV_ALIGN_CENTER, 0, -80); + lv_obj_set_style_local_bg_opa(btnClose, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50); + lv_obj_t* lblClose = lv_label_create(btnClose, nullptr); + lv_label_set_text_static(lblClose, "X"); + lv_obj_set_event_cb(btnClose, event_handler); + lv_obj_set_hidden(btnClose, true); + + btnNextFlag = lv_btn_create(lv_scr_act(), nullptr); + btnNextFlag->user_data = this; + lv_obj_set_size(btnNextFlag, 60, 60); + lv_obj_align(btnNextFlag, lv_scr_act(), LV_ALIGN_IN_RIGHT_MID, -15, 80); + lv_obj_set_style_local_bg_opa(btnNextFlag, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50); + lv_obj_t* lblNextBG = lv_label_create(btnNextFlag, nullptr); + lv_label_set_text_static(lblNextBG, ">"); + lv_obj_set_event_cb(btnNextFlag, event_handler); + lv_obj_set_hidden(btnNextFlag, true); + + btnPrevFlag = lv_btn_create(lv_scr_act(), nullptr); + btnPrevFlag->user_data = this; + lv_obj_set_size(btnPrevFlag, 60, 60); + lv_obj_align(btnPrevFlag, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 15, 80); + lv_obj_set_style_local_bg_opa(btnPrevFlag, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50); + lv_obj_t* lblPrevFlag = lv_label_create(btnPrevFlag, nullptr); + lv_label_set_text_static(lblPrevFlag, "<"); + lv_obj_set_event_cb(btnPrevFlag, event_handler); + lv_obj_set_hidden(btnPrevFlag, true); + + labelDate = lv_label_create(lv_scr_act(), nullptr); + lv_label_set_recolor(labelDate, true); + lv_label_set_align(labelDate, LV_LABEL_ALIGN_CENTER); + lv_obj_set_auto_realign(labelDate, true); + + labelTime = lv_label_create(lv_scr_act(), nullptr); + lv_label_set_recolor(labelTime, true); + lv_obj_align(labelTime, lv_scr_act(), LV_ALIGN_CENTER, 0, 0); + lv_label_set_align(labelTime, LV_LABEL_ALIGN_CENTER); + lv_obj_set_style_local_text_font(labelTime, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42); + lv_obj_set_auto_realign(labelTime, true); + + labelDay = lv_label_create(lv_scr_act(), nullptr); + lv_label_set_recolor(labelDay, true); + lv_label_set_align(labelDay, LV_LABEL_ALIGN_CENTER); + lv_obj_set_auto_realign(labelDay, true); + + stepValue = lv_label_create(lv_scr_act(), nullptr); + lv_label_set_recolor(stepValue, true); + lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_CENTER, 0, 96); + lv_label_set_align(stepValue, LV_LABEL_ALIGN_CENTER); + lv_obj_set_auto_realign(stepValue, true); + + UpdateScreen(settingsController.GetPrideFlag()); + + taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this); + Refresh(); +} + +WatchFacePrideFlag::~WatchFacePrideFlag() { + lv_task_del(taskRefresh); + lv_obj_clean(lv_scr_act()); + delete[] backgroundSections; +} + +bool WatchFacePrideFlag::OnTouchEvent(Pinetime::Applications::TouchEvents event) { + if ((event == Pinetime::Applications::TouchEvents::LongTap) && lv_obj_get_hidden(btnClose)) { + lv_obj_set_hidden(btnPrevFlag, false); + lv_obj_set_hidden(btnNextFlag, false); + lv_obj_set_hidden(btnClose, false); + savedTick = lv_tick_get(); + return true; + } + if ((event == Pinetime::Applications::TouchEvents::DoubleTap) && (lv_obj_get_hidden(btnClose) == false)) { + return true; + } + return false; +} + +void WatchFacePrideFlag::CloseMenu() { + settingsController.SaveSettings(); + lv_obj_set_hidden(btnClose, true); + lv_obj_set_hidden(btnNextFlag, true); + lv_obj_set_hidden(btnPrevFlag, true); +} + +void WatchFacePrideFlag::Refresh() { + powerPresent = batteryController.IsPowerPresent(); + bleState = bleController.IsConnected(); + batteryPercentRemaining = batteryController.PercentRemaining(); + if (batteryPercentRemaining.IsUpdated() || powerPresent.IsUpdated()) { + lv_label_set_text_fmt(batteryValue, "#ffffff %d%%#", batteryPercentRemaining.Get()); + if (batteryController.IsPowerPresent()) { + lv_label_ins_text(batteryValue, LV_LABEL_POS_LAST, " Charging"); + } + } + if (bleState.IsUpdated()) { + if (bleState.Get()) { + lv_label_set_text_static(bluetoothStatus, Symbols::bluetooth); + } else { + lv_label_set_text_static(bluetoothStatus, ""); + } + } + + notificationState = notificationManager.AreNewNotificationsAvailable(); + if (notificationState.IsUpdated()) { + if (notificationState.Get()) { + lv_label_set_text_static(notificationIcon, "You have\nmail!"); + } else { + lv_label_set_text_static(notificationIcon, ""); + } + } + + 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) { + if (hour == 0) { + ampmChar = "AM"; + hour = 12; + } else if (hour == 12) { + ampmChar = "PM"; + } else if (hour > 12) { + hour = hour - 12; + ampmChar = "PM"; + } + } + + lv_label_set_text_fmt(labelTime, "#000000 %02d:%02d:%02d#", hour, minute, second); + + currentDate = std::chrono::time_point_cast(currentDateTime.Get()); + if (currentDate.IsUpdated() || ampmChar.IsUpdated()) { + uint16_t year = dateTimeController.Year(); + Controllers::DateTime::Months month = dateTimeController.Month(); + uint8_t day = dateTimeController.Day(); + Controllers::DateTime::Days dayOfWeek = dateTimeController.DayOfWeek(); + lv_label_set_text_fmt(labelDate, "#ffffff %02d-%02d-%04d#", day, static_cast(month), year); + if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) { + lv_label_set_text_fmt(labelDay, "#ffffff %s %s#", dateTimeController.DayOfWeekToStringLow(dayOfWeek), ampmChar); + } else { + lv_label_set_text_fmt(labelDay, "#ffffff %s#", dateTimeController.DayOfWeekToStringLow(dayOfWeek)); + } + } + } + + stepCount = motionController.NbSteps(); + if (stepCount.IsUpdated()) { + lv_label_set_text_fmt(stepValue, "#ffffff %lu steps#", stepCount.Get()); + } +} + +void WatchFacePrideFlag::UpdateSelected(lv_obj_t* object, lv_event_t event) { + auto valueFlag = settingsController.GetPrideFlag(); + bool flagChanged = false; + + if (event == LV_EVENT_CLICKED) { + if (object == btnClose) { + CloseMenu(); + } + if (object == btnNextFlag) { + valueFlag = GetNext(valueFlag); + flagChanged = true; + } + if (object == btnPrevFlag) { + valueFlag = GetPrevious(valueFlag); + flagChanged = true; + } + settingsController.SetPrideFlag(valueFlag); + if (flagChanged) { + UpdateScreen(valueFlag); + } + } +} + +bool WatchFacePrideFlag::OnButtonPushed() { + if (!lv_obj_get_hidden(btnClose)) { + CloseMenu(); + return true; + } + return false; +} + +void WatchFacePrideFlag::UpdateScreen(Pinetime::Controllers::Settings::PrideFlag prideFlag) { + auto prideFlagAsInt = static_cast(prideFlag); + if (initialized) { + for (int i = 0; i < numBackgrounds; i++) { + lv_obj_del(backgroundSections[i]); + } + delete[] backgroundSections; + } + initialized = true; + switch (prideFlagAsInt) { + case 0: + numBackgrounds = 6; + backgroundSections = new lv_obj_t*[numBackgrounds]; + for (int i = 0; i < numBackgrounds; i++) { + backgroundSections[i] = lv_obj_create(lv_scr_act(), nullptr); + lv_obj_set_size(backgroundSections[i], LV_HOR_RES, LV_VER_RES / numBackgrounds); + lv_obj_set_pos(backgroundSections[i], 0, i * LV_VER_RES / numBackgrounds); + lv_obj_set_style_local_radius(backgroundSections[i], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, 0); + lv_obj_move_background(backgroundSections[i]); + } + lv_obj_set_style_local_bg_color(backgroundSections[0], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_RED); + lv_obj_set_style_local_bg_color(backgroundSections[1], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_ORANGE); + lv_obj_set_style_local_bg_color(backgroundSections[2], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_YELLOW); + lv_obj_set_style_local_bg_color(backgroundSections[3], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GREEN); + lv_obj_set_style_local_bg_color(backgroundSections[4], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLUE); + lv_obj_set_style_local_bg_color(backgroundSections[5], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_PURPLE); + lv_obj_align(labelDate, lv_scr_act(), LV_ALIGN_CENTER, 0, -58); + lv_obj_align(labelDay, lv_scr_act(), LV_ALIGN_CENTER, 0, 58); + lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_CENTER, 0, 96); + break; + case 1: + numBackgrounds = 5; + backgroundSections = new lv_obj_t*[numBackgrounds]; + for (int i = 0; i < numBackgrounds; i++) { + backgroundSections[i] = lv_obj_create(lv_scr_act(), nullptr); + lv_obj_set_size(backgroundSections[i], LV_HOR_RES, LV_VER_RES / numBackgrounds); + lv_obj_set_pos(backgroundSections[i], 0, i * LV_VER_RES / numBackgrounds); + lv_obj_set_style_local_radius(backgroundSections[i], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, 0); + lv_obj_move_background(backgroundSections[i]); + } + lv_obj_set_style_local_bg_color(backgroundSections[0], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lightBlue); + lv_obj_set_style_local_bg_color(backgroundSections[1], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lightPink); + lv_obj_set_style_local_bg_color(backgroundSections[2], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE); + lv_obj_set_style_local_bg_color(backgroundSections[3], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lightPink); + lv_obj_set_style_local_bg_color(backgroundSections[4], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lightBlue); + lv_obj_align(labelDate, lv_scr_act(), LV_ALIGN_CENTER, 0, -48); + lv_obj_align(labelDay, lv_scr_act(), LV_ALIGN_CENTER, 0, 48); + lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_CENTER, 0, 96); + break; + case 2: + numBackgrounds = 5; + backgroundSections = new lv_obj_t*[numBackgrounds]; + for (int i = 0; i < numBackgrounds; i++) { + backgroundSections[i] = lv_obj_create(lv_scr_act(), nullptr); + lv_obj_set_size(backgroundSections[i], LV_HOR_RES, LV_VER_RES / numBackgrounds); + lv_obj_set_pos(backgroundSections[i], 0, i * LV_VER_RES / numBackgrounds); + lv_obj_set_style_local_radius(backgroundSections[i], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, 0); + lv_obj_move_background(backgroundSections[i]); + } + lv_obj_set_style_local_bg_color(backgroundSections[0], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, hotPink); + lv_obj_set_style_local_bg_color(backgroundSections[1], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, hotPink); + lv_obj_set_style_local_bg_color(backgroundSections[2], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, grayPurple); + lv_obj_set_style_local_bg_color(backgroundSections[3], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, darkBlue); + lv_obj_set_style_local_bg_color(backgroundSections[4], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, darkBlue); + lv_obj_align(labelDate, lv_scr_act(), LV_ALIGN_CENTER, 0, -48); + lv_obj_align(labelDay, lv_scr_act(), LV_ALIGN_CENTER, 0, 48); + lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_CENTER, 0, 96); + break; + case 3: + numBackgrounds = 7; + backgroundSections = new lv_obj_t*[numBackgrounds]; + for (int i = 0; i < numBackgrounds; i++) { + backgroundSections[i] = lv_obj_create(lv_scr_act(), nullptr); + lv_obj_set_size(backgroundSections[i], LV_HOR_RES, (LV_VER_RES / numBackgrounds) + 1); + lv_obj_set_pos(backgroundSections[i], 0, i * LV_VER_RES / numBackgrounds); + lv_obj_set_style_local_radius(backgroundSections[i], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, 0); + lv_obj_move_background(backgroundSections[i]); + } + lv_obj_set_style_local_bg_color(backgroundSections[0], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_RED); + lv_obj_set_style_local_bg_color(backgroundSections[1], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, orange); + lv_obj_set_style_local_bg_color(backgroundSections[2], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lightOrange); + lv_obj_set_style_local_bg_color(backgroundSections[3], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE); + lv_obj_set_style_local_bg_color(backgroundSections[4], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lightPurple); + lv_obj_set_style_local_bg_color(backgroundSections[5], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, darkPurple); + lv_obj_set_style_local_bg_color(backgroundSections[6], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, magenta); + lv_obj_align(labelDate, lv_scr_act(), LV_ALIGN_CENTER, 0, -50); + lv_obj_align(labelDay, lv_scr_act(), LV_ALIGN_CENTER, 0, 50); + lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_CENTER, 0, 96); + break; + } +} + +Pinetime::Controllers::Settings::PrideFlag WatchFacePrideFlag::GetNext(Pinetime::Controllers::Settings::PrideFlag prideFlag) { + auto prideFlagAsInt = static_cast(prideFlag); + Pinetime::Controllers::Settings::PrideFlag nextFlag; + if (prideFlagAsInt < 3) { + nextFlag = static_cast(prideFlagAsInt + 1); + } else { + nextFlag = static_cast(0); + } + return nextFlag; +} + +Pinetime::Controllers::Settings::PrideFlag WatchFacePrideFlag::GetPrevious(Pinetime::Controllers::Settings::PrideFlag prideFlag) { + auto prideFlagAsInt = static_cast(prideFlag); + Pinetime::Controllers::Settings::PrideFlag prevFlag; + if (prideFlagAsInt > 0) { + prevFlag = static_cast(prideFlagAsInt - 1); + } else { + prevFlag = static_cast(3); + } + return prevFlag; +} diff --git a/src/displayapp/screens/WatchFaceTransFlag.h b/src/displayapp/screens/WatchFacePrideFlag.h similarity index 63% rename from src/displayapp/screens/WatchFaceTransFlag.h rename to src/displayapp/screens/WatchFacePrideFlag.h index bf458ed113..64f09185ff 100644 --- a/src/displayapp/screens/WatchFaceTransFlag.h +++ b/src/displayapp/screens/WatchFacePrideFlag.h @@ -23,18 +23,25 @@ namespace Pinetime { namespace Applications { namespace Screens { - class WatchFaceTransFlag : public Screen { + class WatchFacePrideFlag : public Screen { public: - WatchFaceTransFlag(Controllers::DateTime& dateTimeController, + WatchFacePrideFlag(Controllers::DateTime& dateTimeController, const Controllers::Battery& batteryController, const Controllers::Ble& bleController, Controllers::NotificationManager& notificationManager, Controllers::Settings& settingsController, Controllers::MotionController& motionController); - ~WatchFaceTransFlag() override; + ~WatchFacePrideFlag() override; + + bool OnTouchEvent(TouchEvents event) override; + bool OnButtonPushed() override; void Refresh() override; + void UpdateSelected(lv_obj_t* object, lv_event_t event); + + void UpdateScreen(Pinetime::Controllers::Settings::PrideFlag); + private: Utility::DirtyValue batteryPercentRemaining {}; Utility::DirtyValue powerPresent {}; @@ -46,11 +53,15 @@ namespace Pinetime { // Must be wrapped in a dirty value, since it is displayed in the day but is updated twice a day Utility::DirtyValue ampmChar {"AM"}; - lv_obj_t* topBlueBackground; - lv_obj_t* topPinkBackground; - lv_obj_t* whiteBackground; - lv_obj_t* bottomPinkBackground; - lv_obj_t* bottomBlueBackground; + static Pinetime::Controllers::Settings::PrideFlag GetNext(Controllers::Settings::PrideFlag prideFlag); + static Pinetime::Controllers::Settings::PrideFlag GetPrevious(Controllers::Settings::PrideFlag prideFlag); + + + uint32_t savedTick = 0; + bool initialized = false; + + lv_obj_t** backgroundSections; + uint8_t numBackgrounds; lv_obj_t* bluetoothStatus; lv_obj_t* labelTime; lv_obj_t* labelDate; @@ -58,9 +69,20 @@ namespace Pinetime { lv_obj_t* batteryValue; lv_obj_t* stepValue; lv_obj_t* notificationIcon; + lv_obj_t* btnClose; + lv_obj_t* btnNextFlag; + lv_obj_t* btnPrevFlag; static constexpr lv_color_t lightBlue = LV_COLOR_MAKE(0x00, 0xbf, 0xf3); static constexpr lv_color_t lightPink = LV_COLOR_MAKE(0xf4, 0x9a, 0xc1); + static constexpr lv_color_t hotPink = LV_COLOR_MAKE(0xd6, 0x02, 0x70); + static constexpr lv_color_t grayPurple = LV_COLOR_MAKE(0x9b, 0x4f, 0x96); + static constexpr lv_color_t darkBlue = LV_COLOR_MAKE(0x00, 0x38, 0xa8); + static constexpr lv_color_t orange = LV_COLOR_MAKE(0xef, 0x76, 0x27); + static constexpr lv_color_t lightOrange = LV_COLOR_MAKE(0xff, 0x9b, 0x55); + static constexpr lv_color_t lightPurple = LV_COLOR_MAKE(0xd4, 0x61, 0xa6); + static constexpr lv_color_t darkPurple = LV_COLOR_MAKE(0xb5, 0x56, 0x90); + static constexpr lv_color_t magenta = LV_COLOR_MAKE(0xa5, 0x00, 0x62); Controllers::DateTime& dateTimeController; const Controllers::Battery& batteryController; @@ -70,16 +92,17 @@ namespace Pinetime { Controllers::MotionController& motionController; lv_task_t* taskRefresh; + void CloseMenu(); }; } template <> - struct WatchFaceTraits { - static constexpr WatchFace watchFace = WatchFace::TransFlag; - static constexpr const char* name = "Trans Flag"; + struct WatchFaceTraits { + static constexpr WatchFace watchFace = WatchFace::PrideFlag; + static constexpr const char* name = "Pride Flag"; static Screens::Screen* Create(AppControllers& controllers) { - return new Screens::WatchFaceTransFlag(controllers.dateTimeController, + return new Screens::WatchFacePrideFlag(controllers.dateTimeController, controllers.batteryController, controllers.bleController, controllers.notificationManager, diff --git a/src/displayapp/screens/WatchFaceTransFlag.cpp b/src/displayapp/screens/WatchFaceTransFlag.cpp deleted file mode 100644 index 89304d1d3e..0000000000 --- a/src/displayapp/screens/WatchFaceTransFlag.cpp +++ /dev/null @@ -1,167 +0,0 @@ -#include -#include "displayapp/screens/WatchFaceTransFlag.h" -#include "displayapp/screens/BatteryIcon.h" -#include "displayapp/screens/NotificationIcon.h" -#include "displayapp/screens/Symbols.h" -#include "components/battery/BatteryController.h" -#include "components/ble/BleController.h" -#include "components/motion/MotionController.h" -#include "components/settings/Settings.h" - -using namespace Pinetime::Applications::Screens; - -WatchFaceTransFlag::WatchFaceTransFlag(Controllers::DateTime& dateTimeController, - const Controllers::Battery& batteryController, - const Controllers::Ble& bleController, - Controllers::NotificationManager& notificationManager, - Controllers::Settings& settingsController, - Controllers::MotionController& motionController) - : currentDateTime {{}}, - dateTimeController {dateTimeController}, - batteryController {batteryController}, - bleController {bleController}, - notificationManager {notificationManager}, - settingsController {settingsController}, - motionController {motionController} { - - topBlueBackground = lv_obj_create(lv_scr_act(), nullptr); - lv_obj_set_size(topBlueBackground, LV_HOR_RES, LV_VER_RES / 5); - lv_obj_set_pos(topBlueBackground, 0, 0); - lv_obj_set_style_local_bg_color(topBlueBackground, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lightBlue); - lv_obj_set_style_local_radius(topBlueBackground, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, 0); - topPinkBackground = lv_obj_create(lv_scr_act(), nullptr); - lv_obj_set_size(topPinkBackground, LV_HOR_RES, LV_VER_RES / 5); - lv_obj_set_pos(topPinkBackground, 0, LV_VER_RES / 5); - lv_obj_set_style_local_bg_color(topPinkBackground, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lightPink); - lv_obj_set_style_local_radius(topPinkBackground, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, 0); - whiteBackground = lv_obj_create(lv_scr_act(), nullptr); - lv_obj_set_size(whiteBackground, LV_HOR_RES, LV_VER_RES / 5); - lv_obj_set_pos(whiteBackground, 0, 2 * LV_VER_RES / 5); - lv_obj_set_style_local_bg_color(whiteBackground, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE); - lv_obj_set_style_local_radius(whiteBackground, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, 0); - bottomPinkBackground = lv_obj_create(lv_scr_act(), nullptr); - lv_obj_set_size(bottomPinkBackground, LV_HOR_RES, LV_VER_RES / 5); - lv_obj_set_pos(bottomPinkBackground, 0, 3 * LV_VER_RES / 5); - lv_obj_set_style_local_bg_color(bottomPinkBackground, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lightPink); - lv_obj_set_style_local_radius(bottomPinkBackground, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, 0); - bottomBlueBackground = lv_obj_create(lv_scr_act(), nullptr); - lv_obj_set_size(bottomBlueBackground, LV_HOR_RES, LV_VER_RES / 5); - lv_obj_set_pos(bottomBlueBackground, 0, 4 * LV_VER_RES / 5); - lv_obj_set_style_local_bg_color(bottomBlueBackground, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lightBlue); - lv_obj_set_style_local_radius(bottomBlueBackground, LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, 0); - - bluetoothStatus = lv_label_create(lv_scr_act(), nullptr); - lv_label_set_text_static(bluetoothStatus, ""); - lv_obj_align(bluetoothStatus, nullptr, LV_ALIGN_IN_TOP_RIGHT, -16, 0); - - batteryValue = lv_label_create(lv_scr_act(), nullptr); - lv_label_set_recolor(batteryValue, true); - lv_obj_align(batteryValue, lv_scr_act(), LV_ALIGN_CENTER, 0, -96); - lv_label_set_align(batteryValue, LV_LABEL_ALIGN_CENTER); - lv_obj_set_auto_realign(batteryValue, true); - - notificationIcon = lv_label_create(lv_scr_act(), nullptr); - lv_obj_align(notificationIcon, nullptr, LV_ALIGN_IN_LEFT_MID, 0, -110); - lv_obj_set_style_local_text_color(notificationIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK); - - labelDate = lv_label_create(lv_scr_act(), nullptr); - lv_label_set_recolor(labelDate, true); - lv_obj_align(labelDate, lv_scr_act(), LV_ALIGN_CENTER, 0, -48); - lv_label_set_align(labelDate, LV_LABEL_ALIGN_CENTER); - lv_obj_set_auto_realign(labelDate, true); - - labelTime = lv_label_create(lv_scr_act(), nullptr); - lv_label_set_recolor(labelTime, true); - lv_obj_align(labelTime, lv_scr_act(), LV_ALIGN_CENTER, 0, 0); - lv_label_set_align(labelTime, LV_LABEL_ALIGN_CENTER); - lv_obj_set_style_local_text_font(labelTime, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42); - lv_obj_set_auto_realign(labelTime, true); - - labelDay = lv_label_create(lv_scr_act(), nullptr); - lv_label_set_recolor(labelDay, true); - lv_obj_align(labelDay, lv_scr_act(), LV_ALIGN_CENTER, 0, 48); - lv_label_set_align(labelDay, LV_LABEL_ALIGN_CENTER); - lv_obj_set_auto_realign(labelDay, true); - - stepValue = lv_label_create(lv_scr_act(), nullptr); - lv_label_set_recolor(stepValue, true); - lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_CENTER, 0, 96); - lv_label_set_align(stepValue, LV_LABEL_ALIGN_CENTER); - lv_obj_set_auto_realign(stepValue, true); - - taskRefresh = lv_task_create(RefreshTaskCallback, LV_DISP_DEF_REFR_PERIOD, LV_TASK_PRIO_MID, this); - Refresh(); -} - -WatchFaceTransFlag::~WatchFaceTransFlag() { - lv_task_del(taskRefresh); - lv_obj_clean(lv_scr_act()); -} - -void WatchFaceTransFlag::Refresh() { - powerPresent = batteryController.IsPowerPresent(); - bleState = bleController.IsConnected(); - batteryPercentRemaining = batteryController.PercentRemaining(); - if (batteryPercentRemaining.IsUpdated() || powerPresent.IsUpdated()) { - lv_label_set_text_fmt(batteryValue, "#ffffff %d%%#", batteryPercentRemaining.Get()); - if (batteryController.IsPowerPresent()) { - lv_label_ins_text(batteryValue, LV_LABEL_POS_LAST, " Charging"); - } - } - if (bleState.IsUpdated()) { - if (bleState.Get()) { - lv_label_set_text_static(bluetoothStatus, Symbols::bluetooth); - } else { - lv_label_set_text_static(bluetoothStatus, ""); - } - } - - notificationState = notificationManager.AreNewNotificationsAvailable(); - if (notificationState.IsUpdated()) { - if (notificationState.Get()) { - lv_label_set_text_static(notificationIcon, "You have\nmail!"); - } else { - lv_label_set_text_static(notificationIcon, ""); - } - } - - 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) { - if (hour == 0) { - ampmChar = "AM"; - hour = 12; - } else if (hour == 12) { - ampmChar = "PM"; - } else if (hour > 12) { - hour = hour - 12; - ampmChar = "PM"; - } - } - - lv_label_set_text_fmt(labelTime, "#000000 %02d:%02d:%02d#", hour, minute, second); - - currentDate = std::chrono::time_point_cast(currentDateTime.Get()); - if (currentDate.IsUpdated() || ampmChar.IsUpdated()) { - uint16_t year = dateTimeController.Year(); - Controllers::DateTime::Months month = dateTimeController.Month(); - uint8_t day = dateTimeController.Day(); - Controllers::DateTime::Days dayOfWeek = dateTimeController.DayOfWeek(); - lv_label_set_text_fmt(labelDate, "#ffffff %02d-%02d-%04d#", day, static_cast(month), year); - if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) { - lv_label_set_text_fmt(labelDay, "#ffffff %s %s#", dateTimeController.DayOfWeekToStringLow(dayOfWeek), ampmChar); - } else { - lv_label_set_text_fmt(labelDay, "#ffffff %s#", dateTimeController.DayOfWeekToStringLow(dayOfWeek)); - } - } - } - - stepCount = motionController.NbSteps(); - if (stepCount.IsUpdated()) { - lv_label_set_text_fmt(stepValue, "#ffffff %lu steps#", stepCount.Get()); - } -} From 274798d5238c5fd1397eac565415dac01defd946 Mon Sep 17 00:00:00 2001 From: Eshe Date: Sun, 23 Mar 2025 15:25:58 +0000 Subject: [PATCH 11/26] Applied formatting patches --- src/components/settings/Settings.h | 2 +- src/displayapp/screens/WatchFacePrideFlag.cpp | 1 - src/displayapp/screens/WatchFacePrideFlag.h | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/components/settings/Settings.h b/src/components/settings/Settings.h index c45777bfc9..f3c2bea02f 100644 --- a/src/components/settings/Settings.h +++ b/src/components/settings/Settings.h @@ -36,7 +36,7 @@ namespace Pinetime { }; enum class PTSGaugeStyle : uint8_t { Full, Half, Numeric }; enum class PTSWeather : uint8_t { On, Off }; - enum class PrideFlag: uint8_t {Rainbow, Trans, Bi, Lesbian}; + enum class PrideFlag : uint8_t { Rainbow, Trans, Bi, Lesbian }; struct PineTimeStyle { Colors ColorTime = Colors::Teal; diff --git a/src/displayapp/screens/WatchFacePrideFlag.cpp b/src/displayapp/screens/WatchFacePrideFlag.cpp index 1d548d8593..183ff079a0 100644 --- a/src/displayapp/screens/WatchFacePrideFlag.cpp +++ b/src/displayapp/screens/WatchFacePrideFlag.cpp @@ -31,7 +31,6 @@ WatchFacePrideFlag::WatchFacePrideFlag(Controllers::DateTime& dateTimeController settingsController {settingsController}, motionController {motionController} { - bluetoothStatus = lv_label_create(lv_scr_act(), nullptr); lv_label_set_text_static(bluetoothStatus, ""); lv_obj_align(bluetoothStatus, nullptr, LV_ALIGN_IN_TOP_RIGHT, -16, 0); diff --git a/src/displayapp/screens/WatchFacePrideFlag.h b/src/displayapp/screens/WatchFacePrideFlag.h index 64f09185ff..923642f557 100644 --- a/src/displayapp/screens/WatchFacePrideFlag.h +++ b/src/displayapp/screens/WatchFacePrideFlag.h @@ -56,7 +56,6 @@ namespace Pinetime { static Pinetime::Controllers::Settings::PrideFlag GetNext(Controllers::Settings::PrideFlag prideFlag); static Pinetime::Controllers::Settings::PrideFlag GetPrevious(Controllers::Settings::PrideFlag prideFlag); - uint32_t savedTick = 0; bool initialized = false; From 857309e617185cf8123f9e7bd4b5be955ab9b91c Mon Sep 17 00:00:00 2001 From: Eshe Date: Sun, 23 Mar 2025 18:00:58 +0000 Subject: [PATCH 12/26] Fixed labels having wrong position --- src/displayapp/screens/WatchFacePrideFlag.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/displayapp/screens/WatchFacePrideFlag.cpp b/src/displayapp/screens/WatchFacePrideFlag.cpp index 183ff079a0..0c5b1d403e 100644 --- a/src/displayapp/screens/WatchFacePrideFlag.cpp +++ b/src/displayapp/screens/WatchFacePrideFlag.cpp @@ -37,7 +37,6 @@ WatchFacePrideFlag::WatchFacePrideFlag(Controllers::DateTime& dateTimeController batteryValue = lv_label_create(lv_scr_act(), nullptr); lv_label_set_recolor(batteryValue, true); - lv_obj_align(batteryValue, lv_scr_act(), LV_ALIGN_CENTER, 0, -96); lv_label_set_align(batteryValue, LV_LABEL_ALIGN_CENTER); lv_obj_set_auto_realign(batteryValue, true); @@ -256,9 +255,10 @@ void WatchFacePrideFlag::UpdateScreen(Pinetime::Controllers::Settings::PrideFlag lv_obj_set_style_local_bg_color(backgroundSections[3], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GREEN); lv_obj_set_style_local_bg_color(backgroundSections[4], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLUE); lv_obj_set_style_local_bg_color(backgroundSections[5], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_PURPLE); - lv_obj_align(labelDate, lv_scr_act(), LV_ALIGN_CENTER, 0, -58); - lv_obj_align(labelDay, lv_scr_act(), LV_ALIGN_CENTER, 0, 58); - lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_CENTER, 0, 96); + lv_obj_align(batteryValue, lv_scr_act(), LV_ALIGN_CENTER, 0, -99); + lv_obj_align(labelDate, lv_scr_act(), LV_ALIGN_CENTER, 0, -60); + lv_obj_align(labelDay, lv_scr_act(), LV_ALIGN_CENTER, 0, 60); + lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_CENTER, 0, 99); break; case 1: numBackgrounds = 5; @@ -275,6 +275,7 @@ void WatchFacePrideFlag::UpdateScreen(Pinetime::Controllers::Settings::PrideFlag lv_obj_set_style_local_bg_color(backgroundSections[2], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE); lv_obj_set_style_local_bg_color(backgroundSections[3], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lightPink); lv_obj_set_style_local_bg_color(backgroundSections[4], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lightBlue); + lv_obj_align(batteryValue, lv_scr_act(), LV_ALIGN_CENTER, 0, -96); lv_obj_align(labelDate, lv_scr_act(), LV_ALIGN_CENTER, 0, -48); lv_obj_align(labelDay, lv_scr_act(), LV_ALIGN_CENTER, 0, 48); lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_CENTER, 0, 96); @@ -294,6 +295,7 @@ void WatchFacePrideFlag::UpdateScreen(Pinetime::Controllers::Settings::PrideFlag lv_obj_set_style_local_bg_color(backgroundSections[2], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, grayPurple); lv_obj_set_style_local_bg_color(backgroundSections[3], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, darkBlue); lv_obj_set_style_local_bg_color(backgroundSections[4], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, darkBlue); + lv_obj_align(batteryValue, lv_scr_act(), LV_ALIGN_CENTER, 0, -96); lv_obj_align(labelDate, lv_scr_act(), LV_ALIGN_CENTER, 0, -48); lv_obj_align(labelDay, lv_scr_act(), LV_ALIGN_CENTER, 0, 48); lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_CENTER, 0, 96); @@ -315,9 +317,10 @@ void WatchFacePrideFlag::UpdateScreen(Pinetime::Controllers::Settings::PrideFlag lv_obj_set_style_local_bg_color(backgroundSections[4], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lightPurple); lv_obj_set_style_local_bg_color(backgroundSections[5], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, darkPurple); lv_obj_set_style_local_bg_color(backgroundSections[6], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, magenta); - lv_obj_align(labelDate, lv_scr_act(), LV_ALIGN_CENTER, 0, -50); - lv_obj_align(labelDay, lv_scr_act(), LV_ALIGN_CENTER, 0, 50); - lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_CENTER, 0, 96); + lv_obj_align(batteryValue, lv_scr_act(), LV_ALIGN_CENTER, 0, -102); + lv_obj_align(labelDate, lv_scr_act(), LV_ALIGN_CENTER, 0, -51); + lv_obj_align(labelDay, lv_scr_act(), LV_ALIGN_CENTER, 0, 51); + lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_CENTER, 0, 102); break; } } From c8f45f8c41b0b235c95ff7d258ca406db09ac31a Mon Sep 17 00:00:00 2001 From: Eshe Date: Fri, 16 May 2025 13:51:07 +0100 Subject: [PATCH 13/26] Added text colour changing; fixed time label incorrectly aligned --- src/displayapp/screens/WatchFacePrideFlag.cpp | 32 ++++++++++++------- src/displayapp/screens/WatchFacePrideFlag.h | 3 ++ 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/src/displayapp/screens/WatchFacePrideFlag.cpp b/src/displayapp/screens/WatchFacePrideFlag.cpp index 0c5b1d403e..f905d101dc 100644 --- a/src/displayapp/screens/WatchFacePrideFlag.cpp +++ b/src/displayapp/screens/WatchFacePrideFlag.cpp @@ -81,7 +81,7 @@ WatchFacePrideFlag::WatchFacePrideFlag(Controllers::DateTime& dateTimeController labelTime = lv_label_create(lv_scr_act(), nullptr); lv_label_set_recolor(labelTime, true); - lv_obj_align(labelTime, lv_scr_act(), LV_ALIGN_CENTER, 0, 0); + lv_obj_align(labelTime, lv_scr_act(), LV_ALIGN_CENTER, 0, -1); lv_label_set_align(labelTime, LV_LABEL_ALIGN_CENTER); lv_obj_set_style_local_text_font(labelTime, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, &jetbrains_mono_42); lv_obj_set_auto_realign(labelTime, true); @@ -134,8 +134,8 @@ void WatchFacePrideFlag::Refresh() { powerPresent = batteryController.IsPowerPresent(); bleState = bleController.IsConnected(); batteryPercentRemaining = batteryController.PercentRemaining(); - if (batteryPercentRemaining.IsUpdated() || powerPresent.IsUpdated()) { - lv_label_set_text_fmt(batteryValue, "#ffffff %d%%#", batteryPercentRemaining.Get()); + if (batteryPercentRemaining.IsUpdated() || powerPresent.IsUpdated() || themeChanged) { + lv_label_set_text_fmt(batteryValue, "%s %d%%#", defaultLabelColour, batteryPercentRemaining.Get()); if (batteryController.IsPowerPresent()) { lv_label_ins_text(batteryValue, LV_LABEL_POS_LAST, " Charging"); } @@ -158,7 +158,7 @@ void WatchFacePrideFlag::Refresh() { } currentDateTime = std::chrono::time_point_cast(dateTimeController.CurrentDateTime()); - if (currentDateTime.IsUpdated()) { + if (currentDateTime.IsUpdated() || themeChanged) { uint8_t hour = dateTimeController.Hours(); uint8_t minute = dateTimeController.Minutes(); uint8_t second = dateTimeController.Seconds(); @@ -175,27 +175,28 @@ void WatchFacePrideFlag::Refresh() { } } - lv_label_set_text_fmt(labelTime, "#000000 %02d:%02d:%02d#", hour, minute, second); + lv_label_set_text_fmt(labelTime, "%s %02d:%02d:%02d#", labelTimeColour, hour, minute, second); currentDate = std::chrono::time_point_cast(currentDateTime.Get()); - if (currentDate.IsUpdated() || ampmChar.IsUpdated()) { + if (currentDate.IsUpdated() || ampmChar.IsUpdated() || themeChanged) { uint16_t year = dateTimeController.Year(); Controllers::DateTime::Months month = dateTimeController.Month(); uint8_t day = dateTimeController.Day(); Controllers::DateTime::Days dayOfWeek = dateTimeController.DayOfWeek(); - lv_label_set_text_fmt(labelDate, "#ffffff %02d-%02d-%04d#", day, static_cast(month), year); + lv_label_set_text_fmt(labelDate, "%s %02d-%02d-%04d#", defaultLabelColour, day, static_cast(month), year); if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) { - lv_label_set_text_fmt(labelDay, "#ffffff %s %s#", dateTimeController.DayOfWeekToStringLow(dayOfWeek), ampmChar); + lv_label_set_text_fmt(labelDay, "%s %s %s#", defaultLabelColour, dateTimeController.DayOfWeekToStringLow(dayOfWeek), ampmChar); } else { - lv_label_set_text_fmt(labelDay, "#ffffff %s#", dateTimeController.DayOfWeekToStringLow(dayOfWeek)); + lv_label_set_text_fmt(labelDay, "%s %s#", defaultLabelColour, dateTimeController.DayOfWeekToStringLow(dayOfWeek)); } } } stepCount = motionController.NbSteps(); - if (stepCount.IsUpdated()) { - lv_label_set_text_fmt(stepValue, "#ffffff %lu steps#", stepCount.Get()); + if (stepCount.IsUpdated() || themeChanged) { + lv_label_set_text_fmt(stepValue, "%s %lu steps#", defaultLabelColour, stepCount.Get()); } + if (themeChanged) themeChanged = false; } void WatchFacePrideFlag::UpdateSelected(lv_obj_t* object, lv_event_t event) { @@ -230,6 +231,7 @@ bool WatchFacePrideFlag::OnButtonPushed() { } void WatchFacePrideFlag::UpdateScreen(Pinetime::Controllers::Settings::PrideFlag prideFlag) { + themeChanged = true; auto prideFlagAsInt = static_cast(prideFlag); if (initialized) { for (int i = 0; i < numBackgrounds; i++) { @@ -259,6 +261,8 @@ void WatchFacePrideFlag::UpdateScreen(Pinetime::Controllers::Settings::PrideFlag lv_obj_align(labelDate, lv_scr_act(), LV_ALIGN_CENTER, 0, -60); lv_obj_align(labelDay, lv_scr_act(), LV_ALIGN_CENTER, 0, 60); lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_CENTER, 0, 99); + strncpy(labelTimeColour, "#000000", 7); + strncpy(defaultLabelColour, "#ffffff", 7); break; case 1: numBackgrounds = 5; @@ -279,6 +283,8 @@ void WatchFacePrideFlag::UpdateScreen(Pinetime::Controllers::Settings::PrideFlag lv_obj_align(labelDate, lv_scr_act(), LV_ALIGN_CENTER, 0, -48); lv_obj_align(labelDay, lv_scr_act(), LV_ALIGN_CENTER, 0, 48); lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_CENTER, 0, 96); + strncpy(labelTimeColour, "#000000", 7); + strncpy(defaultLabelColour, "#ffffff", 7); break; case 2: numBackgrounds = 5; @@ -299,6 +305,8 @@ void WatchFacePrideFlag::UpdateScreen(Pinetime::Controllers::Settings::PrideFlag lv_obj_align(labelDate, lv_scr_act(), LV_ALIGN_CENTER, 0, -48); lv_obj_align(labelDay, lv_scr_act(), LV_ALIGN_CENTER, 0, 48); lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_CENTER, 0, 96); + strncpy(labelTimeColour, "#ffffff", 7); + strncpy(defaultLabelColour, "#000000", 7); break; case 3: numBackgrounds = 7; @@ -321,6 +329,8 @@ void WatchFacePrideFlag::UpdateScreen(Pinetime::Controllers::Settings::PrideFlag lv_obj_align(labelDate, lv_scr_act(), LV_ALIGN_CENTER, 0, -51); lv_obj_align(labelDay, lv_scr_act(), LV_ALIGN_CENTER, 0, 51); lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_CENTER, 0, 102); + strncpy(labelTimeColour, "#000000", 7); + strncpy(defaultLabelColour, "#ffffff", 7); break; } } diff --git a/src/displayapp/screens/WatchFacePrideFlag.h b/src/displayapp/screens/WatchFacePrideFlag.h index 923642f557..5439ebd72b 100644 --- a/src/displayapp/screens/WatchFacePrideFlag.h +++ b/src/displayapp/screens/WatchFacePrideFlag.h @@ -60,6 +60,9 @@ namespace Pinetime { bool initialized = false; lv_obj_t** backgroundSections; + char labelTimeColour[8] = "#000000"; + char defaultLabelColour[8] = "#ffffff"; + bool themeChanged = false; uint8_t numBackgrounds; lv_obj_t* bluetoothStatus; lv_obj_t* labelTime; From 12109a8a18d88e1f2f1eaa2e6eba27ce335276f5 Mon Sep 17 00:00:00 2001 From: Eshe Date: Fri, 16 May 2025 20:29:50 +0100 Subject: [PATCH 14/26] Fixed formatting --- src/displayapp/screens/WatchFacePrideFlag.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/displayapp/screens/WatchFacePrideFlag.cpp b/src/displayapp/screens/WatchFacePrideFlag.cpp index f905d101dc..9686122bc6 100644 --- a/src/displayapp/screens/WatchFacePrideFlag.cpp +++ b/src/displayapp/screens/WatchFacePrideFlag.cpp @@ -196,7 +196,8 @@ void WatchFacePrideFlag::Refresh() { if (stepCount.IsUpdated() || themeChanged) { lv_label_set_text_fmt(stepValue, "%s %lu steps#", defaultLabelColour, stepCount.Get()); } - if (themeChanged) themeChanged = false; + if (themeChanged) + themeChanged = false; } void WatchFacePrideFlag::UpdateSelected(lv_obj_t* object, lv_event_t event) { From 0adf807c812209905055327099740fc00e3c3843 Mon Sep 17 00:00:00 2001 From: Eshe Date: Mon, 16 Jun 2025 11:53:09 +0100 Subject: [PATCH 15/26] Swapped out rainbow flag for MLM flag --- src/components/settings/Settings.h | 4 +-- src/displayapp/screens/WatchFacePrideFlag.cpp | 27 ++++++++++--------- src/displayapp/screens/WatchFacePrideFlag.h | 5 ++++ 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/components/settings/Settings.h b/src/components/settings/Settings.h index f3c2bea02f..eae69f809e 100644 --- a/src/components/settings/Settings.h +++ b/src/components/settings/Settings.h @@ -36,7 +36,7 @@ namespace Pinetime { }; enum class PTSGaugeStyle : uint8_t { Full, Half, Numeric }; enum class PTSWeather : uint8_t { On, Off }; - enum class PrideFlag : uint8_t { Rainbow, Trans, Bi, Lesbian }; + enum class PrideFlag : uint8_t { Gay, Trans, Bi, Lesbian }; struct PineTimeStyle { Colors ColorTime = Colors::Teal; @@ -330,7 +330,7 @@ namespace Pinetime { PineTimeStyle PTS; - PrideFlag prideFlag = PrideFlag::Rainbow; + PrideFlag prideFlag = PrideFlag::Gay; WatchFaceInfineat watchFaceInfineat; diff --git a/src/displayapp/screens/WatchFacePrideFlag.cpp b/src/displayapp/screens/WatchFacePrideFlag.cpp index 9686122bc6..5617c3b038 100644 --- a/src/displayapp/screens/WatchFacePrideFlag.cpp +++ b/src/displayapp/screens/WatchFacePrideFlag.cpp @@ -243,27 +243,28 @@ void WatchFacePrideFlag::UpdateScreen(Pinetime::Controllers::Settings::PrideFlag initialized = true; switch (prideFlagAsInt) { case 0: - numBackgrounds = 6; + numBackgrounds = 7; backgroundSections = new lv_obj_t*[numBackgrounds]; for (int i = 0; i < numBackgrounds; i++) { backgroundSections[i] = lv_obj_create(lv_scr_act(), nullptr); - lv_obj_set_size(backgroundSections[i], LV_HOR_RES, LV_VER_RES / numBackgrounds); + lv_obj_set_size(backgroundSections[i], LV_HOR_RES, (LV_VER_RES / numBackgrounds) + 1); lv_obj_set_pos(backgroundSections[i], 0, i * LV_VER_RES / numBackgrounds); lv_obj_set_style_local_radius(backgroundSections[i], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, 0); lv_obj_move_background(backgroundSections[i]); } - lv_obj_set_style_local_bg_color(backgroundSections[0], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_RED); - lv_obj_set_style_local_bg_color(backgroundSections[1], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_ORANGE); - lv_obj_set_style_local_bg_color(backgroundSections[2], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_YELLOW); - lv_obj_set_style_local_bg_color(backgroundSections[3], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_GREEN); - lv_obj_set_style_local_bg_color(backgroundSections[4], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLUE); - lv_obj_set_style_local_bg_color(backgroundSections[5], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_PURPLE); - lv_obj_align(batteryValue, lv_scr_act(), LV_ALIGN_CENTER, 0, -99); - lv_obj_align(labelDate, lv_scr_act(), LV_ALIGN_CENTER, 0, -60); - lv_obj_align(labelDay, lv_scr_act(), LV_ALIGN_CENTER, 0, 60); - lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_CENTER, 0, 99); + lv_obj_set_style_local_bg_color(backgroundSections[0], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, darkGreen); + lv_obj_set_style_local_bg_color(backgroundSections[1], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, cyan); + lv_obj_set_style_local_bg_color(backgroundSections[2], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lightGreen); + lv_obj_set_style_local_bg_color(backgroundSections[3], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE); + lv_obj_set_style_local_bg_color(backgroundSections[4], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lightBlue); + lv_obj_set_style_local_bg_color(backgroundSections[5], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, indigo); + lv_obj_set_style_local_bg_color(backgroundSections[6], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, steelBlue); + lv_obj_align(batteryValue, lv_scr_act(), LV_ALIGN_CENTER, 0, -102); + lv_obj_align(labelDate, lv_scr_act(), LV_ALIGN_CENTER, 0, -51); + lv_obj_align(labelDay, lv_scr_act(), LV_ALIGN_CENTER, 0, 51); + lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_CENTER, 0, 102); strncpy(labelTimeColour, "#000000", 7); - strncpy(defaultLabelColour, "#ffffff", 7); + strncpy(defaultLabelColour, "#000000", 7); break; case 1: numBackgrounds = 5; diff --git a/src/displayapp/screens/WatchFacePrideFlag.h b/src/displayapp/screens/WatchFacePrideFlag.h index 5439ebd72b..afc7a5bc85 100644 --- a/src/displayapp/screens/WatchFacePrideFlag.h +++ b/src/displayapp/screens/WatchFacePrideFlag.h @@ -85,6 +85,11 @@ namespace Pinetime { static constexpr lv_color_t lightPurple = LV_COLOR_MAKE(0xd4, 0x61, 0xa6); static constexpr lv_color_t darkPurple = LV_COLOR_MAKE(0xb5, 0x56, 0x90); static constexpr lv_color_t magenta = LV_COLOR_MAKE(0xa5, 0x00, 0x62); + static constexpr lv_color_t darkGreen = LV_COLOR_MAKE(0x07, 0x8d, 0x70); + static constexpr lv_color_t cyan = LV_COLOR_MAKE(0x26, 0xce, 0xaa); + static constexpr lv_color_t lightGreen = LV_COLOR_MAKE(0x98, 0xe8, 0xc1); + static constexpr lv_color_t indigo = LV_COLOR_MAKE(0x50, 0x49, 0xcc); + static constexpr lv_color_t steelBlue = LV_COLOR_MAKE(0x3d, 0x1a, 0x78); Controllers::DateTime& dateTimeController; const Controllers::Battery& batteryController; From 2ab7f6b8e259fff49e76ba49360c0a916200eef7 Mon Sep 17 00:00:00 2001 From: Eshe Date: Mon, 16 Jun 2025 15:35:49 +0100 Subject: [PATCH 16/26] Made top and bottom half of text have different colours in the MLM flag --- src/displayapp/screens/WatchFacePrideFlag.cpp | 22 +++++++++++-------- src/displayapp/screens/WatchFacePrideFlag.h | 3 ++- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/displayapp/screens/WatchFacePrideFlag.cpp b/src/displayapp/screens/WatchFacePrideFlag.cpp index 5617c3b038..11b15b0eef 100644 --- a/src/displayapp/screens/WatchFacePrideFlag.cpp +++ b/src/displayapp/screens/WatchFacePrideFlag.cpp @@ -135,7 +135,7 @@ void WatchFacePrideFlag::Refresh() { bleState = bleController.IsConnected(); batteryPercentRemaining = batteryController.PercentRemaining(); if (batteryPercentRemaining.IsUpdated() || powerPresent.IsUpdated() || themeChanged) { - lv_label_set_text_fmt(batteryValue, "%s %d%%#", defaultLabelColour, batteryPercentRemaining.Get()); + lv_label_set_text_fmt(batteryValue, "%s %d%%#", defaultTopLabelColour, batteryPercentRemaining.Get()); if (batteryController.IsPowerPresent()) { lv_label_ins_text(batteryValue, LV_LABEL_POS_LAST, " Charging"); } @@ -183,18 +183,18 @@ void WatchFacePrideFlag::Refresh() { Controllers::DateTime::Months month = dateTimeController.Month(); uint8_t day = dateTimeController.Day(); Controllers::DateTime::Days dayOfWeek = dateTimeController.DayOfWeek(); - lv_label_set_text_fmt(labelDate, "%s %02d-%02d-%04d#", defaultLabelColour, day, static_cast(month), year); + lv_label_set_text_fmt(labelDate, "%s %02d-%02d-%04d#", defaultTopLabelColour, day, static_cast(month), year); if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) { - lv_label_set_text_fmt(labelDay, "%s %s %s#", defaultLabelColour, dateTimeController.DayOfWeekToStringLow(dayOfWeek), ampmChar); + lv_label_set_text_fmt(labelDay, "%s %s %s#", defaultBottomLabelColour, dateTimeController.DayOfWeekToStringLow(dayOfWeek), ampmChar); } else { - lv_label_set_text_fmt(labelDay, "%s %s#", defaultLabelColour, dateTimeController.DayOfWeekToStringLow(dayOfWeek)); + lv_label_set_text_fmt(labelDay, "%s %s#", defaultBottomLabelColour, dateTimeController.DayOfWeekToStringLow(dayOfWeek)); } } } stepCount = motionController.NbSteps(); if (stepCount.IsUpdated() || themeChanged) { - lv_label_set_text_fmt(stepValue, "%s %lu steps#", defaultLabelColour, stepCount.Get()); + lv_label_set_text_fmt(stepValue, "%s %lu steps#", defaultBottomLabelColour, stepCount.Get()); } if (themeChanged) themeChanged = false; @@ -264,7 +264,8 @@ void WatchFacePrideFlag::UpdateScreen(Pinetime::Controllers::Settings::PrideFlag lv_obj_align(labelDay, lv_scr_act(), LV_ALIGN_CENTER, 0, 51); lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_CENTER, 0, 102); strncpy(labelTimeColour, "#000000", 7); - strncpy(defaultLabelColour, "#000000", 7); + strncpy(defaultTopLabelColour, "#000000", 7); + strncpy(defaultBottomLabelColour, "#ffffff", 7); break; case 1: numBackgrounds = 5; @@ -286,7 +287,8 @@ void WatchFacePrideFlag::UpdateScreen(Pinetime::Controllers::Settings::PrideFlag lv_obj_align(labelDay, lv_scr_act(), LV_ALIGN_CENTER, 0, 48); lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_CENTER, 0, 96); strncpy(labelTimeColour, "#000000", 7); - strncpy(defaultLabelColour, "#ffffff", 7); + strncpy(defaultTopLabelColour, "#ffffff", 7); + strncpy(defaultBottomLabelColour, "#ffffff", 7); break; case 2: numBackgrounds = 5; @@ -308,7 +310,8 @@ void WatchFacePrideFlag::UpdateScreen(Pinetime::Controllers::Settings::PrideFlag lv_obj_align(labelDay, lv_scr_act(), LV_ALIGN_CENTER, 0, 48); lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_CENTER, 0, 96); strncpy(labelTimeColour, "#ffffff", 7); - strncpy(defaultLabelColour, "#000000", 7); + strncpy(defaultTopLabelColour, "#000000", 7); + strncpy(defaultBottomLabelColour, "#000000", 7); break; case 3: numBackgrounds = 7; @@ -332,7 +335,8 @@ void WatchFacePrideFlag::UpdateScreen(Pinetime::Controllers::Settings::PrideFlag lv_obj_align(labelDay, lv_scr_act(), LV_ALIGN_CENTER, 0, 51); lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_CENTER, 0, 102); strncpy(labelTimeColour, "#000000", 7); - strncpy(defaultLabelColour, "#ffffff", 7); + strncpy(defaultTopLabelColour, "#ffffff", 7); + strncpy(defaultBottomLabelColour, "#ffffff", 7); break; } } diff --git a/src/displayapp/screens/WatchFacePrideFlag.h b/src/displayapp/screens/WatchFacePrideFlag.h index afc7a5bc85..a66e054179 100644 --- a/src/displayapp/screens/WatchFacePrideFlag.h +++ b/src/displayapp/screens/WatchFacePrideFlag.h @@ -61,7 +61,8 @@ namespace Pinetime { lv_obj_t** backgroundSections; char labelTimeColour[8] = "#000000"; - char defaultLabelColour[8] = "#ffffff"; + char defaultTopLabelColour[8] = "#ffffff"; + char defaultBottomLabelColour[8] = "#ffffff"; bool themeChanged = false; uint8_t numBackgrounds; lv_obj_t* bluetoothStatus; From 7d533456305027fb7e469e4fe81b5309ab97e17c Mon Sep 17 00:00:00 2001 From: Eshe Date: Mon, 16 Jun 2025 16:48:16 +0100 Subject: [PATCH 17/26] Fixed formatting --- src/displayapp/screens/WatchFacePrideFlag.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/displayapp/screens/WatchFacePrideFlag.cpp b/src/displayapp/screens/WatchFacePrideFlag.cpp index 11b15b0eef..4a6ca55b94 100644 --- a/src/displayapp/screens/WatchFacePrideFlag.cpp +++ b/src/displayapp/screens/WatchFacePrideFlag.cpp @@ -185,7 +185,11 @@ void WatchFacePrideFlag::Refresh() { Controllers::DateTime::Days dayOfWeek = dateTimeController.DayOfWeek(); lv_label_set_text_fmt(labelDate, "%s %02d-%02d-%04d#", defaultTopLabelColour, day, static_cast(month), year); if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) { - lv_label_set_text_fmt(labelDay, "%s %s %s#", defaultBottomLabelColour, dateTimeController.DayOfWeekToStringLow(dayOfWeek), ampmChar); + lv_label_set_text_fmt(labelDay, + "%s %s %s#", + defaultBottomLabelColour, + dateTimeController.DayOfWeekToStringLow(dayOfWeek), + ampmChar); } else { lv_label_set_text_fmt(labelDay, "%s %s#", defaultBottomLabelColour, dateTimeController.DayOfWeekToStringLow(dayOfWeek)); } From 1f0265f1bb72ccddf31bd7ba09039c5d8f9828a5 Mon Sep 17 00:00:00 2001 From: Eshe Date: Mon, 16 Jun 2025 19:34:53 +0100 Subject: [PATCH 18/26] Incremented settingsVersion --- src/components/settings/Settings.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/settings/Settings.h b/src/components/settings/Settings.h index eae69f809e..c961512647 100644 --- a/src/components/settings/Settings.h +++ b/src/components/settings/Settings.h @@ -312,7 +312,7 @@ namespace Pinetime { private: Pinetime::Controllers::FS& fs; - static constexpr uint32_t settingsVersion = 0x0008; + static constexpr uint32_t settingsVersion = 0x0009; struct SettingsData { uint32_t version = settingsVersion; From 32c3651c15c242116c0d1307b7441433a2996219 Mon Sep 17 00:00:00 2001 From: Eshe Date: Mon, 16 Jun 2025 20:58:09 +0100 Subject: [PATCH 19/26] Implemented suggested changes --- src/displayapp/screens/WatchFacePrideFlag.cpp | 52 +++++++++++-------- src/displayapp/screens/WatchFacePrideFlag.h | 29 ++--------- 2 files changed, 33 insertions(+), 48 deletions(-) diff --git a/src/displayapp/screens/WatchFacePrideFlag.cpp b/src/displayapp/screens/WatchFacePrideFlag.cpp index 4a6ca55b94..3ed39b08d9 100644 --- a/src/displayapp/screens/WatchFacePrideFlag.cpp +++ b/src/displayapp/screens/WatchFacePrideFlag.cpp @@ -1,12 +1,6 @@ -#include #include "displayapp/screens/WatchFacePrideFlag.h" -#include "displayapp/screens/BatteryIcon.h" -#include "displayapp/screens/NotificationIcon.h" +#include #include "displayapp/screens/Symbols.h" -#include "components/battery/BatteryController.h" -#include "components/ble/BleController.h" -#include "components/motion/MotionController.h" -#include "components/settings/Settings.h" using namespace Pinetime::Applications::Screens; @@ -15,6 +9,24 @@ namespace { auto* screen = static_cast(obj->user_data); screen->UpdateSelected(obj, event); } + char labelTimeColour[8] = "#000000"; + char defaultTopLabelColour[8] = "#ffffff"; + char defaultBottomLabelColour[8] = "#ffffff"; + static constexpr lv_color_t lightBlue = LV_COLOR_MAKE(0x00, 0xbf, 0xf3); + static constexpr lv_color_t lightPink = LV_COLOR_MAKE(0xf4, 0x9a, 0xc1); + static constexpr lv_color_t hotPink = LV_COLOR_MAKE(0xd6, 0x02, 0x70); + static constexpr lv_color_t grayPurple = LV_COLOR_MAKE(0x9b, 0x4f, 0x96); + static constexpr lv_color_t darkBlue = LV_COLOR_MAKE(0x00, 0x38, 0xa8); + static constexpr lv_color_t orange = LV_COLOR_MAKE(0xef, 0x76, 0x27); + static constexpr lv_color_t lightOrange = LV_COLOR_MAKE(0xff, 0x9b, 0x55); + static constexpr lv_color_t lightPurple = LV_COLOR_MAKE(0xd4, 0x61, 0xa6); + static constexpr lv_color_t darkPurple = LV_COLOR_MAKE(0xb5, 0x56, 0x90); + static constexpr lv_color_t magenta = LV_COLOR_MAKE(0xa5, 0x00, 0x62); + static constexpr lv_color_t darkGreen = LV_COLOR_MAKE(0x07, 0x8d, 0x70); + static constexpr lv_color_t cyan = LV_COLOR_MAKE(0x26, 0xce, 0xaa); + static constexpr lv_color_t lightGreen = LV_COLOR_MAKE(0x98, 0xe8, 0xc1); + static constexpr lv_color_t indigo = LV_COLOR_MAKE(0x50, 0x49, 0xcc); + static constexpr lv_color_t steelBlue = LV_COLOR_MAKE(0x3d, 0x1a, 0x78); } WatchFacePrideFlag::WatchFacePrideFlag(Controllers::DateTime& dateTimeController, @@ -106,7 +118,6 @@ WatchFacePrideFlag::WatchFacePrideFlag(Controllers::DateTime& dateTimeController WatchFacePrideFlag::~WatchFacePrideFlag() { lv_task_del(taskRefresh); lv_obj_clean(lv_scr_act()); - delete[] backgroundSections; } bool WatchFacePrideFlag::OnTouchEvent(Pinetime::Applications::TouchEvents event) { @@ -238,19 +249,16 @@ bool WatchFacePrideFlag::OnButtonPushed() { void WatchFacePrideFlag::UpdateScreen(Pinetime::Controllers::Settings::PrideFlag prideFlag) { themeChanged = true; auto prideFlagAsInt = static_cast(prideFlag); - if (initialized) { - for (int i = 0; i < numBackgrounds; i++) { - lv_obj_del(backgroundSections[i]); - } - delete[] backgroundSections; + for (int i = 0; i < backgroundSections.size(); i++) { + lv_obj_del(backgroundSections[i]); } - initialized = true; + backgroundSections.clear(); switch (prideFlagAsInt) { case 0: numBackgrounds = 7; - backgroundSections = new lv_obj_t*[numBackgrounds]; + backgroundSections.reserve(numBackgrounds); for (int i = 0; i < numBackgrounds; i++) { - backgroundSections[i] = lv_obj_create(lv_scr_act(), nullptr); + backgroundSections.push_back(lv_obj_create(lv_scr_act(), nullptr)); lv_obj_set_size(backgroundSections[i], LV_HOR_RES, (LV_VER_RES / numBackgrounds) + 1); lv_obj_set_pos(backgroundSections[i], 0, i * LV_VER_RES / numBackgrounds); lv_obj_set_style_local_radius(backgroundSections[i], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, 0); @@ -273,9 +281,9 @@ void WatchFacePrideFlag::UpdateScreen(Pinetime::Controllers::Settings::PrideFlag break; case 1: numBackgrounds = 5; - backgroundSections = new lv_obj_t*[numBackgrounds]; + backgroundSections.reserve(numBackgrounds); for (int i = 0; i < numBackgrounds; i++) { - backgroundSections[i] = lv_obj_create(lv_scr_act(), nullptr); + backgroundSections.push_back(lv_obj_create(lv_scr_act(), nullptr)); lv_obj_set_size(backgroundSections[i], LV_HOR_RES, LV_VER_RES / numBackgrounds); lv_obj_set_pos(backgroundSections[i], 0, i * LV_VER_RES / numBackgrounds); lv_obj_set_style_local_radius(backgroundSections[i], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, 0); @@ -296,9 +304,9 @@ void WatchFacePrideFlag::UpdateScreen(Pinetime::Controllers::Settings::PrideFlag break; case 2: numBackgrounds = 5; - backgroundSections = new lv_obj_t*[numBackgrounds]; + backgroundSections.reserve(numBackgrounds); for (int i = 0; i < numBackgrounds; i++) { - backgroundSections[i] = lv_obj_create(lv_scr_act(), nullptr); + backgroundSections.push_back(lv_obj_create(lv_scr_act(), nullptr)); lv_obj_set_size(backgroundSections[i], LV_HOR_RES, LV_VER_RES / numBackgrounds); lv_obj_set_pos(backgroundSections[i], 0, i * LV_VER_RES / numBackgrounds); lv_obj_set_style_local_radius(backgroundSections[i], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, 0); @@ -319,9 +327,9 @@ void WatchFacePrideFlag::UpdateScreen(Pinetime::Controllers::Settings::PrideFlag break; case 3: numBackgrounds = 7; - backgroundSections = new lv_obj_t*[numBackgrounds]; + backgroundSections.reserve(numBackgrounds); for (int i = 0; i < numBackgrounds; i++) { - backgroundSections[i] = lv_obj_create(lv_scr_act(), nullptr); + backgroundSections.push_back(lv_obj_create(lv_scr_act(), nullptr)); lv_obj_set_size(backgroundSections[i], LV_HOR_RES, (LV_VER_RES / numBackgrounds) + 1); lv_obj_set_pos(backgroundSections[i], 0, i * LV_VER_RES / numBackgrounds); lv_obj_set_style_local_radius(backgroundSections[i], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, 0); diff --git a/src/displayapp/screens/WatchFacePrideFlag.h b/src/displayapp/screens/WatchFacePrideFlag.h index a66e054179..1d3fbc7214 100644 --- a/src/displayapp/screens/WatchFacePrideFlag.h +++ b/src/displayapp/screens/WatchFacePrideFlag.h @@ -2,13 +2,10 @@ #include #include +#include #include -#include -#include +#include "displayapp/Controllers.h" #include "displayapp/screens/Screen.h" -#include "displayapp/widgets/StatusIcons.h" -#include "components/datetime/DateTimeController.h" -#include "components/ble/BleController.h" #include "utility/DirtyValue.h" namespace Pinetime { @@ -57,12 +54,8 @@ namespace Pinetime { static Pinetime::Controllers::Settings::PrideFlag GetPrevious(Controllers::Settings::PrideFlag prideFlag); uint32_t savedTick = 0; - bool initialized = false; - lv_obj_t** backgroundSections; - char labelTimeColour[8] = "#000000"; - char defaultTopLabelColour[8] = "#ffffff"; - char defaultBottomLabelColour[8] = "#ffffff"; + std::vector backgroundSections; bool themeChanged = false; uint8_t numBackgrounds; lv_obj_t* bluetoothStatus; @@ -76,22 +69,6 @@ namespace Pinetime { lv_obj_t* btnNextFlag; lv_obj_t* btnPrevFlag; - static constexpr lv_color_t lightBlue = LV_COLOR_MAKE(0x00, 0xbf, 0xf3); - static constexpr lv_color_t lightPink = LV_COLOR_MAKE(0xf4, 0x9a, 0xc1); - static constexpr lv_color_t hotPink = LV_COLOR_MAKE(0xd6, 0x02, 0x70); - static constexpr lv_color_t grayPurple = LV_COLOR_MAKE(0x9b, 0x4f, 0x96); - static constexpr lv_color_t darkBlue = LV_COLOR_MAKE(0x00, 0x38, 0xa8); - static constexpr lv_color_t orange = LV_COLOR_MAKE(0xef, 0x76, 0x27); - static constexpr lv_color_t lightOrange = LV_COLOR_MAKE(0xff, 0x9b, 0x55); - static constexpr lv_color_t lightPurple = LV_COLOR_MAKE(0xd4, 0x61, 0xa6); - static constexpr lv_color_t darkPurple = LV_COLOR_MAKE(0xb5, 0x56, 0x90); - static constexpr lv_color_t magenta = LV_COLOR_MAKE(0xa5, 0x00, 0x62); - static constexpr lv_color_t darkGreen = LV_COLOR_MAKE(0x07, 0x8d, 0x70); - static constexpr lv_color_t cyan = LV_COLOR_MAKE(0x26, 0xce, 0xaa); - static constexpr lv_color_t lightGreen = LV_COLOR_MAKE(0x98, 0xe8, 0xc1); - static constexpr lv_color_t indigo = LV_COLOR_MAKE(0x50, 0x49, 0xcc); - static constexpr lv_color_t steelBlue = LV_COLOR_MAKE(0x3d, 0x1a, 0x78); - Controllers::DateTime& dateTimeController; const Controllers::Battery& batteryController; const Controllers::Ble bleController; From 5cd30acd7456e3d9bc4cc14fb748e49931636f29 Mon Sep 17 00:00:00 2001 From: Eshe Date: Tue, 17 Jun 2025 13:53:19 +0100 Subject: [PATCH 20/26] - Moved all flag-specific data into a new FlagData class - Implemented all suggested changes --- src/displayapp/screens/WatchFacePrideFlag.cpp | 205 +++++++----------- src/displayapp/screens/WatchFacePrideFlag.h | 47 +++- 2 files changed, 113 insertions(+), 139 deletions(-) diff --git a/src/displayapp/screens/WatchFacePrideFlag.cpp b/src/displayapp/screens/WatchFacePrideFlag.cpp index 3ed39b08d9..6feb310071 100644 --- a/src/displayapp/screens/WatchFacePrideFlag.cpp +++ b/src/displayapp/screens/WatchFacePrideFlag.cpp @@ -1,32 +1,44 @@ #include "displayapp/screens/WatchFacePrideFlag.h" #include +#include "components/battery/BatteryController.h" +#include "components/ble/BleController.h" #include "displayapp/screens/Symbols.h" using namespace Pinetime::Applications::Screens; namespace { - void event_handler(lv_obj_t* obj, lv_event_t event) { + void EventHandler(lv_obj_t* obj, lv_event_t event) { auto* screen = static_cast(obj->user_data); screen->UpdateSelected(obj, event); } - char labelTimeColour[8] = "#000000"; - char defaultTopLabelColour[8] = "#ffffff"; - char defaultBottomLabelColour[8] = "#ffffff"; - static constexpr lv_color_t lightBlue = LV_COLOR_MAKE(0x00, 0xbf, 0xf3); - static constexpr lv_color_t lightPink = LV_COLOR_MAKE(0xf4, 0x9a, 0xc1); - static constexpr lv_color_t hotPink = LV_COLOR_MAKE(0xd6, 0x02, 0x70); - static constexpr lv_color_t grayPurple = LV_COLOR_MAKE(0x9b, 0x4f, 0x96); - static constexpr lv_color_t darkBlue = LV_COLOR_MAKE(0x00, 0x38, 0xa8); - static constexpr lv_color_t orange = LV_COLOR_MAKE(0xef, 0x76, 0x27); - static constexpr lv_color_t lightOrange = LV_COLOR_MAKE(0xff, 0x9b, 0x55); - static constexpr lv_color_t lightPurple = LV_COLOR_MAKE(0xd4, 0x61, 0xa6); - static constexpr lv_color_t darkPurple = LV_COLOR_MAKE(0xb5, 0x56, 0x90); - static constexpr lv_color_t magenta = LV_COLOR_MAKE(0xa5, 0x00, 0x62); - static constexpr lv_color_t darkGreen = LV_COLOR_MAKE(0x07, 0x8d, 0x70); - static constexpr lv_color_t cyan = LV_COLOR_MAKE(0x26, 0xce, 0xaa); - static constexpr lv_color_t lightGreen = LV_COLOR_MAKE(0x98, 0xe8, 0xc1); - static constexpr lv_color_t indigo = LV_COLOR_MAKE(0x50, 0x49, 0xcc); - static constexpr lv_color_t steelBlue = LV_COLOR_MAKE(0x3d, 0x1a, 0x78); + + constexpr lv_color_t lightBlue = LV_COLOR_MAKE(0x00, 0xbf, 0xf3); + constexpr lv_color_t lightPink = LV_COLOR_MAKE(0xf4, 0x9a, 0xc1); + constexpr lv_color_t hotPink = LV_COLOR_MAKE(0xd6, 0x02, 0x70); + constexpr lv_color_t grayPurple = LV_COLOR_MAKE(0x9b, 0x4f, 0x96); + constexpr lv_color_t darkBlue = LV_COLOR_MAKE(0x00, 0x38, 0xa8); + constexpr lv_color_t orange = LV_COLOR_MAKE(0xef, 0x76, 0x27); + constexpr lv_color_t lightOrange = LV_COLOR_MAKE(0xff, 0x9b, 0x55); + constexpr lv_color_t lightPurple = LV_COLOR_MAKE(0xd4, 0x61, 0xa6); + constexpr lv_color_t darkPurple = LV_COLOR_MAKE(0xb5, 0x56, 0x90); + constexpr lv_color_t magenta = LV_COLOR_MAKE(0xa5, 0x00, 0x62); + constexpr lv_color_t darkGreen = LV_COLOR_MAKE(0x07, 0x8d, 0x70); + constexpr lv_color_t cyan = LV_COLOR_MAKE(0x26, 0xce, 0xaa); + constexpr lv_color_t lightGreen = LV_COLOR_MAKE(0x98, 0xe8, 0xc1); + constexpr lv_color_t indigo = LV_COLOR_MAKE(0x50, 0x49, 0xcc); + constexpr lv_color_t steelBlue = LV_COLOR_MAKE(0x3d, 0x1a, 0x78); + constexpr std::array gayColours {darkGreen, cyan, lightGreen, LV_COLOR_WHITE, lightBlue, indigo, steelBlue}; + constexpr std::array transColours {lightBlue, lightPink, LV_COLOR_WHITE, lightPink, lightBlue}; + constexpr std::array biColours {hotPink, hotPink, grayPurple, darkBlue, darkBlue}; + constexpr std::array lesbianColours {LV_COLOR_RED, orange, lightOrange, LV_COLOR_WHITE, lightPurple, darkPurple, magenta}; + constexpr WatchFacePrideFlag::PrideFlagData<7> gayFlagData = + WatchFacePrideFlag::PrideFlagData(gayColours, LV_COLOR_BLACK, LV_COLOR_BLACK, LV_COLOR_WHITE); + constexpr WatchFacePrideFlag::PrideFlagData<5> transFlagData = + WatchFacePrideFlag::PrideFlagData(transColours, LV_COLOR_WHITE, LV_COLOR_BLACK, LV_COLOR_WHITE); + constexpr WatchFacePrideFlag::PrideFlagData<5> biFlagData = + WatchFacePrideFlag::PrideFlagData(biColours, LV_COLOR_BLACK, LV_COLOR_WHITE, LV_COLOR_BLACK); + constexpr WatchFacePrideFlag::PrideFlagData<7> lesbianFlagData = + WatchFacePrideFlag::PrideFlagData(lesbianColours, LV_COLOR_WHITE, LV_COLOR_BLACK, LV_COLOR_WHITE); } WatchFacePrideFlag::WatchFacePrideFlag(Controllers::DateTime& dateTimeController, @@ -63,7 +75,7 @@ WatchFacePrideFlag::WatchFacePrideFlag(Controllers::DateTime& dateTimeController lv_obj_set_style_local_bg_opa(btnClose, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50); lv_obj_t* lblClose = lv_label_create(btnClose, nullptr); lv_label_set_text_static(lblClose, "X"); - lv_obj_set_event_cb(btnClose, event_handler); + lv_obj_set_event_cb(btnClose, EventHandler); lv_obj_set_hidden(btnClose, true); btnNextFlag = lv_btn_create(lv_scr_act(), nullptr); @@ -73,7 +85,7 @@ WatchFacePrideFlag::WatchFacePrideFlag(Controllers::DateTime& dateTimeController lv_obj_set_style_local_bg_opa(btnNextFlag, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50); lv_obj_t* lblNextBG = lv_label_create(btnNextFlag, nullptr); lv_label_set_text_static(lblNextBG, ">"); - lv_obj_set_event_cb(btnNextFlag, event_handler); + lv_obj_set_event_cb(btnNextFlag, EventHandler); lv_obj_set_hidden(btnNextFlag, true); btnPrevFlag = lv_btn_create(lv_scr_act(), nullptr); @@ -83,7 +95,7 @@ WatchFacePrideFlag::WatchFacePrideFlag(Controllers::DateTime& dateTimeController lv_obj_set_style_local_bg_opa(btnPrevFlag, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_OPA_50); lv_obj_t* lblPrevFlag = lv_label_create(btnPrevFlag, nullptr); lv_label_set_text_static(lblPrevFlag, "<"); - lv_obj_set_event_cb(btnPrevFlag, event_handler); + lv_obj_set_event_cb(btnPrevFlag, EventHandler); lv_obj_set_hidden(btnPrevFlag, true); labelDate = lv_label_create(lv_scr_act(), nullptr); @@ -125,10 +137,10 @@ bool WatchFacePrideFlag::OnTouchEvent(Pinetime::Applications::TouchEvents event) lv_obj_set_hidden(btnPrevFlag, false); lv_obj_set_hidden(btnNextFlag, false); lv_obj_set_hidden(btnClose, false); - savedTick = lv_tick_get(); + savedTick = xTaskGetTickCount(); return true; } - if ((event == Pinetime::Applications::TouchEvents::DoubleTap) && (lv_obj_get_hidden(btnClose) == false)) { + if ((event == Pinetime::Applications::TouchEvents::DoubleTap) && !lv_obj_get_hidden(btnClose)) { return true; } return false; @@ -146,7 +158,7 @@ void WatchFacePrideFlag::Refresh() { bleState = bleController.IsConnected(); batteryPercentRemaining = batteryController.PercentRemaining(); if (batteryPercentRemaining.IsUpdated() || powerPresent.IsUpdated() || themeChanged) { - lv_label_set_text_fmt(batteryValue, "%s %d%%#", defaultTopLabelColour, batteryPercentRemaining.Get()); + lv_label_set_text_fmt(batteryValue, "%d%%", batteryPercentRemaining.Get()); if (batteryController.IsPowerPresent()) { lv_label_ins_text(batteryValue, LV_LABEL_POS_LAST, " Charging"); } @@ -186,7 +198,7 @@ void WatchFacePrideFlag::Refresh() { } } - lv_label_set_text_fmt(labelTime, "%s %02d:%02d:%02d#", labelTimeColour, hour, minute, second); + lv_label_set_text_fmt(labelTime, "%02d:%02d:%02d", hour, minute, second); currentDate = std::chrono::time_point_cast(currentDateTime.Get()); if (currentDate.IsUpdated() || ampmChar.IsUpdated() || themeChanged) { @@ -194,22 +206,18 @@ void WatchFacePrideFlag::Refresh() { Controllers::DateTime::Months month = dateTimeController.Month(); uint8_t day = dateTimeController.Day(); Controllers::DateTime::Days dayOfWeek = dateTimeController.DayOfWeek(); - lv_label_set_text_fmt(labelDate, "%s %02d-%02d-%04d#", defaultTopLabelColour, day, static_cast(month), year); + lv_label_set_text_fmt(labelDate, "%02d-%02d-%04d", day, static_cast(month), year); if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) { - lv_label_set_text_fmt(labelDay, - "%s %s %s#", - defaultBottomLabelColour, - dateTimeController.DayOfWeekToStringLow(dayOfWeek), - ampmChar); + lv_label_set_text_fmt(labelDay, "%s %s", dateTimeController.DayOfWeekToStringLow(dayOfWeek), ampmChar); } else { - lv_label_set_text_fmt(labelDay, "%s %s#", defaultBottomLabelColour, dateTimeController.DayOfWeekToStringLow(dayOfWeek)); + lv_label_set_text_fmt(labelDay, "%s", dateTimeController.DayOfWeekToStringLow(dayOfWeek)); } } } stepCount = motionController.NbSteps(); if (stepCount.IsUpdated() || themeChanged) { - lv_label_set_text_fmt(stepValue, "%s %lu steps#", defaultBottomLabelColour, stepCount.Get()); + lv_label_set_text_fmt(stepValue, "%lu steps", stepCount.Get()); } if (themeChanged) themeChanged = false; @@ -246,109 +254,46 @@ bool WatchFacePrideFlag::OnButtonPushed() { return false; } +template +void WatchFacePrideFlag::UseFlagData(PrideFlagData flagData) { + backgroundSections.reserve(N); + for (int i = 0; i < N; i++) { + backgroundSections.push_back(lv_obj_create(lv_scr_act(), nullptr)); + lv_obj_set_style_local_bg_color(backgroundSections[i], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, flagData.sectionColours[i]); + lv_obj_set_size(backgroundSections[i], LV_HOR_RES, (LV_VER_RES / N) + 1); + lv_obj_set_pos(backgroundSections[i], 0, i * LV_VER_RES / N); + lv_obj_set_style_local_radius(backgroundSections[i], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, 0); + lv_obj_move_background(backgroundSections[i]); + } + lv_obj_set_style_local_text_color(labelTime, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, flagData.labelTimeColour); + lv_obj_set_style_local_text_color(batteryValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, flagData.defaultTopLabelColour); + lv_obj_set_style_local_text_color(labelDate, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, flagData.defaultTopLabelColour); + lv_obj_set_style_local_text_color(labelDay, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, flagData.defaultBottomLabelColour); + lv_obj_set_style_local_text_color(stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, flagData.defaultBottomLabelColour); + lv_obj_align(batteryValue, lv_scr_act(), LV_ALIGN_CENTER, 0, -2 * flagData.spacing); + lv_obj_align(labelDate, lv_scr_act(), LV_ALIGN_CENTER, 0, -1 * flagData.spacing); + lv_obj_align(labelDay, lv_scr_act(), LV_ALIGN_CENTER, 0, flagData.spacing); + lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_CENTER, 0, 2 * flagData.spacing); +} + void WatchFacePrideFlag::UpdateScreen(Pinetime::Controllers::Settings::PrideFlag prideFlag) { themeChanged = true; - auto prideFlagAsInt = static_cast(prideFlag); - for (int i = 0; i < backgroundSections.size(); i++) { - lv_obj_del(backgroundSections[i]); + for (lv_obj_t* backgroundSection : backgroundSections) { + lv_obj_del(backgroundSection); } backgroundSections.clear(); - switch (prideFlagAsInt) { - case 0: - numBackgrounds = 7; - backgroundSections.reserve(numBackgrounds); - for (int i = 0; i < numBackgrounds; i++) { - backgroundSections.push_back(lv_obj_create(lv_scr_act(), nullptr)); - lv_obj_set_size(backgroundSections[i], LV_HOR_RES, (LV_VER_RES / numBackgrounds) + 1); - lv_obj_set_pos(backgroundSections[i], 0, i * LV_VER_RES / numBackgrounds); - lv_obj_set_style_local_radius(backgroundSections[i], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, 0); - lv_obj_move_background(backgroundSections[i]); - } - lv_obj_set_style_local_bg_color(backgroundSections[0], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, darkGreen); - lv_obj_set_style_local_bg_color(backgroundSections[1], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, cyan); - lv_obj_set_style_local_bg_color(backgroundSections[2], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lightGreen); - lv_obj_set_style_local_bg_color(backgroundSections[3], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE); - lv_obj_set_style_local_bg_color(backgroundSections[4], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lightBlue); - lv_obj_set_style_local_bg_color(backgroundSections[5], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, indigo); - lv_obj_set_style_local_bg_color(backgroundSections[6], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, steelBlue); - lv_obj_align(batteryValue, lv_scr_act(), LV_ALIGN_CENTER, 0, -102); - lv_obj_align(labelDate, lv_scr_act(), LV_ALIGN_CENTER, 0, -51); - lv_obj_align(labelDay, lv_scr_act(), LV_ALIGN_CENTER, 0, 51); - lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_CENTER, 0, 102); - strncpy(labelTimeColour, "#000000", 7); - strncpy(defaultTopLabelColour, "#000000", 7); - strncpy(defaultBottomLabelColour, "#ffffff", 7); + switch (prideFlag) { + case Pinetime::Controllers::Settings::PrideFlag::Gay: + UseFlagData(gayFlagData); break; - case 1: - numBackgrounds = 5; - backgroundSections.reserve(numBackgrounds); - for (int i = 0; i < numBackgrounds; i++) { - backgroundSections.push_back(lv_obj_create(lv_scr_act(), nullptr)); - lv_obj_set_size(backgroundSections[i], LV_HOR_RES, LV_VER_RES / numBackgrounds); - lv_obj_set_pos(backgroundSections[i], 0, i * LV_VER_RES / numBackgrounds); - lv_obj_set_style_local_radius(backgroundSections[i], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, 0); - lv_obj_move_background(backgroundSections[i]); - } - lv_obj_set_style_local_bg_color(backgroundSections[0], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lightBlue); - lv_obj_set_style_local_bg_color(backgroundSections[1], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lightPink); - lv_obj_set_style_local_bg_color(backgroundSections[2], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE); - lv_obj_set_style_local_bg_color(backgroundSections[3], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lightPink); - lv_obj_set_style_local_bg_color(backgroundSections[4], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lightBlue); - lv_obj_align(batteryValue, lv_scr_act(), LV_ALIGN_CENTER, 0, -96); - lv_obj_align(labelDate, lv_scr_act(), LV_ALIGN_CENTER, 0, -48); - lv_obj_align(labelDay, lv_scr_act(), LV_ALIGN_CENTER, 0, 48); - lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_CENTER, 0, 96); - strncpy(labelTimeColour, "#000000", 7); - strncpy(defaultTopLabelColour, "#ffffff", 7); - strncpy(defaultBottomLabelColour, "#ffffff", 7); + case Pinetime::Controllers::Settings::PrideFlag::Trans: + UseFlagData(transFlagData); break; - case 2: - numBackgrounds = 5; - backgroundSections.reserve(numBackgrounds); - for (int i = 0; i < numBackgrounds; i++) { - backgroundSections.push_back(lv_obj_create(lv_scr_act(), nullptr)); - lv_obj_set_size(backgroundSections[i], LV_HOR_RES, LV_VER_RES / numBackgrounds); - lv_obj_set_pos(backgroundSections[i], 0, i * LV_VER_RES / numBackgrounds); - lv_obj_set_style_local_radius(backgroundSections[i], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, 0); - lv_obj_move_background(backgroundSections[i]); - } - lv_obj_set_style_local_bg_color(backgroundSections[0], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, hotPink); - lv_obj_set_style_local_bg_color(backgroundSections[1], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, hotPink); - lv_obj_set_style_local_bg_color(backgroundSections[2], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, grayPurple); - lv_obj_set_style_local_bg_color(backgroundSections[3], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, darkBlue); - lv_obj_set_style_local_bg_color(backgroundSections[4], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, darkBlue); - lv_obj_align(batteryValue, lv_scr_act(), LV_ALIGN_CENTER, 0, -96); - lv_obj_align(labelDate, lv_scr_act(), LV_ALIGN_CENTER, 0, -48); - lv_obj_align(labelDay, lv_scr_act(), LV_ALIGN_CENTER, 0, 48); - lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_CENTER, 0, 96); - strncpy(labelTimeColour, "#ffffff", 7); - strncpy(defaultTopLabelColour, "#000000", 7); - strncpy(defaultBottomLabelColour, "#000000", 7); + case Pinetime::Controllers::Settings::PrideFlag::Bi: + UseFlagData(biFlagData); break; - case 3: - numBackgrounds = 7; - backgroundSections.reserve(numBackgrounds); - for (int i = 0; i < numBackgrounds; i++) { - backgroundSections.push_back(lv_obj_create(lv_scr_act(), nullptr)); - lv_obj_set_size(backgroundSections[i], LV_HOR_RES, (LV_VER_RES / numBackgrounds) + 1); - lv_obj_set_pos(backgroundSections[i], 0, i * LV_VER_RES / numBackgrounds); - lv_obj_set_style_local_radius(backgroundSections[i], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, 0); - lv_obj_move_background(backgroundSections[i]); - } - lv_obj_set_style_local_bg_color(backgroundSections[0], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_RED); - lv_obj_set_style_local_bg_color(backgroundSections[1], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, orange); - lv_obj_set_style_local_bg_color(backgroundSections[2], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lightOrange); - lv_obj_set_style_local_bg_color(backgroundSections[3], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_WHITE); - lv_obj_set_style_local_bg_color(backgroundSections[4], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, lightPurple); - lv_obj_set_style_local_bg_color(backgroundSections[5], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, darkPurple); - lv_obj_set_style_local_bg_color(backgroundSections[6], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, magenta); - lv_obj_align(batteryValue, lv_scr_act(), LV_ALIGN_CENTER, 0, -102); - lv_obj_align(labelDate, lv_scr_act(), LV_ALIGN_CENTER, 0, -51); - lv_obj_align(labelDay, lv_scr_act(), LV_ALIGN_CENTER, 0, 51); - lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_CENTER, 0, 102); - strncpy(labelTimeColour, "#000000", 7); - strncpy(defaultTopLabelColour, "#ffffff", 7); - strncpy(defaultBottomLabelColour, "#ffffff", 7); + case Pinetime::Controllers::Settings::PrideFlag::Lesbian: + UseFlagData(lesbianFlagData); break; } } diff --git a/src/displayapp/screens/WatchFacePrideFlag.h b/src/displayapp/screens/WatchFacePrideFlag.h index 1d3fbc7214..8115359f70 100644 --- a/src/displayapp/screens/WatchFacePrideFlag.h +++ b/src/displayapp/screens/WatchFacePrideFlag.h @@ -4,9 +4,12 @@ #include #include #include -#include "displayapp/Controllers.h" +#include +#include #include "displayapp/screens/Screen.h" #include "utility/DirtyValue.h" +#include "components/settings/Settings.h" +#include "components/battery/BatteryController.h" namespace Pinetime { namespace Controllers { @@ -30,6 +33,29 @@ namespace Pinetime { Controllers::MotionController& motionController); ~WatchFacePrideFlag() override; + template + class PrideFlagData { + public: + constexpr PrideFlagData(const std::array& sectionColours, + lv_color_t defaultTopLabelColour, + lv_color_t labelTimeColour, + lv_color_t defaultBottomLabelColour) { + this->sectionColours = sectionColours; + this->defaultTopLabelColour = defaultTopLabelColour; + this->labelTimeColour = labelTimeColour; + this->defaultBottomLabelColour = defaultBottomLabelColour; + // Space between adjacent text values calculated according to the following equation + spacing = (uint8_t) (1.5f * ((float) N) + 40.5); + } + + std::array sectionColours; + lv_color_t defaultTopLabelColour; + lv_color_t labelTimeColour; + lv_color_t defaultBottomLabelColour; + uint8_t spacing; + const std::size_t numSections = N; + }; + bool OnTouchEvent(TouchEvents event) override; bool OnButtonPushed() override; @@ -37,15 +63,18 @@ namespace Pinetime { void UpdateSelected(lv_obj_t* object, lv_event_t event); + template + void UseFlagData(PrideFlagData flagData); + void UpdateScreen(Pinetime::Controllers::Settings::PrideFlag); private: - Utility::DirtyValue batteryPercentRemaining {}; - Utility::DirtyValue powerPresent {}; - Utility::DirtyValue bleState {}; - Utility::DirtyValue> currentDateTime {}; - Utility::DirtyValue stepCount {}; - Utility::DirtyValue notificationState {}; + Utility::DirtyValue batteryPercentRemaining; + Utility::DirtyValue powerPresent; + Utility::DirtyValue bleState; + Utility::DirtyValue> currentDateTime; + Utility::DirtyValue stepCount; + Utility::DirtyValue notificationState; Utility::DirtyValue> currentDate; // Must be wrapped in a dirty value, since it is displayed in the day but is updated twice a day Utility::DirtyValue ampmChar {"AM"}; @@ -53,7 +82,7 @@ namespace Pinetime { static Pinetime::Controllers::Settings::PrideFlag GetNext(Controllers::Settings::PrideFlag prideFlag); static Pinetime::Controllers::Settings::PrideFlag GetPrevious(Controllers::Settings::PrideFlag prideFlag); - uint32_t savedTick = 0; + TickType_t savedTick = 0; std::vector backgroundSections; bool themeChanged = false; @@ -71,7 +100,7 @@ namespace Pinetime { Controllers::DateTime& dateTimeController; const Controllers::Battery& batteryController; - const Controllers::Ble bleController; + const Controllers::Ble& bleController; Controllers::NotificationManager& notificationManager; Controllers::Settings& settingsController; Controllers::MotionController& motionController; From f31456974d91fd96773361f8e375977e899c1dbd Mon Sep 17 00:00:00 2001 From: Eshe Date: Tue, 17 Jun 2025 14:07:51 +0100 Subject: [PATCH 21/26] Fixed signedness error in background section for-loop --- src/displayapp/screens/WatchFacePrideFlag.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/displayapp/screens/WatchFacePrideFlag.cpp b/src/displayapp/screens/WatchFacePrideFlag.cpp index 6feb310071..51dfce6b22 100644 --- a/src/displayapp/screens/WatchFacePrideFlag.cpp +++ b/src/displayapp/screens/WatchFacePrideFlag.cpp @@ -257,7 +257,7 @@ bool WatchFacePrideFlag::OnButtonPushed() { template void WatchFacePrideFlag::UseFlagData(PrideFlagData flagData) { backgroundSections.reserve(N); - for (int i = 0; i < N; i++) { + for (uint8_t i = 0; i < N; i++) { backgroundSections.push_back(lv_obj_create(lv_scr_act(), nullptr)); lv_obj_set_style_local_bg_color(backgroundSections[i], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, flagData.sectionColours[i]); lv_obj_set_size(backgroundSections[i], LV_HOR_RES, (LV_VER_RES / N) + 1); From d0217ba994d579f43d030de98cd03ffb0c9d6379 Mon Sep 17 00:00:00 2001 From: Eshe Date: Tue, 17 Jun 2025 14:30:32 +0100 Subject: [PATCH 22/26] Renamed notificationIcon to notificationText, and changed security of UseFlagData to private --- src/displayapp/screens/WatchFacePrideFlag.cpp | 10 +++++----- src/displayapp/screens/WatchFacePrideFlag.h | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/displayapp/screens/WatchFacePrideFlag.cpp b/src/displayapp/screens/WatchFacePrideFlag.cpp index 51dfce6b22..ac29ac1772 100644 --- a/src/displayapp/screens/WatchFacePrideFlag.cpp +++ b/src/displayapp/screens/WatchFacePrideFlag.cpp @@ -64,9 +64,9 @@ WatchFacePrideFlag::WatchFacePrideFlag(Controllers::DateTime& dateTimeController lv_label_set_align(batteryValue, LV_LABEL_ALIGN_CENTER); lv_obj_set_auto_realign(batteryValue, true); - notificationIcon = lv_label_create(lv_scr_act(), nullptr); - lv_obj_align(notificationIcon, nullptr, LV_ALIGN_IN_LEFT_MID, 0, -110); - lv_obj_set_style_local_text_color(notificationIcon, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK); + notificationText = lv_label_create(lv_scr_act(), nullptr); + lv_obj_align(notificationText, nullptr, LV_ALIGN_IN_LEFT_MID, 0, -110); + lv_obj_set_style_local_text_color(notificationText, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, LV_COLOR_BLACK); btnClose = lv_btn_create(lv_scr_act(), nullptr); btnClose->user_data = this; @@ -174,9 +174,9 @@ void WatchFacePrideFlag::Refresh() { notificationState = notificationManager.AreNewNotificationsAvailable(); if (notificationState.IsUpdated()) { if (notificationState.Get()) { - lv_label_set_text_static(notificationIcon, "You have\nmail!"); + lv_label_set_text_static(notificationText, "You have\nmail!"); } else { - lv_label_set_text_static(notificationIcon, ""); + lv_label_set_text_static(notificationText, ""); } } diff --git a/src/displayapp/screens/WatchFacePrideFlag.h b/src/displayapp/screens/WatchFacePrideFlag.h index 8115359f70..340b7248ce 100644 --- a/src/displayapp/screens/WatchFacePrideFlag.h +++ b/src/displayapp/screens/WatchFacePrideFlag.h @@ -63,12 +63,12 @@ namespace Pinetime { void UpdateSelected(lv_obj_t* object, lv_event_t event); - template - void UseFlagData(PrideFlagData flagData); - void UpdateScreen(Pinetime::Controllers::Settings::PrideFlag); private: + template + void UseFlagData(PrideFlagData flagData); + Utility::DirtyValue batteryPercentRemaining; Utility::DirtyValue powerPresent; Utility::DirtyValue bleState; @@ -93,7 +93,7 @@ namespace Pinetime { lv_obj_t* labelDay; lv_obj_t* batteryValue; lv_obj_t* stepValue; - lv_obj_t* notificationIcon; + lv_obj_t* notificationText; lv_obj_t* btnClose; lv_obj_t* btnNextFlag; lv_obj_t* btnPrevFlag; From b582d3ddbd0abb7182c98675737e6468ea164f8e Mon Sep 17 00:00:00 2001 From: Eshe Date: Tue, 17 Jun 2025 14:43:54 +0100 Subject: [PATCH 23/26] Swapped out C-style casts for C++ style --- src/displayapp/screens/WatchFacePrideFlag.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/displayapp/screens/WatchFacePrideFlag.h b/src/displayapp/screens/WatchFacePrideFlag.h index 340b7248ce..c26f7d2e68 100644 --- a/src/displayapp/screens/WatchFacePrideFlag.h +++ b/src/displayapp/screens/WatchFacePrideFlag.h @@ -45,7 +45,7 @@ namespace Pinetime { this->labelTimeColour = labelTimeColour; this->defaultBottomLabelColour = defaultBottomLabelColour; // Space between adjacent text values calculated according to the following equation - spacing = (uint8_t) (1.5f * ((float) N) + 40.5); + spacing = static_cast(1.5f * static_cast(N) + 40.5f); } std::array sectionColours; From 5643c2e538550b654318bf4eb51d5b115993c32c Mon Sep 17 00:00:00 2001 From: Eshe Date: Tue, 17 Jun 2025 15:01:40 +0100 Subject: [PATCH 24/26] Changed UpdateScreen to private --- src/displayapp/screens/WatchFacePrideFlag.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/displayapp/screens/WatchFacePrideFlag.h b/src/displayapp/screens/WatchFacePrideFlag.h index c26f7d2e68..adb886de05 100644 --- a/src/displayapp/screens/WatchFacePrideFlag.h +++ b/src/displayapp/screens/WatchFacePrideFlag.h @@ -63,9 +63,9 @@ namespace Pinetime { void UpdateSelected(lv_obj_t* object, lv_event_t event); + private: void UpdateScreen(Pinetime::Controllers::Settings::PrideFlag); - private: template void UseFlagData(PrideFlagData flagData); From 1c6d4f03b522afc1d80404792c7209f6e33a82f9 Mon Sep 17 00:00:00 2001 From: Eshe Date: Wed, 18 Jun 2025 14:13:32 +0100 Subject: [PATCH 25/26] Implemented suggested changes (moving PrideFlagData into cpp, making constant variables const, and generally tidying up) --- src/displayapp/screens/WatchFacePrideFlag.cpp | 150 ++++++++++-------- src/displayapp/screens/WatchFacePrideFlag.h | 30 ---- 2 files changed, 83 insertions(+), 97 deletions(-) diff --git a/src/displayapp/screens/WatchFacePrideFlag.cpp b/src/displayapp/screens/WatchFacePrideFlag.cpp index ac29ac1772..16d1339e13 100644 --- a/src/displayapp/screens/WatchFacePrideFlag.cpp +++ b/src/displayapp/screens/WatchFacePrideFlag.cpp @@ -12,6 +12,50 @@ namespace { screen->UpdateSelected(obj, event); } + Pinetime::Controllers::Settings::PrideFlag GetNext(Pinetime::Controllers::Settings::PrideFlag prideFlag) { + const auto prideFlagAsInt = static_cast(prideFlag); + Pinetime::Controllers::Settings::PrideFlag nextFlag; + if (prideFlagAsInt < 3) { + nextFlag = static_cast(prideFlagAsInt + 1); + } else { + nextFlag = static_cast(0); + } + return nextFlag; + } + + Pinetime::Controllers::Settings::PrideFlag GetPrevious(Pinetime::Controllers::Settings::PrideFlag prideFlag) { + const auto prideFlagAsInt = static_cast(prideFlag); + Pinetime::Controllers::Settings::PrideFlag prevFlag; + if (prideFlagAsInt > 0) { + prevFlag = static_cast(prideFlagAsInt - 1); + } else { + prevFlag = static_cast(3); + } + return prevFlag; + } + + template + class PrideFlagData { + public: + constexpr PrideFlagData(const std::array& sectionColours, + lv_color_t defaultTopLabelColour, + lv_color_t labelTimeColour, + lv_color_t defaultBottomLabelColour) + : sectionColours {sectionColours}, + defaultTopLabelColour {defaultTopLabelColour}, + labelTimeColour {labelTimeColour}, + defaultBottomLabelColour {defaultBottomLabelColour} { + // Space between adjacent text values calculated according to the following equation + spacing = static_cast(1.5f * static_cast(N) + 40.5f); + } + + std::array sectionColours; + lv_color_t defaultTopLabelColour; + lv_color_t labelTimeColour; + lv_color_t defaultBottomLabelColour; + uint8_t spacing; + }; + constexpr lv_color_t lightBlue = LV_COLOR_MAKE(0x00, 0xbf, 0xf3); constexpr lv_color_t lightPink = LV_COLOR_MAKE(0xf4, 0x9a, 0xc1); constexpr lv_color_t hotPink = LV_COLOR_MAKE(0xd6, 0x02, 0x70); @@ -31,14 +75,10 @@ namespace { constexpr std::array transColours {lightBlue, lightPink, LV_COLOR_WHITE, lightPink, lightBlue}; constexpr std::array biColours {hotPink, hotPink, grayPurple, darkBlue, darkBlue}; constexpr std::array lesbianColours {LV_COLOR_RED, orange, lightOrange, LV_COLOR_WHITE, lightPurple, darkPurple, magenta}; - constexpr WatchFacePrideFlag::PrideFlagData<7> gayFlagData = - WatchFacePrideFlag::PrideFlagData(gayColours, LV_COLOR_BLACK, LV_COLOR_BLACK, LV_COLOR_WHITE); - constexpr WatchFacePrideFlag::PrideFlagData<5> transFlagData = - WatchFacePrideFlag::PrideFlagData(transColours, LV_COLOR_WHITE, LV_COLOR_BLACK, LV_COLOR_WHITE); - constexpr WatchFacePrideFlag::PrideFlagData<5> biFlagData = - WatchFacePrideFlag::PrideFlagData(biColours, LV_COLOR_BLACK, LV_COLOR_WHITE, LV_COLOR_BLACK); - constexpr WatchFacePrideFlag::PrideFlagData<7> lesbianFlagData = - WatchFacePrideFlag::PrideFlagData(lesbianColours, LV_COLOR_WHITE, LV_COLOR_BLACK, LV_COLOR_WHITE); + constexpr PrideFlagData gayFlagData = PrideFlagData(gayColours, LV_COLOR_BLACK, LV_COLOR_BLACK, LV_COLOR_WHITE); + constexpr PrideFlagData transFlagData = PrideFlagData(transColours, LV_COLOR_WHITE, LV_COLOR_BLACK, LV_COLOR_WHITE); + constexpr PrideFlagData biFlagData = PrideFlagData(biColours, LV_COLOR_BLACK, LV_COLOR_WHITE, LV_COLOR_BLACK); + constexpr PrideFlagData lesbianFlagData = PrideFlagData(lesbianColours, LV_COLOR_WHITE, LV_COLOR_BLACK, LV_COLOR_WHITE); } WatchFacePrideFlag::WatchFacePrideFlag(Controllers::DateTime& dateTimeController, @@ -183,8 +223,8 @@ void WatchFacePrideFlag::Refresh() { currentDateTime = std::chrono::time_point_cast(dateTimeController.CurrentDateTime()); if (currentDateTime.IsUpdated() || themeChanged) { uint8_t hour = dateTimeController.Hours(); - uint8_t minute = dateTimeController.Minutes(); - uint8_t second = dateTimeController.Seconds(); + const uint8_t minute = dateTimeController.Minutes(); + const uint8_t second = dateTimeController.Seconds(); if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) { if (hour == 0) { @@ -202,10 +242,10 @@ void WatchFacePrideFlag::Refresh() { currentDate = std::chrono::time_point_cast(currentDateTime.Get()); if (currentDate.IsUpdated() || ampmChar.IsUpdated() || themeChanged) { - uint16_t year = dateTimeController.Year(); - Controllers::DateTime::Months month = dateTimeController.Month(); - uint8_t day = dateTimeController.Day(); - Controllers::DateTime::Days dayOfWeek = dateTimeController.DayOfWeek(); + const uint16_t year = dateTimeController.Year(); + const Controllers::DateTime::Months month = dateTimeController.Month(); + const uint8_t day = dateTimeController.Day(); + const Controllers::DateTime::Days dayOfWeek = dateTimeController.DayOfWeek(); lv_label_set_text_fmt(labelDate, "%02d-%02d-%04d", day, static_cast(month), year); if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) { lv_label_set_text_fmt(labelDay, "%s %s", dateTimeController.DayOfWeekToStringLow(dayOfWeek), ampmChar); @@ -219,15 +259,15 @@ void WatchFacePrideFlag::Refresh() { if (stepCount.IsUpdated() || themeChanged) { lv_label_set_text_fmt(stepValue, "%lu steps", stepCount.Get()); } - if (themeChanged) + if (themeChanged) { themeChanged = false; + } } void WatchFacePrideFlag::UpdateSelected(lv_obj_t* object, lv_event_t event) { - auto valueFlag = settingsController.GetPrideFlag(); - bool flagChanged = false; - if (event == LV_EVENT_CLICKED) { + auto valueFlag = settingsController.GetPrideFlag(); + bool flagChanged = false; if (object == btnClose) { CloseMenu(); } @@ -254,29 +294,27 @@ bool WatchFacePrideFlag::OnButtonPushed() { return false; } -template -void WatchFacePrideFlag::UseFlagData(PrideFlagData flagData) { - backgroundSections.reserve(N); - for (uint8_t i = 0; i < N; i++) { - backgroundSections.push_back(lv_obj_create(lv_scr_act(), nullptr)); - lv_obj_set_style_local_bg_color(backgroundSections[i], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, flagData.sectionColours[i]); - lv_obj_set_size(backgroundSections[i], LV_HOR_RES, (LV_VER_RES / N) + 1); - lv_obj_set_pos(backgroundSections[i], 0, i * LV_VER_RES / N); - lv_obj_set_style_local_radius(backgroundSections[i], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, 0); - lv_obj_move_background(backgroundSections[i]); - } - lv_obj_set_style_local_text_color(labelTime, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, flagData.labelTimeColour); - lv_obj_set_style_local_text_color(batteryValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, flagData.defaultTopLabelColour); - lv_obj_set_style_local_text_color(labelDate, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, flagData.defaultTopLabelColour); - lv_obj_set_style_local_text_color(labelDay, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, flagData.defaultBottomLabelColour); - lv_obj_set_style_local_text_color(stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, flagData.defaultBottomLabelColour); - lv_obj_align(batteryValue, lv_scr_act(), LV_ALIGN_CENTER, 0, -2 * flagData.spacing); - lv_obj_align(labelDate, lv_scr_act(), LV_ALIGN_CENTER, 0, -1 * flagData.spacing); - lv_obj_align(labelDay, lv_scr_act(), LV_ALIGN_CENTER, 0, flagData.spacing); - lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_CENTER, 0, 2 * flagData.spacing); -} - -void WatchFacePrideFlag::UpdateScreen(Pinetime::Controllers::Settings::PrideFlag prideFlag) { +void WatchFacePrideFlag::UpdateScreen(const Pinetime::Controllers::Settings::PrideFlag prideFlag) { + auto UseFlagData = [this](PrideFlagData flagData) { + backgroundSections.reserve(N); + for (size_t i = 0; i < N; i++) { + backgroundSections.push_back(lv_obj_create(lv_scr_act(), nullptr)); + lv_obj_set_style_local_bg_color(backgroundSections[i], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, flagData.sectionColours[i]); + lv_obj_set_size(backgroundSections[i], LV_HOR_RES, (LV_VER_RES / N) + 1); + lv_obj_set_pos(backgroundSections[i], 0, i * LV_VER_RES / N); + lv_obj_set_style_local_radius(backgroundSections[i], LV_OBJ_PART_MAIN, LV_STATE_DEFAULT, 0); + lv_obj_move_background(backgroundSections[i]); + } + lv_obj_set_style_local_text_color(labelTime, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, flagData.labelTimeColour); + lv_obj_set_style_local_text_color(batteryValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, flagData.defaultTopLabelColour); + lv_obj_set_style_local_text_color(labelDate, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, flagData.defaultTopLabelColour); + lv_obj_set_style_local_text_color(labelDay, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, flagData.defaultBottomLabelColour); + lv_obj_set_style_local_text_color(stepValue, LV_LABEL_PART_MAIN, LV_STATE_DEFAULT, flagData.defaultBottomLabelColour); + lv_obj_align(batteryValue, lv_scr_act(), LV_ALIGN_CENTER, 0, -2 * flagData.spacing); + lv_obj_align(labelDate, lv_scr_act(), LV_ALIGN_CENTER, 0, -1 * flagData.spacing); + lv_obj_align(labelDay, lv_scr_act(), LV_ALIGN_CENTER, 0, flagData.spacing); + lv_obj_align(stepValue, lv_scr_act(), LV_ALIGN_CENTER, 0, 2 * flagData.spacing); + }; themeChanged = true; for (lv_obj_t* backgroundSection : backgroundSections) { lv_obj_del(backgroundSection); @@ -284,38 +322,16 @@ void WatchFacePrideFlag::UpdateScreen(Pinetime::Controllers::Settings::PrideFlag backgroundSections.clear(); switch (prideFlag) { case Pinetime::Controllers::Settings::PrideFlag::Gay: - UseFlagData(gayFlagData); + UseFlagData(gayFlagData); break; case Pinetime::Controllers::Settings::PrideFlag::Trans: - UseFlagData(transFlagData); + UseFlagData(transFlagData); break; case Pinetime::Controllers::Settings::PrideFlag::Bi: - UseFlagData(biFlagData); + UseFlagData(biFlagData); break; case Pinetime::Controllers::Settings::PrideFlag::Lesbian: - UseFlagData(lesbianFlagData); + UseFlagData(lesbianFlagData); break; } } - -Pinetime::Controllers::Settings::PrideFlag WatchFacePrideFlag::GetNext(Pinetime::Controllers::Settings::PrideFlag prideFlag) { - auto prideFlagAsInt = static_cast(prideFlag); - Pinetime::Controllers::Settings::PrideFlag nextFlag; - if (prideFlagAsInt < 3) { - nextFlag = static_cast(prideFlagAsInt + 1); - } else { - nextFlag = static_cast(0); - } - return nextFlag; -} - -Pinetime::Controllers::Settings::PrideFlag WatchFacePrideFlag::GetPrevious(Pinetime::Controllers::Settings::PrideFlag prideFlag) { - auto prideFlagAsInt = static_cast(prideFlag); - Pinetime::Controllers::Settings::PrideFlag prevFlag; - if (prideFlagAsInt > 0) { - prevFlag = static_cast(prideFlagAsInt - 1); - } else { - prevFlag = static_cast(3); - } - return prevFlag; -} diff --git a/src/displayapp/screens/WatchFacePrideFlag.h b/src/displayapp/screens/WatchFacePrideFlag.h index adb886de05..10a94e8b4f 100644 --- a/src/displayapp/screens/WatchFacePrideFlag.h +++ b/src/displayapp/screens/WatchFacePrideFlag.h @@ -33,29 +33,6 @@ namespace Pinetime { Controllers::MotionController& motionController); ~WatchFacePrideFlag() override; - template - class PrideFlagData { - public: - constexpr PrideFlagData(const std::array& sectionColours, - lv_color_t defaultTopLabelColour, - lv_color_t labelTimeColour, - lv_color_t defaultBottomLabelColour) { - this->sectionColours = sectionColours; - this->defaultTopLabelColour = defaultTopLabelColour; - this->labelTimeColour = labelTimeColour; - this->defaultBottomLabelColour = defaultBottomLabelColour; - // Space between adjacent text values calculated according to the following equation - spacing = static_cast(1.5f * static_cast(N) + 40.5f); - } - - std::array sectionColours; - lv_color_t defaultTopLabelColour; - lv_color_t labelTimeColour; - lv_color_t defaultBottomLabelColour; - uint8_t spacing; - const std::size_t numSections = N; - }; - bool OnTouchEvent(TouchEvents event) override; bool OnButtonPushed() override; @@ -66,9 +43,6 @@ namespace Pinetime { private: void UpdateScreen(Pinetime::Controllers::Settings::PrideFlag); - template - void UseFlagData(PrideFlagData flagData); - Utility::DirtyValue batteryPercentRemaining; Utility::DirtyValue powerPresent; Utility::DirtyValue bleState; @@ -79,14 +53,10 @@ namespace Pinetime { // Must be wrapped in a dirty value, since it is displayed in the day but is updated twice a day Utility::DirtyValue ampmChar {"AM"}; - static Pinetime::Controllers::Settings::PrideFlag GetNext(Controllers::Settings::PrideFlag prideFlag); - static Pinetime::Controllers::Settings::PrideFlag GetPrevious(Controllers::Settings::PrideFlag prideFlag); - TickType_t savedTick = 0; std::vector backgroundSections; bool themeChanged = false; - uint8_t numBackgrounds; lv_obj_t* bluetoothStatus; lv_obj_t* labelTime; lv_obj_t* labelDate; From 8ae772feb6f4632ed9f2348c0a8e3481b906fa4b Mon Sep 17 00:00:00 2001 From: Eshe Date: Wed, 18 Jun 2025 19:23:23 +0100 Subject: [PATCH 26/26] Cleaned up constructor usage --- src/displayapp/screens/WatchFacePrideFlag.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/displayapp/screens/WatchFacePrideFlag.cpp b/src/displayapp/screens/WatchFacePrideFlag.cpp index 16d1339e13..e029c076f4 100644 --- a/src/displayapp/screens/WatchFacePrideFlag.cpp +++ b/src/displayapp/screens/WatchFacePrideFlag.cpp @@ -75,10 +75,10 @@ namespace { constexpr std::array transColours {lightBlue, lightPink, LV_COLOR_WHITE, lightPink, lightBlue}; constexpr std::array biColours {hotPink, hotPink, grayPurple, darkBlue, darkBlue}; constexpr std::array lesbianColours {LV_COLOR_RED, orange, lightOrange, LV_COLOR_WHITE, lightPurple, darkPurple, magenta}; - constexpr PrideFlagData gayFlagData = PrideFlagData(gayColours, LV_COLOR_BLACK, LV_COLOR_BLACK, LV_COLOR_WHITE); - constexpr PrideFlagData transFlagData = PrideFlagData(transColours, LV_COLOR_WHITE, LV_COLOR_BLACK, LV_COLOR_WHITE); - constexpr PrideFlagData biFlagData = PrideFlagData(biColours, LV_COLOR_BLACK, LV_COLOR_WHITE, LV_COLOR_BLACK); - constexpr PrideFlagData lesbianFlagData = PrideFlagData(lesbianColours, LV_COLOR_WHITE, LV_COLOR_BLACK, LV_COLOR_WHITE); + constexpr PrideFlagData gayFlagData(gayColours, LV_COLOR_BLACK, LV_COLOR_BLACK, LV_COLOR_WHITE); + constexpr PrideFlagData transFlagData(transColours, LV_COLOR_WHITE, LV_COLOR_BLACK, LV_COLOR_WHITE); + constexpr PrideFlagData biFlagData(biColours, LV_COLOR_BLACK, LV_COLOR_WHITE, LV_COLOR_BLACK); + constexpr PrideFlagData lesbianFlagData(lesbianColours, LV_COLOR_WHITE, LV_COLOR_BLACK, LV_COLOR_WHITE); } WatchFacePrideFlag::WatchFacePrideFlag(Controllers::DateTime& dateTimeController,