diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e2b69b8b02..a4b7fc8b17 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/WatchFacePrideFlag.cpp ## 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/components/settings/Settings.h b/src/components/settings/Settings.h index 602de3a585..f3c2bea02f 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 67bbfa7d41..8dc114429f 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/WatchFacePrideFlag.h" namespace Pinetime { namespace Applications { diff --git a/src/displayapp/apps/Apps.h.in b/src/displayapp/apps/Apps.h.in index 2104a267c0..c1a91540f3 100644 --- a/src/displayapp/apps/Apps.h.in +++ b/src/displayapp/apps/Apps.h.in @@ -52,6 +52,7 @@ namespace Pinetime { Terminal, Infineat, CasioStyleG7710, + PrideFlag, }; template diff --git a/src/displayapp/apps/CMakeLists.txt b/src/displayapp/apps/CMakeLists.txt index d78587609e..b67f39b9fb 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::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..0c5b1d403e --- /dev/null +++ b/src/displayapp/screens/WatchFacePrideFlag.cpp @@ -0,0 +1,348 @@ +#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_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(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; + 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(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); + 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(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); + 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(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; + } +} + +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 new file mode 100644 index 0000000000..923642f557 --- /dev/null +++ b/src/displayapp/screens/WatchFacePrideFlag.h @@ -0,0 +1,117 @@ +#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 WatchFacePrideFlag : public Screen { + public: + WatchFacePrideFlag(Controllers::DateTime& dateTimeController, + const Controllers::Battery& batteryController, + const Controllers::Ble& bleController, + Controllers::NotificationManager& notificationManager, + Controllers::Settings& settingsController, + Controllers::MotionController& motionController); + ~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 {}; + 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"}; + + 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; + lv_obj_t* labelDay; + 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; + const Controllers::Ble bleController; + Controllers::NotificationManager& notificationManager; + Controllers::Settings& settingsController; + Controllers::MotionController& motionController; + + lv_task_t* taskRefresh; + void CloseMenu(); + }; + } + + template <> + struct WatchFaceTraits { + static constexpr WatchFace watchFace = WatchFace::PrideFlag; + static constexpr const char* name = "Pride Flag"; + + static Screens::Screen* Create(AppControllers& controllers) { + return new Screens::WatchFacePrideFlag(controllers.dateTimeController, + controllers.batteryController, + controllers.bleController, + controllers.notificationManager, + controllers.settingsController, + controllers.motionController); + }; + + static bool IsAvailable(Pinetime::Controllers::FS& /*filesystem*/) { + return true; + } + }; + } +}