From 5f38c46c69ca5fbb0f6fcb556500c02221f50b41 Mon Sep 17 00:00:00 2001 From: Frank Zimper Date: Tue, 12 Dec 2023 21:49:20 +0100 Subject: [PATCH 1/3] Bugfix: Flip all dots to blank once per hour to blank stale dots --- countdown/countdown.ino | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/countdown/countdown.ino b/countdown/countdown.ino index 32f954a..9ed43d2 100644 --- a/countdown/countdown.ino +++ b/countdown/countdown.ino @@ -138,8 +138,19 @@ void loop() { // char txtCurTimeOld[18]; // char txtTime2WaitOld[18]; - // Display löschen - flipDisplay(false, MODE_CURTAIN_OUT); + if (timeClient.getEpochTime() - lastUpdate > 3600) { + timeClient.update(); + lastUpdate = timeClient.getEpochTime(); + // Display löschen + for (int x = 0; x < DISPLAY_WIDTH; x++) { + for (int y = 0; y < MODULE_HEIGHT; y++) { + flipDotSimple(x, y, false, true); + } + } + } else { + flipDisplay(false, MODE_CURTAIN_OUT); + } + // section77 Schriftzug anzeigen showName(true); delay(2000); @@ -160,8 +171,6 @@ void loop() { showText6x8(0, 0, txtCurTime, true); showText6x8(0, 8, txtTime2Wait, true); } - // memcpy(txtCurTimeOld, txtCurTime, 18); - // memcpy(txtTime2WaitOld, txtTime2Wait, 18); // we don't want to miss THE EVENT int loops = timeToWait < 60 ? 80: 15; @@ -184,26 +193,10 @@ void loop() { showText6x8(0, 8, txtTime2Wait, true); } - // for (int pos=0; pos < sizeof(txtCurTime); pos++) { - // if (txtCurTime[pos] != txtCurTimeOld[pos]) { - // showText6x8(pos*6, 0, (String)txtCurTimeOld[pos], false); - // showText6x8(pos*6, 0, (String)txtCurTime[pos], true); - // } - // if (txtTime2Wait[pos] != txtTime2WaitOld[pos]) { - // showText6x8(pos*6, 8, (String)txtTime2WaitOld[pos], false); - // showText6x8(pos*6, 8, (String)txtTime2Wait[pos], true); - // } - // } - if (timeClient.getEpochTime() - lastUpdate > 3600) { - timeClient.update(); - } while (timeClient.getEpochTime() == curTime) {} - // memcpy(txtCurTimeOld, txtCurTime, sizeof(txtCurTime)); - // memcpy(txtTime2WaitOld, txtTime2Wait, sizeof(txtTime2Wait)); } - //delay(random(MAX_PAUSE_BETWEEN_ACTIONS)); } From bce542594e9a33e38f9a7f83c3b090f8f9146b9e Mon Sep 17 00:00:00 2001 From: Frank Zimper Date: Sat, 30 Nov 2024 11:36:23 +0100 Subject: [PATCH 2/3] more flexible event configuration --- countdown/config_default.h | 30 ++++++++++++++ countdown/countdown.ino | 84 ++++++++++++++++++-------------------- 2 files changed, 70 insertions(+), 44 deletions(-) diff --git a/countdown/config_default.h b/countdown/config_default.h index 03350b9..f18a815 100644 --- a/countdown/config_default.h +++ b/countdown/config_default.h @@ -2,3 +2,33 @@ const char* ssid = "YOUR SSID"; const char* password = "YOUR WIFI PASSWORD"; +struct Event { + long timeBegin; + long timeEnd; + String text1; + String text2; + String text3; +}; + +#define EVENTDATA { \ + { \ + 1703444400, 1703703600, \ + " bis Weihnachten ", \ + " Wir wuenschen ", \ + " Frohe Weihnachten "\ + }, \ + { \ + 1704063600, 1704322800, \ + " bis Neujahr ", \ + " Wir wuenschen ", \ + "ein gutes Neues Jahr!" \ + }, \ + { \ + 1800000000, 1800003600, \ + " bis Dings! ", \ + " Wir wuenschen ", \ + "ein gutes Neues Jahr!" \ + } \ +} + +Event events[3] = EVENTDATA; diff --git a/countdown/countdown.ino b/countdown/countdown.ino index 9ed43d2..2cb2a55 100644 --- a/countdown/countdown.ino +++ b/countdown/countdown.ino @@ -1,10 +1,12 @@ #include "font8x8_basic.h" #include "6x8_horizontal_LSB_1.h" #include "config.h" -#include +#include #include #include + + // pin assignments // // pin on lolin32 header // pin on column driver input header @@ -46,11 +48,6 @@ const byte MODE_CURTAIN_OUT = 3; const int PAUSE_BETWEEN_DOT_FLIPS_IN_MS = 2; // lowest value to reliably flip all dots with 5A power supply (lights off) const int MAX_PAUSE_BETWEEN_ACTIONS = 5000; -// Event time -long timeJubilee = 1700000000; -// Heilig Abend 20:00 CET -long timeJubilee2 = 1703444400; - // internal storage for the current state of the display boolean dotmatrix[DISPLAY_WIDTH][MODULE_HEIGHT]; @@ -60,7 +57,8 @@ long lastUpdate = 0; // Define NTP Client to get time WiFiUDP ntpUDP; NTPClient timeClient(ntpUDP); - + +int currentEvent; void setup() { @@ -128,15 +126,24 @@ void setup() { flipDotSimple(x, y, false, true); } } + + // section77 Schriftzug anzeigen + showName(true); + delay(45000); + + // section77 Schriftzug wieder löschen + showName(false); + + currentEvent = 0; + } void loop() { - char txtCurTime[19]; - char txtTime2Wait[19]; - // char txtCurTimeOld[18]; - // char txtTime2WaitOld[18]; + char txtCurTime[21]; + char txtTime2Wait[21]; + long curTime; if (timeClient.getEpochTime() - lastUpdate > 3600) { timeClient.update(); @@ -158,43 +165,32 @@ void loop() { // section77 Schriftzug wieder löschen showName(false); - // Countdown bis zu DEM EREIGNIS anzeigen - long curTime = timeClient.getEpochTime(); - long timeToWait = timeJubilee - curTime; - sprintf(txtTime2Wait, "Noch %12ss", printfcomma(timeToWait)); - if (timeJubilee == timeJubilee2) { - sprintf(txtCurTime, "%s", " bis Weihnachten "); - showText6x8(2, 0, txtTime2Wait, true); - showText6x8(2, 8, txtCurTime, true); - } else { - sprintf(txtCurTime, " %15ss", printfcomma(curTime)); - showText6x8(0, 0, txtCurTime, true); - showText6x8(0, 8, txtTime2Wait, true); + if (events[currentEvent].timeEnd < timeClient.getEpochTime()) { + currentEvent++; } - // we don't want to miss THE EVENT - int loops = timeToWait < 60 ? 80: 15; + // Countdown bis zum nächsten Event + if (events[currentEvent].timeBegin > timeClient.getEpochTime()) { + // we don't want to miss THE EVENT + int loops = events[currentEvent].timeBegin - curTime < 60 ? 80: 15; - for (int i=0; i Date: Sat, 30 Nov 2024 12:47:38 +0100 Subject: [PATCH 3/3] =?UTF-8?q?Anpassungen=20f=C3=BCr=20Weihnachten=202024?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- countdown/config_default.h | 4 ++++ countdown/countdown.ino | 3 ++- emulator/fdde.py | 20 ++++++++++++-------- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/countdown/config_default.h b/countdown/config_default.h index f18a815..36289ed 100644 --- a/countdown/config_default.h +++ b/countdown/config_default.h @@ -10,6 +10,10 @@ struct Event { String text3; }; +// Timestamps ermitteln bspw. mit Python: +// from datetime import datetime +// datetime(2024, 12, 24, 0, 0, 0, 0).timestamp() + #define EVENTDATA { \ { \ 1703444400, 1703703600, \ diff --git a/countdown/countdown.ino b/countdown/countdown.ino index 2cb2a55..cac96fb 100644 --- a/countdown/countdown.ino +++ b/countdown/countdown.ino @@ -1,7 +1,8 @@ #include "font8x8_basic.h" #include "6x8_horizontal_LSB_1.h" #include "config.h" -#include +//#include +#include #include #include diff --git a/emulator/fdde.py b/emulator/fdde.py index 7eecc41..8d76dca 100755 --- a/emulator/fdde.py +++ b/emulator/fdde.py @@ -66,17 +66,21 @@ def readSerial(): try: data = json.loads(data_raw) except json.JSONDecodeError: - print (data_raw) + print(data_raw) continue if (not isinstance(data, dict)): - print (data_raw) + print(data_raw) + continue + + try: + x = data['column'] + y = data['row'] + if data['status'] == 1: + color = 'yellow' + else: + color = 'black' + except KeyError: continue - x = data['column'] - y = data['row'] - if data['status'] == 1: - color = 'yellow' - else: - color = 'black' display.create_rectangle( (x * 10 + 1, y * 10 + 1),