From 0a48fbcd79d519d0c126d3eabdb8243877d51a25 Mon Sep 17 00:00:00 2001 From: Eshe Date: Mon, 16 Dec 2024 17:29:52 +0000 Subject: [PATCH 1/7] 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 2/7] 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 3/7] 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 4/7] 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 5/7] 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 6/7] 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 7/7] 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;