mod: add clock settings tab, timezone support, and clock size option
Fix clock persistence bug caused by stale legacy read in settings deserialization. Add clock size setting (Small/Medium/Large) and timezone selection with North American presets plus custom UTC offset. Move all clock-related settings into a dedicated Clock tab, rename "Home Screen Clock" to "Clock", and move minute-change detection to main loop so the header clock updates on every screen. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -263,19 +263,22 @@ void BaseTheme::drawHeader(const GfxRenderer& renderer, Rect rect, const char* t
|
||||
showBatteryPercentage);
|
||||
|
||||
// Draw clock on the left side (symmetric with battery on the right)
|
||||
if (SETTINGS.homeScreenClock != CrossPointSettings::CLOCK_OFF) {
|
||||
if (SETTINGS.clockFormat != CrossPointSettings::CLOCK_OFF) {
|
||||
time_t now = time(nullptr);
|
||||
struct tm* t = localtime(&now);
|
||||
if (t != nullptr && t->tm_year > 100) {
|
||||
char timeBuf[16];
|
||||
if (SETTINGS.homeScreenClock == CrossPointSettings::CLOCK_24H) {
|
||||
if (SETTINGS.clockFormat == CrossPointSettings::CLOCK_24H) {
|
||||
snprintf(timeBuf, sizeof(timeBuf), "%02d:%02d", t->tm_hour, t->tm_min);
|
||||
} else {
|
||||
int hour12 = t->tm_hour % 12;
|
||||
if (hour12 == 0) hour12 = 12;
|
||||
snprintf(timeBuf, sizeof(timeBuf), "%d:%02d %s", hour12, t->tm_min, t->tm_hour >= 12 ? "PM" : "AM");
|
||||
}
|
||||
renderer.drawText(SMALL_FONT_ID, rect.x + 12, rect.y + 5, timeBuf, true);
|
||||
int clockFont = SMALL_FONT_ID;
|
||||
if (SETTINGS.clockSize == CrossPointSettings::CLOCK_SIZE_MEDIUM) clockFont = UI_10_FONT_ID;
|
||||
else if (SETTINGS.clockSize == CrossPointSettings::CLOCK_SIZE_LARGE) clockFont = UI_12_FONT_ID;
|
||||
renderer.drawText(clockFont, rect.x + 12, rect.y + 5, timeBuf, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -116,19 +116,22 @@ void LyraTheme::drawHeader(const GfxRenderer& renderer, Rect rect, const char* t
|
||||
showBatteryPercentage);
|
||||
|
||||
// Draw clock on the left side (symmetric with battery on the right)
|
||||
if (SETTINGS.homeScreenClock != CrossPointSettings::CLOCK_OFF) {
|
||||
if (SETTINGS.clockFormat != CrossPointSettings::CLOCK_OFF) {
|
||||
time_t now = time(nullptr);
|
||||
struct tm* t = localtime(&now);
|
||||
if (t != nullptr && t->tm_year > 100) {
|
||||
char timeBuf[16];
|
||||
if (SETTINGS.homeScreenClock == CrossPointSettings::CLOCK_24H) {
|
||||
if (SETTINGS.clockFormat == CrossPointSettings::CLOCK_24H) {
|
||||
snprintf(timeBuf, sizeof(timeBuf), "%02d:%02d", t->tm_hour, t->tm_min);
|
||||
} else {
|
||||
int hour12 = t->tm_hour % 12;
|
||||
if (hour12 == 0) hour12 = 12;
|
||||
snprintf(timeBuf, sizeof(timeBuf), "%d:%02d %s", hour12, t->tm_min, t->tm_hour >= 12 ? "PM" : "AM");
|
||||
}
|
||||
renderer.drawText(SMALL_FONT_ID, rect.x + 12, rect.y + 5, timeBuf, true);
|
||||
int clockFont = SMALL_FONT_ID;
|
||||
if (SETTINGS.clockSize == CrossPointSettings::CLOCK_SIZE_MEDIUM) clockFont = UI_10_FONT_ID;
|
||||
else if (SETTINGS.clockSize == CrossPointSettings::CLOCK_SIZE_LARGE) clockFont = UI_12_FONT_ID;
|
||||
renderer.drawText(clockFont, rect.x + 12, rect.y + 5, timeBuf, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user