From f805fee58f7a600c2479b038b6406e4fb818ddd9 Mon Sep 17 00:00:00 2001 From: David Panusch Date: Wed, 5 Jul 2023 21:19:55 +0200 Subject: [PATCH 01/29] SImplified SendCMD Message --- webpage/script.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webpage/script.js b/webpage/script.js index 4c6042d9..25453d34 100644 --- a/webpage/script.js +++ b/webpage/script.js @@ -621,7 +621,7 @@ function getPaddedString(string, maxStringLength) { } function sendCmd(command, addData = "") { - var data = nstr(command) + addData + "999"; + var data = nstr(command) + addData; debugMessage("Send data: '" + data + "'"); websocket.send(data); } From f132b58bedccc571eaaf8c3f4a52f1097e9ecc97 Mon Sep 17 00:00:00 2001 From: David Panusch Date: Thu, 6 Jul 2023 07:22:03 +0200 Subject: [PATCH 02/29] A color temp slider is introduced --- webpage/script.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/webpage/script.js b/webpage/script.js index 25453d34..7adb80c6 100644 --- a/webpage/script.js +++ b/webpage/script.js @@ -475,13 +475,10 @@ function createColorPicker() { options: { sliderType: "value" } }, { component: iro.ui.Slider, - options: { sliderType: "alpha" } + options: { sliderType: "kelvin" } }] }); colorPicker.on("input:change", changeColor); - // attach extra attribute to the alpha slider to only show it for RGBW LEDs - const alphaSlider = colorPicker.el.lastElementChild.lastElementChild; - alphaSlider.classList.add("specific-colortype-4"); } /** From 76827a2d0985f204cb88900b4d0e89fec528d5db Mon Sep 17 00:00:00 2001 From: David Panusch Date: Thu, 6 Jul 2023 07:32:36 +0200 Subject: [PATCH 03/29] Removed seperate alpha channel of color --- include/EEPROMAnything.h | 3 -- include/Uhr.h | 10 ----- include/clockWork.hpp | 8 ++-- include/led.hpp | 2 - include/mqtt.hpp | 1 - include/webPageAdapter.h | 30 +++++++------- webpage/script.js | 90 ++++++++++++++++++---------------------- 7 files changed, 57 insertions(+), 87 deletions(-) diff --git a/include/EEPROMAnything.h b/include/EEPROMAnything.h index bdeee802..61f34658 100644 --- a/include/EEPROMAnything.h +++ b/include/EEPROMAnything.h @@ -42,15 +42,12 @@ void read() { Serial.printf("FgCol.H : %f\n", G.color[Foreground].hsb.H); Serial.printf("FgCol.S : %f\n", G.color[Foreground].hsb.S); Serial.printf("FgCol.V : %f\n", G.color[Foreground].hsb.B); - Serial.printf("FgCol.A : %u\n", G.color[Foreground].alpha); Serial.printf("BgCol.H : %f\n", G.color[Background].hsb.H); Serial.printf("BgCol.S : %f\n", G.color[Background].hsb.S); Serial.printf("BgCol.V : %f\n", G.color[Background].hsb.B); - Serial.printf("BgCol.A : %u\n", G.color[Background].alpha); Serial.printf("EfCol.H : %f\n", G.color[Effect].hsb.H); Serial.printf("EfCol.S : %f\n", G.color[Effect].hsb.S); Serial.printf("EfCol.V : %f\n", G.color[Effect].hsb.B); - Serial.printf("EfCol.A : %u\n", G.color[Effect].alpha); Serial.printf("Zeitserver: %s\n", G.timeserver); Serial.printf("Lauftext : %s\n", G.scrollingText); Serial.printf("H6 : %u\n", G.h6); diff --git a/include/Uhr.h b/include/Uhr.h index 5877ebbb..b6899cc2 100644 --- a/include/Uhr.h +++ b/include/Uhr.h @@ -77,31 +77,21 @@ enum class SecondVariant { struct Color { HsbColor hsb; - uint16_t alpha; Color() { hsb = HsbColor(0, 0, 0); - alpha = 0; } Color(float newHue) { hsb.H = newHue; - alpha = 0; } Color(HsbColor newHsb) { hsb = newHsb; - alpha = 0; } Color(RgbColor newRgb) { hsb = HsbColor(newRgb); - alpha = 0; - } - - Color(HsbColor newHsb, uint16_t newAlpha) { - hsb = newHsb; - alpha = newAlpha; } }; diff --git a/include/clockWork.hpp b/include/clockWork.hpp index 6883d694..fa6637de 100644 --- a/include/clockWork.hpp +++ b/include/clockWork.hpp @@ -883,14 +883,12 @@ void ClockWork::loop(struct tm &tm) { config["command"] = "set"; for (uint8_t i = 0; i < 2; i++) { char string2Send[7]; - sprintf(string2Send, "hsva%d%d", i, 0); + sprintf(string2Send, "hsb%d%d", i, 0); config[string2Send] = static_cast(G.color[i].hsb.H * 360); - sprintf(string2Send, "hsva%d%d", i, 1); + sprintf(string2Send, "hsb%d%d", i, 1); config[string2Send] = static_cast(G.color[i].hsb.S * 100); - sprintf(string2Send, "hsva%d%d", i, 2); + sprintf(string2Send, "hsb%d%d", i, 2); config[string2Send] = static_cast(G.color[i].hsb.B * 100); - sprintf(string2Send, "hsva%d%d", i, 3); - config[string2Send] = static_cast(G.color[i].alpha); } config["effectBri"] = G.effectBri; config["effectSpeed"] = G.effectSpeed; diff --git a/include/led.hpp b/include/led.hpp index cce8329f..bd86e6c3 100644 --- a/include/led.hpp +++ b/include/led.hpp @@ -153,10 +153,8 @@ void Led::getColorbyPositionWithAppliedBrightness(Color &color, if (G.autoLdrEnabled) { color.hsb.B = setBrightnessAuto(color.hsb.B); - color.alpha = setBrightnessAuto(color.alpha); } else { color.hsb.B *= manBrightnessSetting / 100.f; - color.alpha *= manBrightnessSetting / 100.f; } } diff --git a/include/mqtt.hpp b/include/mqtt.hpp index cfd08e58..ef0c029f 100644 --- a/include/mqtt.hpp +++ b/include/mqtt.hpp @@ -105,7 +105,6 @@ void Mqtt::callback(char *topic, byte *payload, unsigned int length) { if (doc.containsKey("color")) { G.color[Foreground] = RgbColor(doc["color"][0], doc["color"][1], doc["color"][2]); - G.color[Foreground].alpha = 1; } } diff --git a/include/webPageAdapter.h b/include/webPageAdapter.h index 556afba9..84b8e790 100644 --- a/include/webPageAdapter.h +++ b/include/webPageAdapter.h @@ -146,8 +146,7 @@ void payloadTextHandling(const uint8_t *payload, char *text, void parseMainColor(uint8_t *payload, uint8_t position) { G.color[position] = {HsbColor(split(payload, 3) / 360.f, split(payload, 6) / 100.f, - split(payload, 9) / 100.f), - split(payload, 12)}; + split(payload, 9) / 100.f)}; } //------------------------------------------------------------------------------ @@ -192,10 +191,9 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t *payload, parametersChanged = true; parseMainColor(payload, Foreground); - G.color[Background] = {HsbColor(split(payload, 15) / 360.f, - split(payload, 18) / 100.f, - split(payload, 21) / 100.f), - split(payload, 24)}; + G.color[Background] = {HsbColor(split(payload, 12) / 360.f, + split(payload, 15) / 100.f, + split(payload, 18) / 100.f)}; break; } @@ -207,8 +205,8 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t *payload, parseMainColor(payload, Effect); - G.effectBri = split(payload, 27); - G.effectSpeed = split(payload, 30); + G.effectBri = split(payload, 21); + G.effectSpeed = split(payload, 24); break; } @@ -220,8 +218,8 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t *payload, parseMainColor(payload, Effect); - G.effectBri = split(payload, 27); - G.effectSpeed = split(payload, 30); + G.effectBri = split(payload, 21); + G.effectSpeed = split(payload, 24); break; } @@ -233,8 +231,8 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t *payload, parseMainColor(payload, Effect); - G.effectBri = split(payload, 27); - G.effectSpeed = split(payload, 30); + G.effectBri = split(payload, 21); + G.effectSpeed = split(payload, 24); break; } @@ -244,8 +242,8 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t *payload, G.prog = COMMAND_MODE_RAINBOWCYCLE; G.progInit = true; - G.effectBri = split(payload, 27); - G.effectSpeed = split(payload, 30); + G.effectBri = split(payload, 21); + G.effectSpeed = split(payload, 24); break; } @@ -255,8 +253,8 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t *payload, G.prog = COMMAND_MODE_RAINBOW; G.progInit = true; - G.effectBri = split(payload, 27); - G.effectSpeed = split(payload, 30); + G.effectBri = split(payload, 21); + G.effectSpeed = split(payload, 24); break; } diff --git a/webpage/script.js b/webpage/script.js index 7adb80c6..79b35b57 100644 --- a/webpage/script.js +++ b/webpage/script.js @@ -47,9 +47,9 @@ var websocket; var ipEsp = "ws://192.168.4.1"; var debug = true; var command = 1; -var hsva = [ - [0, 100, 50, 0], - [120, 100, 50, 0] +var hsb = [ + [0, 100, 50], + [120, 100, 50] ]; var effectBri = 2; var effectSpeed = 10; @@ -186,9 +186,9 @@ function initConfigValues() { debug = true; command = 1; - hsva = [ - [0, 100, 50, 0], - [120, 100, 50, 0] + hsb = [ + [0, 100, 50], + [120, 100, 50] ]; effectBri = 2; effectSpeed = 10; @@ -395,14 +395,12 @@ function initWebsocket() { enableSpecific("specific-layout-brightness-auto", autoLdrEnabled === 1); } if (data.command === "set") { - hsva[0][0] = data.hsva00; - hsva[0][1] = data.hsva01; - hsva[0][2] = data.hsva02; - hsva[0][3] = data.hsva03; - hsva[1][0] = data.hsva10; - hsva[1][1] = data.hsva11; - hsva[1][2] = data.hsva12; - hsva[1][3] = data.hsva13; + hsb[0][0] = data.hsb00; + hsb[0][1] = data.hsb01; + hsb[0][2] = data.hsb02; + hsb[1][0] = data.hsb10; + hsb[1][1] = data.hsb11; + hsb[1][2] = data.hsb12; effectBri = data.effectBri; effectSpeed = data.effectSpeed; colortype = data.colortype; @@ -456,10 +454,9 @@ function initWebsocket() { } function changeColor(color) { - hsva[color.index][0] = color.hue; - hsva[color.index][1] = color.saturation; - hsva[color.index][2] = color.value; - hsva[color.index][3] = Math.round(255 * (1.0 - color.alpha)); + hsb[color.index][0] = color.hue; + hsb[color.index][1] = color.saturation; + hsb[color.index][2] = color.value; sendColorData(command, nstr(1)); } @@ -485,21 +482,19 @@ function createColorPicker() { * show the color configuration in the color picker */ function setColorPicker(withBackground) { - var hsvaFg = { - h: hsva[COLOR_FOREGROUND][0], - s: hsva[COLOR_FOREGROUND][1], - v: hsva[COLOR_FOREGROUND][2], - a: 1.0 - hsva[COLOR_FOREGROUND][3] / 255.0 + var hsbFg = { + h: hsb[COLOR_FOREGROUND][0], + s: hsb[COLOR_FOREGROUND][1], + v: hsb[COLOR_FOREGROUND][2] }; - var hsvaBg = { - h: hsva[COLOR_BACKGROUND][0], - s: hsva[COLOR_BACKGROUND][1], - v: hsva[COLOR_BACKGROUND][2], - a: 1.0 - hsva[COLOR_BACKGROUND][3] / 255.0 + var hsbBg = { + h: hsb[COLOR_BACKGROUND][0], + s: hsb[COLOR_BACKGROUND][1], + v: hsb[COLOR_BACKGROUND][2] }; - var colors = [hsvaFg]; + var colors = [hsbFg]; if (withBackground) { - colors.push(hsvaBg); + colors.push(hsbBg); } colorPicker.setColors(colors); } @@ -509,10 +504,9 @@ function setColorPicker(withBackground) { */ function setColors() { var withBackground = - hsva[COLOR_BACKGROUND][0] || - hsva[COLOR_BACKGROUND][1] || - hsva[COLOR_BACKGROUND][2] || - hsva[COLOR_BACKGROUND][3]; + hsb[COLOR_BACKGROUND][0] || + hsb[COLOR_BACKGROUND][1] || + hsb[COLOR_BACKGROUND][2]; setColorPicker(withBackground); $("#with-background").set("checked", withBackground); } @@ -524,16 +518,14 @@ function toggleBackground() { var withBackground = $("#with-background").get("checked") | 0; if (withBackground) { // set to dark gray - hsva[COLOR_BACKGROUND][0] = 0; - hsva[COLOR_BACKGROUND][1] = 0; - hsva[COLOR_BACKGROUND][2] = 10; - hsva[COLOR_BACKGROUND][3] = 0; + hsb[COLOR_BACKGROUND][0] = 0; + hsb[COLOR_BACKGROUND][1] = 0; + hsb[COLOR_BACKGROUND][2] = 10; } else { // set to black - hsva[COLOR_BACKGROUND][0] = 0; - hsva[COLOR_BACKGROUND][1] = 0; - hsva[COLOR_BACKGROUND][2] = 0; - hsva[COLOR_BACKGROUND][3] = 0; + hsb[COLOR_BACKGROUND][0] = 0; + hsb[COLOR_BACKGROUND][1] = 0; + hsb[COLOR_BACKGROUND][2] = 0; } setColorPicker(withBackground); sendColorData(command, nstr(1)); @@ -638,14 +630,12 @@ function sendBrightnessData(command, addData = "") { } function sendColorData(command, addData = "") { - sendCmd(command, nstr(hsva[COLOR_FOREGROUND][0]) + - nstr(hsva[COLOR_FOREGROUND][1]) + - nstr(hsva[COLOR_FOREGROUND][2]) + - nstr(hsva[COLOR_FOREGROUND][3]) + - nstr(hsva[COLOR_BACKGROUND][0]) + - nstr(hsva[COLOR_BACKGROUND][1]) + - nstr(hsva[COLOR_BACKGROUND][2]) + - nstr(hsva[COLOR_BACKGROUND][3]) + + sendCmd(command, nstr(hsb[COLOR_FOREGROUND][0]) + + nstr(hsb[COLOR_FOREGROUND][1]) + + nstr(hsb[COLOR_FOREGROUND][2]) + + nstr(hsb[COLOR_BACKGROUND][0]) + + nstr(hsb[COLOR_BACKGROUND][1]) + + nstr(hsb[COLOR_BACKGROUND][2]) + nstr(effectBri) + nstr(effectSpeed)); } From 1834d5a1f1e584ee76af8ccc76ac6e8b2e40ed13 Mon Sep 17 00:00:00 2001 From: David Panusch Date: Thu, 6 Jul 2023 21:43:26 +0200 Subject: [PATCH 04/29] Refactored Marquee to Scrollingtext --- include/Uhr.h | 2 +- include/clockWork.hpp | 2 +- webpage/index.html | 8 ++++---- webpage/language/de.js | 4 ++-- webpage/language/en.js | 4 ++-- webpage/language/nl.js | 4 ++-- webpage/script.js | 16 +++++++--------- 7 files changed, 19 insertions(+), 21 deletions(-) diff --git a/include/Uhr.h b/include/Uhr.h index b6899cc2..f052ec2e 100644 --- a/include/Uhr.h +++ b/include/Uhr.h @@ -231,7 +231,7 @@ enum CommandWords { COMMAND_SET_SETTING_SECOND = 93, COMMAND_SET_MINUTE = 94, COMMAND_SET_BRIGHTNESS = 95, - COMMAND_SET_MARQUEE_TEXT = 96, + COMMAND_SET_SCROLLINGTEXT = 96, COMMAND_SET_TIMESERVER = 97, COMMAND_SET_WIFI_DISABLED = 98, COMMAND_SET_WIFI_AND_RESTART = 99, diff --git a/include/clockWork.hpp b/include/clockWork.hpp index fa6637de..22b6396a 100644 --- a/include/clockWork.hpp +++ b/include/clockWork.hpp @@ -943,7 +943,7 @@ void ClockWork::loop(struct tm &tm) { case COMMAND_SET_TIME: case COMMAND_SET_INITIAL_VALUES: case COMMAND_SET_WEATHER_DATA: - case COMMAND_SET_MARQUEE_TEXT: + case COMMAND_SET_SCROLLINGTEXT: case COMMAND_SET_BOOT: { eeprom::write(); delay(100); diff --git a/webpage/index.html b/webpage/index.html index e1a32956..18c32c44 100644 --- a/webpage/index.html +++ b/webpage/index.html @@ -118,7 +118,7 @@

- + @@ -170,10 +170,10 @@

