From 503543e7857f4794413573126769ff7b5e7704a9 Mon Sep 17 00:00:00 2001 From: Edgar W <36072504+techniccontroller@users.noreply.github.com> Date: Sun, 19 Jan 2025 12:44:03 +0100 Subject: [PATCH 1/7] Set dynColorShiftActive to false by default --- wordclock_esp8266.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wordclock_esp8266.ino b/wordclock_esp8266.ino index e563f2b..f58c8a2 100644 --- a/wordclock_esp8266.ino +++ b/wordclock_esp8266.ino @@ -187,7 +187,7 @@ bool nightMode = false; // stores state of nightmode uint32_t maincolor_clock = colors24bit[2]; // color of the clock and digital clock uint32_t maincolor_snake = colors24bit[1]; // color of the random snake animation bool apmode = false; // stores if WiFi AP mode is active -bool dynColorShiftActive = true; // stores if dynamic color shift is active +bool dynColorShiftActive = false; // stores if dynamic color shift is active uint8_t dynColorShiftPhase = 0; // stores the phase of the dynamic color shift uint8_t dynColorShiftSpeed = 1; // stores the speed of the dynamic color shift -> used to calc update period From 9090720035b2dc0a52e8d257555e1391fed0a62f Mon Sep 17 00:00:00 2001 From: Edgar W Date: Sun, 19 Jan 2025 12:53:56 +0100 Subject: [PATCH 2/7] Toggle visibility of color container based on color shift checkbox state --- data/index.html | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/data/index.html b/data/index.html index 9fda0be..7b00f21 100644 --- a/data/index.html +++ b/data/index.html @@ -501,8 +501,10 @@

WORDCLOCK 2.0

} ckb_colorshift.addEventListener('change', () => { if(ckb_colorshift.checked) { + document.getElementById("colorcontainer").classList.add("hidden"); sendCommand("./cmd?colorshift=1"); } else { + document.getElementById("colorcontainer").classList.remove("hidden"); sendCommand("./cmd?colorshift=0"); } }); @@ -539,7 +541,10 @@

WORDCLOCK 2.0

