diff --git a/bin/wled05dev_1712152_CRONIXIE_dont_use_for_regular_led_strip.bin b/bin/wled05dev_1712152_CRONIXIE_dont_use_for_regular_led_strip.bin new file mode 100644 index 00000000..883276cb Binary files /dev/null and b/bin/wled05dev_1712152_CRONIXIE_dont_use_for_regular_led_strip.bin differ diff --git a/wled00/WS2812FX.cpp b/wled00/WS2812FX.cpp index 46435389..6c2acca3 100644 --- a/wled00/WS2812FX.cpp +++ b/wled00/WS2812FX.cpp @@ -1946,23 +1946,24 @@ void WS2812FX::setPixelColor(uint16_t i, uint8_t r, uint8_t g, uint8_t b, uint8_ #endif } else { if(i>6)return; - uint8_t o = 20*i; + uint8_t o = 10*i; for (int j=o; j< o+19; j++) { setPixelColorRaw(j,0,0,0,0); } switch(_cronixieDigits[i]) { - case 0: setPixelColorRaw(o+5,r,g,b,w); setPixelColorRaw(o+15,r,g,b,w); break; - case 1: setPixelColorRaw(o+0,r,g,b,w); setPixelColorRaw(o+10,r,g,b,w); break; - case 2: setPixelColorRaw(o+6,r,g,b,w); setPixelColorRaw(o+16,r,g,b,w); break; - case 3: setPixelColorRaw(o+1,r,g,b,w); setPixelColorRaw(o+11,r,g,b,w); break; - case 4: setPixelColorRaw(o+7,r,g,b,w); setPixelColorRaw(o+17,r,g,b,w); break; - case 5: setPixelColorRaw(o+2,r,g,b,w); setPixelColorRaw(o+12,r,g,b,w); break; - case 6: setPixelColorRaw(o+8,r,g,b,w); setPixelColorRaw(o+18,r,g,b,w); break; - case 7: setPixelColorRaw(o+3,r,g,b,w); setPixelColorRaw(o+13,r,g,b,w); break; - case 8: setPixelColorRaw(o+9,r,g,b,w); setPixelColorRaw(o+19,r,g,b,w); break; - case 9: setPixelColorRaw(o+4,r,g,b,w); setPixelColorRaw(o+14,r,g,b,w); break; + case 0: setPixelColorRaw(o+5,r,g,b,w); break; + case 1: setPixelColorRaw(o+0,r,g,b,w); break; + case 2: setPixelColorRaw(o+6,r,g,b,w); break; + case 3: setPixelColorRaw(o+1,r,g,b,w); break; + case 4: setPixelColorRaw(o+7,r,g,b,w); break; + case 5: setPixelColorRaw(o+2,r,g,b,w); break; + case 6: setPixelColorRaw(o+8,r,g,b,w); break; + case 7: setPixelColorRaw(o+3,r,g,b,w); break; + case 8: setPixelColorRaw(o+9,r,g,b,w); break; + case 9: setPixelColorRaw(o+4,r,g,b,w); break; + default: break; } } } @@ -1979,6 +1980,25 @@ void WS2812FX::setPixelColor(uint16_t i, uint32_t c) uint32_t WS2812FX::getPixelColor(uint16_t i) { + if (_cronixieMode) + { + if(i>6)return 0; + uint8_t o = 10*i; + switch(_cronixieDigits[i]) + { + case 0: i=o+5; break; + case 1: i=o+0; break; + case 2: i=o+6; break; + case 3: i=o+1; break; + case 4: i=o+7; break; + case 5: i=o+2; break; + case 6: i=o+8; break; + case 7: i=o+3; break; + case 8: i=o+9; break; + case 9: i=o+4; break; + default: return 0; + } + } #ifdef RGBW RgbwColor lColor = NeoPixelBrightnessBus::GetPixelColor(i); return lColor.W*16777216 + lColor.R*65536 + lColor.G*256 + lColor.B; diff --git a/wled00/data/settings.htm b/wled00/data/settings.htm index a87e53c7..3b34cea4 100644 --- a/wled00/data/settings.htm +++ b/wled00/data/settings.htm @@ -102,7 +102,7 @@ Current local time is unknown

Advanced

Default overlay ID:
- WARLS offset: negative
+ WARLS offset:

Security

OTA locked:
Passphrase:
diff --git a/wled00/htmls01.h b/wled00/htmls01.h index 82c9de65..bbc2428e 100644 --- a/wled00/htmls01.h +++ b/wled00/htmls01.h @@ -101,7 +101,7 @@ Get time from NTP server:
Current local time is unknown

Advanced

Default overlay ID:
-WARLS offset: negative
+WARLS offset:

Security

OTA locked:
Passphrase:
diff --git a/wled00/wled00.ino b/wled00/wled00.ino index 782ed372..957141a3 100644 --- a/wled00/wled00.ino +++ b/wled00/wled00.ino @@ -25,42 +25,25 @@ #include "WS2812FX.h" //version in format yymmddb (b = daily build) -#define VERSION 1712141 +#define VERSION 1712152 + +//AP and OTA default passwords (change them!) +String appass = "wled1234"; +String otapass = "wledota"; //If you have an RGBW strip, uncomment first line in WS2812FX.h! -//to toggle usb serial debug (un)comment following line -//#define DEBUG +//overlays, needed for clocks etc. +//#define USEOVERLAYS + +//support for the CRONIXIE clock by Diamex +#define CRONIXIE //spiffs FS only useful for debug //#define USEFS -//overlays, needed for clocks etc. -#define USEOVERLAYS - -//support for the CRONIXIE clock by Diamex -//#define CRONIXIE - -#ifdef USEFS -#include -#endif - -#ifdef DEBUG - #define DEBUG_PRINT(x) Serial.print (x) - #define DEBUG_PRINTLN(x) Serial.println (x) - #define DEBUG_PRINTF(x) Serial.printf (x) -#else - #define DEBUG_PRINT(x) - #define DEBUG_PRINTLN(x) - #define DEBUG_PRINTF(x) -#endif - -//eeprom Version code, enables default settings instead of 0 init on update -#define EEPVER 3 -//0 -> old version, default -//1 -> 0.4p 1711272 and up -//2 -> 0.4p 1711302 and up -//3 -> 0.4 1712121 and up +//to toggle usb serial debug (un)comment following line +//#define DEBUG //Hardware-settings (only changeble via code) #define LEDCOUNT 255 //maximum, exact count set-able via settings @@ -70,10 +53,6 @@ uint8_t auxPin = 15; //use e.g. for external relay uint8_t auxDefaultState = 0; //0: input 1: high 2: low uint8_t auxTriggeredState = 0; //0: input 1: high 2: low -//AP and OTA default passwords (change them!) -String appass = "wled1234"; -String otapass = "wledota"; - TimeChangeRule CEST = {"CEST", Last, Sun, Mar, 2, 120}; //Central European Summer Time TimeChangeRule CET = {"CET ", Last, Sun, Oct, 3, 60}; //Central European Standard Time Timezone TZ(CEST, CET); @@ -83,14 +62,18 @@ time_t local; //cronixie defaults #ifdef CRONIXIE #undef LEDCOUNT -#define LEDCOUNT 120 +#define LEDCOUNT 60 #undef MAXDIRECT #define MAXDIRECT 48 uint8_t ledcount = 6; String apssid = "CRONIXIE-AP"; String alexaInvocationName = "Clock"; -long cronixieRefreshMs = 99; +char cronixieDefault[] = "HHMMSS"; +long cronixieRefreshMs = 497; unsigned long cronixieRefreshedTime; +byte dP[]{0,0,0,0,0,0}; +bool cronixieUseAMPM = false; +boolean ntpEnabled = true; #endif //Default CONFIG @@ -134,7 +117,9 @@ uint16_t udpPort = 21324; uint8_t effectDefault = 0; uint8_t effectSpeedDefault = 75; //NTP stuff +#ifndef CRONIXIE boolean ntpEnabled = false; +#endif IPAddress ntpServerIP; const char* ntpServerName = "pool.ntp.org"; //custom chase @@ -236,7 +221,25 @@ WiFiUDP ntpUdp; WS2812FX strip = WS2812FX(LEDCOUNT); +//eeprom Version code, enables default settings instead of 0 init on update +#define EEPVER 3 +//0 -> old version, default +//1 -> 0.4p 1711272 and up +//2 -> 0.4p 1711302 and up +//3 -> 0.4 1712121 and up + +#ifdef DEBUG + #define DEBUG_PRINT(x) Serial.print (x) + #define DEBUG_PRINTLN(x) Serial.println (x) + #define DEBUG_PRINTF(x) Serial.printf (x) +#else + #define DEBUG_PRINT(x) + #define DEBUG_PRINTLN(x) + #define DEBUG_PRINTF(x) +#endif + #ifdef USEFS +#include ; File fsUploadFile; #endif diff --git a/wled00/wled02_xml.ino b/wled00/wled02_xml.ino index 1a82066e..b7de4abe 100644 --- a/wled00/wled02_xml.ino +++ b/wled00/wled02_xml.ino @@ -128,8 +128,7 @@ String getSettings() resp += ds + "NSALX" + c + alexaNotify +";"; resp += dg + "(\"times\")[0]" + ih + "\"" + getTimeString() + "\";"; resp += ds + "OLDEF" + v + overlayDefault +";"; - resp += ds + "WOFFS" + v + abs(arlsOffset) +";"; - resp += ds + "WOFFN" + c + !arlsSign +";"; + resp += ds + "WOFFS" + v + arlsOffset +";"; resp += ds + "NOOTA" + c + otaLock +";"; resp += ds + "NORAP" + c + recoveryAPDisabled +";"; resp += dg + "(\"sip\")[0]" + ih + "\""; diff --git a/wled00/wled03_set.ino b/wled00/wled03_set.ino index 9f807fd1..0a64dbdc 100644 --- a/wled00/wled03_set.ino +++ b/wled00/wled03_set.ino @@ -229,13 +229,8 @@ void handleSettingsSet() if (server.hasArg("WOFFS")) { int i = server.arg("WOFFS").toInt(); - if (i >= 0 && i <= 255) arlsOffset = i; - arlsSign = true; - if (server.hasArg("WOFFN")) - { - arlsSign = false; - arlsOffset = -arlsOffset; - } + if (i >= -255 && i <= 255) arlsOffset = i; + arlsSign = (i>=0)?true:false; } if (server.hasArg("OPASS")) { @@ -524,7 +519,12 @@ boolean handleSet(String req) applyPreset(req.substring(pos + 3).toInt(), false, false, true); effectUpdated = true; } - + #ifdef CRONIXIE + pos = req.indexOf("NX="); //sets digits to code + if (pos > 0) { + setCronixie(req.substring(pos + 3, pos + 9).c_str()); + } + #endif //internal call, does not send XML response pos = req.indexOf("IN"); if (pos < 1) diff --git a/wled00/wled05_init.ino b/wled00/wled05_init.ino index 2857ab52..62eb9572 100644 --- a/wled00/wled05_init.ino +++ b/wled00/wled05_init.ino @@ -168,6 +168,7 @@ void wledInit() strip.start(); #ifdef CRONIXIE strip.driverModeCronixie(true); + setCronixie(cronixieDefault); #endif if (bootPreset>0) applyPreset(bootPreset, turnOnAtBoot, true, true); colorUpdated(0); diff --git a/wled00/wled11_ol.ino b/wled00/wled11_ol.ino index dfe5572b..deffd1f0 100644 --- a/wled00/wled11_ol.ino +++ b/wled00/wled11_ol.ino @@ -1,3 +1,6 @@ +/* + * The Overlay function is over a year old, largely untested and not configurable during runtime. Consider it as deprecated for now, it might get either removed/simplified/reworked. + */ #ifdef USEOVERLAYS void _nixieDisplay(int num[], int dur[], int pausedur[], int cnt) { diff --git a/wled00/wled13_cronixie.ino b/wled00/wled13_cronixie.ino index 6b323214..9f671901 100644 --- a/wled00/wled13_cronixie.ino +++ b/wled00/wled13_cronixie.ino @@ -1,11 +1,23 @@ #ifdef CRONIXIE -void setCronixieMode(char digits[], uint8_t l) +uint8_t getSameCodeLength(char code, int index, char const digits[]) { - hourDigitCount = 0; + uint8_t counter = 0; + + for (int i = index+1; i < 6; i++) + { + if (digits[i] == code) + { + counter++; + } else { + return counter; + } + } + return counter; +} +void setCronixie(char const digits[]) +{ /* - * bool trailingzero[] - * * digit purpose index * 0-9 | 0-9 (incl. random) * 10 | blank @@ -13,7 +25,7 @@ void setCronixieMode(char digits[], uint8_t l) * 12 | test upw. * 13 | test dnw. * 14 | binary AM/PM - * 15 | BB upper + * 15 | BB upper +50 for no trailing 0 * 16 | BBB * 17 | BBBB * 18 | BBBBB @@ -56,7 +68,6 @@ void setCronixieMode(char digits[], uint8_t l) * 55 | vvvv * 56 | vvvvv * 57 | vvvvvv - * 255 | set by previous */ //H HourLower | HH - Hour 24. | AH - Hour 12. | HHH Hour of Month | HHHH Hour of Year @@ -68,25 +79,29 @@ void setCronixieMode(char digits[], uint8_t l) //I MonthLower | II - Month of Year //W Week of Month | WW Week of Year //D Day of Week | DD Day Of Month | DDD Day Of Year + + DEBUG_PRINT("cset "); + DEBUG_PRINTLN(digits); - for (int i = min(5,l); i >= 0; i--) + for (int i = 0; i < 6; i++) { + dP[i] = 10; switch (digits[i]) { - case '-': break; //blank - case '_': break; //blank, bg off - case 'r': break; //random btw. 1-6 - case 'R': break; //random btw. 0-9 + case 'r': dP[i] = random(1,7); break; //random btw. 1-6 + case 'R': dP[i] = random(0,10); break; //random btw. 0-9 case 't': break; //Test upw. case 'T': break; //Test dnw. case 'b': break; case 'B': break; - case 'h': break; - case 'H': break; - case 'm': break; - case 'M': break; - case 's': break; - case 'S': break; + case 'h': dP[i] = 70 + getSameCodeLength('h',i,digits); i = i+dP[i]-70; break; + case 'H': dP[i] = 20 + getSameCodeLength('H',i,digits); i = i+dP[i]-20; break; + case 'A': dP[i] = 108; i++; break; + case 'a': dP[i] = 58; i++; break; + case 'm': dP[i] = 74 + getSameCodeLength('m',i,digits); i = i+dP[i]-74; break; + case 'M': dP[i] = 24 + getSameCodeLength('M',i,digits); i = i+dP[i]-24; break; + case 's': dP[i] = 80 + getSameCodeLength('s',i,digits); i = i+dP[i]-80; break;break; + case 'S': dP[i] = 30 + getSameCodeLength('S',i,digits); i = i+dP[i]-30; break; case 'Y': break; case 'y': break; case 'I': break; //Month. Don't ask me why month and minute both start with M. @@ -95,20 +110,27 @@ void setCronixieMode(char digits[], uint8_t l) case 'w': break; case 'D': break; case 'd': break; - case '0': break; - case '1': break; - case '2': break; - case '3': break; - case '4': break; - case '5': break; - case '6': break; - case '7': break; - case '8': break; - case '9': break; + case '0': dP[i] = 0; break; + case '1': dP[i] = 1; break; + case '2': dP[i] = 2; break; + case '3': dP[i] = 3; break; + case '4': dP[i] = 4; break; + case '5': dP[i] = 5; break; + case '6': dP[i] = 6; break; + case '7': dP[i] = 7; break; + case '8': dP[i] = 8; break; + case '9': dP[i] = 9; break; case 'V': break; //user var0 case 'v': break; //user var1 } } + DEBUG_PRINT("result "); + for (int i = 0; i < 5; i++) + { + DEBUG_PRINT((int)dP[i]); + DEBUG_PRINT(" "); + } + DEBUG_PRINTLN((int)dP[5]); } void handleCronixie() @@ -117,8 +139,47 @@ void handleCronixie() { cronixieRefreshedTime = millis(); local = TZ.toLocal(now(), &tcr); - - strip.setCronixieDigits(); - //cronixieRefreshMs = 99; + uint8_t h = hour(local); + uint8_t m = minute(local); + uint8_t s = second(local); + if (cronixieUseAMPM) + { + if (h>12) h-=12; + else if (h==0) h+=12; + } + byte _digitOut[]{10,10,10,10,10,10}; + for (int i = 0; i < 6; i++) + { + if (dP[i] < 12) _digitOut[i] = dP[i]; + else { + if (dP[i] < 65) + { + switch(dP[i]) + { + case 21: _digitOut[i] = h/10; _digitOut[i+1] = h- _digitOut[i]*10; i++; break; //HH + case 25: _digitOut[i] = m/10; _digitOut[i+1] = m- _digitOut[i]*10; i++; break; //MM + case 31: _digitOut[i] = s/10; _digitOut[i+1] = s- _digitOut[i]*10; i++; break; //SS + } + } else + { + switch(dP[i]) + { + case 71: _digitOut[i] = h/10; _digitOut[i+1] = h- _digitOut[i]*10; if(_digitOut[i] == 0) _digitOut[i]=10; i++; break; //hh + case 75: _digitOut[i] = m/10; _digitOut[i+1] = m- _digitOut[i]*10; if(_digitOut[i] == 0) _digitOut[i]=10; i++; break; //mm + case 81: _digitOut[i] = s/10; _digitOut[i+1] = s- _digitOut[i]*10; if(_digitOut[i] == 0) _digitOut[i]=10; i++; break; //ss + } + } + } + } + DEBUG_PRINT("out "); + for (int i = 0; i < 5; i++) + { + DEBUG_PRINT((int)_digitOut[i]); + DEBUG_PRINT(" "); + } + DEBUG_PRINTLN((int)_digitOut[5]); + strip.setCronixieDigits(_digitOut); + //strip.trigger(); //this has a drawback, no effects slower than RefreshMs. advantage: Quick update, not dependant on effect time + } } #endif