Pride flag watchface (#2201)

This commit is contained in:
Eshe 2025-06-19 16:53:45 +00:00 committed by GitHub
parent 3fc00f80db
commit 4517fb8c4b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 469 additions and 1 deletions

View file

@ -427,6 +427,7 @@ list(APPEND SOURCE_FILES
displayapp/screens/WatchFaceTerminal.cpp displayapp/screens/WatchFaceTerminal.cpp
displayapp/screens/WatchFacePineTimeStyle.cpp displayapp/screens/WatchFacePineTimeStyle.cpp
displayapp/screens/WatchFaceCasioStyleG7710.cpp displayapp/screens/WatchFaceCasioStyleG7710.cpp
displayapp/screens/WatchFacePrideFlag.cpp
## ##

View file

@ -9,6 +9,8 @@ using namespace Pinetime::Controllers;
namespace { namespace {
constexpr const char* const DaysStringShort[] = {"--", "MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"}; 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 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 MonthsString[] = {"--", "JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"};
constexpr const char* const MonthsStringLow[] = constexpr const char* const MonthsStringLow[] =
{"--", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; {"--", "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<uint8_t>(DayOfWeek())]; return DaysStringShort[static_cast<uint8_t>(DayOfWeek())];
} }
const char* DateTime::DayOfWeekToString() const {
return DaysString[static_cast<uint8_t>(DayOfWeek())];
}
const char* DateTime::MonthShortToStringLow(Months month) { const char* DateTime::MonthShortToStringLow(Months month) {
return MonthsStringLow[static_cast<uint8_t>(month)]; return MonthsStringLow[static_cast<uint8_t>(month)];
} }
@ -152,6 +158,10 @@ const char* DateTime::DayOfWeekShortToStringLow(Days day) {
return DaysStringShortLow[static_cast<uint8_t>(day)]; return DaysStringShortLow[static_cast<uint8_t>(day)];
} }
const char* DateTime::DayOfWeekToStringLow(Days day) {
return DaysStringLow[static_cast<uint8_t>(day)];
}
void DateTime::Register(Pinetime::System::SystemTask* systemTask) { void DateTime::Register(Pinetime::System::SystemTask* systemTask) {
this->systemTask = systemTask; this->systemTask = systemTask;
} }

View file

@ -121,8 +121,10 @@ namespace Pinetime {
const char* MonthShortToString() const; const char* MonthShortToString() const;
const char* DayOfWeekShortToString() const; const char* DayOfWeekShortToString() const;
const char* DayOfWeekToString() const;
static const char* MonthShortToStringLow(Months month); static const char* MonthShortToStringLow(Months month);
static const char* DayOfWeekShortToStringLow(Days day); static const char* DayOfWeekShortToStringLow(Days day);
static const char* DayOfWeekToStringLow(Days day);
std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> CurrentDateTime(); std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> CurrentDateTime();

View file

@ -36,6 +36,7 @@ namespace Pinetime {
}; };
enum class PTSGaugeStyle : uint8_t { Full, Half, Numeric }; enum class PTSGaugeStyle : uint8_t { Full, Half, Numeric };
enum class PTSWeather : uint8_t { On, Off }; enum class PTSWeather : uint8_t { On, Off };
enum class PrideFlag : uint8_t { Gay, Trans, Bi, Lesbian };
struct PineTimeStyle { struct PineTimeStyle {
Colors ColorTime = Colors::Teal; Colors ColorTime = Colors::Teal;
@ -154,6 +155,16 @@ namespace Pinetime {
return settings.PTS.weatherEnable; 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) { void SetAppMenu(uint8_t menu) {
appMenu = menu; appMenu = menu;
}; };
@ -301,7 +312,7 @@ namespace Pinetime {
private: private:
Pinetime::Controllers::FS& fs; Pinetime::Controllers::FS& fs;
static constexpr uint32_t settingsVersion = 0x0008; static constexpr uint32_t settingsVersion = 0x0009;
struct SettingsData { struct SettingsData {
uint32_t version = settingsVersion; uint32_t version = settingsVersion;
@ -319,6 +330,8 @@ namespace Pinetime {
PineTimeStyle PTS; PineTimeStyle PTS;
PrideFlag prideFlag = PrideFlag::Gay;
WatchFaceInfineat watchFaceInfineat; WatchFaceInfineat watchFaceInfineat;
std::bitset<5> wakeUpMode {0}; std::bitset<5> wakeUpMode {0};

View file

@ -14,6 +14,7 @@
#include "displayapp/screens/WatchFaceInfineat.h" #include "displayapp/screens/WatchFaceInfineat.h"
#include "displayapp/screens/WatchFacePineTimeStyle.h" #include "displayapp/screens/WatchFacePineTimeStyle.h"
#include "displayapp/screens/WatchFaceTerminal.h" #include "displayapp/screens/WatchFaceTerminal.h"
#include "displayapp/screens/WatchFacePrideFlag.h"
namespace Pinetime { namespace Pinetime {
namespace Applications { namespace Applications {

View file

@ -53,6 +53,7 @@ namespace Pinetime {
Terminal, Terminal,
Infineat, Infineat,
CasioStyleG7710, CasioStyleG7710,
PrideFlag,
}; };
template <Apps> template <Apps>

View file

@ -28,6 +28,7 @@ else()
set(DEFAULT_WATCHFACE_TYPES "${DEFAULT_WATCHFACE_TYPES}, WatchFace::Terminal") 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::Infineat")
set(DEFAULT_WATCHFACE_TYPES "${DEFAULT_WATCHFACE_TYPES}, WatchFace::CasioStyleG7710") 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") set(WATCHFACE_TYPES "${DEFAULT_WATCHFACE_TYPES}" CACHE STRING "List of watch faces to build into the firmware")
endif() endif()

View file

@ -0,0 +1,337 @@
#include "displayapp/screens/WatchFacePrideFlag.h"
#include <lvgl/lvgl.h>
#include "components/battery/BatteryController.h"
#include "components/ble/BleController.h"
#include "displayapp/screens/Symbols.h"
using namespace Pinetime::Applications::Screens;
namespace {
void EventHandler(lv_obj_t* obj, lv_event_t event) {
auto* screen = static_cast<WatchFacePrideFlag*>(obj->user_data);
screen->UpdateSelected(obj, event);
}
Pinetime::Controllers::Settings::PrideFlag GetNext(Pinetime::Controllers::Settings::PrideFlag prideFlag) {
const auto prideFlagAsInt = static_cast<uint8_t>(prideFlag);
Pinetime::Controllers::Settings::PrideFlag nextFlag;
if (prideFlagAsInt < 3) {
nextFlag = static_cast<Pinetime::Controllers::Settings::PrideFlag>(prideFlagAsInt + 1);
} else {
nextFlag = static_cast<Pinetime::Controllers::Settings::PrideFlag>(0);
}
return nextFlag;
}
Pinetime::Controllers::Settings::PrideFlag GetPrevious(Pinetime::Controllers::Settings::PrideFlag prideFlag) {
const auto prideFlagAsInt = static_cast<uint8_t>(prideFlag);
Pinetime::Controllers::Settings::PrideFlag prevFlag;
if (prideFlagAsInt > 0) {
prevFlag = static_cast<Pinetime::Controllers::Settings::PrideFlag>(prideFlagAsInt - 1);
} else {
prevFlag = static_cast<Pinetime::Controllers::Settings::PrideFlag>(3);
}
return prevFlag;
}
template <std::size_t N>
class PrideFlagData {
public:
constexpr PrideFlagData(const std::array<lv_color_t, N>& 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<uint8_t>(1.5f * static_cast<float>(N) + 40.5f);
}
std::array<lv_color_t, N> 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);
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<lv_color_t, 7> gayColours {darkGreen, cyan, lightGreen, LV_COLOR_WHITE, lightBlue, indigo, steelBlue};
constexpr std::array<lv_color_t, 5> transColours {lightBlue, lightPink, LV_COLOR_WHITE, lightPink, lightBlue};
constexpr std::array<lv_color_t, 5> biColours {hotPink, hotPink, grayPurple, darkBlue, darkBlue};
constexpr std::array<lv_color_t, 7> lesbianColours {LV_COLOR_RED, orange, lightOrange, LV_COLOR_WHITE, lightPurple, darkPurple, magenta};
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,
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);
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;
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, EventHandler);
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, EventHandler);
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, EventHandler);
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, -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);
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());
}
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 = xTaskGetTickCount();
return true;
}
if ((event == Pinetime::Applications::TouchEvents::DoubleTap) && !lv_obj_get_hidden(btnClose)) {
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() || themeChanged) {
lv_label_set_text_fmt(batteryValue, "%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(notificationText, "You have\nmail!");
} else {
lv_label_set_text_static(notificationText, "");
}
}
currentDateTime = std::chrono::time_point_cast<std::chrono::seconds>(dateTimeController.CurrentDateTime());
if (currentDateTime.IsUpdated() || themeChanged) {
uint8_t hour = dateTimeController.Hours();
const uint8_t minute = dateTimeController.Minutes();
const 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, "%02d:%02d:%02d", hour, minute, second);
currentDate = std::chrono::time_point_cast<std::chrono::days>(currentDateTime.Get());
if (currentDate.IsUpdated() || ampmChar.IsUpdated() || themeChanged) {
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<uint8_t>(month), year);
if (settingsController.GetClockType() == Controllers::Settings::ClockType::H12) {
lv_label_set_text_fmt(labelDay, "%s %s", dateTimeController.DayOfWeekToStringLow(dayOfWeek), ampmChar);
} else {
lv_label_set_text_fmt(labelDay, "%s", dateTimeController.DayOfWeekToStringLow(dayOfWeek));
}
}
}
stepCount = motionController.NbSteps();
if (stepCount.IsUpdated() || themeChanged) {
lv_label_set_text_fmt(stepValue, "%lu steps", stepCount.Get());
}
if (themeChanged) {
themeChanged = false;
}
}
void WatchFacePrideFlag::UpdateSelected(lv_obj_t* object, lv_event_t event) {
if (event == LV_EVENT_CLICKED) {
auto valueFlag = settingsController.GetPrideFlag();
bool flagChanged = false;
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(const Pinetime::Controllers::Settings::PrideFlag prideFlag) {
auto UseFlagData = [this]<size_t N>(PrideFlagData<N> 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);
}
backgroundSections.clear();
switch (prideFlag) {
case Pinetime::Controllers::Settings::PrideFlag::Gay:
UseFlagData(gayFlagData);
break;
case Pinetime::Controllers::Settings::PrideFlag::Trans:
UseFlagData(transFlagData);
break;
case Pinetime::Controllers::Settings::PrideFlag::Bi:
UseFlagData(biFlagData);
break;
case Pinetime::Controllers::Settings::PrideFlag::Lesbian:
UseFlagData(lesbianFlagData);
break;
}
}

View file

@ -0,0 +1,102 @@
#pragma once
#include <lvgl/src/lv_core/lv_obj.h>
#include <chrono>
#include <vector>
#include <cstdint>
#include <array>
#include <FreeRTOS.h>
#include "displayapp/screens/Screen.h"
#include "utility/DirtyValue.h"
#include "components/settings/Settings.h"
#include "components/battery/BatteryController.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);
private:
void UpdateScreen(Pinetime::Controllers::Settings::PrideFlag);
Utility::DirtyValue<uint8_t> batteryPercentRemaining;
Utility::DirtyValue<bool> powerPresent;
Utility::DirtyValue<bool> bleState;
Utility::DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::seconds>> currentDateTime;
Utility::DirtyValue<uint32_t> stepCount;
Utility::DirtyValue<bool> notificationState;
Utility::DirtyValue<std::chrono::time_point<std::chrono::system_clock, std::chrono::days>> currentDate;
// Must be wrapped in a dirty value, since it is displayed in the day but is updated twice a day
Utility::DirtyValue<const char*> ampmChar {"AM"};
TickType_t savedTick = 0;
std::vector<lv_obj_t*> backgroundSections;
bool themeChanged = false;
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* notificationText;
lv_obj_t* btnClose;
lv_obj_t* btnNextFlag;
lv_obj_t* btnPrevFlag;
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<WatchFace::PrideFlag> {
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;
}
};
}
}