- - + +
- +
diff --git a/webpage/language/de.js b/webpage/language/de.js index 50b9e515..2273eae7 100644 --- a/webpage/language/de.js +++ b/webpage/language/de.js @@ -30,7 +30,7 @@ let TRANSLATION_DE_DE = { "color": "Farbe", "seconds": "Sekunden", "digital-clock": "Digitaluhr", - "marquee": "Laufschrift", + "scrollingtext": "Laufschrift", "rainbow": "Regenbogen", "color-change": "Farbwechsel" }, @@ -61,7 +61,7 @@ let TRANSLATION_DE_DE = { "settings": { "h2": "Einstellungen", "brightness": "Helligkeit ", - "marquee-text": "Lauftext", + "scrollingtext": "Lauftext", "save": "Speichern", "speed": "Geschwindigkeit ", "leds": "Anzahl LEDs ", diff --git a/webpage/language/en.js b/webpage/language/en.js index 0db1513e..eedb920b 100644 --- a/webpage/language/en.js +++ b/webpage/language/en.js @@ -30,7 +30,7 @@ let TRANSLATION_EN_US = { "color": "Color", "seconds": "Seconds", "digital-clock": "Digital Clock", - "marquee": "Marquee", + "scrollingtext": "Scrollingtext", "rainbow": "Rainbow", "color-change": "Color Change" }, @@ -61,7 +61,7 @@ let TRANSLATION_EN_US = { "settings": { "h2": "Settings", "brightness": "Brightness ", - "marquee-text": "Marquee Text", + "scrollingtext": "Scrolling text", "save": "Save", "speed": "Speed ", "leds": "Number of LEDs ", diff --git a/webpage/language/nl.js b/webpage/language/nl.js index c1c36eb5..f6c45f59 100644 --- a/webpage/language/nl.js +++ b/webpage/language/nl.js @@ -30,7 +30,7 @@ let TRANSLATION_NL = { "color": "Kleur", "seconds": "Seconden", "digital-clock": "Digitale klok", - "marquee": "Tekst", + "scrollingtext": "Tekst", "rainbow": "Regenboog", "color-change": "Kleurverandering" }, @@ -61,7 +61,7 @@ let TRANSLATION_NL = { "settings": { "h2": "Instellingen", "brightness": "Helderheid ", - "marquee-text": "Tekst", + "scrollingtext": "Tekst", "save": "Opslaan", "speed": "Snelheid ", "leds": "Aantal LED's ", diff --git a/webpage/script.js b/webpage/script.js index 79b35b57..cdc0aa2d 100644 --- a/webpage/script.js +++ b/webpage/script.js @@ -114,7 +114,7 @@ const MODE_TO_INPUT_ID = new Map(); MODE_TO_INPUT_ID.set(0, "mode-wordclock"); // Map COMMAND_IDLE to mode wordclock MODE_TO_INPUT_ID.set(COMMAND_MODE_WORD_CLOCK, "mode-wordclock"); MODE_TO_INPUT_ID.set(COMMAND_MODE_SECONDS, "mode-seconds"); -MODE_TO_INPUT_ID.set(COMMAND_MODE_SCROLLINGTEXT, "mode-marquee"); +MODE_TO_INPUT_ID.set(COMMAND_MODE_SCROLLINGTEXT, "mode-scrollingtext"); MODE_TO_INPUT_ID.set(COMMAND_MODE_RAINBOWCYCLE, "mode-rainbow"); MODE_TO_INPUT_ID.set(COMMAND_MODE_RAINBOW, "mode-change"); // Color change MODE_TO_INPUT_ID.set(COMMAND_MODE_COLOR, "mode-color"); @@ -136,7 +136,7 @@ var COMMAND_SET_HOSTNAME = 92; var COMMAND_SET_SETTING_SECOND = 93; var COMMAND_SET_MINUTE = 94; var COMMAND_SET_BRIGHTNESS = 95; -var COMMAND_SET_MARQUEE_TEXT = 96; +var COMMAND_SET_SCROLLINGTEXT = 96; var COMMAND_SET_TIMESERVER = 97; var COMMAND_SET_WIFI_DISABLED = 98; var COMMAND_SET_WIFI_AND_RESTART = 99; @@ -159,7 +159,7 @@ var COLOR_FOREGROUND = 0; var COLOR_BACKGROUND = 1; // data that gets send back to the esp -var DATA_MARQUEE_TEXT_LENGTH = 30; +var DATA_SCROLLINGTEXT_LENGTH = 30; var DATA_TIMESERVER_TEXT_LENGTH = 30; var DATA_MQTT_RESPONSE_TEXT_LENGTH = 30; var DATA_HOST_TEXT_LENGTH = 30; @@ -340,7 +340,7 @@ function initWebsocket() { $("#timeserver").set("value", data.timeserver); $("#hostname").set("value", data.hostname); - $("#marquee").set("value", data.scrollingText); + $("#scrollingtext").set("value", data.scrollingText); $("#brightness-6").set("value", data.h6); $("#brightness-8").set("value", data.h8); @@ -742,7 +742,7 @@ $.ready(function() { if (id === "mode-digital-clock") { command = COMMAND_MODE_DIGITAL_CLOCK; } - if (id === "mode-marquee") { + if (id === "mode-scrollingtext") { hasSpeed = true; hasText = true; command = COMMAND_MODE_SCROLLINGTEXT; @@ -878,10 +878,8 @@ $.ready(function() { debugMessage("Timeserver" + debugMessageReconfigured); return false; }); - $("#marquee-button").on("click", function() { - var marqueeTextValue = $("#marquee").get("value"); - - sendCmd(COMMAND_SET_MARQUEE_TEXT, getPaddedString(marqueeTextValue, DATA_MARQUEE_TEXT_LENGTH)); + $("#scrollingtext-button").on("click", function() { + sendCmd(COMMAND_SET_SCROLLINGTEXT, getPaddedString($("#scrollingtext").get("value"), DATA_SCROLLINGTEXT_LENGTH)); debugMessage("ScrollingText" + debugMessageReconfigured); }); $("[id*='brightness']").on("change", function() { From 8cc1ce74e750eb23daf8751b40538750ff1694d5 Mon Sep 17 00:00:00 2001 From: David Panusch Date: Thu, 6 Jul 2023 21:44:29 +0200 Subject: [PATCH 05/29] Few small cosmetic changes to script.js --- webpage/script.js | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/webpage/script.js b/webpage/script.js index cdc0aa2d..d43880ee 100644 --- a/webpage/script.js +++ b/webpage/script.js @@ -652,14 +652,13 @@ $.ready(function() { $("#with-background").on("change", toggleBackground); $(".status-button").on("click", function() { var value = $(this).get("value"); + $("#status").fill("Verbinden ..."); if (value === "1") { value = 0; - $("#status").fill("Verbinden ..."); $(".status-button").set("value", value); websocket.close(); } else { value = 1; - $("#status").fill("Verbinden ..."); $(".status-button").set("value", value); initWebsocket(); } @@ -871,10 +870,7 @@ $.ready(function() { return false; }); $("#timeserver-button").on("click", function() { - - var timeserverValue = $("#timeserver").get("value"); - - sendCmd(COMMAND_SET_TIMESERVER, getPaddedString(timeserverValue, DATA_TIMESERVER_TEXT_LENGTH)); + sendCmd(COMMAND_SET_TIMESERVER, getPaddedString($("#timeserver").get("value"), DATA_TIMESERVER_TEXT_LENGTH)); debugMessage("Timeserver" + debugMessageReconfigured); return false; }); @@ -886,29 +882,19 @@ $.ready(function() { sendBrightnessData(COMMAND_SET_BRIGHTNESS); }); $("#weather-button").on("click", function() { - - var apiKey = $("#owm-api-key").get("value"); - var cityId = $("#owm-city-id").get("value"); - - sendCmd(COMMAND_SET_WEATHER_DATA, cityId + " " + apiKey); + sendCmd(COMMAND_SET_WEATHER_DATA, $("#owm-city-id").get("value") + " " + $("#owm-api-key").get("value")); debugMessage("OpenWeatherMap Login" + debugMessageReconfigured); }); $("#show-minutes").on("change", function() { - var showMinutesValue = $("#show-minutes").get("value"); - - sendCmd(COMMAND_SET_MINUTE, nstr(showMinutesValue)); + sendCmd(COMMAND_SET_MINUTE, nstr($("#show-minutes").get("value"))); debugMessage("MinuteVariant" + debugMessageReconfigured); }); $("#show-seconds").on("change", function() { - var showSecondsValue = $("#show-seconds").get("value"); - - sendCmd(COMMAND_SET_SETTING_SECOND, nstr(showSecondsValue)); + sendCmd(COMMAND_SET_SETTING_SECOND, nstr($("#show-seconds").get("value"))); debugMessage("SecondVariant" + debugMessageReconfigured); }); $("#front-layout").on("change", function() { - var frontLayout = $("#front-layout").get("value"); - - sendCmd(COMMAND_SET_UHRTYPE, nstr(frontLayout)); + sendCmd(COMMAND_SET_UHRTYPE, nstr($("#front-layout").get("value"))); sendCmd(COMMAND_REQUEST_CONFIG_VALUES); debugMessage("FrontLayout" + debugMessageReconfigured); }); @@ -919,9 +905,7 @@ $.ready(function() { debugMessage("Colortype" + debugMessageReconfigured); }); $("#hostname-button").on("click", function() { - var hostname = $("#hostname").get("value"); - - sendCmd(COMMAND_SET_HOSTNAME, getPaddedString(hostname, DATA_HOST_TEXT_LENGTH)); + sendCmd(COMMAND_SET_HOSTNAME, getPaddedString($("#hostname").get("value"), DATA_HOST_TEXT_LENGTH)); debugMessage("Hostname" + debugMessageReconfigured); }); $("[id*='boot-show']").on("change", function() { From 156eee79da03f033c7847bbe5860d2a7b49d9d90 Mon Sep 17 00:00:00 2001 From: David Panusch Date: Thu, 6 Jul 2023 21:47:54 +0200 Subject: [PATCH 06/29] Removed redundand Code in WeppageAdapter --- include/Uhr.h | 7 ++++- include/webPageAdapter.h | 57 +++++++++++----------------------------- 2 files changed, 21 insertions(+), 43 deletions(-) diff --git a/include/Uhr.h b/include/Uhr.h index f052ec2e..4021ec6a 100644 --- a/include/Uhr.h +++ b/include/Uhr.h @@ -214,8 +214,10 @@ enum CommandWords { COMMAND_MODE_RAINBOW = 5, COMMAND_MODE_COLOR = 6, COMMAND_MODE_DIGITAL_CLOCK = 7, - COMMAND_MODE_ANIMATION = 10, + + PLACEHOLDER_MAX_MODE = 19, + COMMAND_SET_INITIAL_VALUES = 20, COMMAND_SET_TIME = 30, @@ -242,6 +244,8 @@ enum CommandWords { COMMAND_SPEED = 152, + PLACEHOLDER_MAX_SET = 199, + COMMAND_REQUEST_CONFIG_VALUES = 200, COMMAND_REQUEST_COLOR_VALUES = 201, COMMAND_REQUEST_WIFI_LIST = 202, @@ -249,6 +253,7 @@ enum CommandWords { COMMAND_REQUEST_ANIMATION = 204, COMMAND_REQUEST_MQTT_VALUES = 205, + PLACEHOLDER_MAX_REQUEST = 255, }; enum ClockType { diff --git a/include/webPageAdapter.h b/include/webPageAdapter.h index 84b8e790..1647673f 100644 --- a/include/webPageAdapter.h +++ b/include/webPageAdapter.h @@ -178,7 +178,7 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t *payload, case WStype_TEXT: { Serial.printf("[%u] get Text: %s\n", length, payload); - uint16_t command = split(payload, 0); + uint8_t command = split(payload, 0); G.param1 = 0; switch (command) { @@ -186,11 +186,8 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t *payload, if (G.prog != COMMAND_IDLE && G.prog != COMMAND_MODE_WORD_CLOCK) { G.progInit = true; } - G.prog = COMMAND_MODE_WORD_CLOCK; - parametersChanged = true; parseMainColor(payload, Foreground); - G.color[Background] = {HsbColor(split(payload, 12) / 360.f, split(payload, 15) / 100.f, split(payload, 18) / 100.f)}; @@ -200,11 +197,9 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t *payload, //------------------------------------------------------------------------------ case COMMAND_MODE_SECONDS: { - G.prog = COMMAND_MODE_SECONDS; G.progInit = true; parseMainColor(payload, Effect); - G.effectBri = split(payload, 21); G.effectSpeed = split(payload, 24); break; @@ -213,11 +208,9 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t *payload, //------------------------------------------------------------------------------ case COMMAND_MODE_DIGITAL_CLOCK: { - G.prog = COMMAND_MODE_DIGITAL_CLOCK; G.progInit = true; parseMainColor(payload, Effect); - G.effectBri = split(payload, 21); G.effectSpeed = split(payload, 24); break; @@ -226,11 +219,9 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t *payload, //------------------------------------------------------------------------------ case COMMAND_MODE_SCROLLINGTEXT: { - G.prog = COMMAND_MODE_SCROLLINGTEXT; G.progInit = true; parseMainColor(payload, Effect); - G.effectBri = split(payload, 21); G.effectSpeed = split(payload, 24); break; @@ -239,7 +230,6 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t *payload, //------------------------------------------------------------------------------ case COMMAND_MODE_RAINBOWCYCLE: { - G.prog = COMMAND_MODE_RAINBOWCYCLE; G.progInit = true; G.effectBri = split(payload, 21); @@ -250,7 +240,6 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t *payload, //------------------------------------------------------------------------------ case COMMAND_MODE_RAINBOW: { - G.prog = COMMAND_MODE_RAINBOW; G.progInit = true; G.effectBri = split(payload, 21); @@ -261,7 +250,6 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t *payload, //------------------------------------------------------------------------------ case COMMAND_MODE_COLOR: { - G.prog = COMMAND_MODE_COLOR; G.progInit = true; parseMainColor(payload, Effect); @@ -270,17 +258,14 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t *payload, //------------------------------------------------------------------------------ case COMMAND_MODE_ANIMATION: { - G.prog = COMMAND_MODE_ANIMATION; G.progInit = true; + G.animType = split(payload, 3); G.animDuration = split(payload, 6); G.animSpeed = split(payload, 9); G.animColorize = split(payload, 12); G.animDemo = split(payload, 15); - // Serial.printf("animType %d - // animDuration %d animSpeed %d animColorize %d animDemo %d\n", - // G.animType, G.animDuration, G.animSpeed, G.animColorize, - // G.animDemo); + ; break; } @@ -297,15 +282,12 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t *payload, Serial.println("Startwerte gespeichert"); parseMainColor(payload, Foreground); - - G.conf = COMMAND_SET_INITIAL_VALUES; break; } //------------------------------------------------------------------------------ case COMMAND_SET_TIME: { - G.conf = COMMAND_SET_TIME; ii = 0; tmp[0] = '\0'; uint32_t tt = split(payload, 3, 16); @@ -325,7 +307,6 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t *payload, //------------------------------------------------------------------------------ case COMMAND_SET_HOSTNAME: { - G.conf = COMMAND_SET_HOSTNAME; payloadTextHandling(payload, G.hostname); break; } @@ -333,7 +314,6 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t *payload, //------------------------------------------------------------------------------ case COMMAND_SET_SETTING_SECOND: { - G.conf = COMMAND_SET_SETTING_SECOND; G.progInit = true; G.secondVariant = static_cast(split(payload, 3)); @@ -343,7 +323,6 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t *payload, //------------------------------------------------------------------------------ case COMMAND_SET_MINUTE: { - G.conf = COMMAND_SET_MINUTE; G.minuteVariant = static_cast(split(payload, 3)); break; } @@ -351,7 +330,6 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t *payload, //------------------------------------------------------------------------------ case COMMAND_SET_AUTO_LDR: { - G.conf = COMMAND_SET_AUTO_LDR; G.autoLdrEnabled = split(payload, 3); G.autoLdrBright = split(payload, 6); G.autoLdrDark = split(payload, 9); @@ -361,7 +339,6 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t *payload, //------------------------------------------------------------------------------ case COMMAND_SET_LANGUAGE_VARIANT: { - G.conf = COMMAND_SET_LANGUAGE_VARIANT; G.languageVariant[ItIs15] = split(payload, 3); G.languageVariant[ItIs20] = split(payload, 6); G.languageVariant[ItIs40] = split(payload, 9); @@ -374,7 +351,6 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t *payload, //------------------------------------------------------------------------------ case COMMAND_SET_LAYOUT_VARIANT: { - G.conf = COMMAND_SET_LAYOUT_VARIANT; G.layoutVariant[ReverseMinDirection] = split(payload, 3); G.layoutVariant[MirrorVertical] = split(payload, 6); G.layoutVariant[MirrorHorizontal] = split(payload, 9); @@ -384,7 +360,6 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t *payload, //------------------------------------------------------------------------------ case COMMAND_SET_MQTT: { - G.conf = COMMAND_SET_MQTT; if (!G.mqtt.state) { G.progInit = true; } @@ -406,7 +381,6 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t *payload, //------------------------------------------------------------------------------ case COMMAND_SET_TIME_MANUAL: { - G.conf = COMMAND_SET_TIME_MANUAL; time_t old = time(nullptr); struct tm tm; localtime_r(&old, &tm); @@ -425,7 +399,6 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t *payload, //------------------------------------------------------------------------------ case COMMAND_SET_COLORTYPE: { - G.conf = COMMAND_SET_COLORTYPE; G.progInit = true; G.param1 = split(payload, 3); @@ -435,8 +408,8 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t *payload, //------------------------------------------------------------------------------ case COMMAND_SET_BUILDTYPE: { - G.conf = COMMAND_SET_BUILDTYPE; G.progInit = true; + G.param1 = split(payload, 3); break; } @@ -444,7 +417,6 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t *payload, //------------------------------------------------------------------------------ case COMMAND_SET_WHITETYPE: { - G.conf = COMMAND_SET_WHITETYPE; G.wType = static_cast(split(payload, 3)); break; } @@ -452,7 +424,6 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t *payload, //------------------------------------------------------------------------------ case COMMAND_SET_UHRTYPE: { - G.conf = COMMAND_SET_UHRTYPE; G.UhrtypeDef = split(payload, 3); break; } @@ -460,7 +431,6 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t *payload, //------------------------------------------------------------------------------ case COMMAND_SET_WEATHER_DATA: { - G.conf = COMMAND_SET_WEATHER_DATA; ii = 0; for (uint8_t k = 3; k < 10; k++) { if (payload[k] != ' ') { @@ -489,7 +459,6 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t *payload, //------------------------------------------------------------------------------ case COMMAND_SET_BRIGHTNESS: { - G.conf = COMMAND_SET_BRIGHTNESS; G.h6 = split(payload, 3); G.h8 = split(payload, 6); G.h12 = split(payload, 9); @@ -504,8 +473,7 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t *payload, //------------------------------------------------------------------------------ - case COMMAND_SET_MARQUEE_TEXT: { - G.conf = COMMAND_SET_MARQUEE_TEXT; + case COMMAND_SET_SCROLLINGTEXT: { payloadTextHandling(payload, G.scrollingText); break; } @@ -513,7 +481,6 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t *payload, //------------------------------------------------------------------------------ case COMMAND_SET_TIMESERVER: { - G.conf = COMMAND_SET_TIMESERVER; payloadTextHandling(payload, G.timeserver); break; } @@ -521,7 +488,6 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t *payload, //------------------------------------------------------------------------------ case COMMAND_SET_BOOT: { - G.conf = COMMAND_SET_BOOT; G.bootLedBlink = split(payload, 3); G.bootLedSweep = split(payload, 6); G.bootShowWifi = split(payload, 9); @@ -533,7 +499,6 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t *payload, case COMMAND_SET_WIFI_DISABLED: case COMMAND_SET_WIFI_AND_RESTART: case COMMAND_RESET: { - G.conf = command; break; } @@ -544,7 +509,6 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t *payload, case COMMAND_REQUEST_COLOR_VALUES: case COMMAND_REQUEST_WIFI_LIST: case COMMAND_REQUEST_ANIMATION: { - G.conf = command; G.client_nr = num; break; } @@ -552,8 +516,8 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t *payload, //------------------------------------------------------------------------------ case COMMAND_REQUEST_AUTO_LDR: { + G.param1 = split(payload, 3); - G.conf = command; G.client_nr = num; break; } @@ -563,6 +527,15 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t *payload, default: break; } + + if (command < PLACEHOLDER_MAX_MODE) { + G.prog = command; + } else if (command < PLACEHOLDER_MAX_SET) { + G.conf = command; + } else if (command < PLACEHOLDER_MAX_REQUEST) { + G.conf = command; + } + break; } case WStype_BIN: { From 72f708b6708311db3ca3fc2c6f266d6dde1e55fe Mon Sep 17 00:00:00 2001 From: David Panusch Date: Thu, 6 Jul 2023 21:48:20 +0200 Subject: [PATCH 07/29] Clang formated code --- include/Uhr.h | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/include/Uhr.h b/include/Uhr.h index 4021ec6a..f1b0f1ad 100644 --- a/include/Uhr.h +++ b/include/Uhr.h @@ -78,21 +78,13 @@ enum class SecondVariant { struct Color { HsbColor hsb; - Color() { - hsb = HsbColor(0, 0, 0); - } + Color() { hsb = HsbColor(0, 0, 0); } - Color(float newHue) { - hsb.H = newHue; - } + Color(float newHue) { hsb.H = newHue; } - Color(HsbColor newHsb) { - hsb = newHsb; - } + Color(HsbColor newHsb) { hsb = newHsb; } - Color(RgbColor newRgb) { - hsb = HsbColor(newRgb); - } + Color(RgbColor newRgb) { hsb = HsbColor(newRgb); } }; struct GLOBAL { From c0a7b1f61fcff12754a8dc791e96e9d74c7159fe Mon Sep 17 00:00:00 2001 From: David Panusch Date: Thu, 6 Jul 2023 22:03:08 +0200 Subject: [PATCH 08/29] Added a new layout DE16x8 --- include/Uhr.h | 1 + include/Uhrtypes/DE16x8.hpp | 218 ++++++++++++++++++++++++++++++++++++ include/clockWork.hpp | 2 + include/config.h | 4 + webpage/index.html | 1 + webpage/language/de.js | 1 + webpage/language/en.js | 1 + webpage/language/nl.js | 1 + 8 files changed, 229 insertions(+) create mode 100644 include/Uhrtypes/DE16x8.hpp diff --git a/include/Uhr.h b/include/Uhr.h index f1b0f1ad..c5a98617 100644 --- a/include/Uhr.h +++ b/include/Uhr.h @@ -259,6 +259,7 @@ enum ClockType { Ger11x11 = 3, Ger11x11V2 = 8, Ger22x11Weather = 5, + Ger16x8 = 13, Ger16x18 = 7, Nl10x11 = 9, }; diff --git a/include/Uhrtypes/DE16x8.hpp b/include/Uhrtypes/DE16x8.hpp new file mode 100644 index 00000000..dc7b9a56 --- /dev/null +++ b/include/Uhrtypes/DE16x8.hpp @@ -0,0 +1,218 @@ +#pragma once + +#include "Uhrtype.hpp" + +/* + * Layout Front + * COL + * 5 4 3 2 1 X 9 8 7 6 5 4 3 2 1 0 + * ROW + - - - - - - - - - - - - - - - - + * 0 | E S H I S T C W L A N Z E I T X + * 1 | Z W A N Z I G H A L B O Z E H N + * 2 | F Ü N F V I E R T E L T N A C H + * 3 | V O R E H A L B D Z E H N E L F + * 4 | Z W E I D R E I N E U N V I E R + * 5 | A C H T E I N S E C H S F Ü N F + * 6 | S I E B E N Z W Ö L F T A U H R + * 7 | U + D 1 2 3 4 P M I N U T E N X + */ + +class De16x8_t : public iUhrType { +public: + virtual LanguageAbbreviation usedLang() override { + return LanguageAbbreviation::DE; + }; + + //------------------------------------------------------------------------------ + + virtual void setFrontMatrixPixel(const int row, const int col, + bool state = true) { + if (state) { + frontMatrix[row] |= 1UL << col; + } else { + frontMatrix[row] &= ~(1UL << col); + } + } + + //------------------------------------------------------------------------------ + + virtual const uint16_t getFrontMatrixIndex(uint8_t row, + uint8_t col) override { + + row *= 2; + uint8_t newColsWordMatrix = colsWordMatrix(); + uint16_t numPixelsWordMatrix = rowsWordMatrix() * colsWordMatrix(); + + if (G.buildTypeDef == BuildTypeDef::DoubleResM1) { + newColsWordMatrix = 2 * colsWordMatrix() - 1; + numPixelsWordMatrix = rowsWordMatrix() * newColsWordMatrix; + col *= 2; + } + if (row % 2 != 0) { + col = newColsWordMatrix - col - 1; + } + uint16_t returnValue = col + (row * newColsWordMatrix); + + if (returnValue > numPixelsWordMatrix) { + // Serial.println("[ERROR] getFrontMatrixIndex() returnValue out of + // Bounds"); + } + + return returnValue; + }; + + //------------------------------------------------------------------------------ + + /* virtual void setFrontMatrixPixel(const int index, + bool state = true) override { + uint8_t col, row; + getFrontMatrixColRow(row, col, index); + for (uint8_t i = 0; i < 2; i++) { + setFrontMatrixPixel(row + 1, col, state); + } + } */ + + //------------------------------------------------------------------------------ + + virtual const uint8_t rowsWordMatrix() override { return 8; }; + + //------------------------------------------------------------------------------ + + virtual const uint8_t colsWordMatrix() override { return 16; }; + + //------------------------------------------------------------------------------ + + virtual const void getMinuteArray(uint16_t *returnArr, uint8_t col) { + uint16_t numPixelsWordMatrix = rowsWordMatrix() * colsWordMatrix(); + + for (uint8_t i = 0; i < 4; i++) { + switch (col) { + case 0: // LEDs for "LED4x" minute display + returnArr[i] = numPixelsWordMatrix + i; + break; + case 1: // LEDs for "LED7x" minute display + returnArr[i] = numPixelsWordMatrix + i * 2; + break; + + case 2: // LEDs for "16x16Matrix" minute display + returnArr[i] = 124 - i; + break; + + default: + break; + } + } + }; + + //------------------------------------------------------------------------------ + + void show(FrontWord word) override { + switch (word) { + + case FrontWord::es_ist: + // Es + setFrontMatrixWord(0, 14, 15); + // Ist + setFrontMatrixWord(0, 10, 12); + break; + + case FrontWord::nach: + case FrontWord::v_nach: + setFrontMatrixWord(2, 0, 3); + break; + + case FrontWord::vor: + case FrontWord::v_vor: + setFrontMatrixWord(3, 13, 15); + break; + + case FrontWord::viertel: + setFrontMatrixWord(2, 5, 11); + break; + + case FrontWord::fuenf: + setFrontMatrixWord(2, 12, 15); + break; + + case FrontWord::zehn: + setFrontMatrixWord(1, 0, 3); + break; + + case FrontWord::zwanzig: + setFrontMatrixWord(1, 9, 15); + break; + + case FrontWord::halb: + setFrontMatrixWord(3, 8, 11); + break; + + case FrontWord::eins: + setFrontMatrixWord(5, 8, 11); + break; + + case FrontWord::uhr: + setFrontMatrixWord(6, 0, 2); + break; + + case FrontWord::h_ein: + setFrontMatrixWord(4, 7, 9); + break; + + case FrontWord::h_zwei: + setFrontMatrixWord(4, 12, 15); + break; + + case FrontWord::h_drei: + setFrontMatrixWord(4, 8, 11); + break; + + case FrontWord::h_vier: + setFrontMatrixWord(4, 0, 3); + break; + + case FrontWord::h_fuenf: + setFrontMatrixWord(5, 0, 3); + break; + + case FrontWord::h_sechs: + setFrontMatrixWord(5, 4, 8); + break; + + case FrontWord::h_sieben: + setFrontMatrixWord(6, 10, 15); + break; + + case FrontWord::h_acht: + setFrontMatrixWord(5, 12, 15); + break; + + case FrontWord::h_neun: + setFrontMatrixWord(4, 7, 10); + break; + + case FrontWord::h_zehn: + setFrontMatrixWord(3, 3, 6); + break; + + case FrontWord::h_elf: + setFrontMatrixWord(3, 0, 2); + break; + + case FrontWord::h_zwoelf: + setFrontMatrixWord(6, 5, 9); + break; + + case FrontWord::minuten: + setFrontMatrixWord(7, 1, 1); + break; + case FrontWord::minute: + setFrontMatrixWord(7, 2, 7); + break; + + default: + break; + }; + }; +}; + +De16x8_t _de16x8; \ No newline at end of file diff --git a/include/clockWork.hpp b/include/clockWork.hpp index 22b6396a..f5a7238b 100644 --- a/include/clockWork.hpp +++ b/include/clockWork.hpp @@ -60,6 +60,8 @@ iUhrType *ClockWork::getPointer(uint8_t type) { return &_de11x11V2; case Ger22x11Weather: return &_de22x11Weather; + case Ger16x8: + return &_de16x8; case Ger16x18: return &_de16x18; case Eng10x11: diff --git a/include/config.h b/include/config.h index 3c2ab952..8a03839c 100644 --- a/include/config.h +++ b/include/config.h @@ -44,6 +44,10 @@ // 22 rows, each 11 LED's per row, with weather forecast on overall 242 LED's // based on design of Github user @Eisbaeeer // +// #define DEFAULT_LAYOUT Ger16x8 +// 16 rows, each 8 LED's per row, based on a 16x16 presoldered WS2812b matrix +// and a 3D printed case +// // #define DEFAULT_LAYOUT Ger16x18 // 16 rows, each 18 LED's per row, with the layout WordClock24h of // mikrocontroller.net diff --git a/webpage/index.html b/webpage/index.html index 18c32c44..2c410c21 100644 --- a/webpage/index.html +++ b/webpage/index.html @@ -215,6 +215,7 @@

+ diff --git a/webpage/language/de.js b/webpage/language/de.js index 2273eae7..effe2518 100644 --- a/webpage/language/de.js +++ b/webpage/language/de.js @@ -84,6 +84,7 @@ let TRANSLATION_DE_DE = { "de-11-11": "Deutsch 11 × 11", "de-11-11-v2": "Deutsch 11 × 11 Version 2", "de-22-11-weather": "Deutsch 10 × 11 Wetter", + "de-16-8": "Deutsch 16 × 8", "de-16-18": "Deutsch 16 × 18", "en-10-11": "Englisch 10 × 11", "nl-10-11": "Niederländisch 10 × 11", diff --git a/webpage/language/en.js b/webpage/language/en.js index eedb920b..e6b273f3 100644 --- a/webpage/language/en.js +++ b/webpage/language/en.js @@ -84,6 +84,7 @@ let TRANSLATION_EN_US = { "de-11-11": "German 11 × 11", "de-11-11-v2": "German 11 × 11 Version 2", "de-22-11-weather": "German 10 × 11 Weather", + "de-16-8": "German 16 × 8", "de-16-18": "German 16 × 18", "en-10-11": "English 10 × 11", "nl-10-11": "Dutch 10 × 11", diff --git a/webpage/language/nl.js b/webpage/language/nl.js index f6c45f59..01f23580 100644 --- a/webpage/language/nl.js +++ b/webpage/language/nl.js @@ -84,6 +84,7 @@ let TRANSLATION_NL = { "de-11-11": "Duits 11 × 11", "de-11-11-v2": "Duits 11 × 11 Versie 2", "de-22-11-weather": "Duits 10 × 11 Weer", + "de-16-8": "Duits 16 × 8", "de-16-18": "Duits 16 × 18", "en-10-11": "Engels 10 × 11", "nl-10-11": "Nederlands 10 × 11", From 6e136d8668e3955b3b976e4cccf6b6ff5e7825af Mon Sep 17 00:00:00 2001 From: David Panusch Date: Thu, 6 Jul 2023 23:27:08 +0200 Subject: [PATCH 09/29] Enhancements to support more col/row combinations --- include/led.hpp | 46 +++++++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/include/led.hpp b/include/led.hpp index bd86e6c3..450cac07 100644 --- a/include/led.hpp +++ b/include/led.hpp @@ -280,13 +280,15 @@ void Led::setbySecondArray(uint8_t colorPosition) { //------------------------------------------------------------------------------ void Led::setIcon(uint8_t num_icon, uint8_t brightness = 100) { + uint8_t offsetCol = (usedUhrType->colsWordMatrix() - GRAFIK_11X10_COLS) / 2; + for (uint8_t col = 0; col < GRAFIK_11X10_COLS; col++) { for (uint8_t row = 0; row < GRAFIK_11X10_ROWS; row++) { if (pgm_read_word(&(grafik_11x10[num_icon][row])) & (1 << (GRAFIK_11X10_COLS - 1 - col))) { - usedUhrType->setFrontMatrixPixel(row, col); + usedUhrType->setFrontMatrixPixel(row, col + offsetCol); } else { - usedUhrType->setFrontMatrixPixel(row, col, false); + usedUhrType->setFrontMatrixPixel(row, col + offsetCol, false); } } } @@ -440,8 +442,9 @@ inline void Led::clear() { void Led::showNumbers(const char d1, const char d2) { clearClock(); - static uint8_t offsetLetter0 = 0; - static uint8_t offsetLetter1 = fontWidth[normalSizeASCII] + 1; + static uint8_t offsetLetter0 = + usedUhrType->colsWordMatrix() / 2 - fontWidth[normalSizeASCII]; + static uint8_t offsetLetter1 = usedUhrType->colsWordMatrix() / 2 + 1; uint8_t offsetRow = (usedUhrType->rowsWordMatrix() - fontHeight[normalSizeASCII]) / 2; @@ -470,36 +473,37 @@ void Led::showNumbers(const char d1, const char d2) { void Led::showDigitalClock(const char min1, const char min0, const char h1, const char h0) { + + uint8_t letterSpacing = 1; + if (usedUhrType->rowsWordMatrix() >= fontHeight[smallSizeNumbers] * 2) { + letterSpacing++; + } + // 1st Row of letters vertical Offset - static uint8_t offsetLetterH0 = - usedUhrType->colsWordMatrix() / 2 - fontWidth[smallSizeNumbers] - 1; + static uint8_t offsetLetterH0 = 0; static uint8_t offsetLetterH1 = - offsetLetterH0 + fontWidth[smallSizeNumbers] + 2; + offsetLetterH0 + fontWidth[smallSizeNumbers] + letterSpacing; // 2nd Row of letters vertical Offset - static uint8_t offsetLetterMin0 = 3; static uint8_t offsetLetterMin1 = - offsetLetterMin0 + fontWidth[smallSizeNumbers] + 2; + usedUhrType->colsWordMatrix() - fontWidth[smallSizeNumbers]; + static uint8_t offsetLetterMin0 = + offsetLetterMin1 - fontWidth[smallSizeNumbers] - letterSpacing; // 1st Row of letters horizontal Offset - uint8_t offsetRow0 = - usedUhrType->rowsWordMatrix() / 2 - fontHeight[smallSizeNumbers]; + uint8_t offsetRow0 = 0; // 2nd Row of letters horizontal Offset - uint8_t offsetRow1 = offsetRow0 + fontHeight[smallSizeNumbers]; - - // Horizontal offset +1 for clocks > 10 Rows - if (usedUhrType->rowsWordMatrix() > 10) { - offsetRow1++; - } + uint8_t offsetRow1 = + usedUhrType->rowsWordMatrix() - fontHeight[smallSizeNumbers]; // Toggle second dots every second if (_second % 2) { - usedUhrType->setFrontMatrixPixel(offsetRow1 + 1, 1); - usedUhrType->setFrontMatrixPixel(offsetRow1 + 3, 1); + usedUhrType->setFrontMatrixPixel(offsetRow1 + 1, offsetLetterMin0 - 2); + usedUhrType->setFrontMatrixPixel(offsetRow1 + 3, offsetLetterMin0 - 2); } - for (uint8_t col = 0; col < 3; col++) { - for (uint8_t row = 0; row < 5; row++) { + for (uint8_t col = 0; col < fontWidth[smallSizeNumbers]; col++) { + for (uint8_t row = 0; row < fontHeight[smallSizeNumbers]; row++) { // 1st Row setPixelForChar(col, row, offsetLetterH1, offsetRow0, static_cast(h1), smallSizeNumbers); From 2437169adca1fad1034d26bb1985920e499f548d Mon Sep 17 00:00:00 2001 From: David Panusch Date: Sat, 8 Jul 2023 01:30:48 +0200 Subject: [PATCH 10/29] Got Minutes Option working for DE16x8 Layout --- include/Uhrtypes/DE16x8.hpp | 46 +++++++++++------------------------- include/Uhrtypes/Uhrtype.hpp | 3 +++ include/clockWork.hpp | 21 ++++++++++++---- 3 files changed, 34 insertions(+), 36 deletions(-) diff --git a/include/Uhrtypes/DE16x8.hpp b/include/Uhrtypes/DE16x8.hpp index dc7b9a56..8b968d76 100644 --- a/include/Uhrtypes/DE16x8.hpp +++ b/include/Uhrtypes/DE16x8.hpp @@ -41,11 +41,11 @@ class De16x8_t : public iUhrType { row *= 2; uint8_t newColsWordMatrix = colsWordMatrix(); - uint16_t numPixelsWordMatrix = rowsWordMatrix() * colsWordMatrix(); + uint16_t numPixelsWordMatrix = rowsWordMatrix() * colsWordMatrix() * 2; if (G.buildTypeDef == BuildTypeDef::DoubleResM1) { newColsWordMatrix = 2 * colsWordMatrix() - 1; - numPixelsWordMatrix = rowsWordMatrix() * newColsWordMatrix; + numPixelsWordMatrix = rowsWordMatrix() * newColsWordMatrix * 2; col *= 2; } if (row % 2 != 0) { @@ -54,8 +54,8 @@ class De16x8_t : public iUhrType { uint16_t returnValue = col + (row * newColsWordMatrix); if (returnValue > numPixelsWordMatrix) { - // Serial.println("[ERROR] getFrontMatrixIndex() returnValue out of - // Bounds"); + Serial.println( + "[ERROR] getFrontMatrixIndex() returnValue out of Bounds"); } return returnValue; @@ -63,44 +63,21 @@ class De16x8_t : public iUhrType { //------------------------------------------------------------------------------ - /* virtual void setFrontMatrixPixel(const int index, - bool state = true) override { - uint8_t col, row; - getFrontMatrixColRow(row, col, index); - for (uint8_t i = 0; i < 2; i++) { - setFrontMatrixPixel(row + 1, col, state); - } - } */ + virtual const uint8_t rowsWordMatrix() override { return 8; }; //------------------------------------------------------------------------------ - virtual const uint8_t rowsWordMatrix() override { return 8; }; + virtual const uint8_t colsWordMatrix() override { return 16; }; //------------------------------------------------------------------------------ - virtual const uint8_t colsWordMatrix() override { return 16; }; + virtual const bool hasAbsoluteMinLayout() { return true; } //------------------------------------------------------------------------------ virtual const void getMinuteArray(uint16_t *returnArr, uint8_t col) { - uint16_t numPixelsWordMatrix = rowsWordMatrix() * colsWordMatrix(); - for (uint8_t i = 0; i < 4; i++) { - switch (col) { - case 0: // LEDs for "LED4x" minute display - returnArr[i] = numPixelsWordMatrix + i; - break; - case 1: // LEDs for "LED7x" minute display - returnArr[i] = numPixelsWordMatrix + i * 2; - break; - - case 2: // LEDs for "16x16Matrix" minute display - returnArr[i] = 124 - i; - break; - - default: - break; - } + returnArr[i] = 236 - i; } }; @@ -203,12 +180,17 @@ class De16x8_t : public iUhrType { break; case FrontWord::minuten: - setFrontMatrixWord(7, 1, 1); + setFrontMatrixWord(7, 1, 7); break; + case FrontWord::minute: setFrontMatrixWord(7, 2, 7); break; + case FrontWord::plus: + setFrontMatrixWord(7, 14, 14); + break; + default: break; }; diff --git a/include/Uhrtypes/Uhrtype.hpp b/include/Uhrtypes/Uhrtype.hpp index b096910b..89f473e2 100644 --- a/include/Uhrtypes/Uhrtype.hpp +++ b/include/Uhrtypes/Uhrtype.hpp @@ -86,6 +86,7 @@ enum class FrontWord { w_dreissig, w_grad, + plus, funk, h_droelf, happy_birthday @@ -137,6 +138,8 @@ class iUhrType { virtual const bool hasSecondsFrame() { return false; } + virtual const bool hasAbsoluteMinLayout() { return false; } + virtual const uint16_t getFrontMatrixIndex(const uint8_t row, uint8_t col) { uint8_t newColsWordMatrix = colsWordMatrix(); diff --git a/include/clockWork.hpp b/include/clockWork.hpp index f5a7238b..92ce7a1f 100644 --- a/include/clockWork.hpp +++ b/include/clockWork.hpp @@ -322,9 +322,13 @@ void ClockWork::showMinute(uint8_t min) { determineWhichMinuteVariant()); /* Reseting minute byte */ minuteArray = 0; - for (uint8_t i = 0; i < min; i++) { - /* Shifting a 1 Bit for every pixel starting at LSB */ - minuteArray |= 1UL << i; + if (usedUhrType->hasAbsoluteMinLayout() && min > 0) { + minuteArray |= 1UL << (min - 1); + } else { + for (uint8_t i = 0; i < min; i++) { + /* Shifting a 1 Bit for every pixel starting at LSB */ + minuteArray |= 1UL << i; + } } if (G.UhrtypeDef == Nl10x11 && G.minuteVariant == MinuteVariant::InWords) { @@ -433,6 +437,13 @@ FrontWord ClockWork::getFrontWordForNum(uint8_t min) { //------------------------------------------------------------------------------ void ClockWork::setMinute(uint8_t min, uint8_t &offsetHour, bool &fullHour) { + if (min % 5 >= 1) { + usedUhrType->show(FrontWord::plus); + usedUhrType->show(FrontWord::minute); + if (min % 5 >= 2) { + usedUhrType->show(FrontWord::minuten); + } + } if (!usedUhrType->has24HourLayout()) { showMinute(min); min /= 5; @@ -462,7 +473,9 @@ void ClockWork::setMinute(uint8_t min, uint8_t &offsetHour, bool &fullHour) { case 13: case 14: usedUhrType->show(getFrontWordForNum(min)); - usedUhrType->show(FrontWord::minuten); + if (usedUhrType->has24HourLayout()) { + usedUhrType->show(FrontWord::minuten); + } usedUhrType->show(FrontWord::nach); break; case 15: // quarter past From 6ee1ca99fdc28ead33a3534b1b49045d6eb8ede2 Mon Sep 17 00:00:00 2001 From: David Panusch Date: Thu, 13 Jul 2023 23:13:45 +0200 Subject: [PATCH 11/29] Fixed an Issue where Clock is showed mirrored and unmirrored at the same time --- include/clockWork.h | 1 + include/clockWork.hpp | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/include/clockWork.h b/include/clockWork.h index 8066b5a9..3fcd37f5 100644 --- a/include/clockWork.h +++ b/include/clockWork.h @@ -11,6 +11,7 @@ class ClockWork { //------------------------------------------------------------------------------ // Helper Functions //------------------------------------------------------------------------------ + void resetFrontMatrixBuffer(); void loopLdrLogic(); uint32_t num32BitWithOnesAccordingToColumns(); diff --git a/include/clockWork.hpp b/include/clockWork.hpp index 92ce7a1f..7cd0bee5 100644 --- a/include/clockWork.hpp +++ b/include/clockWork.hpp @@ -12,6 +12,14 @@ OpenWMap weather; // Helper Functions //------------------------------------------------------------------------------ +void ClockWork::resetFrontMatrixBuffer() { + for (uint8_t i = 0; i < usedUhrType->rowsWordMatrix(); i++) { + frontMatrix[i] = 0; + } +} + +//------------------------------------------------------------------------------ + void ClockWork::loopLdrLogic() { int16_t lux = analogRead(A0); // Range 0-1023 uint8_t ldrValOld = ldrVal; @@ -731,6 +739,7 @@ void ClockWork::setClock() { //------------------------------------------------------------------------------ void ClockWork::calcClockface() { + resetFrontMatrixBuffer(); if (_hour == 23 && _minute == 59 && _second >= 50) { countdownToMidnight(); From 8f34468919b5073aaff49bd6e626a2787fd1cff9 Mon Sep 17 00:00:00 2001 From: David Panusch Date: Thu, 13 Jul 2023 23:39:29 +0200 Subject: [PATCH 12/29] Removed remaining old color definitions --- include/Animation.hpp | 4 ++-- include/EEPROMAnything.h | 18 +++++++++--------- include/Uhr.h | 14 +------------- include/clockWork.hpp | 6 +++--- include/led.h | 6 +++--- include/led.hpp | 20 ++++++++++---------- src/Wortuhr.cpp | 6 +++--- 7 files changed, 31 insertions(+), 43 deletions(-) diff --git a/include/Animation.hpp b/include/Animation.hpp index 355533c2..c25e5524 100644 --- a/include/Animation.hpp +++ b/include/Animation.hpp @@ -319,7 +319,7 @@ void Animation::set_minutes() { } for (uint8_t i = 0; i < 4; i++) { led.setPixel(minArray[i], - Color{m > i ? foregroundMinute : background}); + HsbColor{m > i ? foregroundMinute : background}); } } } @@ -332,7 +332,7 @@ void Animation::copy2Stripe(RgbfColor **source) { for (uint8_t col = 0; col < maxCols; col++) { led.setPixel(usedUhrType->getFrontMatrixIndex(row + rowStart, col + colStart), - Color{RgbColor(source[row][col].R, source[row][col].G, + HsbColor{RgbColor(source[row][col].R, source[row][col].G, source[row][col].B)}); } } diff --git a/include/EEPROMAnything.h b/include/EEPROMAnything.h index 61f34658..cdf6799e 100644 --- a/include/EEPROMAnything.h +++ b/include/EEPROMAnything.h @@ -39,15 +39,15 @@ void read() { Serial.printf("Sernr : %u\n", G.sernr); Serial.printf("Programm : %u\n", G.prog); Serial.printf("Conf : %u\n", G.conf); - Serial.printf("FgCol.H : %f\n", G.color[Foreground].hsb.H); - Serial.printf("FgCol.S : %f\n", G.color[Foreground].hsb.S); - Serial.printf("FgCol.V : %f\n", G.color[Foreground].hsb.B); - Serial.printf("BgCol.H : %f\n", G.color[Background].hsb.H); - Serial.printf("BgCol.S : %f\n", G.color[Background].hsb.S); - Serial.printf("BgCol.V : %f\n", G.color[Background].hsb.B); - Serial.printf("EfCol.H : %f\n", G.color[Effect].hsb.H); - Serial.printf("EfCol.S : %f\n", G.color[Effect].hsb.S); - Serial.printf("EfCol.V : %f\n", G.color[Effect].hsb.B); + Serial.printf("FgCol.H : %f\n", G.color[Foreground].H); + Serial.printf("FgCol.S : %f\n", G.color[Foreground].S); + Serial.printf("FgCol.V : %f\n", G.color[Foreground].B); + Serial.printf("BgCol.H : %f\n", G.color[Background].H); + Serial.printf("BgCol.S : %f\n", G.color[Background].S); + Serial.printf("BgCol.V : %f\n", G.color[Background].B); + Serial.printf("EfCol.H : %f\n", G.color[Effect].H); + Serial.printf("EfCol.S : %f\n", G.color[Effect].S); + Serial.printf("EfCol.V : %f\n", G.color[Effect].B); Serial.printf("Zeitserver: %s\n", G.timeserver); Serial.printf("Lauftext : %s\n", G.scrollingText); Serial.printf("H6 : %u\n", G.h6); diff --git a/include/Uhr.h b/include/Uhr.h index c5a98617..9472fac7 100644 --- a/include/Uhr.h +++ b/include/Uhr.h @@ -75,25 +75,13 @@ enum class SecondVariant { FrameSectorToggle = 3, }; -struct Color { - HsbColor hsb; - - Color() { hsb = HsbColor(0, 0, 0); } - - Color(float newHue) { hsb.H = newHue; } - - Color(HsbColor newHsb) { hsb = newHsb; } - - Color(RgbColor newRgb) { hsb = HsbColor(newRgb); } -}; - struct GLOBAL { uint8_t sernr; uint16_t prog; uint8_t param1; bool progInit; uint16_t conf; - Color color[3]; + HsbColor color[3]; uint8_t effectBri; uint8_t effectSpeed; uint8_t client_nr; diff --git a/include/clockWork.hpp b/include/clockWork.hpp index 7cd0bee5..89eeb6e8 100644 --- a/include/clockWork.hpp +++ b/include/clockWork.hpp @@ -908,11 +908,11 @@ void ClockWork::loop(struct tm &tm) { for (uint8_t i = 0; i < 2; i++) { char string2Send[7]; sprintf(string2Send, "hsb%d%d", i, 0); - config[string2Send] = static_cast(G.color[i].hsb.H * 360); + config[string2Send] = static_cast(G.color[i].H * 360); sprintf(string2Send, "hsb%d%d", i, 1); - config[string2Send] = static_cast(G.color[i].hsb.S * 100); + config[string2Send] = static_cast(G.color[i].S * 100); sprintf(string2Send, "hsb%d%d", i, 2); - config[string2Send] = static_cast(G.color[i].hsb.B * 100); + config[string2Send] = static_cast(G.color[i].B * 100); } config["effectBri"] = G.effectBri; config["effectSpeed"] = G.effectSpeed; diff --git a/include/led.h b/include/led.h index 0e3d5da8..deb67269 100644 --- a/include/led.h +++ b/include/led.h @@ -34,15 +34,15 @@ class Led { //------------------------------------------------------------------------------ float setBrightnessAuto(float val); void getCurrentManualBrightnessSetting(uint8_t ¤tBrightness); - void getColorbyPositionWithAppliedBrightness(Color &color, + void getColorbyPositionWithAppliedBrightness(HsbColor &color, uint8_t position); void shiftColumnToRight(); //------------------------------------------------------------------------------ // Pixel set Functions //------------------------------------------------------------------------------ - void setPixel(uint16_t ledIndex, Color color); - void setPixel(uint8_t row, uint8_t col, Color color); + void setPixel(uint16_t ledIndex, HsbColor color); + void setPixel(uint8_t row, uint8_t col, HsbColor color); void setbyFrontMatrix(uint8_t ColorPosition = Foreground, bool applyMirrorAndReverse = true); void setbyMinuteArray(uint8_t ColorPosition = Foreground); diff --git a/include/led.hpp b/include/led.hpp index 450cac07..eefdc302 100644 --- a/include/led.hpp +++ b/include/led.hpp @@ -145,16 +145,16 @@ void Led::getCurrentManualBrightnessSetting(uint8_t ¤tBrightness) { //------------------------------------------------------------------------------ -void Led::getColorbyPositionWithAppliedBrightness(Color &color, +void Led::getColorbyPositionWithAppliedBrightness(HsbColor &color, uint8_t colorPosition) { color = G.color[colorPosition]; uint8_t manBrightnessSetting = 100; getCurrentManualBrightnessSetting(manBrightnessSetting); if (G.autoLdrEnabled) { - color.hsb.B = setBrightnessAuto(color.hsb.B); + color.B = setBrightnessAuto(color.B); } else { - color.hsb.B *= manBrightnessSetting / 100.f; + color.B *= manBrightnessSetting / 100.f; } } @@ -198,18 +198,18 @@ void Led::shiftColumnToRight() { // Pixel set Functions //------------------------------------------------------------------------------ -void Led::setPixel(uint16_t ledIndex, Color color) { +void Led::setPixel(uint16_t ledIndex, HsbColor color) { if (G.Colortype == Grbw) { strip_RGBW->SetPixelColor( - ledIndex, convertRgbToRgbw(RgbColor(color.hsb), G.wType)); + ledIndex, convertRgbToRgbw(RgbColor(color), G.wType)); } else { - strip_RGB->SetPixelColor(ledIndex, color.hsb); + strip_RGB->SetPixelColor(ledIndex, color); } } //------------------------------------------------------------------------------ -void Led::setPixel(uint8_t row, uint8_t col, Color color) { +void Led::setPixel(uint8_t row, uint8_t col, HsbColor color) { setPixel(usedUhrType->getFrontMatrixIndex(row, col), color); } @@ -219,7 +219,7 @@ void Led::setbyFrontMatrix(uint8_t colorPosition, bool applyMirrorAndReverse) { if (applyMirrorAndReverse) { applyMirroringAndReverseIfDefined(); } - Color displayedColor; + HsbColor displayedColor; getColorbyPositionWithAppliedBrightness(displayedColor, colorPosition); for (uint8_t row = 0; row < usedUhrType->rowsWordMatrix(); row++) { @@ -242,7 +242,7 @@ void Led::setbyFrontMatrix(uint8_t colorPosition, bool applyMirrorAndReverse) { //------------------------------------------------------------------------------ void Led::setbyMinuteArray(uint8_t colorPosition) { - Color displayedColor; + HsbColor displayedColor; getColorbyPositionWithAppliedBrightness(displayedColor, colorPosition); /* Set minutes According to minute byte */ @@ -257,7 +257,7 @@ void Led::setbyMinuteArray(uint8_t colorPosition) { //------------------------------------------------------------------------------ void Led::setbySecondArray(uint8_t colorPosition) { - Color displayedColor; + HsbColor displayedColor; getColorbyPositionWithAppliedBrightness(displayedColor, colorPosition); const uint8_t offesetSecondsFrame = 5; diff --git a/src/Wortuhr.cpp b/src/Wortuhr.cpp index 5fc41813..d37ab0ff 100644 --- a/src/Wortuhr.cpp +++ b/src/Wortuhr.cpp @@ -146,10 +146,10 @@ void setup() { G.progInit = true; G.conf = COMMAND_IDLE; for (uint8_t i = 0; i < 3; i++) { - G.color[i] = {}; + G.color[i] = {0,0,0}; } - G.color[Foreground].hsb = HsbColor(120 / 360.f, 1.f, 0.5f); - G.color[Effect].hsb = HsbColor(240 / 360.f, 1.f, 0.5f); + G.color[Foreground] = HsbColor(120 / 360.f, 1.f, 0.5f); + G.color[Effect]= HsbColor(240 / 360.f, 1.f, 0.5f); G.effectBri = 2; G.effectSpeed = 10; G.client_nr = 0; From 5679beb94594664d54296bc67394f4795e36c6c7 Mon Sep 17 00:00:00 2001 From: David Panusch Date: Fri, 14 Jul 2023 09:39:26 +0200 Subject: [PATCH 13/29] Refactored enum names --- include/Uhrtypes/DE10x11.2clock.hpp | 6 +++--- include/Uhrtypes/DE10x11.alternative.hpp | 6 +++--- include/Uhrtypes/DE10x11.hpp | 6 +++--- include/Uhrtypes/DE10x11.nero.hpp | 6 +++--- include/Uhrtypes/DE11x11.hpp | 6 +++--- include/Uhrtypes/DE11x11.v2.hpp | 4 ++-- include/Uhrtypes/DE16x18.hpp | 6 +++--- include/Uhrtypes/DE16x8.hpp | 6 +++--- include/Uhrtypes/DE22x11.weather.hpp | 6 +++--- include/Uhrtypes/EN10x11.hpp | 8 ++++---- include/Uhrtypes/NL10x11.hpp | 6 +++--- include/Uhrtypes/Uhrtype.hpp | 12 +++++++---- include/clockWork.hpp | 26 ++++++++++++------------ 13 files changed, 54 insertions(+), 50 deletions(-) diff --git a/include/Uhrtypes/DE10x11.2clock.hpp b/include/Uhrtypes/DE10x11.2clock.hpp index b9289923..adf4cdfb 100644 --- a/include/Uhrtypes/DE10x11.2clock.hpp +++ b/include/Uhrtypes/DE10x11.2clock.hpp @@ -59,15 +59,15 @@ class De10x11Clock_t : public iUhrType { setFrontMatrixWord(2, 0, 10); break; - case FrontWord::fuenf: + case FrontWord::m_fuenf: setFrontMatrixWord(0, 0, 3); break; - case FrontWord::zehn: + case FrontWord::m_zehn: setFrontMatrixWord(1, 7, 10); break; - case FrontWord::zwanzig: + case FrontWord::m_zwanzig: setFrontMatrixWord(1, 0, 6); break; diff --git a/include/Uhrtypes/DE10x11.alternative.hpp b/include/Uhrtypes/DE10x11.alternative.hpp index a00c31cb..affbceee 100644 --- a/include/Uhrtypes/DE10x11.alternative.hpp +++ b/include/Uhrtypes/DE10x11.alternative.hpp @@ -58,15 +58,15 @@ class De10x11Alternative_t : public iUhrType { setFrontMatrixWord(2, 0, 10); break; - case FrontWord::fuenf: + case FrontWord::m_fuenf: setFrontMatrixWord(0, 0, 3); break; - case FrontWord::zehn: + case FrontWord::m_zehn: setFrontMatrixWord(1, 7, 10); break; - case FrontWord::zwanzig: + case FrontWord::m_zwanzig: setFrontMatrixWord(1, 0, 6); break; diff --git a/include/Uhrtypes/DE10x11.hpp b/include/Uhrtypes/DE10x11.hpp index bf1fb8cf..0d2e2797 100644 --- a/include/Uhrtypes/DE10x11.hpp +++ b/include/Uhrtypes/DE10x11.hpp @@ -57,15 +57,15 @@ class De10x11_t : public iUhrType { setFrontMatrixWord(2, 0, 10); break; - case FrontWord::fuenf: + case FrontWord::m_fuenf: setFrontMatrixWord(0, 0, 3); break; - case FrontWord::zehn: + case FrontWord::m_zehn: setFrontMatrixWord(1, 7, 10); break; - case FrontWord::zwanzig: + case FrontWord::m_zwanzig: setFrontMatrixWord(1, 0, 6); break; diff --git a/include/Uhrtypes/DE10x11.nero.hpp b/include/Uhrtypes/DE10x11.nero.hpp index 54b70143..55d2a71e 100644 --- a/include/Uhrtypes/DE10x11.nero.hpp +++ b/include/Uhrtypes/DE10x11.nero.hpp @@ -57,15 +57,15 @@ class De10x11Nero_t : public iUhrType { setFrontMatrixWord(2, 0, 10); break; - case FrontWord::fuenf: + case FrontWord::m_fuenf: setFrontMatrixWord(0, 0, 3); break; - case FrontWord::zehn: + case FrontWord::m_zehn: setFrontMatrixWord(1, 7, 10); break; - case FrontWord::zwanzig: + case FrontWord::m_zwanzig: setFrontMatrixWord(1, 0, 6); break; diff --git a/include/Uhrtypes/DE11x11.hpp b/include/Uhrtypes/DE11x11.hpp index 2af963e2..66c5ff36 100644 --- a/include/Uhrtypes/DE11x11.hpp +++ b/include/Uhrtypes/DE11x11.hpp @@ -83,15 +83,15 @@ class De11x11_t : public iUhrType { setFrontMatrixWord(2, 0, 10); break; - case FrontWord::fuenf: + case FrontWord::m_fuenf: setFrontMatrixWord(0, 0, 3); break; - case FrontWord::zehn: + case FrontWord::m_zehn: setFrontMatrixWord(1, 7, 10); break; - case FrontWord::zwanzig: + case FrontWord::m_zwanzig: setFrontMatrixWord(1, 0, 6); break; diff --git a/include/Uhrtypes/DE11x11.v2.hpp b/include/Uhrtypes/DE11x11.v2.hpp index 730a3486..c6c121ca 100644 --- a/include/Uhrtypes/DE11x11.v2.hpp +++ b/include/Uhrtypes/DE11x11.v2.hpp @@ -44,11 +44,11 @@ class De11x11V2_t : public De11x11_t { setFrontMatrixWord(2, 0, 6); break; - case FrontWord::fuenf: + case FrontWord::m_fuenf: setFrontMatrixWord(0, 0, 3); break; - case FrontWord::zehn: + case FrontWord::m_zehn: setFrontMatrixWord(1, 7, 10); break; diff --git a/include/Uhrtypes/DE16x18.hpp b/include/Uhrtypes/DE16x18.hpp index 5acf7ed7..d2c8442e 100644 --- a/include/Uhrtypes/DE16x18.hpp +++ b/include/Uhrtypes/DE16x18.hpp @@ -69,7 +69,7 @@ class De16x18_t : public iUhrType { setFrontMatrixWord(2, 4, 7); break; - case FrontWord::fuenf: + case FrontWord::m_fuenf: setFrontMatrixWord(2, 12, 15); break; @@ -89,7 +89,7 @@ class De16x18_t : public iUhrType { setFrontMatrixWord(2, 8, 11); break; - case FrontWord::zehn: + case FrontWord::m_zehn: setFrontMatrixWord(3, 0, 3); break; @@ -132,7 +132,7 @@ class De16x18_t : public iUhrType { setFrontMatrixWord(3, 0, 3); break; - case FrontWord::zwanzig: + case FrontWord::m_zwanzig: setFrontMatrixWord(4, 7, 13); break; diff --git a/include/Uhrtypes/DE16x8.hpp b/include/Uhrtypes/DE16x8.hpp index 8b968d76..8f2cb023 100644 --- a/include/Uhrtypes/DE16x8.hpp +++ b/include/Uhrtypes/DE16x8.hpp @@ -107,15 +107,15 @@ class De16x8_t : public iUhrType { setFrontMatrixWord(2, 5, 11); break; - case FrontWord::fuenf: + case FrontWord::m_fuenf: setFrontMatrixWord(2, 12, 15); break; - case FrontWord::zehn: + case FrontWord::m_zehn: setFrontMatrixWord(1, 0, 3); break; - case FrontWord::zwanzig: + case FrontWord::m_zwanzig: setFrontMatrixWord(1, 9, 15); break; diff --git a/include/Uhrtypes/DE22x11.weather.hpp b/include/Uhrtypes/DE22x11.weather.hpp index dcffb44a..59849552 100644 --- a/include/Uhrtypes/DE22x11.weather.hpp +++ b/include/Uhrtypes/DE22x11.weather.hpp @@ -92,21 +92,21 @@ class De22x11Weather_t : public iUhrType { #endif break; - case FrontWord::fuenf: + case FrontWord::m_fuenf: setFrontMatrixWord(0, 0, 3); #if WEATHER_VERBOSE Serial.print("Fünf "); #endif break; - case FrontWord::zehn: + case FrontWord::m_zehn: setFrontMatrixWord(1, 7, 10); #if WEATHER_VERBOSE Serial.print("zehn "); #endif break; - case FrontWord::zwanzig: + case FrontWord::m_zwanzig: setFrontMatrixWord(1, 0, 6); #if WEATHER_VERBOSE Serial.print("zwanzig "); diff --git a/include/Uhrtypes/EN10x11.hpp b/include/Uhrtypes/EN10x11.hpp index 4b426665..5903e54f 100644 --- a/include/Uhrtypes/EN10x11.hpp +++ b/include/Uhrtypes/EN10x11.hpp @@ -104,12 +104,12 @@ class En10x11_t : public iUhrType { setFrontMatrixWord(8, 0, 5); break; - case FrontWord::fuenf: + case FrontWord::m_fuenf: // Five setFrontMatrixWord(2, 1, 4); break; - case FrontWord::zehn: + case FrontWord::m_zehn: // Ten setFrontMatrixWord(3, 3, 5); break; @@ -124,12 +124,12 @@ class En10x11_t : public iUhrType { setFrontMatrixWord(1, 2, 8); break; - case FrontWord::zwanzig: + case FrontWord::m_zwanzig: // Twenty setFrontMatrixWord(2, 5, 10); break; - case FrontWord::twentyfive: + case FrontWord::m_twentyfive: // Twentyfive setFrontMatrixWord(2, 1, 10); break; diff --git a/include/Uhrtypes/NL10x11.hpp b/include/Uhrtypes/NL10x11.hpp index 0fea8925..df0c56e6 100644 --- a/include/Uhrtypes/NL10x11.hpp +++ b/include/Uhrtypes/NL10x11.hpp @@ -49,15 +49,15 @@ class NL10x11_t : public iUhrType { setFrontMatrixWord(2, 0, 4); break; - case FrontWord::fuenf: + case FrontWord::m_fuenf: setFrontMatrixWord(2, 7, 10); break; - case FrontWord::zehn: + case FrontWord::m_zehn: setFrontMatrixWord(1, 0, 3); break; - case FrontWord::zwanzig: + case FrontWord::m_zwanzig: setFrontMatrixWord(1, 4, 10); break; diff --git a/include/Uhrtypes/Uhrtype.hpp b/include/Uhrtypes/Uhrtype.hpp index 89f473e2..81ff496f 100644 --- a/include/Uhrtypes/Uhrtype.hpp +++ b/include/Uhrtypes/Uhrtype.hpp @@ -8,12 +8,12 @@ enum class FrontWord { m_zwei, m_drei, m_vier, - fuenf, + m_fuenf, m_sechs, m_sieben, m_acht, m_neun, - zehn, + m_zehn, m_elf, m_zwoelf, m_dreizehn, @@ -22,8 +22,12 @@ enum class FrontWord { m_siebzehn, m_achtzehn, m_neunzehn, - zwanzig, - twentyfive, + m_zwanzig, + m_twentyfive, + m_num1, + m_num2, + m_num3, + m_num4, es_ist, nach, diff --git a/include/clockWork.hpp b/include/clockWork.hpp index 89eeb6e8..196f635b 100644 --- a/include/clockWork.hpp +++ b/include/clockWork.hpp @@ -196,7 +196,7 @@ void ClockWork::countdownToMidnight() { Serial.printf("Count down: %d\n", 60 - _second); switch (_second) { case 50: - usedUhrType->show(FrontWord::zehn); + usedUhrType->show(FrontWord::m_zehn); break; case 51: usedUhrType->show(FrontWord::h_neun); @@ -211,7 +211,7 @@ void ClockWork::countdownToMidnight() { usedUhrType->show(FrontWord::h_sechs); break; case 55: - usedUhrType->show(FrontWord::fuenf); + usedUhrType->show(FrontWord::m_fuenf); break; case 56: usedUhrType->show(FrontWord::h_vier); @@ -377,7 +377,7 @@ FrontWord ClockWork::getFrontWordForNum(uint8_t min) { break; case 5: - return FrontWord::fuenf; + return FrontWord::m_fuenf; break; case 6: @@ -397,7 +397,7 @@ FrontWord ClockWork::getFrontWordForNum(uint8_t min) { break; case 10: - return FrontWord::zehn; + return FrontWord::m_zehn; break; case 11: @@ -433,7 +433,7 @@ FrontWord ClockWork::getFrontWordForNum(uint8_t min) { break; case 20: - return FrontWord::zwanzig; + return FrontWord::m_zwanzig; default: break; @@ -508,12 +508,12 @@ void ClockWork::setMinute(uint8_t min, uint8_t &offsetHour, bool &fullHour) { break; case 20: // 20 past if (!usedUhrType->hasZwanzig() || G.languageVariant[ItIs20]) { - usedUhrType->show(FrontWord::zehn); + usedUhrType->show(FrontWord::m_zehn); usedUhrType->show(FrontWord::vor); usedUhrType->show(FrontWord::halb); offsetHour = 1; } else { - usedUhrType->show(FrontWord::zwanzig); + usedUhrType->show(FrontWord::m_zwanzig); usedUhrType->show(FrontWord::nach); } break; @@ -523,10 +523,10 @@ void ClockWork::setMinute(uint8_t min, uint8_t &offsetHour, bool &fullHour) { case 24: case 25: if (usedUhrType->hasTwentyfive()) { - usedUhrType->show(FrontWord::twentyfive); + usedUhrType->show(FrontWord::m_twentyfive); usedUhrType->show(FrontWord::nach); } else { - usedUhrType->show(FrontWord::fuenf); + usedUhrType->show(FrontWord::m_fuenf); usedUhrType->show(FrontWord::vor); usedUhrType->show(FrontWord::halb); offsetHour = 1; @@ -568,10 +568,10 @@ void ClockWork::setMinute(uint8_t min, uint8_t &offsetHour, bool &fullHour) { case 34: case 35: if (usedUhrType->hasTwentyfive()) { - usedUhrType->show(FrontWord::twentyfive); + usedUhrType->show(FrontWord::m_twentyfive); usedUhrType->show(FrontWord::vor); } else { - usedUhrType->show(FrontWord::fuenf); + usedUhrType->show(FrontWord::m_fuenf); usedUhrType->show(FrontWord::nach); usedUhrType->show(FrontWord::halb); } @@ -588,11 +588,11 @@ void ClockWork::setMinute(uint8_t min, uint8_t &offsetHour, bool &fullHour) { break; case 40: // 20 to if (!usedUhrType->hasZwanzig() || G.languageVariant[ItIs40]) { - usedUhrType->show(FrontWord::zehn); + usedUhrType->show(FrontWord::m_zehn); usedUhrType->show(FrontWord::nach); usedUhrType->show(FrontWord::halb); } else { - usedUhrType->show(FrontWord::zwanzig); + usedUhrType->show(FrontWord::m_zwanzig); usedUhrType->show(FrontWord::vor); } offsetHour = 1; From df5ac19502b9e3cb91e4de240317f835ed679a04 Mon Sep 17 00:00:00 2001 From: David Panusch Date: Fri, 14 Jul 2023 16:31:49 +0200 Subject: [PATCH 14/29] Refactored Animation code --- include/Animation.h | 4 +- include/Animation.hpp | 108 +++++++++++++++++++++--------------------- 2 files changed, 57 insertions(+), 55 deletions(-) diff --git a/include/Animation.h b/include/Animation.h index 5a8048d5..8ff87cf3 100644 --- a/include/Animation.h +++ b/include/Animation.h @@ -117,7 +117,7 @@ class Animation { void begin(); void loop(struct tm &tm); - bool led_show_notify(bool flag, uint8_t minute); + bool ledShowNotify(bool flag, uint8_t minute); void demoMode(uint8_t &_minute, uint8_t _second); //------------------------------------------------------------------------------ protected: @@ -168,7 +168,7 @@ class Animation { void analyzeColors(RgbfColor **dest, RgbfColor **source, RgbfColor &foreground, RgbfColor &background); uint8_t determineWhichMinuteVariant(); - void set_minutes(void); + void setMinute(void); void copy2Stripe(RgbfColor **source); void copyMatrix(RgbfColor **dest, RgbfColor **source); void copyMatrixFlags(RgbfColor **dest, RgbfColor **source); diff --git a/include/Animation.hpp b/include/Animation.hpp index c25e5524..b01855ac 100644 --- a/include/Animation.hpp +++ b/include/Animation.hpp @@ -112,21 +112,21 @@ bool Animation::changeBrightness() { foregroundMinute = RgbColor(hsbColor); RgbfColor **matrix[3] = {act, old, work}; for (uint8_t m = 0; m < 3; m++) { - for (uint8_t r = 0; r < maxRows; r++) { - for (uint8_t c = 0; c < maxCols; c++) { + for (uint8_t row = 0; row < maxRows; row++) { + for (uint8_t col = 0; col < maxCols; col++) { if (adjustBg) { - if (!matrix[m][r][c].isForeground()) { - matrix[m][r][c] = newBackground; + if (!matrix[m][row][col].isForeground()) { + matrix[m][row][col] = newBackground; } } if (adjustFg) { - if (matrix[m][r][c].isForeground()) { + if (matrix[m][row][col].isForeground()) { if (isColorization()) { - hsbColor = HsbColor(matrix[m][r][c]); + hsbColor = HsbColor(matrix[m][row][col]); hsbColor.B = brightness; - matrix[m][r][c].changeRgb(hsbColor); + matrix[m][row][col].changeRgb(hsbColor); } else { - matrix[m][r][c].changeRgb(newForeground); + matrix[m][row][col].changeRgb(newForeground); } } } @@ -198,14 +198,15 @@ void Animation::colorize(RgbfColor **dest) { hsbColor.H = pseudoRandomHue(); foregroundMinute = isColorization() ? RgbColor(hsbColor) : foreground; hsbColor.H = pseudoRandomHue(); - for (uint8_t r = 0; r < maxRows; r++) { - for (uint8_t c = 0; c < maxCols; c++) { - if (dest[r][c].isForeground()) { + for (uint8_t row = 0; row < maxRows; row++) { + for (uint8_t col = 0; col < maxCols; col++) { + if (dest[row][col].isForeground()) { if ((G.animColorize == CHARACTERS) || changeColor) { changeColor = false; hsbColor.H = pseudoRandomHue(); } - dest[r][c].changeRgb(isColorization() ? hsbColor : foreground); + dest[row][col].changeRgb(isColorization() ? hsbColor + : foreground); } else { changeColor = true; } @@ -238,16 +239,16 @@ void Animation::analyzeColors(RgbfColor **dest, RgbfColor **source, RgbfColor &foreground, RgbfColor &background) { RgbfColor color, color1(0), color2(0); uint32_t colorCounter1 = 0, colorCounter2 = 0; - for (uint8_t r = 0; r < maxRows; r++) { - for (uint8_t c = 0; c < maxCols; c++) { + for (uint8_t row = 0; row < maxRows; row++) { + for (uint8_t col = 0; col < maxCols; col++) { if (source == STRIPE) { color = RgbfColor(led.getPixel(usedUhrType->getFrontMatrixIndex( - r + rowStart, c + colStart))); + row + rowStart, col + colStart))); } else { - color = source[r][c]; + color = source[row][col]; } if (dest != NULL) { - dest[r][c] = color; + dest[row][col] = color; } if (color == color1) { colorCounter1++; @@ -279,9 +280,9 @@ void Animation::analyzeColors(RgbfColor **dest, RgbfColor **source, background.setForeground(false); background.setOverlay(false); if (dest != NULL) { - for (uint8_t r = 0; r < maxRows; r++) { - for (uint8_t c = 0; c < maxCols; c++) { - dest[r][c].setForeground(dest[r][c] == foreground); + for (uint8_t row = 0; row < maxRows; row++) { + for (uint8_t col = 0; col < maxCols; col++) { + dest[row][col].setForeground(dest[row][col] == foreground); } } } @@ -309,7 +310,7 @@ uint8_t Animation::determineWhichMinuteVariant() { //------------------------------------------------------------------------------ -void Animation::set_minutes() { +void Animation::setMinute() { if (G.minuteVariant != MinuteVariant::Off) { uint8_t m = lastMinute % 5; uint16_t minArray[4]; @@ -330,29 +331,30 @@ void Animation::set_minutes() { void Animation::copy2Stripe(RgbfColor **source) { for (uint8_t row = 0; row < maxRows; row++) { for (uint8_t col = 0; col < maxCols; col++) { - led.setPixel(usedUhrType->getFrontMatrixIndex(row + rowStart, - col + colStart), - HsbColor{RgbColor(source[row][col].R, source[row][col].G, - source[row][col].B)}); + led.setPixel( + usedUhrType->getFrontMatrixIndex(row + rowStart, + col + colStart), + HsbColor{RgbColor(source[row][col].R, source[row][col].G, + source[row][col].B)}); } } - set_minutes(); + setMinute(); } //------------------------------------------------------------------------------ void Animation::copyMatrix(RgbfColor **dest, RgbfColor **source) { - for (uint8_t r = 0; r < maxRows; r++) { - memcpy(dest[r], source[r], sizeofColumn); + for (uint8_t row = 0; row < maxRows; row++) { + memcpy(dest[row], source[row], sizeofColumn); } } //------------------------------------------------------------------------------ void Animation::copyMatrixFlags(RgbfColor **dest, RgbfColor **source) { - for (uint8_t r = 0; r < maxRows; r++) { - for (uint8_t c = 0; c < maxCols; c++) { - dest[r][c].setFlags(source[r][c].getFlags()); + for (uint8_t row = 0; row < maxRows; row++) { + for (uint8_t col = 0; col < maxCols; col++) { + dest[row][col].setFlags(source[row][col].getFlags()); } } } @@ -371,8 +373,8 @@ void Animation::fillMatrix(RgbfColor **matrix, RgbfColor color) { // changed: 0 changes, e.g. color, no change of content // changed: 1 content has changed -bool Animation::led_show_notify(bool changed, uint8_t minute) { - bool led_show = true; +bool Animation::ledShowNotify(bool changed, uint8_t minute) { + bool ledShow = true; if (animType == KEINE) { if (changed && (lastMinute != minute)) { @@ -388,16 +390,16 @@ bool Animation::led_show_notify(bool changed, uint8_t minute) { matrixChanged = true; nextActionTime = 0; // ################### phase = 1; // -> start Animation - led_show = false; // ################### + ledShow = false; // ################### } } else { if (brightnessChanged) { copy2Stripe(work); } - led_show = isIdle(); + ledShow = isIdle(); } } - return led_show; + return ledShow; } //------------------------------------------------------------------------------ @@ -661,16 +663,16 @@ uint16_t Animation::animScrollRight(bool dirRight) { uint16_t Animation::animBalls() { static uint32_t starttime; static uint32_t numBalls; - uint32_t oldR, r, c, ballsDown; + uint32_t oldR, row, col, ballsDown; uint32_t timeDelta, now; if (phase == 1) { animationDelay = 50; // 20 Frames per second numBalls = 0; - for (c = 0; (c < maxCols) && (numBalls < maxCols); c++) { - for (r = 0; (r < maxRows) && (numBalls < maxCols); r++) { - if (work[r][c].isForeground()) { - balls[numBalls].begin(r, c, work[r][c], background, + for (col = 0; (col < maxCols) && (numBalls < maxCols); col++) { + for (row = 0; (row < maxRows) && (numBalls < maxCols); row++) { + if (work[row][col].isForeground()) { + balls[numBalls].begin(row, col, work[row][col], background, 100 * numBalls); numBalls++; break; @@ -684,24 +686,24 @@ uint16_t Animation::animBalls() { timeDelta = now - starttime; starttime = now; ballsDown = 0; - for (uint8_t b = 0; b < numBalls; b++) { - oldR = balls[b].r; - ballsDown += balls[b].move(timeDelta); - r = balls[b].r; // r, c new coordinates - c = balls[b].c; - if (r > oldR) { // down - for (; r > oldR; oldR++) { - work[oldR][c] = background; + for (uint8_t i = 0; i < numBalls; i++) { + oldR = balls[i].r; + ballsDown += balls[i].move(timeDelta); + row = balls[i].r; // row, col new coordinates + col = balls[i].c; + if (row > oldR) { // down + for (; row > oldR; oldR++) { + work[oldR][col] = background; } } else { // up - for (; r < oldR; oldR--) { - work[oldR][c] = background; + for (; row < oldR; oldR--) { + work[oldR][col] = background; } } - work[r][c] = balls[b].color; + work[row][col] = balls[i].color; } if (ballsDown >= numBalls) { - copyMatrix(work, act); // TODO(ATho95): shot Balls up + copyMatrix(work, act); return 0; } return phase + 1; From a64f33a2329eb11e8f7aae64829b74d6a96f3c69 Mon Sep 17 00:00:00 2001 From: David Panusch Date: Sat, 15 Jul 2023 10:57:05 +0200 Subject: [PATCH 15/29] Reworked Min for Clocks with Min on FrontMatrix --- include/Animation.h | 1 - include/Animation.hpp | 23 ++--------------------- include/Uhrtypes/DE16x8.hpp | 20 ++++++++++++++++++-- include/Uhrtypes/NL10x11.hpp | 4 ++++ include/Uhrtypes/Uhrtype.hpp | 2 +- include/clockWork.hpp | 28 +++++++++++++++++++--------- include/led.hpp | 6 +++--- webpage/script.js | 4 +++- 8 files changed, 50 insertions(+), 38 deletions(-) diff --git a/include/Animation.h b/include/Animation.h index 8ff87cf3..b9028c6a 100644 --- a/include/Animation.h +++ b/include/Animation.h @@ -167,7 +167,6 @@ class Animation { void saveMatrix(); void analyzeColors(RgbfColor **dest, RgbfColor **source, RgbfColor &foreground, RgbfColor &background); - uint8_t determineWhichMinuteVariant(); void setMinute(void); void copy2Stripe(RgbfColor **source); void copyMatrix(RgbfColor **dest, RgbfColor **source); diff --git a/include/Animation.hpp b/include/Animation.hpp index b01855ac..6cac96c0 100644 --- a/include/Animation.hpp +++ b/include/Animation.hpp @@ -290,31 +290,12 @@ void Animation::analyzeColors(RgbfColor **dest, RgbfColor **source, //------------------------------------------------------------------------------ -uint8_t Animation::determineWhichMinuteVariant() { - switch (G.minuteVariant) { - case MinuteVariant::LED4x: - return 0; - break; - case MinuteVariant::LED7x: - return 1; - break; - case MinuteVariant::Corners: - return 2; - break; - default: - Serial.println("[ERROR] G.minuteVariant undefined"); - return 0; - break; - } -} - -//------------------------------------------------------------------------------ - void Animation::setMinute() { if (G.minuteVariant != MinuteVariant::Off) { uint8_t m = lastMinute % 5; uint16_t minArray[4]; - usedUhrType->getMinuteArray(minArray, determineWhichMinuteVariant()); + usedUhrType->getMinuteArray(minArray, + clockWork.determineWhichMinuteVariant()); if (G.layoutVariant[ReverseMinDirection]) { std::reverse(std::begin(minArray), std::end(minArray)); } diff --git a/include/Uhrtypes/DE16x8.hpp b/include/Uhrtypes/DE16x8.hpp index 8f2cb023..179bc9bd 100644 --- a/include/Uhrtypes/DE16x8.hpp +++ b/include/Uhrtypes/DE16x8.hpp @@ -71,13 +71,13 @@ class De16x8_t : public iUhrType { //------------------------------------------------------------------------------ - virtual const bool hasAbsoluteMinLayout() { return true; } + virtual const bool hasMinuteInWords() { return true; } //------------------------------------------------------------------------------ virtual const void getMinuteArray(uint16_t *returnArr, uint8_t col) { for (uint8_t i = 0; i < 4; i++) { - returnArr[i] = 236 - i; + returnArr[i] = 256 + i; } }; @@ -191,6 +191,22 @@ class De16x8_t : public iUhrType { setFrontMatrixWord(7, 14, 14); break; + case FrontWord::m_num1: + setFrontMatrixWord(7, 12, 12); + break; + + case FrontWord::m_num2: + setFrontMatrixWord(7, 11, 11); + break; + + case FrontWord::m_num3: + setFrontMatrixWord(7, 10, 10); + break; + + case FrontWord::m_num4: + setFrontMatrixWord(7, 9, 9); + break; + default: break; }; diff --git a/include/Uhrtypes/NL10x11.hpp b/include/Uhrtypes/NL10x11.hpp index df0c56e6..5439b65e 100644 --- a/include/Uhrtypes/NL10x11.hpp +++ b/include/Uhrtypes/NL10x11.hpp @@ -27,6 +27,10 @@ class NL10x11_t : public iUhrType { //------------------------------------------------------------------------------ + virtual const bool hasMinuteInWords() { return true; } + + //------------------------------------------------------------------------------ + void show(FrontWord word) override { switch (word) { diff --git a/include/Uhrtypes/Uhrtype.hpp b/include/Uhrtypes/Uhrtype.hpp index 81ff496f..3604409e 100644 --- a/include/Uhrtypes/Uhrtype.hpp +++ b/include/Uhrtypes/Uhrtype.hpp @@ -142,7 +142,7 @@ class iUhrType { virtual const bool hasSecondsFrame() { return false; } - virtual const bool hasAbsoluteMinLayout() { return false; } + virtual const bool hasMinuteInWords() { return false; } virtual const uint16_t getFrontMatrixIndex(const uint8_t row, uint8_t col) { diff --git a/include/clockWork.hpp b/include/clockWork.hpp index 196f635b..97c37d43 100644 --- a/include/clockWork.hpp +++ b/include/clockWork.hpp @@ -302,15 +302,30 @@ uint8_t ClockWork::determineWhichMinuteVariant() { //------------------------------------------------------------------------------ void ClockWork::showMinuteInWords(uint8_t min) { + if (G.UhrtypeDef == Ger16x8 && min > 0) { + usedUhrType->show(FrontWord::plus); + usedUhrType->show(FrontWord::minute); + if (min % 5 > 1) { + usedUhrType->show(FrontWord::minuten); + } + } switch (min) { case 0: usedUhrType->show(FrontWord::nur); break; case 1: + usedUhrType->show(FrontWord::m_num1); + break; + case 2: + usedUhrType->show(FrontWord::m_num2); + break; case 3: + usedUhrType->show(FrontWord::m_num3); + break; case 4: + usedUhrType->show(FrontWord::m_num4); usedUhrType->show(FrontWord::gewesen); break; @@ -330,7 +345,7 @@ void ClockWork::showMinute(uint8_t min) { determineWhichMinuteVariant()); /* Reseting minute byte */ minuteArray = 0; - if (usedUhrType->hasAbsoluteMinLayout() && min > 0) { + if (usedUhrType->hasMinuteInWords() && min > 0) { minuteArray |= 1UL << (min - 1); } else { for (uint8_t i = 0; i < min; i++) { @@ -339,7 +354,8 @@ void ClockWork::showMinute(uint8_t min) { } } - if (G.UhrtypeDef == Nl10x11 && G.minuteVariant == MinuteVariant::InWords) { + if (usedUhrType->hasMinuteInWords() && + G.minuteVariant == MinuteVariant::InWords) { showMinuteInWords(min); } } @@ -445,13 +461,6 @@ FrontWord ClockWork::getFrontWordForNum(uint8_t min) { //------------------------------------------------------------------------------ void ClockWork::setMinute(uint8_t min, uint8_t &offsetHour, bool &fullHour) { - if (min % 5 >= 1) { - usedUhrType->show(FrontWord::plus); - usedUhrType->show(FrontWord::minute); - if (min % 5 >= 2) { - usedUhrType->show(FrontWord::minuten); - } - } if (!usedUhrType->has24HourLayout()) { showMinute(min); min /= 5; @@ -894,6 +903,7 @@ void ClockWork::loop(struct tm &tm) { config["hasZwanzig"] = usedUhrType->hasZwanzig(); config["hasWeatherLayout"] = usedUhrType->hasWeatherLayout(); config["hasSecondsFrame"] = usedUhrType->hasSecondsFrame(); + config["hasMinuteInWords"] = usedUhrType->hasMinuteInWords(); config["numOfRows"] = usedUhrType->rowsWordMatrix(); serializeJson(config, str); Serial.print("Sending Payload:"); diff --git a/include/led.hpp b/include/led.hpp index eefdc302..49acb164 100644 --- a/include/led.hpp +++ b/include/led.hpp @@ -200,8 +200,8 @@ void Led::shiftColumnToRight() { void Led::setPixel(uint16_t ledIndex, HsbColor color) { if (G.Colortype == Grbw) { - strip_RGBW->SetPixelColor( - ledIndex, convertRgbToRgbw(RgbColor(color), G.wType)); + strip_RGBW->SetPixelColor(ledIndex, + convertRgbToRgbw(RgbColor(color), G.wType)); } else { strip_RGB->SetPixelColor(ledIndex, color); } @@ -349,7 +349,7 @@ void Led::set(bool changed) { setbySecondArray(Foreground); } - if (animation->led_show_notify(changed, _minute)) { + if (animation->ledShowNotify(changed, _minute)) { show(); } } diff --git a/webpage/script.js b/webpage/script.js index d43880ee..c9f00cd6 100644 --- a/webpage/script.js +++ b/webpage/script.js @@ -387,7 +387,9 @@ function initWebsocket() { enableSpecific("specific-layout-6", data.UhrtypeDef === 10); // EN10x11 enableSpecific("specific-colortype-4", data.colortype === 4); removeSpecificOption("show-minutes", "3", data.numOfRows !== 11); // MinuteVariant "Corners" only for DE11x11 Variants - removeSpecificOption("show-minutes", "4", data.UhrtypeDef !== 9); // MinuteVariant "In Words" + removeSpecificOption("show-minutes", "4", !data.hasMinuteInWords); + removeSpecificOption("show-minutes", "1", data.UhrtypeDef === 13); // Remove "LED4x" for Ger16x8 + removeSpecificOption("show-minutes", "2", data.UhrtypeDef === 13); // Remove "LED7x" for Ger16x8 autoLdrEnabled = data.autoLdrEnabled; $("#auto-ldr-enabled").set("value", autoLdrEnabled); From 6d3df049d7a7b6113227a343efa71985c5548708 Mon Sep 17 00:00:00 2001 From: David Panusch Date: Sat, 15 Jul 2023 10:59:13 +0200 Subject: [PATCH 16/29] Reworked setIcons() --- include/clockWork.h | 6 +++++- include/clockWork.hpp | 19 +++++++------------ include/led.h | 3 ++- include/led.hpp | 16 +++++++++++++--- 4 files changed, 27 insertions(+), 17 deletions(-) diff --git a/include/clockWork.h b/include/clockWork.h index 3fcd37f5..e1b66b9e 100644 --- a/include/clockWork.h +++ b/include/clockWork.h @@ -26,7 +26,6 @@ class ClockWork { //------------------------------------------------------------------------------ // Minute Functions //------------------------------------------------------------------------------ - uint8_t determineWhichMinuteVariant(); void showMinuteInWords(uint8_t min); void showMinute(uint8_t min); void resetMinVariantIfNotAvailable(); @@ -56,6 +55,11 @@ class ClockWork { iUhrType *getPointer(uint8_t type); void initLedStrip(uint8_t num); + //------------------------------------------------------------------------------ + // Minute Functions + //------------------------------------------------------------------------------ + uint8_t determineWhichMinuteVariant(); + //------------------------------------------------------------------------------ // Boot Functions //------------------------------------------------------------------------------ diff --git a/include/clockWork.hpp b/include/clockWork.hpp index 97c37d43..6cc576e4 100644 --- a/include/clockWork.hpp +++ b/include/clockWork.hpp @@ -12,14 +12,6 @@ OpenWMap weather; // Helper Functions //------------------------------------------------------------------------------ -void ClockWork::resetFrontMatrixBuffer() { - for (uint8_t i = 0; i < usedUhrType->rowsWordMatrix(); i++) { - frontMatrix[i] = 0; - } -} - -//------------------------------------------------------------------------------ - void ClockWork::loopLdrLogic() { int16_t lux = analogRead(A0); // Range 0-1023 uint8_t ldrValOld = ldrVal; @@ -248,11 +240,11 @@ void ClockWork::initBootShowIp(const char *buf) { void ClockWork::initBootWifiSignalStrength(int strength) { if (strength <= 100) { - led.setIcon(WLAN100, 100); + led.setIcon(WLAN100); } else if (strength <= 60) { - led.setIcon(WLAN60, 60); + led.setIcon(WLAN60); } else if (strength <= 30) { - led.setIcon(WLAN30, 30); + led.setIcon(WLAN30); } } @@ -292,6 +284,9 @@ uint8_t ClockWork::determineWhichMinuteVariant() { case MinuteVariant::Corners: return 2; break; + case MinuteVariant::InWords: + return 0; + break; default: Serial.println("[ERROR] G.minuteVariant undefined"); return 0; @@ -748,7 +743,7 @@ void ClockWork::setClock() { //------------------------------------------------------------------------------ void ClockWork::calcClockface() { - resetFrontMatrixBuffer(); + led.resetFrontMatrixBuffer(); if (_hour == 23 && _minute == 59 && _second >= 50) { countdownToMidnight(); diff --git a/include/led.h b/include/led.h index deb67269..6786abaf 100644 --- a/include/led.h +++ b/include/led.h @@ -21,6 +21,7 @@ class Led { // Helper Functions //------------------------------------------------------------------------------ inline void checkIfHueIsOutOfBound(uint16_t &hue); + void resetFrontMatrixBuffer(); //------------------------------------------------------------------------------ // Manipulate Functions @@ -47,7 +48,7 @@ class Led { bool applyMirrorAndReverse = true); void setbyMinuteArray(uint8_t ColorPosition = Foreground); void setbySecondArray(uint8_t ColorPosition = Foreground); - void setIcon(uint8_t num_icon, uint8_t brightness); + void setIcon(uint8_t iconNum); void setSingle(uint8_t wait); void setPixelForChar(uint8_t col, uint8_t row, uint8_t offsetCol, uint8_t offsetRow, unsigned char unsigned_d1, diff --git a/include/led.hpp b/include/led.hpp index 49acb164..b6060942 100644 --- a/include/led.hpp +++ b/include/led.hpp @@ -111,6 +111,14 @@ RgbwColor convertRgbToRgbw(RgbColor light, WhiteType wType) { return returnColor; } +//------------------------------------------------------------------------------ + +void Led::resetFrontMatrixBuffer() { + for (uint8_t i = 0; i < usedUhrType->rowsWordMatrix(); i++) { + frontMatrix[i] = 0; + } +} + //------------------------------------------------------------------------------ // Brightness Functions //------------------------------------------------------------------------------ @@ -279,19 +287,21 @@ void Led::setbySecondArray(uint8_t colorPosition) { //------------------------------------------------------------------------------ -void Led::setIcon(uint8_t num_icon, uint8_t brightness = 100) { +void Led::setIcon(uint8_t iconNum) { + resetFrontMatrixBuffer(); uint8_t offsetCol = (usedUhrType->colsWordMatrix() - GRAFIK_11X10_COLS) / 2; for (uint8_t col = 0; col < GRAFIK_11X10_COLS; col++) { for (uint8_t row = 0; row < GRAFIK_11X10_ROWS; row++) { - if (pgm_read_word(&(grafik_11x10[num_icon][row])) & - (1 << (GRAFIK_11X10_COLS - 1 - col))) { + if (pgm_read_word(&(grafik_11x10[iconNum][row])) & + (1 << (GRAFIK_11X10_COLS - col - 1))) { usedUhrType->setFrontMatrixPixel(row, col + offsetCol); } else { usedUhrType->setFrontMatrixPixel(row, col + offsetCol, false); } } } + setbyFrontMatrix(Foreground); show(); } From 5d0afe56cb6eb557a89d1b260f2fb9bcc511ac10 Mon Sep 17 00:00:00 2001 From: David Panusch Date: Sat, 15 Jul 2023 11:00:44 +0200 Subject: [PATCH 17/29] Removed some unused references --- include/led.hpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/include/led.hpp b/include/led.hpp index b6060942..fe71f0c2 100644 --- a/include/led.hpp +++ b/include/led.hpp @@ -70,13 +70,13 @@ bool Led::getCharCol(fontSize font, uint8_t col, uint8_t row, void Led::applyMirroringAndReverseIfDefined() { if (G.layoutVariant[ReverseMinDirection]) { - led.mirrorMinuteArrayVertical(); + mirrorMinuteArrayVertical(); } if (G.layoutVariant[MirrorVertical]) { - led.mirrorFrontMatrixVertical(); + mirrorFrontMatrixVertical(); } if (G.layoutVariant[MirrorHorizontal]) { - led.mirrorFrontMatrixHorizontal(); + mirrorFrontMatrixHorizontal(); } } @@ -321,11 +321,11 @@ void Led::setSingle(uint8_t wait) { clear(); if (row % 2 != 0) { - led.setPixel(row, usedUhrType->colsWordMatrix() - 1 - col, - HsbColor(hue / 360.f, 1.f, G.effectBri / 100.f)); + setPixel(row, usedUhrType->colsWordMatrix() - 1 - col, + HsbColor(hue / 360.f, 1.f, G.effectBri / 100.f)); } else { - led.setPixel(row, col, - HsbColor(hue / 360.f, 1.f, G.effectBri / 100.f)); + setPixel(row, col, + HsbColor(hue / 360.f, 1.f, G.effectBri / 100.f)); } show(); delay(wait); From 3ea19c82dccb17f1d599458ae2e738606926e547 Mon Sep 17 00:00:00 2001 From: David Panusch Date: Sat, 15 Jul 2023 11:02:13 +0200 Subject: [PATCH 18/29] removed unused reference --- include/clockWork.h | 1 - 1 file changed, 1 deletion(-) diff --git a/include/clockWork.h b/include/clockWork.h index e1b66b9e..0fe11720 100644 --- a/include/clockWork.h +++ b/include/clockWork.h @@ -11,7 +11,6 @@ class ClockWork { //------------------------------------------------------------------------------ // Helper Functions //------------------------------------------------------------------------------ - void resetFrontMatrixBuffer(); void loopLdrLogic(); uint32_t num32BitWithOnesAccordingToColumns(); From dfb87bd813a4756229b1b75720377e13ae559397 Mon Sep 17 00:00:00 2001 From: David Panusch Date: Sat, 15 Jul 2023 11:51:15 +0200 Subject: [PATCH 19/29] Refactored animation Code --- include/Animation.h | 24 ++++++++++++------------ include/Animation.hpp | 6 +++--- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/include/Animation.h b/include/Animation.h index b9028c6a..515c9019 100644 --- a/include/Animation.h +++ b/include/Animation.h @@ -218,8 +218,8 @@ class Rain { stopPhase = frames - speedlimit * maxRows; } - RgbaColor get(int32_t r) { - int32_t row = (maxRows - 1 - r); + RgbaColor get(int32_t _row) { + int32_t row = (maxRows - 1 - _row); // per image row runs from (maxRows - 1) down to 0 int32_t pos = (row + offset) % (deadtime + lifetime); @@ -283,12 +283,12 @@ class Ball { } virtual ~Ball(){}; - void begin(int32_t row, int32_t column, RgbfColor foreground, + void begin(int32_t _row, int32_t _col, RgbfColor foreground, RgbfColor background, int32_t delay) { this->delay = delay; - y = row << 8; // increase precision - r = row; - c = column; + y = _row << 8; // increase precision + row = _row; + col = _col; vy = 0; colorForeground = foreground; colorBackground = background; @@ -318,7 +318,7 @@ class Ball { } lastDown |= (_vy < 0) && (vy >= 0) && (y > lastPos); // upper turning point - r = y >> 8; + row = y >> 8; } color = end ? colorBackground : colorForeground; } @@ -326,7 +326,7 @@ class Ball { } public: - int32_t r, c; // after calling move() r and c contain new actual values + int32_t row, col; // after calling move() row & col contain new actual val RgbfColor color; protected: @@ -507,19 +507,19 @@ class Firework { maxLayer = layer; } - bool getPixel(uint8_t r, uint8_t c, RgbColor &color) { + bool getPixel(uint8_t row, uint8_t col, RgbColor &color) { // void Animation::copyBlock(RgbfColor color, uint32_t block, bool fgbg, // bool mirrored, // bool init) { - if ((r < 10) && (r < maxRows) && (c < 11) && (c < maxCols)) { + if ((row < 10) && (row < maxRows) && (col < 11) && (col < maxCols)) { uint16_t pixels = 0; for (int32_t layer = 0; layer <= maxLayer; layer++) { if (icons[layer] != static_cast(0)) { pixels = animation->reverse( - pgm_read_word(&(grafik_11x10[icons[layer]][r])), + pgm_read_word(&(grafik_11x10[icons[layer]][row])), mirrored); - if (pixels & (1 << c)) { + if (pixels & (1 << col)) { color = colors[layer]; return true; } diff --git a/include/Animation.hpp b/include/Animation.hpp index 6cac96c0..6d622c71 100644 --- a/include/Animation.hpp +++ b/include/Animation.hpp @@ -668,10 +668,10 @@ uint16_t Animation::animBalls() { starttime = now; ballsDown = 0; for (uint8_t i = 0; i < numBalls; i++) { - oldR = balls[i].r; + oldR = balls[i].row; ballsDown += balls[i].move(timeDelta); - row = balls[i].r; // row, col new coordinates - col = balls[i].c; + row = balls[i].row; // row, col new coordinates + col = balls[i].col; if (row > oldR) { // down for (; row > oldR; oldR++) { work[oldR][col] = background; From 301faf88dcc9d1d597d8b51b8845bc4cbdfae129 Mon Sep 17 00:00:00 2001 From: David Panusch Date: Sat, 15 Jul 2023 13:02:31 +0200 Subject: [PATCH 20/29] Fixed bug ScrollingText is now changeable --- include/clockWork.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/clockWork.hpp b/include/clockWork.hpp index 6cc576e4..41302ce5 100644 --- a/include/clockWork.hpp +++ b/include/clockWork.hpp @@ -153,7 +153,7 @@ void ClockWork::scrollingText(const char *buf) { (usedUhrType->rowsWordMatrix() - fontHeight[normalSizeASCII]) / 2; uint8_t fontIndex = buf[ii]; - led.setbyFrontMatrix(Foreground); // Needed for Mirrored Display + led.setbyFrontMatrix(Effect); // Needed for Mirrored Display led.shiftColumnToRight(); led.clearFrontExeptofFontspace(offsetRow); @@ -169,7 +169,7 @@ void ClockWork::scrollingText(const char *buf) { } } - led.setbyFrontMatrix(Foreground); + led.setbyFrontMatrix(Effect); led.show(); i++; From 576733e9988d774135dda63009ac250358161be2 Mon Sep 17 00:00:00 2001 From: David Panusch Date: Sat, 15 Jul 2023 13:09:51 +0200 Subject: [PATCH 21/29] Bug fixed, flickering in modes when changing color --- include/clockWork.hpp | 5 ++++- include/webPageAdapter.h | 37 ++++++++++++++++++++++++++----------- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/include/clockWork.hpp b/include/clockWork.hpp index 41302ce5..121cb833 100644 --- a/include/clockWork.hpp +++ b/include/clockWork.hpp @@ -1106,8 +1106,11 @@ void ClockWork::loop(struct tm &tm) { case COMMAND_MODE_DIGITAL_CLOCK: { if (G.progInit) { clearClockByProgInit(); + } + if (parametersChanged) { led.showDigitalClock(_minute % 10, _minute / 10, _hour % 10, _hour / 10); + parametersChanged = false; } break; } @@ -1117,8 +1120,8 @@ void ClockWork::loop(struct tm &tm) { case COMMAND_MODE_RAINBOW: { if (G.progInit) { countMillisSpeed = (11u - G.effectSpeed) * 30u; + clearClockByProgInit(); } - clearClockByProgInit(); if (countMillisSpeed >= (11u - G.effectSpeed) * 30u) { switch (G.prog) { diff --git a/include/webPageAdapter.h b/include/webPageAdapter.h index 1647673f..98eb41f1 100644 --- a/include/webPageAdapter.h +++ b/include/webPageAdapter.h @@ -143,6 +143,13 @@ void payloadTextHandling(const uint8_t *payload, char *text, //------------------------------------------------------------------------------ +bool compareEffBriAndSpeedToOld(uint8_t *payload) { + return ((G.effectBri != split(payload, 21)) || + (G.effectSpeed != split(payload, 24))); +} + +//------------------------------------------------------------------------------ + void parseMainColor(uint8_t *payload, uint8_t position) { G.color[position] = {HsbColor(split(payload, 3) / 360.f, split(payload, 6) / 100.f, @@ -197,32 +204,34 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t *payload, //------------------------------------------------------------------------------ case COMMAND_MODE_SECONDS: { - G.progInit = true; + if (G.prog != command) { + G.progInit = true; + } parseMainColor(payload, Effect); - G.effectBri = split(payload, 21); - G.effectSpeed = split(payload, 24); break; } //------------------------------------------------------------------------------ case COMMAND_MODE_DIGITAL_CLOCK: { - G.progInit = true; + if (G.prog != command) { + G.progInit = true; + } parseMainColor(payload, Effect); - G.effectBri = split(payload, 21); - G.effectSpeed = split(payload, 24); + parametersChanged = true; break; } //------------------------------------------------------------------------------ case COMMAND_MODE_SCROLLINGTEXT: { - G.progInit = true; + if ((G.prog != command) || compareEffBriAndSpeedToOld(payload)) { + G.progInit = true; + } parseMainColor(payload, Effect); - G.effectBri = split(payload, 21); G.effectSpeed = split(payload, 24); break; } @@ -230,7 +239,9 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t *payload, //------------------------------------------------------------------------------ case COMMAND_MODE_RAINBOWCYCLE: { - G.progInit = true; + if ((G.prog != command) || compareEffBriAndSpeedToOld(payload)) { + G.progInit = true; + } G.effectBri = split(payload, 21); G.effectSpeed = split(payload, 24); @@ -240,7 +251,9 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t *payload, //------------------------------------------------------------------------------ case COMMAND_MODE_RAINBOW: { - G.progInit = true; + if ((G.prog != command) || compareEffBriAndSpeedToOld(payload)) { + G.progInit = true; + } G.effectBri = split(payload, 21); G.effectSpeed = split(payload, 24); @@ -250,7 +263,9 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t *payload, //------------------------------------------------------------------------------ case COMMAND_MODE_COLOR: { - G.progInit = true; + if (G.prog != command) { + G.progInit = true; + } parseMainColor(payload, Effect); break; From 6af096fa2fd0da64b574864a0e9b6f80a6ca0a9d Mon Sep 17 00:00:00 2001 From: David Panusch Date: Sat, 15 Jul 2023 13:11:03 +0200 Subject: [PATCH 22/29] Fixed Bug, Scrollingtext not dispalying correctly --- webpage/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webpage/index.html b/webpage/index.html index 2c410c21..28e7db4b 100644 --- a/webpage/index.html +++ b/webpage/index.html @@ -170,7 +170,7 @@

- +
From 3e1872ddba1298675417a78e0e3c7c5474bce112 Mon Sep 17 00:00:00 2001 From: David Panusch Date: Sat, 15 Jul 2023 13:12:06 +0200 Subject: [PATCH 23/29] Increase in Monitor Speed for smoother handling --- platformio.ini | 2 +- src/Wortuhr.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/platformio.ini b/platformio.ini index 43d4c927..8c031ef9 100644 --- a/platformio.ini +++ b/platformio.ini @@ -17,7 +17,7 @@ board = nodemcuv2 board_build.f_cpu = 160000000L framework = arduino upload_speed = 230400 -monitor_speed = 115200 +monitor_speed = 460800 monitor_filters = esp8266_exception_decoder lib_deps = makuna/NeoPixelBus@^2.7.6 diff --git a/src/Wortuhr.cpp b/src/Wortuhr.cpp index d37ab0ff..ddfacf0a 100644 --- a/src/Wortuhr.cpp +++ b/src/Wortuhr.cpp @@ -121,7 +121,7 @@ void setup() { // Start serial interface if required //------------------------------------- #if GENERAL_VERBOSE - Serial.begin(115200); + Serial.begin(460800); Serial.println(""); Serial.println("--------------------------------------"); Serial.println("Begin Setup"); From f4f2804e6a6cf32bf182e200a90c7581e9445cc2 Mon Sep 17 00:00:00 2001 From: David Panusch Date: Sat, 15 Jul 2023 14:15:25 +0200 Subject: [PATCH 24/29] Added a new Mode "Symbol" --- include/Uhr.h | 24 ++++---- include/clockWork.h | 1 + include/clockWork.hpp | 43 +++++++++++++- include/icons.h | 124 ++++++++++++++++++--------------------- include/led.hpp | 2 +- include/webPageAdapter.h | 12 ++++ webpage/index.html | 2 + webpage/language/de.js | 3 +- webpage/language/en.js | 3 +- webpage/language/nl.js | 3 +- webpage/script.js | 6 ++ 11 files changed, 138 insertions(+), 85 deletions(-) diff --git a/include/Uhr.h b/include/Uhr.h index 9472fac7..bda02484 100644 --- a/include/Uhr.h +++ b/include/Uhr.h @@ -194,6 +194,7 @@ enum CommandWords { COMMAND_MODE_RAINBOW = 5, COMMAND_MODE_COLOR = 6, COMMAND_MODE_DIGITAL_CLOCK = 7, + COMMAND_MODE_SYMBOL = 8, COMMAND_MODE_ANIMATION = 10, PLACEHOLDER_MAX_MODE = 19, @@ -253,16 +254,15 @@ enum ClockType { }; enum Icons { - WLANT = 0, - WLAN100 = 1, - WLAN60 = 2, - WLAN30 = 3, - HERZ = 4, - SMILY = 5, - FIRE_1 = 6, - FIRE_2 = 7, - FIRE_3 = 8, - FIRE_4 = 9, - FIRE_5 = 10, - FIRE_6 = 11, + WLAN100 = 0, + WLAN60 = 1, + WLAN30 = 2, + FIRE_1 = 3, + FIRE_2 = 4, + FIRE_3 = 5, + FIRE_4 = 6, + FIRE_5 = 7, + FIRE_6 = 8, + HEART = 9, + SMILEY = 10, }; diff --git a/include/clockWork.h b/include/clockWork.h index 0fe11720..68a9d3c7 100644 --- a/include/clockWork.h +++ b/include/clockWork.h @@ -20,6 +20,7 @@ class ClockWork { void rainbow(); void rainbowCycle(); void scrollingText(const char *buf); + void displaySymbols(uint8_t iconNum); void countdownToMidnight(); //------------------------------------------------------------------------------ diff --git a/include/clockWork.hpp b/include/clockWork.hpp index 121cb833..68c10c20 100644 --- a/include/clockWork.hpp +++ b/include/clockWork.hpp @@ -184,6 +184,42 @@ void ClockWork::scrollingText(const char *buf) { //------------------------------------------------------------------------------ +void ClockWork::displaySymbols(uint8_t iconNum) { + static uint8_t count = 0; + + switch (iconNum) { + case HEART: + /* Heartbeat begin */ + if (count < 10) { + G.color[Effect].B += 0.03; + if (G.color[Effect].B > 1) { + G.color[Effect].B = 1; + } + count++; + } else if (count < 20) { + G.color[Effect].B -= 0.03; + if (G.color[Effect].B <= 0) { + G.color[Effect].B = 0; + } + count++; + } else { + count = 0; + } + /* Heartbeat end */ + led.setIcon(HEART); + break; + + case SMILEY: + led.setIcon(SMILEY); + break; + + default: + break; + } +} + +//------------------------------------------------------------------------------ + void ClockWork::countdownToMidnight() { Serial.printf("Count down: %d\n", 60 - _second); switch (_second) { @@ -1117,7 +1153,8 @@ void ClockWork::loop(struct tm &tm) { case COMMAND_MODE_SCROLLINGTEXT: case COMMAND_MODE_RAINBOWCYCLE: - case COMMAND_MODE_RAINBOW: { + case COMMAND_MODE_RAINBOW: + case COMMAND_MODE_SYMBOL: { if (G.progInit) { countMillisSpeed = (11u - G.effectSpeed) * 30u; clearClockByProgInit(); @@ -1137,6 +1174,10 @@ void ClockWork::loop(struct tm &tm) { rainbow(); break; } + case COMMAND_MODE_SYMBOL: { + displaySymbols(HEART); + break; + } default: break; } diff --git a/include/icons.h b/include/icons.h index 196a4cfd..8d5a0d2f 100644 --- a/include/icons.h +++ b/include/icons.h @@ -4,38 +4,26 @@ #define GRAFIK_11X10_COLS 11 const uint16_t grafik_11x10[][11] PROGMEM = { - - {0b10001010000, // 0 WLANT 0: O . . . O . O . . . . : 10 - 0b10101010000, // 1 21: O . O . O . O . . . . : 11 - 0b11011010000, // 2 22: O O . 0 0 . 0 . . . . : 32 - 0b10001011110, // 3 43: O . . O . . O O O O . : 33 - 0b00000000000, // 4 44: . . . . . . . . . . . : 54 - 0b01110010001, // 5 65: . O O O . . O . . . O : 55 - 0b10001011001, // 6 66: O . . . O . O O . . O : 76 - 0b11111010101, // 7 87: O O O O O . O . O . O : 77 - 0b10001010011, // 8 88: O . . . O . O . . O O : 98 - 0b00000000000}, // 9 109: . . . . . . . . . . . : 99 - - {0b00011111000, // 0 WLAN100 0: . . . O O O O O . . . : 10 - 0b01111111110, // 1 21: . O O O O O O O O O . : 11 - 0b11100000111, // 2 22: O O O . . . . . O O O : 32 - 0b10011111001, // 3 43: O . . O O O O O . . O : 33 - 0b00111111100, // 4 44: . . O O O O O O O . . : 54 - 0b00100000100, // 5 65: . . O . . . . . O . . : 55 - 0b00000100000, // 6 66: . . . . . O . . . . . : 76 - 0b00001110000, // 7 87: . . . . O O O . . . . : 77 - 0b00000100000, // 8 88: . . . . . O . . . . . : 98 + {0b00011111000, // 0 WLAN100 0: . . . 0 0 0 0 0 . . . : 10 + 0b01111111110, // 1 21: . 0 0 0 0 0 0 0 0 0 . : 11 + 0b11100000111, // 2 22: 0 0 0 . . . . . 0 0 0 : 32 + 0b10011111001, // 3 43: 0 . . 0 0 0 0 0 . . 0 : 33 + 0b00111111100, // 4 44: . . 0 0 0 0 0 0 0 . . : 54 + 0b00100000100, // 5 65: . . 0 . . . . . 0 . . : 55 + 0b00000100000, // 6 66: . . . . . 0 . . . . . : 76 + 0b00001110000, // 7 87: . . . . 0 0 0 . . . . : 77 + 0b00000100000, // 8 88: . . . . . 0 . . . . . : 98 0b00000000000}, // 9 109: . . . . . . . . . . . : 99 {0b00000000000, // 0 WLAN60 0: . . . . . . . . . . . : 10 0b00000000000, // 1 21: . . . . . . . . . . . : 11 0b00000000000, // 2 22: . . . . . . . . . . . : 32 - 0b00011111000, // 3 43: . . . O O O O O . . . : 33 - 0b00111111100, // 4 44: . . O O O O O O O . . : 54 - 0b00100000100, // 5 65: . . O . . . . . O . . : 55 - 0b00000100000, // 6 66: . . . . . O . . . . . : 76 - 0b00001110000, // 7 87: . . . . O O O . . . . : 77 - 0b00000100000, // 8 88: . . . . . O . . . . . : 98 + 0b00011111000, // 3 43: . . . 0 0 0 0 0 . . . : 33 + 0b00111111100, // 4 44: . . 0 0 0 0 0 0 0 . . : 54 + 0b00100000100, // 5 65: . . 0 . . . . . 0 . . : 55 + 0b00000100000, // 6 66: . . . . . 0 . . . . . : 76 + 0b00001110000, // 7 87: . . . . 0 0 0 . . . . : 77 + 0b00000100000, // 8 88: . . . . . 0 . . . . . : 98 0b00000000000}, // 9 109: . . . . . . . . . . . : 99 {0b00000000000, // 0 WLAN30 0: . . . . . . . . . . . : 10 @@ -44,33 +32,11 @@ const uint16_t grafik_11x10[][11] PROGMEM = { 0b00000000000, // 3 43: . . . . . . . . . . . : 33 0b00000000000, // 4 44: . . . . . . . . . . . : 54 0b00000000000, // 5 65: . . . . . . . . . . . : 55 - 0b00000100000, // 6 66: . . . . . O . . . . . : 76 - 0b00001110000, // 7 87: . . . . O O O . . . . : 77 - 0b00000100000, // 8 88: . . . . . O . . . . . : 98 + 0b00000100000, // 6 66: . . . . . 0 . . . . . : 76 + 0b00001110000, // 7 87: . . . . 0 0 0 . . . . : 77 + 0b00000100000, // 8 88: . . . . . 0 . . . . . : 98 0b00000000000}, // 9 109: . . . . . . . . . . . : 99 - {0b00110001100, // 0 HERZ 0: . . 0 0 . . . 0 0 . . : 10 - 0b01111011110, // 1 21: . 0 0 0 0 . 0 0 0 0 . : 11 - 0b11111111111, // 2 22: 0 0 0 0 0 0 0 0 0 0 0 : 32 - 0b11111111111, // 3 43: 0 0 0 0 0 0 O O O O O : 33 - 0b11111111111, // 4 44: O O O O O O O O O O O : 54 - 0b01111111110, // 5 65: . 0 0 0 0 O O O O O . : 55 - 0b00111111100, // 6 66: . . 0 0 0 O 0 0 0 . . : 76 - 0b00011111000, // 7 87: . . . 0 O O O 0 . . . : 77 - 0b00001110000, // 8 88: . . . . O O O . . . . : 98 - 0b00000100000}, // 9 109: . . . . . O . . . . . : 99 - - {0b00011111000, // 0 SMILY 0: . . . 0 O O O 0 . . . : 10 - 0b00111111100, // 1 21: . . 0 0 0 0 0 0 0 . . : 11 - 0b01101110110, // 2 22: . 0 0 . 0 0 0 . 0 0 . : 32 - 0b11111111111, // 3 43: 0 0 0 0 0 0 O O O O O : 33 - 0b11111111111, // 4 44: O O O O O O O O O O O : 54 - 0b10111111101, // 5 65: 0 . 0 0 0 O O O O . 0 : 55 - 0b11001110011, // 6 66: 0 0 . . 0 O 0 . . 0 0 : 76 - 0b01110001110, // 7 87: . 0 0 0 . . . 0 0 0 . : 77 - 0b00111111100, // 8 88: . . 0 0 O O O O 0 . . : 98 - 0b00011111000}, // 9 109: . . . 0 0 O 0 0 . . . : 99 - {0b00000000000, // 0 FIRE1 0: . . . . . . . . . . . : 10 0b00000000000, // 1 21: . . . . . . . . . . . : 11 0b00000000000, // 2 22: . . . . . . . . . . . : 32 @@ -80,7 +46,7 @@ const uint16_t grafik_11x10[][11] PROGMEM = { 0b00000000000, // 6 66: . . . . . . . . . . . : 76 0b00000000000, // 7 87: . . . . . . . . . . . : 77 0b00000000000, // 8 88: . . . . . . . . . . . : 98 - 0b00100000000}, // 9 109: . . O . . . . . . . . : 99 + 0b00100000000}, // 9 109: . . 0 . . . . . . . . : 99 {0b00000000000, // 0 FIRE2 0: . . . . . . . . . . . : 10 0b00000000000, // 1 21: . . . . . . . . . . . : 11 @@ -89,26 +55,26 @@ const uint16_t grafik_11x10[][11] PROGMEM = { 0b00000000000, // 4 44: . . . . . . . . . . . : 54 0b00000000000, // 5 65: . . . . . . . . . . . : 55 0b00000000000, // 6 66: . . . . . . . . . . . : 76 - 0b00010000000, // 7 87: . . . O . . . . . . . : 77 - 0b00100000000, // 8 88: . . O . . . . . . . . : 98 + 0b00010000000, // 7 87: . . . 0 . . . . . . . : 77 + 0b00100000000, // 8 88: . . 0 . . . . . . . . : 98 0b00000000000}, // 9 109: . . . . . . . . . . . : 99 {0b00000000000, // 0 FIRE3 0: . . . . . . . . . . . : 10 0b00000000000, // 1 21: . . . . . . . . . . . : 11 0b00000000000, // 2 22: . . . . . . . . . . . : 32 0b00000000000, // 3 43: . . . . . . . . . . . : 33 - 0b00000100000, // 4 44: . . . . . O . . . . . : 54 - 0b00001000000, // 5 65: . . . . O . . . . . . : 55 - 0b00001000000, // 6 66: . . . . O . . . . . . : 76 + 0b00000100000, // 4 44: . . . . . 0 . . . . . : 54 + 0b00001000000, // 5 65: . . . . 0 . . . . . . : 55 + 0b00001000000, // 6 66: . . . . 0 . . . . . . : 76 0b00000000000, // 7 87: . . . . . . . . . . . : 77 0b00000000000, // 8 88: . . . . . . . . . . . : 98 0b00000000000}, // 9 109: . . . . . . . . . . . : 99 {0b00000000000, // 0 FIRE4 0: . . . . . . . . . . . : 10 0b00000000000, // 1 21: . . . . . . . . . . . : 11 - 0b00000010000, // 2 22: . . . . . . O . . . . : 32 - 0b00000101000, // 3 43: . . . . . O . O . . . : 33 - 0b00000010000, // 4 44: . . . . . . O . . . . : 54 + 0b00000010000, // 2 22: . . . . . . 0 . . . . : 32 + 0b00000101000, // 3 43: . . . . . 0 . 0 . . . : 33 + 0b00000010000, // 4 44: . . . . . . 0 . . . . : 54 0b00000000000, // 5 65: . . . . . . . . . . . : 55 0b00000000000, // 6 66: . . . . . . . . . . . : 76 0b00000000000, // 7 87: . . . . . . . . . . . : 77 @@ -126,14 +92,36 @@ const uint16_t grafik_11x10[][11] PROGMEM = { 0b00000000000, // 8 88: . . . . . . . . . . . : 98 0b00000000000}, // 9 109: . . . . . . . . . . . : 99 - {0b00000111000, // 0 FIRE6 0: . . . . . O O O . . . : 10 - 0b00001000100, // 1 21: . . . . O . . . O . . : 11 - 0b00010000010, // 2 22: . . . O . . . . . O . : 32 - 0b00010000010, // 3 43: . . . O . . . . . O . : 33 - 0b00010000010, // 4 44: . . . O . . . . . O . : 54 - 0b00001000100, // 5 65: . . . . O . . . O . . : 55 - 0b00000111000, // 6 66: . . . . . O O O . . . : 76 + {0b00000111000, // 0 FIRE6 0: . . . . . 0 0 0 . . . : 10 + 0b00001000100, // 1 21: . . . . 0 . . . 0 . . : 11 + 0b00010000010, // 2 22: . . . 0 . . . . . 0 . : 32 + 0b00010000010, // 3 43: . . . 0 . . . . . 0 . : 33 + 0b00010000010, // 4 44: . . . 0 . . . . . 0 . : 54 + 0b00001000100, // 5 65: . . . . 0 . . . 0 . . : 55 + 0b00000111000, // 6 66: . . . . . 0 0 0 . . . : 76 0b00000000000, // 7 87: . . . . . . . . . . . : 77 0b00000000000, // 8 88: . . . . . . . . . . . : 98 0b00000000000}, // 9 109: . . . . . . . . . . . : 99 + + {0b00110001100, // 0 HEART 0: . . 0 0 . . . 0 0 . . : 10 + 0b01111011110, // 1 21: . 0 0 0 0 . 0 0 0 0 . : 11 + 0b11111111111, // 2 22: 0 0 0 0 0 0 0 0 0 0 0 : 32 + 0b11111111111, // 3 43: 0 0 0 0 0 0 0 0 0 0 0 : 33 + 0b11111111111, // 4 44: 0 0 0 0 0 0 0 0 0 0 0 : 54 + 0b01111111110, // 5 65: . 0 0 0 0 0 0 0 0 0 . : 55 + 0b00111111100, // 6 66: . . 0 0 0 0 0 0 0 . . : 76 + 0b00011111000, // 7 87: . . . 0 0 0 0 0 . . . : 77 + 0b00001110000, // 8 88: . . . . 0 0 0 . . . . : 98 + 0b00000100000}, // 9 109: . . . . . 0 . . . . . : 99 + + {0b00011111000, // 0 SMILEY 0: . . . 0 0 0 0 0 . . . : 10 + 0b00111111100, // 1 21: . . 0 0 0 0 0 0 0 . . : 11 + 0b01101110110, // 2 22: . 0 0 . 0 0 0 . 0 0 . : 32 + 0b11111111111, // 3 43: 0 0 0 0 0 0 0 0 0 0 0 : 33 + 0b11111111111, // 4 44: 0 0 0 0 0 0 0 0 0 0 0 : 54 + 0b10111111101, // 5 65: 0 . 0 0 0 0 0 0 0 . 0 : 55 + 0b11001110011, // 6 66: 0 0 . . 0 0 0 . . 0 0 : 76 + 0b01110001110, // 7 87: . 0 0 0 . . . 0 0 0 . : 77 + 0b00111111100, // 8 88: . . 0 0 0 0 0 0 0 . . : 98 + 0b00011111000}, // 9 109: . . . 0 0 0 0 0 . . . : 99 }; diff --git a/include/led.hpp b/include/led.hpp index fe71f0c2..604a4a6c 100644 --- a/include/led.hpp +++ b/include/led.hpp @@ -302,7 +302,7 @@ void Led::setIcon(uint8_t iconNum) { } } - setbyFrontMatrix(Foreground); + setbyFrontMatrix(Effect); show(); } diff --git a/include/webPageAdapter.h b/include/webPageAdapter.h index 98eb41f1..655dc17b 100644 --- a/include/webPageAdapter.h +++ b/include/webPageAdapter.h @@ -272,6 +272,18 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t *payload, } //------------------------------------------------------------------------------ + case COMMAND_MODE_SYMBOL: { + if ((G.prog != command) || compareEffBriAndSpeedToOld(payload)) { + G.progInit = true; + } + + parseMainColor(payload, Effect); + G.effectBri = split(payload, 21); + G.effectSpeed = split(payload, 24); + break; + } + //------------------------------------------------------------------------------ + case COMMAND_MODE_ANIMATION: { G.progInit = true; diff --git a/webpage/index.html b/webpage/index.html index 28e7db4b..ffaa839a 100644 --- a/webpage/index.html +++ b/webpage/index.html @@ -123,6 +123,8 @@

+ +
diff --git a/webpage/language/de.js b/webpage/language/de.js index effe2518..45780b1f 100644 --- a/webpage/language/de.js +++ b/webpage/language/de.js @@ -32,7 +32,8 @@ let TRANSLATION_DE_DE = { "digital-clock": "Digitaluhr", "scrollingtext": "Laufschrift", "rainbow": "Regenbogen", - "color-change": "Farbwechsel" + "color-change": "Farbwechsel", + "symbol": "Symbol" }, "animation": { "h2": "Animation", diff --git a/webpage/language/en.js b/webpage/language/en.js index e6b273f3..8a938827 100644 --- a/webpage/language/en.js +++ b/webpage/language/en.js @@ -32,7 +32,8 @@ let TRANSLATION_EN_US = { "digital-clock": "Digital Clock", "scrollingtext": "Scrollingtext", "rainbow": "Rainbow", - "color-change": "Color Change" + "color-change": "Color Change", + "symbol": "Symbol" }, "animation": { "h2": "Animation", diff --git a/webpage/language/nl.js b/webpage/language/nl.js index 01f23580..cbca78bf 100644 --- a/webpage/language/nl.js +++ b/webpage/language/nl.js @@ -32,7 +32,8 @@ let TRANSLATION_NL = { "digital-clock": "Digitale klok", "scrollingtext": "Tekst", "rainbow": "Regenboog", - "color-change": "Kleurverandering" + "color-change": "Kleurverandering", + "symbol": "Symbool" }, "animation": { "h2": "Animatie", diff --git a/webpage/script.js b/webpage/script.js index c9f00cd6..a0e66262 100644 --- a/webpage/script.js +++ b/webpage/script.js @@ -103,6 +103,7 @@ var COMMAND_MODE_RAINBOWCYCLE = 4; var COMMAND_MODE_RAINBOW = 5; var COMMAND_MODE_COLOR = 6; var COMMAND_MODE_DIGITAL_CLOCK = 7; +var COMMAND_MODE_SYMBOL = 8; var COMMAND_MODE_ANIMATION = 10; /** @@ -119,6 +120,7 @@ MODE_TO_INPUT_ID.set(COMMAND_MODE_RAINBOWCYCLE, "mode-rainbow"); MODE_TO_INPUT_ID.set(COMMAND_MODE_RAINBOW, "mode-change"); // Color change MODE_TO_INPUT_ID.set(COMMAND_MODE_COLOR, "mode-color"); MODE_TO_INPUT_ID.set(COMMAND_MODE_DIGITAL_CLOCK, "mode-digital-clock"); +MODE_TO_INPUT_ID.set(COMMAND_MODE_SYMBOL, "mode-symbol"); MODE_TO_INPUT_ID.set(COMMAND_MODE_ANIMATION, "mode-wordclock"); // other commands @@ -758,6 +760,10 @@ $.ready(function() { hasSpeed = true; command = COMMAND_MODE_RAINBOW; } + if (id === "mode-symbol") { + hasSpeed = true; + command = COMMAND_MODE_SYMBOL; + } setAnimation(); From 9a2bde43fd326f78ccc86682bfef6e95b20ea482 Mon Sep 17 00:00:00 2001 From: David Panusch Date: Sat, 15 Jul 2023 14:16:00 +0200 Subject: [PATCH 25/29] Fixed Bug, Showing minutes in Color only mode --- include/clockWork.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/clockWork.hpp b/include/clockWork.hpp index 68c10c20..1bcd558b 100644 --- a/include/clockWork.hpp +++ b/include/clockWork.hpp @@ -1188,7 +1188,7 @@ void ClockWork::loop(struct tm &tm) { case COMMAND_MODE_COLOR: { if (G.progInit) { - G.progInit = false; + clearClockByProgInit(); for (uint8_t row = 0; row < usedUhrType->rowsWordMatrix(); row++) { frontMatrix[row] = num32BitWithOnesAccordingToColumns(); } From 9fe3174a354d7fd7499149e896bf1f1c5135f7dd Mon Sep 17 00:00:00 2001 From: David Panusch Date: Sat, 15 Jul 2023 14:17:00 +0200 Subject: [PATCH 26/29] Fixed Bug, minutes not cleared in frame Uhrtype --- include/led.hpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/led.hpp b/include/led.hpp index 604a4a6c..cfb5ba85 100644 --- a/include/led.hpp +++ b/include/led.hpp @@ -410,8 +410,7 @@ inline void Led::clearRow(uint8_t row) { //------------------------------------------------------------------------------ inline void Led::clearMinArray() { - for (uint16_t i = minutePixelArray[0]; - i <= minutePixelArray[3] - usedUhrType->numPixelsFrameMatrix(); i++) { + for (uint16_t i = minutePixelArray[0]; i <= minutePixelArray[3]; i++) { clearPixel(i); } minuteArray = 0; From 17579dedf3d63b458371e305ceddc64555bda650 Mon Sep 17 00:00:00 2001 From: David Panusch Date: Sat, 15 Jul 2023 14:18:38 +0200 Subject: [PATCH 27/29] Fixed Bug, Digital-clk on non mirrored build --- include/led.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/include/led.hpp b/include/led.hpp index cfb5ba85..44d2722b 100644 --- a/include/led.hpp +++ b/include/led.hpp @@ -482,6 +482,7 @@ void Led::showNumbers(const char d1, const char d2) { void Led::showDigitalClock(const char min1, const char min0, const char h1, const char h0) { + resetFrontMatrixBuffer(); uint8_t letterSpacing = 1; if (usedUhrType->rowsWordMatrix() >= fontHeight[smallSizeNumbers] * 2) { From b230de260aaea07a9767a48bec9ac2308cd8ce1e Mon Sep 17 00:00:00 2001 From: David Panusch Date: Sat, 15 Jul 2023 14:19:02 +0200 Subject: [PATCH 28/29] Slower transferspeed for reliable upload --- platformio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platformio.ini b/platformio.ini index 8c031ef9..5c4227b9 100644 --- a/platformio.ini +++ b/platformio.ini @@ -16,7 +16,7 @@ platform = espressif8266 board = nodemcuv2 board_build.f_cpu = 160000000L framework = arduino -upload_speed = 230400 +upload_speed = 115200 monitor_speed = 460800 monitor_filters = esp8266_exception_decoder lib_deps = From e40448e7d0e05f84d3713a17b6064bada3f2a663 Mon Sep 17 00:00:00 2001 From: David Panusch Date: Sat, 15 Jul 2023 14:21:14 +0200 Subject: [PATCH 29/29] Clang formatted --- src/Wortuhr.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Wortuhr.cpp b/src/Wortuhr.cpp index ddfacf0a..122a0744 100644 --- a/src/Wortuhr.cpp +++ b/src/Wortuhr.cpp @@ -146,10 +146,10 @@ void setup() { G.progInit = true; G.conf = COMMAND_IDLE; for (uint8_t i = 0; i < 3; i++) { - G.color[i] = {0,0,0}; + G.color[i] = {0, 0, 0}; } G.color[Foreground] = HsbColor(120 / 360.f, 1.f, 0.5f); - G.color[Effect]= HsbColor(240 / 360.f, 1.f, 0.5f); + G.color[Effect] = HsbColor(240 / 360.f, 1.f, 0.5f); G.effectBri = 2; G.effectSpeed = 10; G.client_nr = 0;