From 06176e360a3f3def224e5a49c4103ebf4e70bb72 Mon Sep 17 00:00:00 2001 From: Halfware Date: Mon, 3 Nov 2025 13:42:19 +0100 Subject: [PATCH] Minute progress on clock face --- docs/api.md | 1 + src/Apps.cpp | 60 +++++++++++++++++++++++++++++------------- src/DisplayManager.cpp | 2 ++ src/Globals.cpp | 3 +++ src/Globals.h | 1 + 5 files changed, 49 insertions(+), 18 deletions(-) diff --git a/docs/api.md b/docs/api.md index 65e42d41..65bbad39 100644 --- a/docs/api.md +++ b/docs/api.md @@ -379,6 +379,7 @@ You can adjust each property in the JSON object according to your preferences. I | `CBCOL` | string/array of ints | Calendar body color of the time app. | RGB array or hex color |`#FFFFFF`| | `CTCOL` | string/array of ints | Calendar text color in the time app. | RGB array or hex color |`#000000` | | `WD` | boolean | Enable or disable the weekday display. | `true`/`false` | true | +| `MP` | boolean | Enable or disable the minute progress bar (ignored if WD is active) display. | `true`/`false` | true | | `WDCA` | string/array of ints | Active weekday color. | RGB array or hex color | N/A | | `WDCI` | string/array of ints | Inactive weekday color. | RGB array or hex color | N/A | | `BRI` | number | Matrix brightness. | 0-255 | N/A | diff --git a/src/Apps.cpp b/src/Apps.cpp index 23d36977..2149f9f7 100644 --- a/src/Apps.cpp +++ b/src/Apps.cpp @@ -166,26 +166,50 @@ void TimeApp(FastLED_NeoMatrix *matrix, MatrixDisplayUiState *state, int16_t x, DisplayManager.matrixPrint(day_str); } - if (!SHOW_WEEKDAY) - return; - - // line of week days - uint8_t LINE_WIDTH = TIME_MODE > 0 ? 2 : 3; - uint8_t LINE_SPACING = 1; - uint8_t LINE_START = TIME_MODE > 0 ? 10 : 2; - uint8_t dayOffset = START_ON_MONDAY ? 0 : 1; - for (int i = 0; i <= 6; i++) - { - int lineStart = LINE_START + i * (LINE_WIDTH + LINE_SPACING); - int lineEnd = lineStart + LINE_WIDTH - 1; + if (SHOW_WEEKDAY) { + // line of week days + uint8_t LINE_WIDTH = TIME_MODE > 0 ? 2 : 3; + uint8_t LINE_SPACING = 1; + uint8_t LINE_START = TIME_MODE > 0 ? 10 : 2; + uint8_t dayOffset = START_ON_MONDAY ? 0 : 1; + for (int i = 0; i <= 6; i++) + { + int lineStart = LINE_START + i * (LINE_WIDTH + LINE_SPACING); + int lineEnd = lineStart + LINE_WIDTH - 1; - uint32_t color; - if (i == (timer_localtime()->tm_wday + 6 + dayOffset) % 7) - color = WDC_ACTIVE; // current day - else - color = WDC_INACTIVE; // other days + uint32_t color; + if (i == (timer_localtime()->tm_wday + 6 + dayOffset) % 7) + color = WDC_ACTIVE; // current day + else + color = WDC_INACTIVE; // other days - DisplayManager.drawLine(lineStart + x, wdPosY + y, lineEnd + x, wdPosY + y, color); + DisplayManager.drawLine(lineStart + x, wdPosY + y, lineEnd + x, wdPosY + y, color); + } + } else if (SHOW_MINUTEPROGRESS) { + const uint8_t spaceStart = (TIME_MODE > 0 ? 10 : 0) + x; + const uint8_t spaceWidth = TIME_MODE > 0 ? 22 : 32; + const uint8_t secondsPerPixel = TIME_MODE > 0 ? 5 : 3; + const uint8_t segments = 4; + const uint8_t totalPixels = 60 / secondsPerPixel; + const uint8_t pixelsPerSegment = totalPixels / segments; + + uint8_t lineX = spaceStart + spaceWidth / 2 - (totalPixels + segments) / 2; + const uint8_t lineEnd = lineX + totalPixels + segments - 1; + uint8_t coloredPixels = timer_localtime()->tm_sec / secondsPerPixel; + while (coloredPixels >= pixelsPerSegment) { + DisplayManager.drawLine(lineX, wdPosY + y, lineX + pixelsPerSegment - 1, wdPosY + y, WDC_ACTIVE); + coloredPixels -= pixelsPerSegment; + lineX += pixelsPerSegment + 1; + } + if (coloredPixels > 0) { + DisplayManager.drawLine(lineX + coloredPixels, wdPosY + y, lineX + pixelsPerSegment - 1, wdPosY + y, WDC_INACTIVE); + DisplayManager.drawLine(lineX, wdPosY + y, lineX + coloredPixels - 1, wdPosY + y, WDC_ACTIVE); + lineX += pixelsPerSegment + 1; + } + while (lineX < lineEnd) { + DisplayManager.drawLine(lineX, wdPosY + y, lineX + pixelsPerSegment - 1, wdPosY + y, WDC_INACTIVE); + lineX += pixelsPerSegment + 1; + } } } diff --git a/src/DisplayManager.cpp b/src/DisplayManager.cpp index 8ddf6cf9..aaf5d592 100644 --- a/src/DisplayManager.cpp +++ b/src/DisplayManager.cpp @@ -2041,6 +2041,7 @@ String DisplayManager_::getSettings() doc["CCORRECTION"] = CRGBtoHex(COLOR_CORRECTION); doc["CTEMP"] = CRGBtoHex(COLOR_TEMPERATURE); doc["WD"] = SHOW_WEEKDAY; + doc["MP"] = SHOW_MINUTEPROGRESS; doc["TEFF"] = TRANS_EFFECT; doc["WDCA"] = WDC_ACTIVE; doc["WDCI"] = WDC_INACTIVE; @@ -2109,6 +2110,7 @@ void DisplayManager_::setNewSettings(const char *json) AUTO_TRANSITION = doc.containsKey("ATRANS") ? doc["ATRANS"].as() : AUTO_TRANSITION; UPPERCASE_LETTERS = doc.containsKey("UPPERCASE") ? doc["UPPERCASE"].as() : UPPERCASE_LETTERS; SHOW_WEEKDAY = doc.containsKey("WD") ? doc["WD"].as() : SHOW_WEEKDAY; + SHOW_MINUTEPROGRESS = doc.containsKey("MP") ? doc["MP"].as() : SHOW_MINUTEPROGRESS; BLOCK_NAVIGATION = doc.containsKey("BLOCKN") ? doc["BLOCKN"].as() : BLOCK_NAVIGATION; SHOW_TIME = doc.containsKey("TIM") ? doc["TIM"].as() : SHOW_TIME; SHOW_DATE = doc.containsKey("DAT") ? doc["DAT"].as() : SHOW_DATE; diff --git a/src/Globals.cpp b/src/Globals.cpp index 53155999..a75a5e8a 100644 --- a/src/Globals.cpp +++ b/src/Globals.cpp @@ -262,6 +262,7 @@ void loadSettings() WDC_INACTIVE = Settings.getUInt("WDCI", 0x666666); AUTO_TRANSITION = Settings.getBool("ATRANS", true); SHOW_WEEKDAY = Settings.getBool("WD", true); + SHOW_MINUTEPROGRESS = Settings.getBool("MP", false); TIME_PER_TRANSITION = Settings.getUInt("TSPEED", 400); TIME_PER_APP = Settings.getUInt("ATIME", 7000); TIME_FORMAT = Settings.getString("TFORMAT", "%H %M"); @@ -298,6 +299,7 @@ void saveSettings() Settings.putUInt("TEFF", TRANS_EFFECT); Settings.putUInt("BRI", BRIGHTNESS); Settings.putBool("WD", SHOW_WEEKDAY); + Settings.putBool("MP", SHOW_MINUTEPROGRESS); Settings.putBool("ABRI", AUTO_BRIGHTNESS); Settings.putBool("BLOCKN", BLOCK_NAVIGATION); Settings.putBool("ATRANS", AUTO_TRANSITION); @@ -356,6 +358,7 @@ bool SHOW_TEMP = true; bool SHOW_HUM = true; bool SHOW_SECONDS = true; bool SHOW_WEEKDAY = true; +bool SHOW_MINUTEPROGRESS = true; String NET_IP = "192.168.178.10"; String NET_GW = "192.168.178.1"; String NET_SN = "255.255.255.0"; diff --git a/src/Globals.h b/src/Globals.h index a88eded7..cb28b814 100644 --- a/src/Globals.h +++ b/src/Globals.h @@ -52,6 +52,7 @@ extern bool SHOW_TEMP; extern bool SHOW_HUM; extern bool SHOW_SECONDS; extern bool SHOW_WEEKDAY; +extern bool SHOW_MINUTEPROGRESS; extern int8_t TRANS_EFFECT; extern String NET_IP; extern String NET_GW;