if(myVar != null && myVar.stateAutoChange == "0"){ switch(modeid){ case 0: // clock - document.getElementById("colorcontainer").classList.remove("hidden"); + var ckb_colorshift = document.querySelector('input[id="ColorShift"]'); + if(!ckb_colorshift.checked) { + document.getElementById("colorcontainer").classList.remove("hidden"); + } document.getElementById("colorshiftcontainer").classList.remove("hidden"); break; case 1: // diclock From 0f6773ad7a0c44beee9250b584ee06dbb2506bc0 Mon Sep 17 00:00:00 2001 From: Edgar W Date: Sat, 25 Jan 2025 12:25:27 +0100 Subject: [PATCH 3/7] Add LED off functionality and update night mode handling --- data/index.html | 37 ++++++++++++++++++++++++++--------- wordclock_esp8266.ino | 45 +++++++++++++++++++------------------------ 2 files changed, 48 insertions(+), 34 deletions(-) diff --git a/data/index.html b/data/index.html index 7b00f21..ef19ee4 100644 --- a/data/index.html +++ b/data/index.html @@ -311,9 +311,15 @@

WORDCLOCK 2.0

- +
- + active +
+
+
+ +
+
@@ -456,20 +462,33 @@

WORDCLOCK 2.0

modebuttons[state].classList.add("active"); // set checkbox states - var ckb_nightmode = document.querySelector('input[id="Nightmode"]'); + var span_nightMode = document.querySelector('span[id="NightMode"]'); if(myVar.nightMode == "1") { console.log("nightMode == 1"); - ckb_nightmode.checked = true; + span_nightMode.textContent = "active"; + span_nightMode.style.color = "green"; } else { console.log("nightMode == 0"); - ckb_nightmode.checked = false; + span_nightMode.textContent = "inactive"; + span_nightMode.style.color = "red"; + } + + // set checkbox states + var ckb_ledoff = document.querySelector('input[id="LED_Off"]'); + if(myVar.ledoff == "1") { + console.log("ledoff == 1"); + ckb_ledoff.checked = true; + } + else { + console.log("ledoff == 0"); + ckb_ledoff.checked = false; } - ckb_nightmode.addEventListener('change', () => { - if(ckb_nightmode.checked) { - sendCommand("./cmd?nightmode=1"); + ckb_ledoff.addEventListener('change', () => { + if(ckb_ledoff.checked) { + sendCommand("./cmd?ledoff=1"); } else { - sendCommand("./cmd?nightmode=0"); + sendCommand("./cmd?ledoff=0"); } }); diff --git a/wordclock_esp8266.ino b/wordclock_esp8266.ino index f58c8a2..b711164 100644 --- a/wordclock_esp8266.ino +++ b/wordclock_esp8266.ino @@ -184,6 +184,7 @@ float filterFactor = DEFAULT_SMOOTHING_FACTOR;// stores smoothing factor for led uint8_t currentState = st_clock; // stores current state bool stateAutoChange = false; // stores state of automatic state change bool nightMode = false; // stores state of nightmode +bool ledOff = false; // stores state of led off uint32_t maincolor_clock = colors24bit[2]; // color of the clock and digital clock uint32_t maincolor_snake = colors24bit[1]; // color of the random snake animation bool apmode = false; // stores if WiFi AP mode is active @@ -414,11 +415,17 @@ void loop() { } // handle state behaviours (trigger loopCycles of different states depending on current state) - if(!nightMode && (millis() - lastStep > behaviorUpdatePeriod) && (millis() - lastLEDdirect > TIMEOUT_LEDDIRECT)){ + if(!nightMode && !ledOff && (millis() - lastStep > behaviorUpdatePeriod) && (millis() - lastLEDdirect > TIMEOUT_LEDDIRECT)){ updateStateBehavior(currentState); lastStep = millis(); } + // Turn off LEDs if ledOff is true or nightmode is active + if((ledOff || nightMode) && !waitForTimeAfterReboot){ + ledmatrix.gridFlush(); + ledmatrix.drawOnMatrixInstant(); + } + // periodically write colors to matrix if(millis() - lastAnimationStep > PERIOD_MATRIXUPDATE && !waitForTimeAfterReboot){ ledmatrix.drawOnMatrixSmooth(filterFactor); @@ -429,7 +436,7 @@ void loop() { handleButton(); // handle state changes - if(stateAutoChange && (millis() - lastStateChange > PERIOD_STATECHANGE) && !nightMode){ + if(stateAutoChange && (millis() - lastStateChange > PERIOD_STATECHANGE) && !nightMode && !ledOff){ // increment state variable and trigger state change stateChange((currentState + 1) % NUM_STATES, false); @@ -621,7 +628,6 @@ void checkNightmode(){ logger.logString("Nightmode activated"); } } - setNightmode(nightMode); } /** @@ -691,9 +697,8 @@ void entryAction(uint8_t state){ * @param persistant if true, the state will be saved to EEPROM */ void stateChange(uint8_t newState, bool persistant){ - if(nightMode){ - // deactivate Nightmode - setNightmode(false); + if(ledOff){ + ledOff = false; } // first clear matrix ledmatrix.gridFlush(); @@ -782,14 +787,14 @@ void handleButton(){ // longpress -> nightmode logger.logString("Button press ended - longpress"); - setNightmode(true); + ledOff = true; } else if((millis() - buttonPressStart) > SHORTPRESS){ // shortpress -> state change logger.logString("Button press ended - shortpress"); - if(nightMode){ - setNightmode(false); + if(ledOff){ + ledOff = false; }else{ stateChange((currentState + 1) % NUM_STATES, true); } @@ -930,11 +935,11 @@ void handleCommand() { stateChange(st_pingpong, true); } } - else if(server.argName(0) == "nightmode"){ + else if(server.argName(0) == "ledoff"){ String modestr = server.arg(0); - logger.logString("Nightmode change via Webserver to: " + modestr); - if(modestr == "1") setNightmode(true); - else setNightmode(false); + logger.logString("LED off change via Webserver to: " + modestr); + if(modestr == "1") ledOff = true; + else ledOff = false; } else if(server.argName(0) == "setting"){ String timestr = server.arg(0) + "-"; @@ -1105,6 +1110,8 @@ void handleDataRequest() { message += ","; message += "\"stateAutoChange\":\"" + String(stateAutoChange) + "\""; message += ","; + message += "\"ledoff\":\"" + String(ledOff) + "\""; + message += ","; message += "\"nightMode\":\"" + String(nightMode) + "\""; message += ","; message += "\"nightModeStart\":\"" + leadingZero2Digit(nightModeStartHour) + "-" + leadingZero2Digit(nightModeStartMin) + "\""; @@ -1122,18 +1129,6 @@ void handleDataRequest() { } } -/** - * @brief Set the nightmode state - * - * @param on true -> nightmode on - */ -void setNightmode(bool on){ - if(on){ - ledmatrix.gridFlush(); - } - nightMode = on; -} - /** * @brief Convert Integer to String with leading zero * From d9069bf234f35d076a2b2f80570ecde1cc0004f4 Mon Sep 17 00:00:00 2001 From: Edgar W Date: Sat, 25 Jan 2025 23:33:51 +0100 Subject: [PATCH 4/7] Implement night mode activation switch --- data/index.html | 35 ++++++++++++++++++++--------------- wordclock_esp8266.ino | 23 ++++++++++++++++++----- 2 files changed, 38 insertions(+), 20 deletions(-) diff --git a/data/index.html b/data/index.html index ef19ee4..4bce60d 100644 --- a/data/index.html +++ b/data/index.html @@ -243,7 +243,7 @@ } .show{ - height: 230px; + height: 280px; transition: height 1s; } @@ -288,6 +288,12 @@

WORDCLOCK 2.0

+
+ +
+ +
+
@@ -310,12 +316,6 @@

WORDCLOCK 2.0

-
- -
- active -
-
@@ -462,17 +462,22 @@

WORDCLOCK 2.0

modebuttons[state].classList.add("active"); // set checkbox states - var span_nightMode = document.querySelector('span[id="NightMode"]'); - if(myVar.nightMode == "1") { - console.log("nightMode == 1"); - span_nightMode.textContent = "active"; - span_nightMode.style.color = "green"; + var ckb_nightmodeactivated = document.querySelector('input[id="NightMode"]'); + if(myVar.nightModeActivated == "1") { + console.log("nightmodeactivated == 1"); + ckb_nightmodeactivated.checked = true; } else { - console.log("nightMode == 0"); - span_nightMode.textContent = "inactive"; - span_nightMode.style.color = "red"; + console.log("nightmodeactivated == 0"); + ckb_nightmodeactivated.checked = false; } + ckb_nightmodeactivated.addEventListener('change', () => { + if(ckb_nightmodeactivated.checked) { + sendCommand("./cmd?nightmodeactivated=1"); + } else { + sendCommand("./cmd?nightmodeactivated=0"); + } + }); // set checkbox states var ckb_ledoff = document.querySelector('input[id="LED_Off"]'); diff --git a/wordclock_esp8266.ino b/wordclock_esp8266.ino index b711164..e263347 100644 --- a/wordclock_esp8266.ino +++ b/wordclock_esp8266.ino @@ -58,6 +58,7 @@ #define ADR_MC_GREEN 22 #define ADR_MC_BLUE 24 #define ADR_STATE 26 +#define ADR_NM_ACTIVATED 27 #define ADR_COLSHIFTSPEED 28 #define ADR_COLSHIFTACTIVE 29 @@ -184,6 +185,7 @@ float filterFactor = DEFAULT_SMOOTHING_FACTOR;// stores smoothing factor for led uint8_t currentState = st_clock; // stores current state bool stateAutoChange = false; // stores state of automatic state change bool nightMode = false; // stores state of nightmode +bool nightModeActivated = true; // stores if the function nightmode is activated (its not the state of nightmode) bool ledOff = false; // stores state of led off uint32_t maincolor_clock = colors24bit[2]; // color of the clock and digital clock uint32_t maincolor_snake = colors24bit[1]; // color of the random snake animation @@ -617,15 +619,15 @@ void checkNightmode(){ int startInMinutes = nightModeStartHour * 60 + nightModeStartMin; int endInMinutes = nightModeEndHour * 60 + nightModeEndMin; - if (startInMinutes < endInMinutes) { // Same day scenario + if (startInMinutes < endInMinutes && nightModeActivated) { // Same day scenario if (startInMinutes < currentTimeInMinutes && currentTimeInMinutes < endInMinutes) { nightMode = true; - logger.logString("Nightmode activated"); + logger.logString("Nightmode active"); } - } else if (startInMinutes > endInMinutes) { // Overnight scenario + } else if (startInMinutes > endInMinutes && nightModeActivated) { // Overnight scenario if (currentTimeInMinutes >= startInMinutes || currentTimeInMinutes < endInMinutes) { nightMode = true; - logger.logString("Nightmode activated"); + logger.logString("Nightmode active"); } } } @@ -853,10 +855,12 @@ void loadNightmodeSettingsFromEEPROM() nightModeStartMin = EEPROM.read(ADR_NM_START_M); nightModeEndHour = EEPROM.read(ADR_NM_END_H); nightModeEndMin = EEPROM.read(ADR_NM_END_M); + nightModeActivated = EEPROM.read(ADR_NM_ACTIVATED); if(nightModeStartHour < 0 || nightModeStartHour > 23) nightModeStartHour = 22; if(nightModeStartMin < 0 || nightModeStartMin > 59) nightModeStartMin = 0; if(nightModeEndHour < 0 || nightModeEndHour > 23) nightModeEndHour = 7; if(nightModeEndMin < 0 || nightModeEndMin > 59) nightModeEndMin = 0; + logger.logString("Nightmode activated: " + String(nightModeActivated)); logger.logString("Nightmode starts at: " + String(nightModeStartHour) + ":" + String(nightModeStartMin)); logger.logString("Nightmode ends at: " + String(nightModeEndHour) + ":" + String(nightModeEndMin)); } @@ -941,6 +945,15 @@ void handleCommand() { if(modestr == "1") ledOff = true; else ledOff = false; } + else if(server.argName(0) == "nightmodeactivated"){ + String modestr = server.arg(0); + logger.logString("nightModeActivated change via Webserver to: " + modestr); + if(modestr == "1") nightModeActivated = true; + else nightModeActivated = false; + EEPROM.write(ADR_NM_ACTIVATED, nightModeActivated); + EEPROM.commit(); + checkNightmode(); + } else if(server.argName(0) == "setting"){ String timestr = server.arg(0) + "-"; logger.logString("Nightmode setting change via Webserver to: " + timestr); @@ -1112,7 +1125,7 @@ void handleDataRequest() { message += ","; message += "\"ledoff\":\"" + String(ledOff) + "\""; message += ","; - message += "\"nightMode\":\"" + String(nightMode) + "\""; + message += "\"nightModeActivated\":\"" + String(nightModeActivated) + "\""; message += ","; message += "\"nightModeStart\":\"" + leadingZero2Digit(nightModeStartHour) + "-" + leadingZero2Digit(nightModeStartMin) + "\""; message += ","; From 1d1fa0aff774b1b149e90e07ddb66d44c580b8b2 Mon Sep 17 00:00:00 2001 From: Edgar W <36072504+techniccontroller@users.noreply.github.com> Date: Sun, 26 Jan 2025 13:09:08 +0100 Subject: [PATCH 5/7] remove wrong comment --- wordclock_esp8266.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wordclock_esp8266.ino b/wordclock_esp8266.ino index e263347..520ae62 100644 --- a/wordclock_esp8266.ino +++ b/wordclock_esp8266.ino @@ -64,7 +64,7 @@ #define NEOPIXELPIN 5 // pin to which the NeoPixels are attached -#define NUMPIXELS 125 // number of pixels attached to Attiny85 +#define NUMPIXELS 125 // number of pixels attached #define BUTTONPIN 14 // pin to which the button is attached #define LEFT 1 #define RIGHT 2 From dff237af730c86871da7ad66573cf65386f3e9c5 Mon Sep 17 00:00:00 2001 From: Edgar W <36072504+techniccontroller@users.noreply.github.com> Date: Sun, 26 Jan 2025 13:16:50 +0100 Subject: [PATCH 6/7] remove not used define --- wordclock_esp8266.ino | 1 - 1 file changed, 1 deletion(-) diff --git a/wordclock_esp8266.ino b/wordclock_esp8266.ino index 520ae62..b28faea 100644 --- a/wordclock_esp8266.ino +++ b/wordclock_esp8266.ino @@ -64,7 +64,6 @@ #define NEOPIXELPIN 5 // pin to which the NeoPixels are attached -#define NUMPIXELS 125 // number of pixels attached #define BUTTONPIN 14 // pin to which the button is attached #define LEFT 1 #define RIGHT 2 From 3f48ad864428de06f6f9c6e0004ff75555466bc4 Mon Sep 17 00:00:00 2001 From: Edgar W <36072504+techniccontroller@users.noreply.github.com> Date: Sun, 26 Jan 2025 17:24:48 +0100 Subject: [PATCH 7/7] Update README.md --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 23f9232..0668086 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,14 @@ The code compiles only with one file named *wordclockfunctions.ino*. So please r Thank you to everyone who provided feedback on adding new languages and testing their accuracy — your efforts have been invaluable in making this project truly inclusive and reliable! +**Special Branches** + +We've got some interesting branches in this repo inspired by user feedback. These branches explore unique features and experimental ideas. Some will stay updated with the main branch's features. + +- [**hour_animation**](https://github.com/techniccontroller/wordclock_esp8266/tree/hour_animation): This branch replaces the spiral animation with some custom pattern animation defined as x/y coordinate pattern including custom color for each letter. Also, this animation is show ones per hour. +- [**mode_seconds**](https://github.com/techniccontroller/wordclock_esp8266/tree/mode_seconds): This branch adds one additional mode to show the seconds as numbers on the clock. Thanks to [@Bram](https://github.com/BramWerbrouck) +- [**rgbw_leds**](https://github.com/techniccontroller/wordclock_esp8266/tree/rgbw_leds): This branch uses RGBW LEDs instead of RGB LEDs. +- [**static_background_pattern**](https://github.com/techniccontroller/wordclock_esp8266/tree/static_background_pattern): This branch allows to light up specific letters always during clock mode. E.G., to display some special words in another color. ## Features - 6 modes (Clock, Digital Clock, SPIRAL animation, TETRIS, SNAKE, PONG)