From 0e054e676c2e7eda5e5492ffbf8b951282ba2e4f Mon Sep 17 00:00:00 2001 From: KonradIT Date: Fri, 31 Oct 2025 19:33:40 +0100 Subject: [PATCH] feature: show leading zero --- package.json | 3 ++- src/c/main.c | 12 +++++++----- src/c/messaging.c | 5 +++++ src/c/settings.c | 1 + src/c/settings.h | 6 ++++-- src/pkjs/config.json | 5 +++++ 6 files changed, 24 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index ec63c68..f89795a 100644 --- a/package.json +++ b/package.json @@ -45,7 +45,8 @@ "SETTING_RING_SUNSET_COLOR", "SETTING_SUN_STROKE_COLOR", "SETTING_SUN_FILL_COLOR", - "SETTING_USE_LARGE_FONTS" + "SETTING_USE_LARGE_FONTS", + "SETTING_SHOW_LEADING_ZERO" ], "resources": { "media": [ diff --git a/src/c/main.c b/src/c/main.c index 87fdc31..c804c47 100644 --- a/src/c/main.c +++ b/src/c/main.c @@ -96,11 +96,13 @@ static void update_clock() { strftime(timeText, TIME_STR_LEN, "%I:%M", timeInfo); } - // now trim leading 0's - if (timeText[0] == '0') { - // shuffle everyone back by 1 - for (int i = 0; i < TIME_STR_LEN; i++) { - timeText[i] = timeText[i + 1]; + if (!globalSettings.showLeadingZero) { + // now trim leading 0's + if (timeText[0] == '0') { + // shuffle everyone back by 1 + for (int i = 0; i < TIME_STR_LEN; i++) { + timeText[i] = timeText[i + 1]; + } } } diff --git a/src/c/messaging.c b/src/c/messaging.c index 7d3dcb5..6c5b427 100644 --- a/src/c/messaging.c +++ b/src/c/messaging.c @@ -62,6 +62,7 @@ void inbox_received_callback(DictionaryIterator *iterator, void *context) { Tuple *sunStrokeColor_tuple = dict_find(iterator, MESSAGE_KEY_SETTING_SUN_STROKE_COLOR); Tuple *sunFillColor_tuple = dict_find(iterator, MESSAGE_KEY_SETTING_SUN_FILL_COLOR); Tuple *useLargeFonts_tuple = dict_find(iterator, MESSAGE_KEY_SETTING_USE_LARGE_FONTS); + Tuple *showLeadingZero_tuple = dict_find(iterator, MESSAGE_KEY_SETTING_SHOW_LEADING_ZERO); if(timeColor_tuple != NULL) { globalSettings.timeColor = GColorFromHEX(timeColor_tuple->value->int32); @@ -119,6 +120,10 @@ void inbox_received_callback(DictionaryIterator *iterator, void *context) { globalSettings.useLargeFonts = (bool)useLargeFonts_tuple->value->int8; } + if(showLeadingZero_tuple != NULL) { + globalSettings.showLeadingZero = (bool)showLeadingZero_tuple->value->int8; + } + Settings_saveToStorage(); message_processed_callback(); diff --git a/src/c/settings.c b/src/c/settings.c index 9fd37bd..62c5229 100644 --- a/src/c/settings.c +++ b/src/c/settings.c @@ -32,6 +32,7 @@ void Settings_loadFromStorage() { // metrics globalSettings.useLargeFonts = false; + globalSettings.showLeadingZero = false; // globalSettings.widgets[0] = PBL_IF_HEALTH_ELSE(HEALTH, BATTERY_METER); // globalSettings.widgets[1] = EMPTY; diff --git a/src/c/settings.h b/src/c/settings.h index e033b63..5ab452b 100644 --- a/src/c/settings.h +++ b/src/c/settings.h @@ -63,7 +63,8 @@ typedef struct { GColor sunFillColor; bool useLargeFonts; - + bool showLeadingZero; + // // general settings // uint8_t languageId; // bool showLeadingZero; @@ -128,7 +129,8 @@ typedef struct { GColor sunFillColor; uint8_t useLargeFonts:1; - + uint8_t showLeadingZero:1; + // other appearance settings // uint8_t timeShowLeadingZero:1; diff --git a/src/pkjs/config.json b/src/pkjs/config.json index 3a2b6ae..fb9aa90 100644 --- a/src/pkjs/config.json +++ b/src/pkjs/config.json @@ -205,6 +205,11 @@ "type": "toggle", "messageKey": "SETTING_USE_LARGE_FONTS", "label": "Use large fonts" + }, + { + "type": "toggle", + "messageKey": "SETTING_SHOW_LEADING_ZERO", + "label": "Show leading zero in the 0-9 hour" } ] },