Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 434cc44607 | |||
| 2366dc790e | |||
| f21094a404 | |||
| 2b6977a97e | |||
| d7bdae65df | |||
| bb8da924df | |||
| cadd97909d | |||
| 5162083180 | |||
| 396138383e | |||
| 26ace4849c | |||
| 106a8be897 | |||
| bebbc539cc | |||
| 50272d6ed5 | |||
| 3e770bdcac | |||
| 472ae25cb9 | |||
| 64e3a5eb05 | |||
| 043742dccf |
File diff suppressed because it is too large
Load Diff
+94096
File diff suppressed because it is too large
Load Diff
Binary file not shown.
+94096
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
+1784230
File diff suppressed because it is too large
Load Diff
Binary file not shown.
+1784356
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+1793844
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
+100170
File diff suppressed because it is too large
Load Diff
+1704660
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 1.1 MiB |
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 1.1 MiB |
@@ -1,16 +1,68 @@
|
|||||||
# Wordclock
|
# Wordclock
|
||||||
|
|
||||||
Firmware für die WordClock vom c3e.
|
Firmware für die WordClock (in der Art von https://www.amazon.de/dp/B01N5TKXP3/) vom c3e. Als Rahmen bietet sich ["RIBBA" von IKEA](https://www.ikea.com/de/de/catalog/products/40378401/) an.
|
||||||
|
Außerdem wird benötigt:
|
||||||
|
* Ein ESP8266 (z.B. [WeMos D1 Mini](https://www.amazon.de/dp/B076F53B6S/))
|
||||||
|
* Ein LED-Strip WS8212 mit 60 LED/m, 1m reicht (also 60 LED) z.B. von eBay
|
||||||
|
* Kabel in 3 Farben, am besten Draht, Litze 3-adrig flach geht notfalls auch
|
||||||
|
* Ein USB-Netzteil mit genügend Leistung z.B. https://www.amazon.de/dp/B00WLI5E3M
|
||||||
|
* Ein USB-Kabel
|
||||||
|
* Etwa 2.5 m² MDF (Mitteldichte Faserplatte) 2,5mm die gelasert wird
|
||||||
|
* Karton zum Lasern der Worte
|
||||||
|
* Viel Geduld beim Löten
|
||||||
|
|
||||||
## Anleitung
|
## Hardware
|
||||||
|
|
||||||
|
Die MDF-Platte zuschneiden und mit den CAD-Dateien lasern (Makerspace in der Umgebung ansteuern, z.B. [Chaosdorf Düsseldorf](https://wiki.chaosdorf.de/Lasercutter), [Das Labor in Bochum](https://wiki.das-labor.org/w/LABOR_Wiki)). Die einzelnen LEDs vom Strip schneiden und auf die Trägerplatte an den vorgezeichneten Stellen aufkleben (z.B. mit UHU Flüssigkleber). Dabei darauf achten, dass die LEDs innerhalb einer Zeile immer die gleiche Ausrichtung (+5V, Din/DO, GND) haben und die Ausrichtungen von Zeile zu Zeile entgegengesetzt sind.
|
||||||
|
Die LEDs mit Drahtstücken verlöten, dabei darauf achten, dass alle Leitungen jeweils durchgängig verbunden sind (also alle +5V miteinander, alle GND, alle D) und nicht untereinander.
|
||||||
|
Am Anfang den ESP anlöten:
|
||||||
|
* 5V->+5V
|
||||||
|
* G->GND
|
||||||
|
* D1->Din (Pin-Benennung im Quelltext ist etwas anders)
|
||||||
|
|
||||||
|
### Material
|
||||||
|
* 230 mm x 230 mm Pappe (schwarz) für Wortfolie
|
||||||
|
- -> [Wortfolie.dxf](cad-files/Wortfolie.dxf) verwenden
|
||||||
|
* 230 mm x 230 mm Transparentpapier (z.B. für technisches Zeichnen) als Diffusor, alternativ weißes Backpapier
|
||||||
|
* min 280 mm x 280 mm MDF für Trennwände
|
||||||
|
- -> [Trennwaende_fuer_Laser.dxf](cad-files/Trennwaende_fuer_Laser.dxf) verwenden
|
||||||
|
- Zahlen auf der linken Seite nach Möglichkeit nur gravieren oder weglassen
|
||||||
|
* Rückwand der Rahmens (CAD-Datei ist passend für "RIBBA" von IKEA)
|
||||||
|
- -> [Rueckwand-ohne-Gravuren.dxf](cad-files/Rueckwand-ohne-Gravuren.dxf) (alle Konturen außer der Umrandung ganz ausschneiden) **oder**
|
||||||
|
- -> [Rueckwand-mit-Gravuren.dxf](cad-files/Rueckwand-mit-Gravuren.dxf) (LED-Markierungen und Pfeile nur mit einer Tiefe von ca. 0.2-0.5 mm gravieren) verwenden
|
||||||
|
|
||||||
|
|
||||||
|
## Flashen
|
||||||
|
1. Dieses Repo clonen (`git clone https://github.com/c3e/wordclock.git`)
|
||||||
|
2. Die Arduino IDE installieren (https://www.arduino.cc/en/Main/Software)
|
||||||
|
3. Die Datei `wordclock/wordclock.ino` in der Arduino IDE öffnen
|
||||||
|
4. In der IDE unter Datei->Voreinstellungen->Zusätzliche Boardverwalter-URLs http://arduino.esp8266.com/stable/package_esp8266com_index.json hinzufügen
|
||||||
|
5. Unter Werkzeuge->Boards->Boardverwalter nach "esp" suchen, esp8266 installieren
|
||||||
|
6. Das richtige Board unter Werkzeuge->Boards aus wählen (z.B. WeMos D1 R1)
|
||||||
|
7. Sketcch->Bibliothek einbinden->Bibliotheken verwalten
|
||||||
|
8. Folgende installieren:
|
||||||
|
* FastLED
|
||||||
|
* WiFiManager
|
||||||
|
9. Folgende Zip-Dateien herunterladen:
|
||||||
|
* https://github.com/PaulStoffregen/Time/archive/master.zip
|
||||||
|
* https://github.com/JChristensen/Timezone/archive/master.zip
|
||||||
|
10. In der Arduino IDE unter Sketch->Bibliothek einbinden->.ZIP-Bibliothek hinzufügen die beiden heruntergeladenen .zip-Dateien auswählen
|
||||||
|
11. Den "Kompilieren"-Haken oben links anklicken (die Warnungen bzgl. Architektur und bitbanging können ignoriert werden)
|
||||||
|
12. Den ESP per USB anschließen
|
||||||
|
13. Den "Hochladen"-Pfeil klicken, darauf warten, dass der Upload vollständig ist (wird in Konsole und Statuszeile ausgegeben)
|
||||||
|
|
||||||
|
## Inbetriebnahme
|
||||||
|
|
||||||
1. Strom anschließen, 5V, USB-Netzeil
|
1. Strom anschließen, 5V, USB-Netzeil
|
||||||
2. Ins WLAN `WordClock` verbinden
|
2. Ins WLAN `WordClock` verbinden (Der Name kann im Quelltext verändert werden)
|
||||||
3. Im Browser die IP `192.168.4.1` aufrufen
|
3. Im Browser die IP `192.168.4.1` aufrufen
|
||||||
4. WLAN auswählen und ggf. Passwort eingeben
|
4. WLAN auswählen und ggf. Passwort eingeben
|
||||||
5. Nach dem Speichern der Einstellungen verschwindet das WLAN
|
5. Nach dem Speichern der Einstellungen verschwindet das WLAN
|
||||||
6. Uhr zeigt die Uhrzeit an
|
6. Uhr zeigt die Uhrzeit an
|
||||||
|
|
||||||
|
Wenn das WLAN (wird für den Empfang der Uhrzeit benötigt) nicht mehr auffindbar ist, wird das Konfigurations-WLAN unter `192.168.4.1` automatisch wieder aufgebaut. Um die Einstellungen von Hand zurückzusetzen:
|
||||||
|
In der Arduino-IDE: Werkzeuge->Erase Flash->All Flash contents auswählen, dann den Programmcode erneut hochladen
|
||||||
|
|
||||||
## Design
|
## Design
|
||||||
|
|
||||||
Die Idee für das Design wurden vom FabLab Nürnberg übernommen. Die Firmware ist eine Eigenentwicklung.
|
Die Idee für das Design wurden vom FabLab Nürnberg übernommen. Die Firmware ist eine Eigenentwicklung.
|
||||||
|
|||||||
@@ -0,0 +1,686 @@
|
|||||||
|
#include <ESP8266WiFi.h>
|
||||||
|
#include <ESP8266WebServer.h>
|
||||||
|
#include <Adafruit_NeoPixel.h>
|
||||||
|
#include <EEPROM.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <WiFiManager.h>
|
||||||
|
|
||||||
|
|
||||||
|
// ================= LED =================
|
||||||
|
#define PIN D4
|
||||||
|
#define NUMPIXELS 110
|
||||||
|
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
|
||||||
|
|
||||||
|
// ================= SERVER =================
|
||||||
|
ESP8266WebServer server(80);
|
||||||
|
|
||||||
|
// ================= NTP =================
|
||||||
|
String ntpServer = "de.pool.ntp.org";
|
||||||
|
String tzString = "CET-1CEST,M3.5.0/02,M10.5.0/03";
|
||||||
|
|
||||||
|
// ================= SETTINGS =================
|
||||||
|
struct Settings {
|
||||||
|
int brightness;
|
||||||
|
int nightBrightness;
|
||||||
|
bool autoNight;
|
||||||
|
int nightStart;
|
||||||
|
int nightEnd;
|
||||||
|
uint32_t color;
|
||||||
|
uint32_t bgColor;
|
||||||
|
bool backgroundMode;
|
||||||
|
char ntpServer[64];
|
||||||
|
char tzString[64];
|
||||||
|
} settings;
|
||||||
|
|
||||||
|
// ================= VAR =================
|
||||||
|
uint32_t currentColor = 0x00FFFF;
|
||||||
|
uint32_t lastColor = 0x00FFFF;
|
||||||
|
uint32_t bgColor = 0x000000;
|
||||||
|
bool backgroundMode = false;
|
||||||
|
bool forceInstant = false;
|
||||||
|
bool updateNeeded = true;
|
||||||
|
|
||||||
|
int brightness = 120;
|
||||||
|
int nightBrightness = 10;
|
||||||
|
bool autoNight = true;
|
||||||
|
int nightStart = 22;
|
||||||
|
int nightEnd = 6;
|
||||||
|
|
||||||
|
uint32_t targetBuffer[NUMPIXELS];
|
||||||
|
uint32_t currentBuffer[NUMPIXELS];
|
||||||
|
|
||||||
|
int lastMinute = -1;
|
||||||
|
|
||||||
|
// ================= EEPROM =================
|
||||||
|
void saveSettings(){
|
||||||
|
settings.brightness = brightness;
|
||||||
|
settings.nightBrightness = nightBrightness;
|
||||||
|
settings.autoNight = autoNight;
|
||||||
|
settings.nightStart = nightStart;
|
||||||
|
settings.nightEnd = nightEnd;
|
||||||
|
settings.color = currentColor;
|
||||||
|
settings.bgColor = bgColor;
|
||||||
|
settings.backgroundMode = backgroundMode;
|
||||||
|
strncpy(settings.ntpServer, ntpServer.c_str(), sizeof(settings.ntpServer));
|
||||||
|
strncpy(settings.tzString, tzString.c_str(), sizeof(settings.tzString));
|
||||||
|
|
||||||
|
EEPROM.put(0, settings);
|
||||||
|
EEPROM.commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void loadSettings(){
|
||||||
|
EEPROM.begin(512);
|
||||||
|
EEPROM.get(0, settings);
|
||||||
|
|
||||||
|
// Prüfen, ob EEPROM leer ist (über Helligkeit)
|
||||||
|
if(settings.brightness == 0 || settings.brightness == 255){
|
||||||
|
// Standardwerte setzen
|
||||||
|
brightness = 120;
|
||||||
|
nightBrightness = 10;
|
||||||
|
autoNight = true;
|
||||||
|
nightStart = 22;
|
||||||
|
nightEnd = 6;
|
||||||
|
currentColor = 0x00FFFF;
|
||||||
|
bgColor = 0x000000;
|
||||||
|
backgroundMode = false;
|
||||||
|
ntpServer = "de.pool.ntp.org";
|
||||||
|
tzString = "CET-1CEST,M3.5.0/02,M10.5.0/03";
|
||||||
|
} else {
|
||||||
|
brightness = settings.brightness;
|
||||||
|
nightBrightness = settings.nightBrightness;
|
||||||
|
autoNight = settings.autoNight;
|
||||||
|
nightStart = settings.nightStart;
|
||||||
|
nightEnd = settings.nightEnd;
|
||||||
|
currentColor = settings.color;
|
||||||
|
bgColor = settings.bgColor;
|
||||||
|
backgroundMode = settings.backgroundMode;
|
||||||
|
ntpServer = String(settings.ntpServer);
|
||||||
|
tzString = String(settings.tzString);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Zeitkonfiguration sofort anwenden
|
||||||
|
configTime(tzString.c_str(), ntpServer.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// ================= HELFER =================
|
||||||
|
void clearTarget(){
|
||||||
|
for(int i=0;i<NUMPIXELS;i++) targetBuffer[i]=0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setRange(int a,int b){
|
||||||
|
for(int i=a;i<=b;i++) targetBuffer[i]=currentColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
void setRangeColor(int a,int b, uint32_t col){
|
||||||
|
for(int i=a;i<=b;i++) targetBuffer[i] = col;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint32_t blend(uint32_t c1, uint32_t c2, float t){
|
||||||
|
uint8_t r1=(c1>>16)&255, g1=(c1>>8)&255, b1=c1&255;
|
||||||
|
uint8_t r2=(c2>>16)&255, g2=(c2>>8)&255, b2=c2&255;
|
||||||
|
|
||||||
|
return pixels.Color(
|
||||||
|
r1 + (r2 - r1) * t,
|
||||||
|
g1 + (g2 - g1) * t,
|
||||||
|
b1 + (b2 - b1) * t
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t applyBrightness(uint32_t c, float brightnessFactor){
|
||||||
|
uint8_t r = ((c >> 16) & 255) * brightnessFactor;
|
||||||
|
uint8_t g = ((c >> 8) & 255) * brightnessFactor;
|
||||||
|
uint8_t b = (c & 255) * brightnessFactor;
|
||||||
|
|
||||||
|
return pixels.Color(r,g,b);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t gamma8(uint8_t x){
|
||||||
|
if(x<5) return 0;
|
||||||
|
float f = x / 255.0;
|
||||||
|
f = pow(f, 2.2); // Gamma 2.2
|
||||||
|
return (uint8_t)(f * 255);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t applyGammaBrightness(uint32_t c, float brightnessFactor){
|
||||||
|
|
||||||
|
uint8_t r = ((c >> 16) & 255) * brightnessFactor;
|
||||||
|
uint8_t g = ((c >> 8) & 255) * brightnessFactor;
|
||||||
|
uint8_t b = (c & 255) * brightnessFactor;
|
||||||
|
|
||||||
|
// 🔥 Gamma Korrektur
|
||||||
|
r = gamma8(r);
|
||||||
|
g = gamma8(g);
|
||||||
|
b = gamma8(b);
|
||||||
|
|
||||||
|
return pixels.Color(r,g,b);
|
||||||
|
}
|
||||||
|
|
||||||
|
void updateDisplayNow(){
|
||||||
|
time_t now = time(nullptr);
|
||||||
|
struct tm *t = localtime(&now);
|
||||||
|
if(t){
|
||||||
|
showTimeWords(t->tm_hour, t->tm_min);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void showInstant(){
|
||||||
|
|
||||||
|
time_t now = time(nullptr);
|
||||||
|
struct tm *t = localtime(&now);
|
||||||
|
|
||||||
|
float b = getBrightness(t) / 255.0;
|
||||||
|
|
||||||
|
for(int i=0;i<NUMPIXELS;i++){
|
||||||
|
uint32_t c = applyGammaBrightness(targetBuffer[i], b);
|
||||||
|
pixels.setPixelColor(i, c);
|
||||||
|
}
|
||||||
|
|
||||||
|
pixels.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ================= WORTUHR =================
|
||||||
|
|
||||||
|
// ES IST
|
||||||
|
void word_ES(){ setRange(0,1); }
|
||||||
|
void word_IST(){ setRange(3,5); }
|
||||||
|
|
||||||
|
// Minuten
|
||||||
|
void word_FUENF_M(){ setRange(7,10); }
|
||||||
|
void word_ZEHN_M(){ setRange(18,20); }
|
||||||
|
void word_ZWANZIG(){ setRange(11,17); }
|
||||||
|
void word_VIERTEL(){ setRange(22,28); }
|
||||||
|
void word_VOR(){ setRange(30,32); }
|
||||||
|
void word_NACH(){ setRange(40,43); }
|
||||||
|
void word_HALB(){ setRange(33,36); }
|
||||||
|
|
||||||
|
// Stunden
|
||||||
|
void word_EINS(){ setRange(62,65); }
|
||||||
|
void word_EIN(){ setRange(62,64); }
|
||||||
|
void word_ZWEI(){ setRange(55,58); }
|
||||||
|
void word_DREI(){ setRange(66,69); }
|
||||||
|
void word_VIER(){ setRange(73,76); }
|
||||||
|
void word_FUENF_H(){ setRange(51,54); }
|
||||||
|
void word_SECHS(){ setRange(83,87); }
|
||||||
|
void word_SIEBEN(){ setRange(88,93); }
|
||||||
|
void word_ACHT(){ setRange(77,80); }
|
||||||
|
void word_NEUN(){ setRange(44,47); }
|
||||||
|
void word_ZEHN_H(){ setRange(106,109); }
|
||||||
|
void word_ELF(){ setRange(103,105); }
|
||||||
|
void word_ZWOELF(){ setRange(94,98); }
|
||||||
|
|
||||||
|
// UHR
|
||||||
|
void word_UHR(){ setRange(99,101); }
|
||||||
|
|
||||||
|
// ================= TEXT =================
|
||||||
|
String hourToText(int h){
|
||||||
|
String arr[]={"Zwölf","Eins","Zwei","Drei","Vier","Fünf","Sechs","Sieben","Acht","Neun","Zehn","Elf"};
|
||||||
|
return arr[h%12];
|
||||||
|
}
|
||||||
|
|
||||||
|
String hourText(int h,bool full){
|
||||||
|
int hh = h % 12;
|
||||||
|
|
||||||
|
if(hh == 1){
|
||||||
|
return full ? "ein" : "eins";
|
||||||
|
}
|
||||||
|
return hourToText(h);
|
||||||
|
}
|
||||||
|
|
||||||
|
String getTimeText(int h,int m){
|
||||||
|
int m5=(m/5)*5;
|
||||||
|
if(m5>=25) h++;
|
||||||
|
|
||||||
|
String t="Es ist ";
|
||||||
|
|
||||||
|
switch(m5){
|
||||||
|
case 0: t+= hourText(h, true)+" Uhr"; break;
|
||||||
|
case 5: t+="fünf nach "+hourToText(h); break;
|
||||||
|
case 10: t+="zehn nach "+hourToText(h); break;
|
||||||
|
case 15: t+="viertel nach "+hourToText(h); break;
|
||||||
|
case 20: t+="zwanzig nach "+hourToText(h); break;
|
||||||
|
case 25: t+="fünf vor halb "+hourToText(h); break;
|
||||||
|
case 30: t+="halb "+hourToText(h); break;
|
||||||
|
case 35: t+="fünf nach halb "+hourToText(h); break;
|
||||||
|
case 40: t+="zwanzig vor "+hourToText(h); break;
|
||||||
|
case 45: t+="viertel vor "+hourToText(h); break;
|
||||||
|
case 50: t+="zehn vor "+hourToText(h); break;
|
||||||
|
case 55: t+="fünf vor "+hourToText(h); break;
|
||||||
|
}
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ================= NACHTMODUS =================
|
||||||
|
int getBrightness(struct tm *t){
|
||||||
|
if(!autoNight) return brightness;
|
||||||
|
|
||||||
|
int h=t->tm_hour;
|
||||||
|
if(nightStart > nightEnd){
|
||||||
|
if(h >= nightStart || h < nightEnd) return nightBrightness;
|
||||||
|
} else {
|
||||||
|
if(h >= nightStart && h < nightEnd) return nightBrightness;
|
||||||
|
}
|
||||||
|
return brightness;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void fadeToTargetSmooth(int steps = 10, int delayMs = 5){
|
||||||
|
|
||||||
|
time_t now = time(nullptr);
|
||||||
|
struct tm *t = localtime(&now);
|
||||||
|
|
||||||
|
float bTarget = getBrightness(t) / 255.0;
|
||||||
|
|
||||||
|
for(int s = 0; s <= steps; s++){
|
||||||
|
float tBlend = (float)s / steps;
|
||||||
|
|
||||||
|
for(int i=0;i<NUMPIXELS;i++){
|
||||||
|
|
||||||
|
uint32_t c = blend(currentBuffer[i], targetBuffer[i], tBlend);
|
||||||
|
|
||||||
|
uint32_t finalColor = applyGammaBrightness(c, bTarget);
|
||||||
|
|
||||||
|
pixels.setPixelColor(i, finalColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
pixels.show();
|
||||||
|
delay(delayMs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ================= ANZEIGE =================
|
||||||
|
void showTimeWords(int h, int m){
|
||||||
|
|
||||||
|
// 🔥 aktuellen Zustand als Start für Fade holen
|
||||||
|
for(int i=0;i<NUMPIXELS;i++){
|
||||||
|
currentBuffer[i] = pixels.getPixelColor(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 🔥 Zielbuffer komplett neu aufbauen
|
||||||
|
for(int i=0;i<NUMPIXELS;i++){
|
||||||
|
if(backgroundMode){
|
||||||
|
targetBuffer[i] = bgColor; // frei wählbarer Hintergrund
|
||||||
|
} else {
|
||||||
|
targetBuffer[i] = 0; // aus
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Grundtext
|
||||||
|
word_ES();
|
||||||
|
word_IST();
|
||||||
|
|
||||||
|
int m5 = (m/5)*5;
|
||||||
|
bool full = (m5 == 0);
|
||||||
|
|
||||||
|
if(m5 >= 25) h++;
|
||||||
|
|
||||||
|
// Minuten
|
||||||
|
switch(m5){
|
||||||
|
case 0: word_UHR(); break;
|
||||||
|
case 5: word_FUENF_M(); word_NACH(); break;
|
||||||
|
case 10: word_ZEHN_M(); word_NACH(); break;
|
||||||
|
case 15: word_VIERTEL(); word_NACH(); break;
|
||||||
|
case 20: word_ZWANZIG(); word_NACH(); break;
|
||||||
|
case 25: word_FUENF_M(); word_VOR(); word_HALB(); break;
|
||||||
|
case 30: word_HALB(); break;
|
||||||
|
case 35: word_FUENF_M(); word_NACH(); word_HALB(); break;
|
||||||
|
case 40: word_ZWANZIG(); word_VOR(); break;
|
||||||
|
case 45: word_VIERTEL(); word_VOR(); break;
|
||||||
|
case 50: word_ZEHN_M(); word_VOR(); break;
|
||||||
|
case 55: word_FUENF_M(); word_VOR(); break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stunden
|
||||||
|
int hh = h % 12;
|
||||||
|
|
||||||
|
if(hh == 1 && full) word_EIN();
|
||||||
|
else if(hh == 1) word_EINS();
|
||||||
|
else if(hh == 2) word_ZWEI();
|
||||||
|
else if(hh == 3) word_DREI();
|
||||||
|
else if(hh == 4) word_VIER();
|
||||||
|
else if(hh == 5) word_FUENF_H();
|
||||||
|
else if(hh == 6) word_SECHS();
|
||||||
|
else if(hh == 7) word_SIEBEN();
|
||||||
|
else if(hh == 8) word_ACHT();
|
||||||
|
else if(hh == 9) word_NEUN();
|
||||||
|
else if(hh == 10) word_ZEHN_H();
|
||||||
|
else if(hh == 11) word_ELF();
|
||||||
|
else word_ZWOELF();
|
||||||
|
|
||||||
|
// 🔥 jetzt alles weich darstellen (inkl. Gamma & Brightness)
|
||||||
|
if(forceInstant){
|
||||||
|
showInstant();
|
||||||
|
forceInstant = false;
|
||||||
|
}else{
|
||||||
|
fadeToTargetSmooth(10,5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ================= WEB =================
|
||||||
|
void handleNTP() {
|
||||||
|
if (server.hasArg("val")) {
|
||||||
|
ntpServer = server.arg("val");
|
||||||
|
// Konfiguration sofort mit neuem Server aktualisieren
|
||||||
|
configTime(tzString.c_str(), ntpServer.c_str());
|
||||||
|
Serial.println("NTP Server geändert: " + ntpServer);
|
||||||
|
}
|
||||||
|
server.send(200, "text/plain", "OK");
|
||||||
|
}
|
||||||
|
|
||||||
|
void handleTZ() {
|
||||||
|
if (server.hasArg("val")) {
|
||||||
|
tzString = server.arg("val");
|
||||||
|
// Konfiguration sofort mit neuer Zeitzone aktualisieren
|
||||||
|
configTime(tzString.c_str(), ntpServer.c_str());
|
||||||
|
Serial.println("Zeitzone geändert: " + tzString);
|
||||||
|
}
|
||||||
|
server.send(200, "text/plain", "OK");
|
||||||
|
}
|
||||||
|
|
||||||
|
void handleColor(){
|
||||||
|
if(server.hasArg("c")){
|
||||||
|
lastColor=currentColor;
|
||||||
|
currentColor=strtoul(server.arg("c").c_str(),NULL,16);
|
||||||
|
forceInstant = true;
|
||||||
|
updateDisplayNow();
|
||||||
|
|
||||||
|
}
|
||||||
|
server.send(200,"text/plain","OK");
|
||||||
|
}
|
||||||
|
|
||||||
|
void handleBGColor(){
|
||||||
|
if(server.hasArg("c")){
|
||||||
|
bgColor=strtoul(server.arg("c").c_str(),NULL,16);
|
||||||
|
forceInstant = true;
|
||||||
|
updateNeeded = true;
|
||||||
|
}
|
||||||
|
server.send(200,"text/plain","OK");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void handleBrightness(){
|
||||||
|
brightness=server.arg("val").toInt();
|
||||||
|
forceInstant = true;
|
||||||
|
updateNeeded = true;
|
||||||
|
server.send(200,"text/plain","OK");
|
||||||
|
}
|
||||||
|
|
||||||
|
void handleNight(){
|
||||||
|
autoNight=server.arg("val").toInt();
|
||||||
|
forceInstant = true;
|
||||||
|
updateNeeded = true;
|
||||||
|
server.send(200,"text/plain","OK");
|
||||||
|
}
|
||||||
|
|
||||||
|
void handleBG(){
|
||||||
|
backgroundMode=server.arg("val").toInt();
|
||||||
|
forceInstant = true;
|
||||||
|
updateNeeded = true;
|
||||||
|
server.send(200,"text/plain","OK");
|
||||||
|
}
|
||||||
|
|
||||||
|
void handleSave(){
|
||||||
|
saveSettings();
|
||||||
|
server.send(200,"text/plain","saved");
|
||||||
|
}
|
||||||
|
|
||||||
|
void handleNightStart(){
|
||||||
|
int val = server.arg("val").toInt();
|
||||||
|
if(val >= 0 && val <= 23) {
|
||||||
|
nightStart = val;
|
||||||
|
forceInstant = true;
|
||||||
|
updateNeeded = true;
|
||||||
|
server.send(200, "text/plain", "OK");
|
||||||
|
} else {
|
||||||
|
server.send(400, "text/plain", "Ungueltiger Wert");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void handleNightEnd(){
|
||||||
|
int val = server.arg("val").toInt();
|
||||||
|
|
||||||
|
if(val >= 0 && val <= 23) {
|
||||||
|
nightEnd = val;
|
||||||
|
forceInstant = true;
|
||||||
|
updateNeeded = true;
|
||||||
|
server.send(200, "text/plain", "OK");
|
||||||
|
} else {
|
||||||
|
server.send(400, "text/plain", "Ungueltiger Wert");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void handleNightBrightness(){
|
||||||
|
nightBrightness = server.arg("val").toInt();
|
||||||
|
forceInstant = true;
|
||||||
|
updateNeeded = true;
|
||||||
|
server.send(200, "text/plain", "OK");
|
||||||
|
}
|
||||||
|
|
||||||
|
void handleStatus() {
|
||||||
|
time_t now = time(nullptr);
|
||||||
|
struct tm *t = localtime(&now);
|
||||||
|
char hexCol[10];
|
||||||
|
snprintf(hexCol, sizeof(hexCol), "#%06X", currentColor);
|
||||||
|
char hexBg[10];
|
||||||
|
snprintf(hexBg, sizeof(hexBg), "#%06X",bgColor);
|
||||||
|
|
||||||
|
String ntpStat = (now > 100000) ? "OK" : "SYNC...";
|
||||||
|
Serial.println(ntpStat);
|
||||||
|
String json = "{";
|
||||||
|
json += "\"txt\":\"" + getTimeText(t->tm_hour, t->tm_min) + "\",";
|
||||||
|
json += "\"ip\":\"" + WiFi.localIP().toString() + "\",";
|
||||||
|
json += "\"ntp\":\"" + ntpStat + "\",";
|
||||||
|
json += "\"ntpServer\":\"" + ntpServer + "\",";
|
||||||
|
json += "\"tzString\":\"" + tzString + "\",";
|
||||||
|
json += "\"brightness\":" + String(brightness) + ",";
|
||||||
|
json += "\"nightBrightness\":" + String(nightBrightness) + ",";
|
||||||
|
json += "\"color\":\"" + String(hexCol) + "\",";
|
||||||
|
json += "\"bgColor\":\"" + String(hexBg) + "\",";
|
||||||
|
json += "\"night\":" + String(autoNight ? 1 : 0) + ",";
|
||||||
|
json += "\"nightStart\":" + String(nightStart) + ",";
|
||||||
|
json += "\"nightEnd\":" + String(nightEnd) + ",";
|
||||||
|
json += "\"bg\":" + String(backgroundMode ? 1 : 0); // Hier KEIN Komma am Ende
|
||||||
|
json += "}";
|
||||||
|
|
||||||
|
server.send(200, "application/json", json);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ================= HTML =================
|
||||||
|
void handleRoot(){
|
||||||
|
String html = R"rawliteral(
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset='UTF-8'>
|
||||||
|
<meta name='viewport' content='width=device-width, initial-scale=1'>
|
||||||
|
<style>
|
||||||
|
body{font-family:Arial,sans-serif; background:#fff; margin:0; color:#333; display:flex; flex-direction:column; align-items:center}
|
||||||
|
.card{width:90%; max-width:400px; margin:10px; padding:15px; border-radius:12px; background:#f2f2f2; box-shadow: 0 2px 5px rgba(0,0,0,0.1)}
|
||||||
|
.big{font-size:26px; text-align:center; font-weight:bold; color:#0055ff}
|
||||||
|
#status{font-size:0.85em; color:#666; text-align:center}
|
||||||
|
.grid{display:flex; gap:10px; align-items:center; margin-top:10px}
|
||||||
|
.sub-label{font-size:0.85em; margin-top:10px; display:block; color:#555}
|
||||||
|
input[type='number']{width:55px; padding:8px; border-radius:6px; border:1px solid #ccc; text-align:center}
|
||||||
|
input[type='range'], input[type='color']{width:100%; cursor:pointer}
|
||||||
|
button{width:100%; padding:12px; border-radius:8px; border:none; background:#0055ff; color:#fff; font-weight:bold; cursor:pointer}
|
||||||
|
label{font-weight:bold; display:block; margin-bottom:5px}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div class='card big' id='txt'>--:--</div>
|
||||||
|
<div class='card' id='status'>Verbinde...</div>
|
||||||
|
|
||||||
|
<div class='card'>
|
||||||
|
<label>Wort-LED Farbe</label>
|
||||||
|
<input type='color' id='col' onchange='c(this.value)'>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class='card'>
|
||||||
|
<label>Standard Helligkeit</label>
|
||||||
|
<input type='range' id='br' min='0' max='255' oninput='b(this.value)'>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class='card'>
|
||||||
|
<input type='checkbox' id='night' onchange='n(this.checked)'> <b>Nachtmodus (Auto)</b>
|
||||||
|
|
||||||
|
<span class='sub-label'>Zeitraum:</span>
|
||||||
|
<div class='grid'>
|
||||||
|
Von: <input type='number' id='nS' min='0' max='23' oninput='ns(this.value)' autocomplete='off'> Uhr
|
||||||
|
Bis: <input type='number' id='nE' min='0' max='23' oninput='ne(this.value)' autocomplete='off'> Uhr
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<span class='sub-label'>Nacht-Helligkeit:</span>
|
||||||
|
<input type='range' id='nbr' min='0' max='255' oninput='nb(this.value)'>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class='card'>
|
||||||
|
<input type='checkbox' id='bg' onchange='bgf(this.checked)'> <b>Hintergrund</b>
|
||||||
|
<span class='sub-label'>Farbe</span>
|
||||||
|
<input type='color' id='bgcol' onchange='bgc(this.value)'>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class='card'>
|
||||||
|
<label>Zeit-Quellen</label>
|
||||||
|
<span class='sub-label'>NTP Server:</span>
|
||||||
|
<input type='text' id='ntpS' onchange='setNTP(this.value)' style='width:100%'>
|
||||||
|
|
||||||
|
<span class='sub-label'>Zeitzone (POSIX TZ):</span>
|
||||||
|
<input type='text' id='tzS' onchange='setTZ(this.value)' style='width:100%'>
|
||||||
|
<a href='https://github.com/nayarsystems/posix_tz_db/blob/master/zones.csv' target='_blank' style='font-size:0.7em'>TZ-Datenbank Hilfe</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class='card'>
|
||||||
|
<button onclick='save()'>Einstellungen im EEPROM speichern</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function c(v){fetch('/color?c='+v.substring(1))}
|
||||||
|
function bgc(v){fetch('/bgcolor?c='+v.substring(1))}
|
||||||
|
function b(v){fetch('/brightness?val='+v)}
|
||||||
|
function n(v){fetch('/night?val='+(v?1:0))}
|
||||||
|
function nb(v){fetch('/nightBrightness?val='+v)} // NEU: Nacht-Helligkeit
|
||||||
|
function bgf(v){fetch('/bg?val='+(v?1:0))}
|
||||||
|
function save(){fetch('/save').then(()=>alert('Gespeichert!'))}
|
||||||
|
function setNTP(v){ fetch('/setNTP?val=' + encodeURIComponent(v)); }
|
||||||
|
function setTZ(v){ fetch('/setTZ?val=' + encodeURIComponent(v)); }
|
||||||
|
function setNTP(v){ fetch('/setNTP?val=' + encodeURIComponent(v)); }
|
||||||
|
function setTZ(v){ fetch('/setTZ?val=' + encodeURIComponent(v)); }
|
||||||
|
|
||||||
|
function ns(v){
|
||||||
|
if(v === "") return; // Warten, bis eine Zahl drin steht
|
||||||
|
let val = parseInt(v);
|
||||||
|
if(val < 0) val = 0; if(val > 23) val = 23;
|
||||||
|
fetch('/nightStart?val=' + val);
|
||||||
|
}
|
||||||
|
|
||||||
|
function ne(v){
|
||||||
|
if(v === "") return;
|
||||||
|
let val = parseInt(v);
|
||||||
|
if(val < 0) val = 0; if(val > 23) val = 23;
|
||||||
|
fetch('/nightEnd?val=' + val);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function update(){
|
||||||
|
fetch('/status').then(r=>r.json()).then(d=>{
|
||||||
|
// Hilfsfunktion zum sicheren Setzen von Werten
|
||||||
|
const setVal = (id, val, isCheck = false) => {
|
||||||
|
const el = document.getElementById(id);
|
||||||
|
if(!el) return; // Falls Element nicht existiert, überspringen
|
||||||
|
if(document.activeElement === el) return; // Falls User gerade tippt, überspringen
|
||||||
|
|
||||||
|
if(isCheck) el.checked = (val == 1);
|
||||||
|
else el.value = val;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Texte immer aktualisieren
|
||||||
|
const txt = document.getElementById('txt');
|
||||||
|
const stat = document.getElementById('status');
|
||||||
|
if(txt) txt.innerHTML = d.txt;
|
||||||
|
if(stat) stat.innerHTML = "IP: " + d.ip + " | NTP: " + d.ntp;
|
||||||
|
|
||||||
|
// Alle Eingabefelder sicher aktualisieren
|
||||||
|
setVal('col', d.color);
|
||||||
|
setVal('bgcol', d.bgColor);
|
||||||
|
setVal('br', d.brightness);
|
||||||
|
setVal('nbr', d.nightBrightness);
|
||||||
|
setVal('nS', d.nightStart);
|
||||||
|
setVal('nE', d.nightEnd);
|
||||||
|
setVal('ntpS', d.ntpServer);
|
||||||
|
setVal('tzS', d.tzString);
|
||||||
|
|
||||||
|
// Checkboxen
|
||||||
|
setVal('night', d.night, true);
|
||||||
|
setVal('bg', d.bg, true);
|
||||||
|
|
||||||
|
}).catch(err => {
|
||||||
|
console.error("Update-Fehler:", err);
|
||||||
|
const stat = document.getElementById('status');
|
||||||
|
if(stat) stat.innerHTML = "Verbindung unterbrochen...";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
setInterval(update, 2000);
|
||||||
|
update();
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
)rawliteral";
|
||||||
|
server.send(200, "text/html", html);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ================= SETUP =================
|
||||||
|
void setup(){
|
||||||
|
Serial.begin(115200);
|
||||||
|
|
||||||
|
WiFiManager wm;
|
||||||
|
wm.autoConnect("Wortuhr");
|
||||||
|
|
||||||
|
configTime(tzString.c_str(), ntpServer.c_str());
|
||||||
|
for(int i=0;i<NUMPIXELS;i++){
|
||||||
|
currentBuffer[i] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
pixels.begin();
|
||||||
|
loadSettings();
|
||||||
|
|
||||||
|
server.on("/",handleRoot);
|
||||||
|
server.on("/status",handleStatus);
|
||||||
|
server.on("/color",handleColor);
|
||||||
|
server.on("/bgcolor",handleBGColor);
|
||||||
|
server.on("/brightness",handleBrightness);
|
||||||
|
server.on("/night",handleNight);
|
||||||
|
server.on("/nightStart",handleNightStart);
|
||||||
|
server.on("/nightEnd",handleNightEnd);
|
||||||
|
server.on("/nightBrightness",handleNightBrightness);
|
||||||
|
server.on("/bg",handleBG);
|
||||||
|
server.on("/save",handleSave);
|
||||||
|
server.on("/setNTP", handleNTP);
|
||||||
|
server.on("/setTZ", handleTZ);
|
||||||
|
|
||||||
|
server.begin();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ================= LOOP =================
|
||||||
|
void loop(){
|
||||||
|
server.handleClient();
|
||||||
|
|
||||||
|
time_t now=time(nullptr);
|
||||||
|
struct tm *t=localtime(&now);
|
||||||
|
|
||||||
|
if(t && t->tm_min !=lastMinute){
|
||||||
|
lastMinute=t->tm_min;
|
||||||
|
updateNeeded = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(updateNeeded){
|
||||||
|
showTimeWords(t->tm_hour,t->tm_min);
|
||||||
|
updateNeeded = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,378 @@
|
|||||||
|
#include <ESP8266WiFi.h>
|
||||||
|
#include <ESP8266WebServer.h>
|
||||||
|
#include <Adafruit_NeoPixel.h>
|
||||||
|
#include <EEPROM.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <WiFiManager.h>
|
||||||
|
|
||||||
|
// ================= LED =================
|
||||||
|
#define PIN D4
|
||||||
|
#define NUMPIXELS 110
|
||||||
|
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
|
||||||
|
|
||||||
|
// ================= SERVER & NTP =================
|
||||||
|
ESP8266WebServer server(80);
|
||||||
|
String ntpServer = "de.pool.ntp.org";
|
||||||
|
String tzString = "CET-1CEST,M3.5.0/02,M10.5.0/03";
|
||||||
|
|
||||||
|
// ================= SETTINGS =================
|
||||||
|
struct Settings {
|
||||||
|
int brightness;
|
||||||
|
int nightBrightness;
|
||||||
|
bool autoNight;
|
||||||
|
int nightStart;
|
||||||
|
int nightEnd;
|
||||||
|
uint32_t color;
|
||||||
|
uint32_t bgColor;
|
||||||
|
bool backgroundMode;
|
||||||
|
char ntpServer[64];
|
||||||
|
char tzString[64];
|
||||||
|
bool nightBackgroundDisabled; // Neu
|
||||||
|
} settings;
|
||||||
|
|
||||||
|
// ================= VAR =================
|
||||||
|
uint32_t currentColor = 0x00FFFF;
|
||||||
|
uint32_t lastColor = 0x00FFFF;
|
||||||
|
uint32_t bgColor = 0x000000;
|
||||||
|
bool backgroundMode = false;
|
||||||
|
bool nightBackgroundDisabled = false; // Neu
|
||||||
|
bool forceInstant = false;
|
||||||
|
bool updateNeeded = true;
|
||||||
|
int brightness = 120;
|
||||||
|
int nightBrightness = 10;
|
||||||
|
bool autoNight = true;
|
||||||
|
int nightStart = 22;
|
||||||
|
int nightEnd = 6;
|
||||||
|
uint32_t targetBuffer[NUMPIXELS];
|
||||||
|
uint32_t currentBuffer[NUMPIXELS];
|
||||||
|
int lastMinute = -1;
|
||||||
|
int lastH = -1;
|
||||||
|
|
||||||
|
// ================= EEPROM =================
|
||||||
|
void saveSettings(){
|
||||||
|
settings.brightness = brightness;
|
||||||
|
settings.nightBrightness = nightBrightness;
|
||||||
|
settings.autoNight = autoNight;
|
||||||
|
settings.nightStart = nightStart;
|
||||||
|
settings.nightEnd = nightEnd;
|
||||||
|
settings.color = currentColor;
|
||||||
|
settings.bgColor = bgColor;
|
||||||
|
settings.backgroundMode = backgroundMode;
|
||||||
|
settings.nightBackgroundDisabled = nightBackgroundDisabled; // Neu
|
||||||
|
strncpy(settings.ntpServer, ntpServer.c_str(), sizeof(settings.ntpServer));
|
||||||
|
strncpy(settings.tzString, tzString.c_str(), sizeof(settings.tzString));
|
||||||
|
EEPROM.put(0, settings);
|
||||||
|
EEPROM.commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
void loadSettings(){
|
||||||
|
EEPROM.begin(512);
|
||||||
|
EEPROM.get(0, settings);
|
||||||
|
if(settings.brightness == 0 || settings.brightness == 255){
|
||||||
|
brightness = 120;
|
||||||
|
nightBrightness = 10;
|
||||||
|
autoNight = true;
|
||||||
|
nightStart = 22;
|
||||||
|
nightEnd = 6;
|
||||||
|
currentColor = 0x00FFFF;
|
||||||
|
bgColor = 0x000000;
|
||||||
|
backgroundMode = false;
|
||||||
|
nightBackgroundDisabled = false;
|
||||||
|
ntpServer = "de.pool.ntp.org";
|
||||||
|
tzString = "CET-1CEST,M3.5.0/02,M10.5.0/03";
|
||||||
|
} else {
|
||||||
|
brightness = settings.brightness;
|
||||||
|
nightBrightness = settings.nightBrightness;
|
||||||
|
autoNight = settings.autoNight;
|
||||||
|
nightStart = settings.nightStart;
|
||||||
|
nightEnd = settings.nightEnd;
|
||||||
|
currentColor = settings.color;
|
||||||
|
bgColor = settings.bgColor;
|
||||||
|
backgroundMode = settings.backgroundMode;
|
||||||
|
nightBackgroundDisabled = settings.nightBackgroundDisabled;
|
||||||
|
ntpServer = String(settings.ntpServer);
|
||||||
|
tzString = String(settings.tzString);
|
||||||
|
}
|
||||||
|
configTime(tzString.c_str(), ntpServer.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
// ================= HELFER =================
|
||||||
|
bool isNightTime(struct tm *t){
|
||||||
|
if(!autoNight) return false;
|
||||||
|
int h = t->tm_hour;
|
||||||
|
if(nightStart > nightEnd){
|
||||||
|
return (h >= nightStart || h < nightEnd);
|
||||||
|
} else {
|
||||||
|
return (h >= nightStart && h < nightEnd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void setRange(int a,int b){
|
||||||
|
for(int i=a;i<=b;i++) targetBuffer[i]=currentColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t blend(uint32_t c1, uint32_t c2, float t){
|
||||||
|
uint8_t r1=(c1>>16)&255, g1=(c1>>8)&255, b1=c1&255;
|
||||||
|
uint8_t r2=(c2>>16)&255, g2=(c2>>8)&255, b2=c2&255;
|
||||||
|
return pixels.Color(r1+(r2-r1)*t, g1+(g2-g1)*t, b1+(b2-b1)*t);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t gamma8(uint8_t x) {
|
||||||
|
if (x == 0) return 0;
|
||||||
|
// Verwende einen leicht angepassten Exponenten für den Nachtmodus
|
||||||
|
float f = (float)x / 255.0;
|
||||||
|
return (uint8_t)(pow(f, 2.0) * 255.0 + 0.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t applyGammaBrightness(uint32_t c, float brightnessFactor) {
|
||||||
|
// Wenn der Faktor extrem klein ist, erzwingen wir eine Mindesthelligkeit für aktive LEDs
|
||||||
|
if (brightnessFactor < 0.01 && brightnessFactor > 0) brightnessFactor = 0.01;
|
||||||
|
|
||||||
|
uint8_t r = (uint8_t)(((c >> 16) & 255) * brightnessFactor);
|
||||||
|
uint8_t g = (uint8_t)(((c >> 8) & 255) * brightnessFactor);
|
||||||
|
uint8_t b = (uint8_t)((c & 255) * brightnessFactor);
|
||||||
|
|
||||||
|
return pixels.Color(gamma8(r), gamma8(g), gamma8(b));
|
||||||
|
}
|
||||||
|
|
||||||
|
int getBrightness(struct tm *t){
|
||||||
|
return isNightTime(t) ? nightBrightness : brightness;
|
||||||
|
}
|
||||||
|
|
||||||
|
void showInstant(){
|
||||||
|
time_t now = time(nullptr);
|
||||||
|
struct tm *t = localtime(&now);
|
||||||
|
float b = getBrightness(t) / 255.0;
|
||||||
|
for(int i=0;i<NUMPIXELS;i++){
|
||||||
|
pixels.setPixelColor(i, applyGammaBrightness(targetBuffer[i], b));
|
||||||
|
}
|
||||||
|
pixels.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
void fadeToTargetSmooth(int steps = 30, int delayMs = 15) {
|
||||||
|
time_t now = time(nullptr);
|
||||||
|
struct tm *t = localtime(&now);
|
||||||
|
float bTarget = getBrightness(t) / 255.0;
|
||||||
|
|
||||||
|
// Im Nachtmodus faden wir langsamer (mehr Schritte), um das Springen zu kaschieren
|
||||||
|
if (isNightTime(t)) {
|
||||||
|
steps = 60;
|
||||||
|
delayMs = 25;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int s = 0; s <= steps; s++) {
|
||||||
|
float tBlend = (float)s / steps;
|
||||||
|
for (int i = 0; i < NUMPIXELS; i++) {
|
||||||
|
uint32_t c = blend(currentBuffer[i], targetBuffer[i], tBlend);
|
||||||
|
pixels.setPixelColor(i, applyGammaBrightness(c, bTarget));
|
||||||
|
}
|
||||||
|
pixels.show();
|
||||||
|
yield(); // Verhindert WDT-Reset beim ESP8266
|
||||||
|
delay(delayMs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ================= WORTUHR LOGIK =================
|
||||||
|
void word_ES(){ setRange(0,1); } void word_IST(){ setRange(3,5); }
|
||||||
|
void word_FUENF_M(){ setRange(7,10); } void word_ZEHN_M(){ setRange(18,20); }
|
||||||
|
void word_ZWANZIG(){ setRange(11,17); } void word_VIERTEL(){ setRange(22,28); }
|
||||||
|
void word_VOR(){ setRange(30,32); } void word_NACH(){ setRange(40,43); }
|
||||||
|
void word_HALB(){ setRange(33,36); } void word_EINS(){ setRange(62,65); }
|
||||||
|
void word_EIN(){ setRange(62,64); } void word_ZWEI(){ setRange(55,58); }
|
||||||
|
void word_DREI(){ setRange(66,69); } void word_VIER(){ setRange(73,76); }
|
||||||
|
void word_FUENF_H(){ setRange(51,54); } void word_SECHS(){ setRange(83,87); }
|
||||||
|
void word_SIEBEN(){ setRange(88,93); } void word_ACHT(){ setRange(77,80); }
|
||||||
|
void word_NEUN(){ setRange(44,47); } void word_ZEHN_H(){ setRange(106,109); }
|
||||||
|
void word_ELF(){ setRange(103,105); } void word_ZWOELF(){ setRange(94,98); }
|
||||||
|
void word_UHR(){ setRange(99,101); }
|
||||||
|
|
||||||
|
String getTimeText(int h, int m){
|
||||||
|
int m5=(m/5)*5; if(m5>=25) h++;
|
||||||
|
String arr[]={"Zwölf","Eins","Zwei","Drei","Vier","Fünf","Sechs","Sieben","Acht","Neun","Zehn","Elf"};
|
||||||
|
String hT = arr[h%12]; if(m5==0 && h%12==1) hT = "ein";
|
||||||
|
String t = "Es ist ";
|
||||||
|
switch(m5){
|
||||||
|
case 0: t+= hT + " Uhr"; break;
|
||||||
|
case 5: t+= "fünf nach " + arr[h%12]; break;
|
||||||
|
case 10: t+= "zehn nach " + arr[h%12]; break;
|
||||||
|
case 15: t+= "viertel nach " + arr[h%12]; break;
|
||||||
|
case 20: t+= "zwanzig nach " + arr[h%12]; break;
|
||||||
|
case 25: t+= "fünf vor halb " + arr[h%12]; break;
|
||||||
|
case 30: t+= "halb " + arr[h%12]; break;
|
||||||
|
case 35: t+= "fünf nach halb " + arr[h%12]; break;
|
||||||
|
case 40: t+= "zwanzig vor " + arr[h%12]; break;
|
||||||
|
case 45: t+= "viertel vor " + arr[h%12]; break;
|
||||||
|
case 50: t+= "zehn vor " + arr[h%12]; break;
|
||||||
|
case 55: t+= "fünf vor " + arr[h%12]; break;
|
||||||
|
}
|
||||||
|
return t;
|
||||||
|
}
|
||||||
|
|
||||||
|
void showTimeWords(int h, int m){
|
||||||
|
time_t now = time(nullptr);
|
||||||
|
struct tm *t = localtime(&now);
|
||||||
|
|
||||||
|
for(int i=0;i<NUMPIXELS;i++) currentBuffer[i] = pixels.getPixelColor(i);
|
||||||
|
|
||||||
|
// HG Logik mit Nacht-Aus-Option
|
||||||
|
uint32_t activeBg = 0;
|
||||||
|
if(backgroundMode) {
|
||||||
|
if(nightBackgroundDisabled && isNightTime(t)) {
|
||||||
|
activeBg = 0;
|
||||||
|
} else {
|
||||||
|
activeBg = bgColor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(int i=0;i<NUMPIXELS;i++) targetBuffer[i] = activeBg;
|
||||||
|
|
||||||
|
word_ES(); word_IST();
|
||||||
|
int m5 = (m/5)*5; bool full = (m5 == 0); if(m5 >= 25) h++;
|
||||||
|
switch(m5){
|
||||||
|
case 0: word_UHR(); break;
|
||||||
|
case 5: word_FUENF_M(); word_NACH(); break;
|
||||||
|
case 10: word_ZEHN_M(); word_NACH(); break;
|
||||||
|
case 15: word_VIERTEL(); word_NACH(); break;
|
||||||
|
case 20: word_ZWANZIG(); word_NACH(); break;
|
||||||
|
case 25: word_FUENF_M(); word_VOR(); word_HALB(); break;
|
||||||
|
case 30: word_HALB(); break;
|
||||||
|
case 35: word_FUENF_M(); word_NACH(); word_HALB(); break;
|
||||||
|
case 40: word_ZWANZIG(); word_VOR(); break;
|
||||||
|
case 45: word_VIERTEL(); word_VOR(); break;
|
||||||
|
case 50: word_ZEHN_M(); word_VOR(); break;
|
||||||
|
case 55: word_FUENF_M(); word_VOR(); break;
|
||||||
|
}
|
||||||
|
int hh = h % 12;
|
||||||
|
if(hh == 1 && full) word_EIN();
|
||||||
|
else if(hh == 1) word_EINS(); else if(hh == 2) word_ZWEI(); else if(hh == 3) word_DREI();
|
||||||
|
else if(hh == 4) word_VIER(); else if(hh == 5) word_FUENF_H(); else if(hh == 6) word_SECHS();
|
||||||
|
else if(hh == 7) word_SIEBEN(); else if(hh == 8) word_ACHT(); else if(hh == 9) word_NEUN();
|
||||||
|
else if(hh == 10) word_ZEHN_H(); else if(hh == 11) word_ELF(); else word_ZWOELF();
|
||||||
|
|
||||||
|
if(forceInstant){ showInstant(); forceInstant = false; }
|
||||||
|
else { fadeToTargetSmooth(20, 10); }
|
||||||
|
}
|
||||||
|
|
||||||
|
// ================= WEB HANDLERS =================
|
||||||
|
void handleStatus() {
|
||||||
|
time_t now = time(nullptr);
|
||||||
|
struct tm *t = localtime(&now);
|
||||||
|
char hexCol[10], hexBg[10];
|
||||||
|
snprintf(hexCol, sizeof(hexCol), "#%06X", currentColor);
|
||||||
|
snprintf(hexBg, sizeof(hexBg), "#%06X", bgColor);
|
||||||
|
String ntpStat = (now > 100000) ? "OK" : "SYNC...";
|
||||||
|
String json = "{";
|
||||||
|
json += "\"txt\":\"" + getTimeText(t->tm_hour, t->tm_min) + "\",";
|
||||||
|
json += "\"ip\":\"" + WiFi.localIP().toString() + "\",";
|
||||||
|
json += "\"ntp\":\"" + ntpStat + "\",";
|
||||||
|
json += "\"ntpServer\":\"" + ntpServer + "\",";
|
||||||
|
json += "\"tzString\":\"" + tzString + "\",";
|
||||||
|
json += "\"brightness\":" + String(brightness) + ",";
|
||||||
|
json += "\"nightBrightness\":" + String(nightBrightness) + ",";
|
||||||
|
json += "\"color\":\"" + String(hexCol) + "\",";
|
||||||
|
json += "\"bgColor\":\"" + String(hexBg) + "\",";
|
||||||
|
json += "\"night\":" + String(autoNight ? 1 : 0) + ",";
|
||||||
|
json += "\"nightStart\":" + String(nightStart) + ",";
|
||||||
|
json += "\"nightEnd\":" + String(nightEnd) + ",";
|
||||||
|
json += "\"bg\":" + String(backgroundMode ? 1 : 0) + ",";
|
||||||
|
json += "\"nightBgOff\":" + String(nightBackgroundDisabled ? 1 : 0);
|
||||||
|
json += "}";
|
||||||
|
server.send(200, "application/json", json);
|
||||||
|
}
|
||||||
|
|
||||||
|
void handleRoot(){
|
||||||
|
String html = R"rawliteral(
|
||||||
|
<html><head><meta charset='UTF-8'><meta name='viewport' content='width=device-width, initial-scale=1'>
|
||||||
|
<style>
|
||||||
|
body{font-family:Arial,sans-serif; background:#fff; margin:0; color:#333; display:flex; flex-direction:column; align-items:center}
|
||||||
|
.card{width:90%; max-width:400px; margin:10px; padding:15px; border-radius:12px; background:#f2f2f2; box-shadow: 0 2px 5px rgba(0,0,0,0.1)}
|
||||||
|
.big{font-size:26px; text-align:center; font-weight:bold; color:#0055ff}
|
||||||
|
input[type='range'], input[type='color'], input[type='text']{width:100%; margin-bottom:10px}
|
||||||
|
button{width:100%; padding:12px; border-radius:8px; background:#0055ff; color:#fff; border:none; cursor:pointer}
|
||||||
|
label{font-weight:bold; display:block; margin-bottom:5px}
|
||||||
|
</style></head><body>
|
||||||
|
<div class='card big' id='txt'>Lade...</div>
|
||||||
|
<div class='card' id='status'>Verbinde...</div>
|
||||||
|
<div class='card'><label>Farbe Worte</label><div> </div><input type='color' id='col' onchange="f('/color?c='+this.value.substring(1))">
|
||||||
|
<label>Helligkeit</label><input type='range' id='br' min='0' max='255' oninput="f('/brightness?val='+this.value)"></div>
|
||||||
|
<div class='card'><input type='checkbox' id='bg' onchange="f('/bg?val='+(this.checked?1:0))"> <b>Hintergrund</b><br><div> </div>
|
||||||
|
<input type='color' id='bgcol' onchange="f('/bgcolor?c='+this.value.substring(1))"></div>
|
||||||
|
<div class='card'><input type='checkbox' id='night' onchange="f('/night?val='+(this.checked?1:0))"> <b>Nachtmodus</b><br> <div> </div>
|
||||||
|
Von: <input type='number' id='nS' style='width:50px' oninput="f('/nightStart?val='+this.value)"> Uhr
|
||||||
|
Bis: <input type='number' id='nE' style='width:50px' oninput="f('/nightEnd?val='+this.value)"> Uhr<br><div> </div>
|
||||||
|
<label>Nacht-Helligkeit</label><input type='range' id='nbr' min='0' max='255' oninput="f('/nightBrightness?val='+this.value)">
|
||||||
|
<br><input type='checkbox' id='nightBgOff' onchange="f('/nightBgOff?val='+(this.checked?1:0))"> HG in Nacht aus</div>
|
||||||
|
|
||||||
|
<div class='card'><label>NTP Server:</label><input type='text' id='ntpS' onchange="f('/setNTP?val='+this.value)">
|
||||||
|
<label>Zeitzone:</label><input type='text' id='tzS' onchange="f('/setTZ?val='+this.value)"></div>
|
||||||
|
<div class='card'><button onclick="f('/save');alert('Gespeichert!')">EEPROM Speichern</button></div>
|
||||||
|
<script>
|
||||||
|
function f(u){fetch(u)}
|
||||||
|
function u(){fetch('/status').then(r=>r.json()).then(d=>{
|
||||||
|
document.getElementById('txt').innerText=d.txt;
|
||||||
|
document.getElementById('status').innerText="IP: "+d.ip+" | NTP: "+d.ntp;
|
||||||
|
const s=(i,v,c=false)=>{const e=document.getElementById(i);if(e&&document.activeElement!==e){if(c)e.checked=(v==1);else e.value=v;}};
|
||||||
|
s('col',d.color);s('br',d.brightness);s('night',d.night,true);s('nS',d.nightStart);s('nE',d.nightEnd);
|
||||||
|
s('nbr',d.nightBrightness);s('bg',d.bg,true);s('bgcol',d.bgColor);s('ntpS',d.ntpServer);s('tzS',d.tzString);
|
||||||
|
s('nightBgOff',d.nightBgOff,true);
|
||||||
|
})}
|
||||||
|
setInterval(u, 2500); u();
|
||||||
|
</script></body></html>)rawliteral";
|
||||||
|
server.send(200, "text/html", html);
|
||||||
|
}
|
||||||
|
|
||||||
|
void handleColor(){ if(server.hasArg("c")){ currentColor=strtoul(server.arg("c").c_str(),NULL,16); forceInstant=true; showTimeWords(lastH, lastMinute); } server.send(200); }
|
||||||
|
void handleBGColor(){ if(server.hasArg("c")){ bgColor=strtoul(server.arg("c").c_str(),NULL,16); forceInstant=true; updateNeeded=true; } server.send(200); }
|
||||||
|
void handleBrightness(){ brightness=server.arg("val").toInt(); forceInstant=true; updateNeeded=true; server.send(200); }
|
||||||
|
void handleNight(){ autoNight=server.arg("val").toInt(); forceInstant=true; updateNeeded=true; server.send(200); }
|
||||||
|
void handleNightStart(){ nightStart=server.arg("val").toInt(); forceInstant=true; updateNeeded=true; server.send(200); }
|
||||||
|
void handleNightEnd(){ nightEnd=server.arg("val").toInt(); forceInstant=true; updateNeeded=true; server.send(200); }
|
||||||
|
void handleNightBrightness(){ nightBrightness=server.arg("val").toInt(); forceInstant=true; updateNeeded=true; server.send(200); }
|
||||||
|
void handleNightBgOff(){ nightBackgroundDisabled=server.arg("val").toInt(); forceInstant=true; updateNeeded=true; server.send(200); }
|
||||||
|
void handleBG(){ backgroundMode=server.arg("val").toInt(); forceInstant=true; updateNeeded=true; server.send(200); }
|
||||||
|
void handleNTP(){ ntpServer=server.arg("val"); configTime(tzString.c_str(), ntpServer.c_str()); server.send(200); }
|
||||||
|
void handleTZ(){ tzString=server.arg("val"); configTime(tzString.c_str(), ntpServer.c_str()); server.send(200); }
|
||||||
|
void handleSave(){ saveSettings(); server.send(200); }
|
||||||
|
|
||||||
|
// ================= SETUP & LOOP =================
|
||||||
|
void setup(){
|
||||||
|
Serial.begin(115200);
|
||||||
|
WiFiManager wm; wm.autoConnect("Wortuhr");
|
||||||
|
loadSettings();
|
||||||
|
server.on("/", handleRoot);
|
||||||
|
server.on("/status", handleStatus);
|
||||||
|
server.on("/color", handleColor);
|
||||||
|
server.on("/bgcolor", handleBGColor);
|
||||||
|
server.on("/brightness", handleBrightness);
|
||||||
|
server.on("/night", handleNight);
|
||||||
|
server.on("/nightStart", handleNightStart);
|
||||||
|
server.on("/nightEnd", handleNightEnd);
|
||||||
|
server.on("/nightBrightness", handleNightBrightness);
|
||||||
|
server.on("/nightBgOff", handleNightBgOff);
|
||||||
|
server.on("/bg", handleBG);
|
||||||
|
server.on("/setNTP", handleNTP);
|
||||||
|
server.on("/setTZ", handleTZ);
|
||||||
|
server.on("/save", handleSave);
|
||||||
|
server.begin();
|
||||||
|
pixels.begin();
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop(){
|
||||||
|
server.handleClient();
|
||||||
|
|
||||||
|
time_t now = time(nullptr);
|
||||||
|
struct tm *t = localtime(&now);
|
||||||
|
|
||||||
|
if(t) {
|
||||||
|
int currentM5 = (t->tm_min / 5) * 5;
|
||||||
|
if(currentM5 != lastMinute || t->tm_hour != lastH){
|
||||||
|
lastMinute = currentM5;
|
||||||
|
lastH = t->tm_hour;
|
||||||
|
updateNeeded = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(updateNeeded){
|
||||||
|
showTimeWords(lastH, (t ? t->tm_min : 0));
|
||||||
|
updateNeeded = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -22,8 +22,13 @@
|
|||||||
#include <ESP8266WebServer.h>
|
#include <ESP8266WebServer.h>
|
||||||
#include <WiFiManager.h>
|
#include <WiFiManager.h>
|
||||||
|
|
||||||
|
// #define BRIGHTNESS 200
|
||||||
|
#define BRIGHTNESS_HIGH 200
|
||||||
|
#define BRIGHTNESS_LOW 100
|
||||||
|
#define BRIGHTNESS_HIGH_TIME 8
|
||||||
|
#define BRIGHTNESS_LOW_TIME 20
|
||||||
|
|
||||||
#define NUM_LEDS 42
|
#define NUM_LEDS 43
|
||||||
#define DATA_PIN 5
|
#define DATA_PIN 5
|
||||||
|
|
||||||
CRGB leds[NUM_LEDS];
|
CRGB leds[NUM_LEDS];
|
||||||
@@ -37,51 +42,52 @@ static const char ntpServerName[] = "pool.ntp.org";
|
|||||||
#define M_IST 1
|
#define M_IST 1
|
||||||
#define M_FUENF 2
|
#define M_FUENF 2
|
||||||
#define M_ZEHN 3
|
#define M_ZEHN 3
|
||||||
#define M_VIERTEL 4
|
#define M_ZWANZIG 4
|
||||||
#define M_VOR 5
|
#define M_VIERTEL 5
|
||||||
#define M_NACH 6
|
#define M_VOR 6
|
||||||
|
#define M_NACH 8
|
||||||
#define M_HALB 7
|
#define M_HALB 7
|
||||||
#define M_UHR 8
|
#define M_UHR 21
|
||||||
#define H_EINS 9
|
#define H_EINS 11
|
||||||
#define H_EIN 9
|
#define H_ZWEI 12
|
||||||
#define H_ZWEI 10
|
#define H_DREI 13
|
||||||
#define H_DREI 11
|
#define H_VIER 14
|
||||||
#define H_VIER 12
|
#define H_FUENF 10
|
||||||
#define H_FUENF 13
|
#define H_SECHS 15
|
||||||
#define H_SECHS 14
|
#define H_SIEBEN 17
|
||||||
#define H_SIEBEN 15
|
|
||||||
#define H_ACHT 16
|
#define H_ACHT 16
|
||||||
#define H_NEUN 17
|
#define H_NEUN 9
|
||||||
#define H_ZEHN 18
|
#define H_ZEHN 19
|
||||||
#define H_ELF 19
|
#define H_ELF 20
|
||||||
#define H_ZWOELF 20
|
#define H_ZWOELF 18
|
||||||
|
|
||||||
TimeChangeRule myDST = {"CEST", Last, Sun, Mar, 2, 120}; //Daylight time = UTC - 4 hours
|
TimeChangeRule myDST = {"CEST", Last, Sun, Mar, 2, 120}; //Daylight time = UTC - 4 hours
|
||||||
TimeChangeRule mySTD = {"CET", Last, Sun, Oct, 2, 60}; //Standard time = UTC - 5 hours
|
TimeChangeRule mySTD = {"CET", Last, Sun, Oct, 2, 60}; //Standard time = UTC - 5 hours
|
||||||
Timezone myTZ(myDST, mySTD);
|
Timezone myTZ(myDST, mySTD);
|
||||||
|
|
||||||
int clockWords[21][10] = {
|
int clockWords[22][10] = {
|
||||||
{3,-1,-1,-1,-1,-1,-1,-1,-1,-1}, // es 0
|
{0,-1,-1,-1,-1,-1,-1,-1,-1,-1}, // es 0
|
||||||
{2,-1,-1,-1,-1,-1,-1,-1,-1,-1}, // ist 1
|
{1,-1,-1,-1,-1,-1,-1,-1,-1,-1}, // ist 1
|
||||||
{0,1,-1,-1,-1,-1,-1,-1,-1,-1}, // fuenf 2
|
{2,3,-1,-1,-1,-1,-1,-1,-1,-1}, // fuenf 2
|
||||||
{4,5,-1,-1,-1,-1,-1,-1,-1,-1}, // zehn 3
|
{7,8,-1,-1,-1,-1,-1,-1,-1,-1}, // zehn 3
|
||||||
{8,9,10,-1,-1,-1,-1,-1,-1,-1}, // viertel 4
|
{4,5,6,-1,-1,-1,-1,-1,-1,-1}, // zwanzig 4
|
||||||
{11,12,-1,-1,-1,-1,-1,-1,-1,-1}, // vor 5
|
{9,10,11,-1,-1,-1,-1,-1,-1,-1}, // viertel 5
|
||||||
{6,7,-1,-1,-1,-1,-1,-1,-1,-1}, // nach 6
|
{12,-1,-1,-1,-1,-1,-1,-1,-1,-1}, // vor 6
|
||||||
{13,14,-1,-1,-1,-1,-1,-1,-1,-1}, // halb 7
|
{13,14,-1,-1,-1,-1,-1,-1,-1,-1}, // nach 8
|
||||||
{40,41,-1,-1,-1,-1,-1,-1,-1,-1}, // uhr 8
|
{15,16,-1,-1,-1,-1,-1,-1,-1,-1}, // halb 7
|
||||||
{19,20,-1,-1,-1,-1,-1,-1,-1,-1}, // ein 9
|
{17,18,-1,-1,-1,-1,-1,-1,-1,-1}, // neun 9
|
||||||
{21,22,-1,-1,-1,-1,-1,-1,-1,-1}, // zwei 10
|
{19,20,-1,-1,-1,-1,-1,-1,-1,-1}, // fuenf 10
|
||||||
{25,26,-1,-1,-1,-1,-1,-1,-1,-1}, // drei 11
|
{23,24,-1,-1,-1,-1,-1,-1,-1,-1}, // eins 11
|
||||||
{23,24,-1,-1,-1,-1,-1,-1,-1,-1}, // vier 12
|
{21,22,-1,-1,-1,-1,-1,-1,-1,-1}, // zwei 12
|
||||||
{15,16,-1,-1,-1,-1,-1,-1,-1,-1}, // fuenf 13
|
{25,26,-1,-1,-1,-1,-1,-1,-1,-1}, // drei 13
|
||||||
{27,28,-1,-1,-1,-1,-1,-1,-1,-1}, // sechs 14
|
{27,28,-1,-1,-1,-1,-1,-1,-1,-1}, // vier 14
|
||||||
{33,34,35,-1,-1,-1,-1,-1,-1,-1}, // sieben 15
|
{31,32,-1,-1,-1,-1,-1,-1,-1,-1}, // sechs 15
|
||||||
{29,30,-1,-1,-1,-1,-1,-1,-1,-1}, // acht 16
|
{29,30,-1,-1,-1,-1,-1,-1,-1,-1}, // acht 16
|
||||||
{17,18,-1,-1,-1,-1,-1,-1,-1,-1}, // neun 17
|
{33,34,35,-1,-1,-1,-1,-1,-1,-1}, // sieben 17
|
||||||
{36,37,-1,-1,-1,-1,-1,-1,-1,-1}, // zehn 18
|
{36,37,38,-1,-1,-1,-1,-1,-1,-1}, // zwölf 18
|
||||||
{38,39,-1,-1,-1,-1,-1,-1,-1,-1}, // elf 19
|
{41,42,-1,-1,-1,-1,-1,-1,-1,-1}, // zehn 19
|
||||||
{31,32,-1,-1,-1,-1,-1,-1,-1,-1}, // zwölf 20
|
{40,-1,-1,-1,-1,-1,-1,-1,-1,-1}, // elf 20
|
||||||
|
{39,-1,-1,-1,-1,-1,-1,-1,-1}, // uhr 21
|
||||||
};
|
};
|
||||||
|
|
||||||
WiFiUDP Udp;
|
WiFiUDP Udp;
|
||||||
@@ -92,6 +98,7 @@ uint8_t color = 0;
|
|||||||
int lastmin = 100;
|
int lastmin = 100;
|
||||||
void printDigits(int digits);
|
void printDigits(int digits);
|
||||||
void sendNTPpacket(IPAddress &address);
|
void sendNTPpacket(IPAddress &address);
|
||||||
|
uint8_t brightness = BRIGHTNESS_HIGH;
|
||||||
|
|
||||||
void clear(bool show=true)
|
void clear(bool show=true)
|
||||||
{
|
{
|
||||||
@@ -107,7 +114,7 @@ void noWifi()
|
|||||||
{
|
{
|
||||||
for(int i=0; i<NUM_LEDS; i++)
|
for(int i=0; i<NUM_LEDS; i++)
|
||||||
{
|
{
|
||||||
leds[i] = CHSV((255/(NUM_LEDS-1))*i, 255, 128);
|
leds[i] = CHSV((255/(NUM_LEDS-1))*i, 255, brightness);
|
||||||
FastLED.show();
|
FastLED.show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -141,7 +148,14 @@ void digitalClockDisplay()
|
|||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS);
|
FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS);
|
||||||
|
clear();
|
||||||
|
for (int initcount=0; initcount <= NUM_LEDS; initcount++) {
|
||||||
|
clear();
|
||||||
|
leds[initcount] = CHSV((255/NUM_LEDS)*initcount, 255, brightness);
|
||||||
|
FastLED.show();
|
||||||
|
delay(100);
|
||||||
|
}
|
||||||
clear();
|
clear();
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
WiFiManager wifiManager;
|
WiFiManager wifiManager;
|
||||||
@@ -201,7 +215,7 @@ void set_word(int word, time_t current_time = loctime) {
|
|||||||
{
|
{
|
||||||
if (clockWords[word][i] >= 0)
|
if (clockWords[word][i] >= 0)
|
||||||
{
|
{
|
||||||
leds[clockWords[word][i]] = CHSV(color, 255, 128);
|
leds[clockWords[word][i]] = CHSV(color, 255, brightness);
|
||||||
Serial.print(clockWords[word][i]);
|
Serial.print(clockWords[word][i]);
|
||||||
Serial.print(" ");
|
Serial.print(" ");
|
||||||
}
|
}
|
||||||
@@ -209,10 +223,25 @@ void set_word(int word, time_t current_time = loctime) {
|
|||||||
Serial.println();
|
Serial.println();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void set_brightness()
|
||||||
|
{
|
||||||
|
switch(int(hour(loctime)))
|
||||||
|
{
|
||||||
|
case BRIGHTNESS_HIGH_TIME:
|
||||||
|
brightness = BRIGHTNESS_HIGH;
|
||||||
|
break;
|
||||||
|
case BRIGHTNESS_LOW_TIME:
|
||||||
|
brightness = BRIGHTNESS_LOW;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void setClock() {
|
void setClock() {
|
||||||
Serial.println("Updating display...");
|
Serial.println("Updating display...");
|
||||||
time_t current_time = loctime;
|
time_t current_time = loctime;
|
||||||
clear(false);
|
clear(false);
|
||||||
|
set_brightness(); // ***Should set brightness
|
||||||
set_word(M_ES); // switch es on
|
set_word(M_ES); // switch es on
|
||||||
set_word(M_IST); // switch ist on
|
set_word(M_IST); // switch ist on
|
||||||
getMinuteWord(); //get word for "minute"
|
getMinuteWord(); //get word for "minute"
|
||||||
@@ -229,13 +258,13 @@ int getHour()
|
|||||||
/*
|
/*
|
||||||
get current hour if minute < 20
|
get current hour if minute < 20
|
||||||
Es ist viertel nach zehn
|
Es ist viertel nach zehn
|
||||||
get next hour if minute >=20
|
get next hour if minute >=25
|
||||||
Es ist zehn vor halb elf
|
Es ist fuenf vor halb elf
|
||||||
adjust hour to correct word around midnight:
|
adjust hour to correct word around midnight:
|
||||||
23:25 --> Es ist fuenf vor halb zwoelf
|
23:25 --> Es ist fuenf vor halb zwoelf
|
||||||
*/
|
*/
|
||||||
Serial.println(m);
|
Serial.println(m);
|
||||||
if (m >= 20)
|
if (m >= 25)
|
||||||
{
|
{
|
||||||
if (h < 23)
|
if (h < 23)
|
||||||
{
|
{
|
||||||
@@ -264,7 +293,7 @@ void getHourWord()
|
|||||||
// special case to get sigular @ "ein uhr"
|
// special case to get sigular @ "ein uhr"
|
||||||
if (int(minute(loctime)) < 5)
|
if (int(minute(loctime)) < 5)
|
||||||
{
|
{
|
||||||
set_word(H_EIN);
|
set_word(H_EINS);
|
||||||
Serial.println("ein");
|
Serial.println("ein");
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
@@ -372,10 +401,9 @@ void getMinuteWord()
|
|||||||
case 22:
|
case 22:
|
||||||
case 23:
|
case 23:
|
||||||
case 24:
|
case 24:
|
||||||
set_word(M_ZEHN);
|
set_word(M_ZWANZIG);
|
||||||
set_word(M_VOR);
|
set_word(M_NACH);
|
||||||
set_word(M_HALB);
|
Serial.println("zwanzig nach");
|
||||||
Serial.println("zehn vor halb");
|
|
||||||
break;
|
break;
|
||||||
case 25:
|
case 25:
|
||||||
case 26:
|
case 26:
|
||||||
@@ -410,9 +438,8 @@ void getMinuteWord()
|
|||||||
case 42:
|
case 42:
|
||||||
case 43:
|
case 43:
|
||||||
case 44:
|
case 44:
|
||||||
set_word(M_ZEHN);
|
set_word(M_ZWANZIG);
|
||||||
set_word(M_NACH);
|
set_word(M_VOR);
|
||||||
set_word(M_HALB);
|
|
||||||
Serial.println("zehn nach halb");
|
Serial.println("zehn nach halb");
|
||||||
break;
|
break;
|
||||||
case 45:
|
case 45:
|
||||||
Reference in New Issue
Block a user