Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
225e66a522
45
usermods/rotary_encoder_change_effect/wled06_usermod.ino
Normal file
45
usermods/rotary_encoder_change_effect/wled06_usermod.ino
Normal file
@ -0,0 +1,45 @@
|
||||
//Use userVar0 and userVar1 (API calls &U0=,&U1=, uint16_t)
|
||||
|
||||
long lastTime = 0;
|
||||
int delayMs = 10;
|
||||
const int pinA = D6; //data
|
||||
const int pinB = D7; //clk
|
||||
int oldA = LOW;
|
||||
|
||||
//gets called once at boot. Do all initialization that doesn't depend on network here
|
||||
void userSetup() {
|
||||
pinMode(pinA, INPUT_PULLUP);
|
||||
pinMode(pinB, INPUT_PULLUP);
|
||||
}
|
||||
|
||||
//gets called every time WiFi is (re-)connected. Initialize own network interfaces here
|
||||
void userConnected() {
|
||||
}
|
||||
|
||||
//loop. You can use "if (WLED_CONNECTED)" to check for successful connection
|
||||
void userLoop() {
|
||||
if (millis()-lastTime > delayMs) {
|
||||
int A = digitalRead(pinA);
|
||||
int B = digitalRead(pinB);
|
||||
|
||||
if (oldA == LOW && A == HIGH) {
|
||||
if (oldB == HIGH) {
|
||||
// bri += 10;
|
||||
// if (bri > 250) bri = 10;
|
||||
effectCurrent += 1;
|
||||
if (effectCurrent >= MODE_COUNT) effectCurrent = 0;
|
||||
}
|
||||
else {
|
||||
// bri -= 10;
|
||||
// if (bri < 10) bri = 250;
|
||||
effectCurrent -= 1;
|
||||
if (effectCurrent < 0) effectCurrent = (MODE_COUNT-1);
|
||||
}
|
||||
oldA = A;
|
||||
|
||||
//call for notifier -> 0: init 1: direct change 2: button 3: notification 4: nightlight 5: other (No notification)
|
||||
// 6: fx changed 7: hue 8: preset cycle 9: blynk 10: alexa
|
||||
colorUpdated(6);
|
||||
lastTime = millis();
|
||||
}
|
||||
}
|
@ -533,11 +533,18 @@ uint16_t WS2812FX::mode_dissolve_random(void) {
|
||||
*/
|
||||
uint16_t WS2812FX::mode_sparkle(void) {
|
||||
for(uint16_t i=SEGMENT.start; i < SEGMENT.stop; i++) {
|
||||
setPixelColor(i, color_from_palette(i, true, PALETTE_SOLID_WRAP, 1));
|
||||
setPixelColor(i, color_from_palette(i, true, PALETTE_SOLID_WRAP, 1));
|
||||
}
|
||||
SEGENV.aux0 = random16(SEGLEN); // aux0 stores the random led index
|
||||
uint32_t cycleTime = 10 + (255 - SEGMENT.speed)*2;
|
||||
uint32_t it = now / cycleTime;
|
||||
if (it != SEGENV.step)
|
||||
{
|
||||
SEGENV.aux0 = random16(SEGLEN); // aux0 stores the random led index
|
||||
SEGENV.step = it;
|
||||
}
|
||||
|
||||
setPixelColor(SEGMENT.start + SEGENV.aux0, SEGCOLOR(0));
|
||||
return 10 + (uint16_t)(255 - SEGMENT.speed);
|
||||
return FRAMETIME;
|
||||
}
|
||||
|
||||
|
||||
@ -546,15 +553,10 @@ uint16_t WS2812FX::mode_sparkle(void) {
|
||||
* Inspired by www.tweaking4all.com/hardware/arduino/adruino-led-strip-effects/
|
||||
*/
|
||||
uint16_t WS2812FX::mode_flash_sparkle(void) {
|
||||
if(SEGENV.call == 0) {
|
||||
for(uint16_t i=SEGMENT.start; i < SEGMENT.stop; i++) {
|
||||
setPixelColor(i, color_from_palette(i, true, PALETTE_SOLID_WRAP, 0));
|
||||
}
|
||||
for(uint16_t i=SEGMENT.start; i < SEGMENT.stop; i++) {
|
||||
setPixelColor(i, color_from_palette(i, true, PALETTE_SOLID_WRAP, 0));
|
||||
}
|
||||
|
||||
uint16_t i = SEGMENT.start + SEGENV.aux0;
|
||||
setPixelColor(i, color_from_palette(i, true, PALETTE_SOLID_WRAP, 0));
|
||||
|
||||
if(random8(5) == 0) {
|
||||
SEGENV.aux0 = random16(SEGLEN); // aux0 stores the random led index
|
||||
setPixelColor(SEGMENT.start + SEGENV.aux0, SEGCOLOR(1));
|
||||
@ -613,7 +615,6 @@ uint16_t WS2812FX::mode_multi_strobe(void) {
|
||||
uint16_t WS2812FX::mode_android(void) {
|
||||
if (SEGENV.call == 0)
|
||||
{
|
||||
SEGENV.aux0 = 0;
|
||||
SEGENV.step = SEGMENT.start;
|
||||
}
|
||||
|
||||
@ -1530,13 +1531,13 @@ uint16_t WS2812FX::mode_palette()
|
||||
}
|
||||
|
||||
bool noWrap = (paletteBlend == 2 || (paletteBlend == 0 && SEGMENT.speed == 0));
|
||||
for (uint16_t i = SEGMENT.start; i < SEGMENT.stop; i++)
|
||||
for (uint16_t i = 0; i < SEGLEN; i++)
|
||||
{
|
||||
uint8_t colorIndex = (i * 255 / SEGLEN) - counter;
|
||||
|
||||
if (noWrap) colorIndex = map(colorIndex, 0, 255, 0, 240); //cut off blend at palette "end"
|
||||
|
||||
setPixelColor(i, color_from_palette(colorIndex, false, true, 255));
|
||||
setPixelColor(SEGMENT.start + i, color_from_palette(colorIndex, false, true, 255));
|
||||
}
|
||||
return FRAMETIME;
|
||||
}
|
||||
@ -2376,6 +2377,20 @@ uint16_t WS2812FX::mode_sinelon(void) {
|
||||
}
|
||||
|
||||
|
||||
//Rainbow with glitter, inspired by https://gist.github.com/kriegsman/062e10f7f07ba8518af6
|
||||
uint16_t WS2812FX::mode_glitter()
|
||||
{
|
||||
mode_palette();
|
||||
|
||||
if (SEGMENT.intensity > random8())
|
||||
{
|
||||
setPixelColor(SEGMENT.start + random16(SEGLEN), ULTRAWHITE);
|
||||
}
|
||||
|
||||
return FRAMETIME;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* POPCORN
|
||||
*/
|
||||
@ -2422,4 +2437,53 @@ uint16_t WS2812FX::mode_popcorn(void) {
|
||||
}
|
||||
|
||||
return SPEED_FORMULA_L;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//values close to 100 produce 5Hz flicker, which looks very candle-y
|
||||
//Inspired by https://github.com/avanhanegem/ArduinoCandleEffectNeoPixel
|
||||
//and https://cpldcpu.wordpress.com/2016/01/05/reverse-engineering-a-real-candle/
|
||||
|
||||
uint16_t WS2812FX::mode_candle()
|
||||
{
|
||||
if (SEGENV.call == 0) {
|
||||
SEGENV.aux0 = 128; SEGENV.aux1 = 132; SEGENV.step = 1;
|
||||
}
|
||||
bool newTarget = false;
|
||||
|
||||
uint8_t s = SEGENV.aux0, target = SEGENV.aux1, fadeStep = SEGENV.step;
|
||||
|
||||
if (target > s) { //fade up
|
||||
s = qadd8(s, fadeStep);
|
||||
if (s >= target) newTarget = true;
|
||||
} else {
|
||||
s = qsub8(s, fadeStep);
|
||||
if (s <= target) newTarget = true;
|
||||
}
|
||||
SEGENV.aux0 = s;
|
||||
|
||||
for (uint16_t i = SEGMENT.start; i < SEGMENT.stop; i++) {
|
||||
setPixelColor(i, color_blend(color_from_palette(i, true, PALETTE_SOLID_WRAP, 0), SEGCOLOR(1), 255-s));
|
||||
}
|
||||
|
||||
if (newTarget)
|
||||
{
|
||||
uint8_t valrange = SEGMENT.intensity;
|
||||
uint8_t rndval = valrange >> 1;
|
||||
target = random8(rndval) + random8(rndval);
|
||||
if (target < (rndval >> 1)) target = (rndval >> 1) + random8(rndval);
|
||||
uint8_t offset = (255 - valrange) >> 1;
|
||||
target += offset;
|
||||
|
||||
uint8_t dif = (target > s) ? target - s : s - target;
|
||||
|
||||
//how much to move closer to target per frame
|
||||
fadeStep = dif >> 2; //mode called every ~25 ms, so 4 frames to have a new target every 100ms
|
||||
if (fadeStep == 0) fadeStep = 1;
|
||||
|
||||
SEGENV.step = fadeStep;
|
||||
SEGENV.aux1 = target;
|
||||
}
|
||||
|
||||
return FRAMETIME;
|
||||
}
|
||||
|
28
wled00/FX.h
28
wled00/FX.h
@ -42,7 +42,7 @@
|
||||
|
||||
/* Not used in all effects yet */
|
||||
#define WLED_FPS 42
|
||||
#define FRAMETIME 1000/WLED_FPS
|
||||
#define FRAMETIME (1000/WLED_FPS)
|
||||
|
||||
/* each segment uses 37 bytes of SRAM memory, so if you're application fails because of
|
||||
insufficient memory, decreasing MAX_NUM_SEGMENTS may help */
|
||||
@ -84,7 +84,7 @@
|
||||
#define IS_REVERSE ((SEGMENT.options & REVERSE ) == REVERSE )
|
||||
#define IS_SELECTED ((SEGMENT.options & SELECTED) == SELECTED )
|
||||
|
||||
#define MODE_COUNT 90
|
||||
#define MODE_COUNT 92
|
||||
|
||||
#define FX_MODE_STATIC 0
|
||||
#define FX_MODE_BLINK 1
|
||||
@ -173,9 +173,11 @@
|
||||
#define FX_MODE_TRI_STATIC_PATTERN 84
|
||||
#define FX_MODE_SPOTS 85
|
||||
#define FX_MODE_SPOTS_FADE 86
|
||||
#define FX_MODE_BOUNCINGBALLS 87
|
||||
#define FX_MODE_SINELON 88
|
||||
#define FX_MODE_POPCORN 89
|
||||
#define FX_MODE_GLITTER 87
|
||||
#define FX_MODE_CANDLE 88
|
||||
#define FX_MODE_BOUNCINGBALLS 89
|
||||
#define FX_MODE_SINELON 90
|
||||
#define FX_MODE_POPCORN 91
|
||||
|
||||
|
||||
class WS2812FX {
|
||||
@ -323,6 +325,8 @@ class WS2812FX {
|
||||
_mode[FX_MODE_BOUNCINGBALLS] = &WS2812FX::mode_BouncingBalls;
|
||||
_mode[FX_MODE_SINELON] = &WS2812FX::mode_sinelon;
|
||||
_mode[FX_MODE_POPCORN] = &WS2812FX::mode_popcorn;
|
||||
_mode[FX_MODE_GLITTER] = &WS2812FX::mode_glitter;
|
||||
_mode[FX_MODE_CANDLE] = &WS2812FX::mode_candle;
|
||||
|
||||
_brightness = DEFAULT_BRIGHTNESS;
|
||||
currentPalette = CRGBPalette16(CRGB::Black);
|
||||
@ -506,7 +510,10 @@ class WS2812FX {
|
||||
mode_spots_fade(void),
|
||||
mode_BouncingBalls(void),
|
||||
mode_sinelon(void),
|
||||
mode_popcorn(void);
|
||||
mode_popcorn(void),
|
||||
mode_glitter(void),
|
||||
mode_candle(void);
|
||||
|
||||
|
||||
private:
|
||||
NeoPixelWrapper *bus;
|
||||
@ -573,13 +580,14 @@ class WS2812FX {
|
||||
const char JSON_mode_names[] PROGMEM = R"=====([
|
||||
"Solid","Blink","Breathe","Wipe","Wipe Random","Random Colors","Sweep","Dynamic","Colorloop","Rainbow",
|
||||
"Scan","Dual Scan","Fade","Theater","Theater Rainbow","Running","Saw","Twinkle","Dissolve","Dissolve Rnd",
|
||||
"Sparkle","Dark Sparkle","Sparkle+","Strobe","Strobe Rainbow","Mega Strobe","Blink Rainbow","Android","Chase","Chase Random",
|
||||
"Sparkle","Sparkle Dark","Sparkle+","Strobe","Strobe Rainbow","Strobe Mega","Blink Rainbow","Android","Chase","Chase Random",
|
||||
"Chase Rainbow","Chase Flash","Chase Flash Rnd","Rainbow Runner","Colorful","Traffic Light","Sweep Random","Running 2","Red & Blue","Stream",
|
||||
"Scanner","Lighthouse","Fireworks","Rain","Merry Christmas","Fire Flicker","Gradient","Loading","Police","Police All",
|
||||
"Two Dots","Two Areas","Circus","Halloween","Tri Chase","Tri Wipe","Tri Fade","Lightning","ICU","Multi Comet",
|
||||
"Dual Scanner","Stream 2","Oscillate","Pride 2015","Juggle","Palette","Fire 2012","Colorwaves","Bpm","Fill Noise",
|
||||
"Noise 1","Noise 2","Noise 3","Noise 4","Colortwinkles","Lake","Meteor","Smooth Meteor","Railway","Ripple",
|
||||
"Twinklefox","Twinklecat","Halloween Eyes","Solid Pattern","Solid Pattern Tri","Spots","Spots Fade","Bouncing Balls", "Sinelon","Popcorn"
|
||||
"Scanner Dual ","Stream 2","Oscillate","Pride 2015","Juggle","Palette","Fire 2012","Colorwaves","Bpm","Fill Noise",
|
||||
"Noise 1","Noise 2","Noise 3","Noise 4","Colortwinkles","Lake","Meteor","Meteor Smooth","Railway","Ripple",
|
||||
"Twinklefox","Twinklecat","Halloween Eyes","Solid Pattern","Solid Pattern Tri","Spots","Spots Fade","Glitter","Candle",
|
||||
"Bouncing Balls", "Sinelon","Popcorn"
|
||||
])=====";
|
||||
|
||||
|
||||
|
@ -711,7 +711,8 @@ void WS2812FX::handle_palette(void)
|
||||
_segment_index_palette_last = _segment_index;
|
||||
|
||||
byte paletteIndex = SEGMENT.palette;
|
||||
if ((SEGMENT.mode >= FX_MODE_METEOR) && SEGMENT.palette == 0) paletteIndex = 4;
|
||||
if (SEGMENT.mode == FX_MODE_GLITTER && paletteIndex == 0) paletteIndex = 11;
|
||||
if (SEGMENT.mode >= FX_MODE_METEOR && paletteIndex == 0) paletteIndex = 4;
|
||||
|
||||
switch (paletteIndex)
|
||||
{
|
||||
@ -725,6 +726,7 @@ void WS2812FX::handle_palette(void)
|
||||
case FX_MODE_NOISE16_2 : targetPalette = gGradientPalettes[30]; break;//Blue cyan yellow
|
||||
case FX_MODE_NOISE16_3 : targetPalette = gGradientPalettes[22]; break;//heat palette
|
||||
case FX_MODE_NOISE16_4 : targetPalette = gGradientPalettes[13]; break;//landscape 33
|
||||
//case FX_MODE_GLITTER : targetPalette = RainbowColors_p; break;
|
||||
|
||||
default: targetPalette = PartyColors_p; break;//palette, bpm
|
||||
}
|
||||
@ -763,7 +765,8 @@ void WS2812FX::handle_palette(void)
|
||||
case 5: {//based on primary + secondary
|
||||
CRGB prim = col_to_crgb(SEGCOLOR(0));
|
||||
CRGB sec = col_to_crgb(SEGCOLOR(1));
|
||||
targetPalette = CRGBPalette16(sec,prim,CRGB::White); break;}
|
||||
CRGB ter = col_to_crgb(SEGCOLOR(2));
|
||||
targetPalette = CRGBPalette16(ter,sec,prim); break;}
|
||||
case 6: //Party colors
|
||||
targetPalette = PartyColors_p; break;
|
||||
case 7: //Cloud colors
|
||||
|
File diff suppressed because one or more lines are too long
@ -23,16 +23,19 @@
|
||||
<script>
|
||||
update();
|
||||
|
||||
var tmout = null;
|
||||
function update()
|
||||
{
|
||||
if (document.hidden) {
|
||||
setTimeout(update, 250);
|
||||
clearTimeout(tmout);
|
||||
tmout = setTimeout(update, 250);
|
||||
return;
|
||||
}
|
||||
fetch('/json/live')
|
||||
.then(res => {
|
||||
if (!res.ok) {
|
||||
setTimeout(update, 2500);
|
||||
clearTimeout(tmout);
|
||||
tmout = setTimeout(update, 2500);
|
||||
}
|
||||
return res.json();
|
||||
})
|
||||
@ -47,10 +50,12 @@
|
||||
}
|
||||
str += ")";
|
||||
document.getElementById("canv").style.background = str;
|
||||
setTimeout(update, 40);
|
||||
clearTimeout(tmout);
|
||||
tmout = setTimeout(update, 40);
|
||||
})
|
||||
.catch(function (error) {
|
||||
setTimeout(update, 2500);
|
||||
clearTimeout(tmout);
|
||||
tmout = setTimeout(update, 2500);
|
||||
})
|
||||
|
||||
}
|
||||
|
@ -104,5 +104,28 @@
|
||||
<i>Clear the token field to disable. </i><a href="https://github.com/Aircoookie/WLED/wiki/Blynk" target="_blank">Setup info</a>
|
||||
<h3>MQTT</h3>
|
||||
Broker: <input name="MS" maxlength="32"><br>
|
||||
唉敳湲浡㩥㰠湩異⁴慮敭∽免呔单剅•慭汸湥瑧㵨㌢∲㰾牢ਾऀऀ慐獳潷摲›椼灮瑵琠灹㵥瀢獡睳牯≤椠灮瑵渠浡㵥䴢呑偔十≓洠硡敬杮桴∽㈳㸢戼㹲
|
||||
䌉楬湥⁴䑉›椼灮瑵渠浡㵥䴢呑䍔䑉•慭汸湥瑧㵨㌢∲㰾牢ਾऀऀ䐀攀瘀椀挀攀 吀漀瀀椀挀㨀 㰀椀渀瀀甀琀 渀愀洀攀㴀∀䴀䐀∀ 洀愀砀氀攀渀最琀栀㴀∀㌀㈀∀㸀㰀戀爀㸀ഀऀऀ䜀爀漀甀瀀 吀漀瀀椀挀㨀 㰀椀渀瀀甀琀 渀愀洀攀㴀∀䴀䜀∀ 洀愀砀氀攀渀最琀栀㴀∀㌀㈀∀㸀㰀戀爀㸀ഀऀऀ㰀愀 栀爀攀昀㴀∀栀琀琀瀀猀㨀⼀⼀最椀琀栀甀戀⸀挀漀洀⼀䄀椀爀挀漀漀漀欀椀攀⼀圀䰀䔀䐀⼀眀椀欀椀⼀䴀儀吀吀∀ 琀愀爀最攀琀㴀∀开戀氀愀渀欀∀㸀䴀儀吀吀 椀渀昀漀㰀⼀愀㸀ഀऀऀ㰀栀㌀㸀倀栀椀氀椀瀀猀 䠀甀攀㰀⼀栀㌀㸀ഀऀऀ㰀椀㸀夀漀甀 挀愀渀 昀椀渀搀 琀栀攀 戀爀椀搀最攀 䤀倀 愀渀搀 琀栀攀 氀椀最栀琀 渀甀洀戀攀爀 椀渀 琀栀攀 ✀䄀戀漀甀琀✀ 猀攀挀琀椀漀渀 漀昀 琀栀攀 栀甀攀 愀瀀瀀⸀㰀⼀椀㸀㰀戀爀㸀ഀऀऀ倀漀氀氀 䠀甀攀 氀椀最栀琀 㰀椀渀瀀甀琀 渀愀洀攀㴀∀䠀䰀∀ 琀礀瀀攀㴀∀渀甀洀戀攀爀∀ 洀椀渀㴀∀∀ 洀愀砀㴀∀㤀㤀∀ 爀攀焀甀椀爀攀搀㸀 攀瘀攀爀礀 㰀椀渀瀀甀琀 渀愀洀攀㴀∀䠀䤀∀ 琀礀瀀攀㴀∀渀甀洀戀攀爀∀ 洀椀渀㴀∀ ∀ 洀愀砀㴀∀㘀㔀 ∀ 爀攀焀甀椀爀攀搀㸀 洀猀㨀 㰀椀渀瀀甀琀 琀礀瀀攀㴀∀挀栀攀挀欀戀漀砀∀ 渀愀洀攀㴀∀䠀倀∀㸀㰀戀爀㸀ഀऀऀ吀栀攀渀Ⰰ 爀攀挀攀椀瘀攀 㰀椀渀瀀甀琀 琀礀瀀攀㴀∀挀栀攀挀欀戀漀砀∀ 渀愀洀攀㴀∀䠀伀∀㸀 伀渀⼀伀昀昀Ⰰ 㰀椀渀瀀甀琀 琀礀瀀攀㴀∀挀栀攀挀欀戀漀砀∀ 渀愀洀攀㴀∀䠀䈀∀㸀 䈀爀椀最栀琀渀攀猀猀Ⰰ 愀渀搀 㰀椀渀瀀甀琀 琀礀瀀攀㴀∀挀栀攀挀欀戀漀砀∀ 渀愀洀攀㴀∀䠀䌀∀㸀 䌀漀氀漀爀㰀戀爀㸀ഀऀऀ䠀甀攀 䈀爀椀搀最攀 䤀倀㨀㰀戀爀㸀ഀऀऀ㰀椀渀瀀甀琀 渀愀洀攀㴀∀䠀 ∀ 琀礀瀀攀㴀∀渀甀洀戀攀爀∀ 洀椀渀㴀∀ ∀ 洀愀砀㴀∀㈀㔀㔀∀ 爀攀焀甀椀爀攀搀㸀 ⸀ഀऀऀ㰀椀渀瀀甀琀 渀愀洀攀㴀∀䠀∀ 琀礀瀀攀㴀∀渀甀洀戀攀爀∀ 洀椀渀㴀∀ ∀ 洀愀砀㴀∀㈀㔀㔀∀ 爀攀焀甀椀爀攀搀㸀 ⸀ഀऀऀ㰀椀渀瀀甀琀 渀愀洀攀㴀∀䠀㈀∀ 琀礀瀀攀㴀∀渀甀洀戀攀爀∀ 洀椀渀㴀∀ ∀ 洀愀砀㴀∀㈀㔀㔀∀ 爀攀焀甀椀爀攀搀㸀 ⸀ഀऀऀ㰀椀渀瀀甀琀 渀愀洀攀㴀∀䠀㌀∀ 琀礀瀀攀㴀∀渀甀洀戀攀爀∀ 洀椀渀㴀∀ ∀ 洀愀砀㴀∀㈀㔀㔀∀ 爀攀焀甀椀爀攀搀㸀㰀戀爀㸀ഀऀऀ㰀戀㸀倀爀攀猀猀 琀栀攀 瀀甀猀栀氀椀渀欀 戀甀琀琀漀渀 漀渀 琀栀攀 戀爀椀搀最攀Ⰰ 愀昀琀攀爀 琀栀愀琀 猀愀瘀攀 琀栀椀猀 瀀愀最攀℀㰀⼀戀㸀㰀戀爀㸀ഀऀऀ⠀眀栀攀渀 昀椀爀猀琀 挀漀渀渀攀挀琀椀渀最⤀㰀戀爀㸀ഀऀऀ㰀℀ⴀⴀ唀瀀搀愀琀攀 䠀甀攀 最爀漀甀瀀 㰀椀渀瀀甀琀 渀愀洀攀㴀∀䠀唀䔀䜀刀∀ 琀礀瀀攀㴀∀渀甀洀戀攀爀∀ 洀椀渀㴀∀ ∀ 洀愀砀㴀∀㤀㤀∀ 爀攀焀甀椀爀攀搀㸀 㰀戀爀㸀ഀऀऀ匀攀渀搀 㰀椀渀瀀甀琀 琀礀瀀攀㴀∀挀栀攀挀欀戀漀砀∀ 渀愀洀攀㴀∀䠀唀䔀䤀伀∀㸀 伀渀⼀伀昀昀Ⰰ 㰀椀渀瀀甀琀 琀礀瀀攀㴀∀挀栀攀挀欀戀漀砀∀ 渀愀洀攀㴀∀䠀唀䔀䈀刀∀㸀 䈀爀椀最栀琀渀攀猀猀Ⰰ 愀渀搀 㰀椀渀瀀甀琀 琀礀瀀攀㴀∀挀栀攀挀欀戀漀砀∀ 渀愀洀攀㴀∀䠀唀䔀䌀䰀∀㸀 䌀漀氀漀爀㰀戀爀㸀ⴀⴀ㸀ഀऀऀ㰀℀ⴀⴀ䄀昀琀攀爀 搀攀瘀椀挀攀 挀漀氀漀爀 甀瀀搀愀琀攀Ⰰ 椀最渀漀爀攀 䠀甀攀 甀瀀搀愀琀攀猀 昀漀爀 㰀椀渀瀀甀琀 渀愀洀攀㴀∀䠀唀䔀䰀䤀∀ 琀礀瀀攀㴀∀渀甀洀戀攀爀∀ 洀椀渀㴀∀ ∀ 洀愀砀㴀∀㈀㔀㔀∀ 爀攀焀甀椀爀攀搀㸀 洀椀渀甀琀攀猀㰀戀爀㸀ⴀⴀ㸀ഀऀऀ䠀甀攀 猀琀愀琀甀猀㨀 㰀猀瀀愀渀 挀氀愀猀猀㴀∀栀洀猀∀㸀 䤀渀琀攀爀渀愀氀 䔀匀倀 䔀爀爀漀爀℀ 㰀⼀猀瀀愀渀㸀㰀栀爀㸀ഀऀऀ㰀戀甀琀琀漀渀 琀礀瀀攀㴀∀戀甀琀琀漀渀∀ 漀渀挀氀椀挀欀㴀∀䈀⠀⤀∀㸀䈀愀挀欀㰀⼀戀甀琀琀漀渀㸀㰀戀甀琀琀漀渀 琀礀瀀攀㴀∀猀甀戀洀椀琀∀㸀匀愀瘀攀㰀⼀戀甀琀琀漀渀㸀ഀऀ㰀⼀昀漀爀洀㸀ഀ㰀⼀戀漀搀礀㸀ഀ㰀⼀栀琀洀氀㸀
|
||||
Username: <input name="MQTTUSER" maxlength="32"><br>
|
||||
Password: <input type="password" input name="MQTTPASS" maxlength="32"><br>
|
||||
Client ID: <input name="MQTTCID" maxlength="32"><br>
|
||||
Device Topic: <input name="MD" maxlength="32"><br>
|
||||
Group Topic: <input name="MG" maxlength="32"><br>
|
||||
<a href="https://github.com/Aircoookie/WLED/wiki/MQTT" target="_blank">MQTT info</a>
|
||||
<h3>Philips Hue</h3>
|
||||
<i>You can find the bridge IP and the light number in the 'About' section of the hue app.</i><br>
|
||||
Poll Hue light <input name="HL" type="number" min="1" max="99" required> every <input name="HI" type="number" min="100" max="65000" required> ms: <input type="checkbox" name="HP"><br>
|
||||
Then, receive <input type="checkbox" name="HO"> On/Off, <input type="checkbox" name="HB"> Brightness, and <input type="checkbox" name="HC"> Color<br>
|
||||
Hue Bridge IP:<br>
|
||||
<input name="H0" type="number" min="0" max="255" required> .
|
||||
<input name="H1" type="number" min="0" max="255" required> .
|
||||
<input name="H2" type="number" min="0" max="255" required> .
|
||||
<input name="H3" type="number" min="0" max="255" required><br>
|
||||
<b>Press the pushlink button on the bridge, after that save this page!</b><br>
|
||||
(when first connecting)<br>
|
||||
<!--Update Hue group <input name="HUEGR" type="number" min="0" max="99" required> <br>
|
||||
Send <input type="checkbox" name="HUEIO"> On/Off, <input type="checkbox" name="HUEBR"> Brightness, and <input type="checkbox" name="HUECL"> Color<br>-->
|
||||
<!--After device color update, ignore Hue updates for <input name="HUELI" type="number" min="0" max="255" required> minutes<br>-->
|
||||
Hue status: <span class="hms"> Internal ESP Error! </span><hr>
|
||||
<button type="button" onclick="B()">Back</button><button type="submit">Save</button>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
@ -20,7 +20,7 @@ const char PAGE_msg[] PROGMEM = R"=====(<!DOCTYPE html>
|
||||
const char PAGE_update[] PROGMEM = R"=====(<!DOCTYPE html>
|
||||
<html><head><meta content='width=device-width' name='viewport'><title>WLED Update</title><script>function B(){window.history.back()}</script>
|
||||
<style>.bt{background:#333;color:#fff;font-family:Verdana,sans-serif;border:.3ch solid #333;display:inline-block;font-size:20px;margin:8px;margin-top:12px}input[type=file]{font-size:16px}body{font-family:Verdana,sans-serif;text-align:center;background:#222;color:#fff;line-height:200%}</style></head>
|
||||
<body><h2>WLED Software Update</h2>Installed version: 0.9.0-dev<br>Download the latest binary: <a href="https://github.com/Aircoookie/WLED/releases"><img src="https://img.shields.io/github/release/Aircoookie/WLED.svg?style=flat-square"></a><br><form method='POST' action='/update' enctype='multipart/form-data'><input type='file' class="bt" name='update' required><br><input type='submit' class="bt" value='Update!'></form><button type="button" class="bt" onclick="B()">Back</button></body></html>)=====";
|
||||
<body><h2>WLED Software Update</h2>Installed version: 0.9.0-b1<br>Download the latest binary: <a href="https://github.com/Aircoookie/WLED/releases"><img src="https://img.shields.io/github/release/Aircoookie/WLED.svg?style=flat-square"></a><br><form method='POST' action='/update' enctype='multipart/form-data'><input type='file' class="bt" name='update' required><br><input type='submit' class="bt" value='Update!'></form><button type="button" class="bt" onclick="B()">Back</button></body></html>)=====";
|
||||
|
||||
|
||||
//new user welcome page
|
||||
@ -36,14 +36,50 @@ const char PAGE_liveview[] PROGMEM = R"=====(<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<meta name=theme-color content=#222222>
|
||||
<title>WLED Live Preview</title>
|
||||
<style>body{margin:0}#canv{background:black;filter:brightness(175%);width:100%;height:100%;position:absolute}</style>
|
||||
</head>
|
||||
<body><div id=canv />
|
||||
<script>update();function update()
|
||||
{if(document.hidden){setTimeout(update,250);return;}
|
||||
fetch('/json/live').then(res=>{if(!res.ok){setTimeout(update,2500);}
|
||||
return res.json();}).then(json=>{var str="linear-gradient(90deg,";var len=json.leds.length;for(i=0;i<len;i++){var leddata=json.leds[i];if(leddata.length>6)leddata=leddata.substring(2);str+="#"+leddata;if(i<len-1)str+=","}
|
||||
str+=")";document.getElementById("canv").style.background=str;setTimeout(update,40);}).catch(function(error){setTimeout(update,2500);})}</script>
|
||||
<style>
|
||||
body {margin: 0;}
|
||||
#canv {background: black;filter: brightness(175%);width: 100%;height: 100%;position: absolute;}
|
||||
</style></head>
|
||||
<body>
|
||||
<div id="canv" />
|
||||
<script>
|
||||
update();
|
||||
var tmout = null;
|
||||
function update()
|
||||
{
|
||||
if (document.hidden) {
|
||||
clearTimeout(tmout);
|
||||
tmout = setTimeout(update, 250);
|
||||
return;
|
||||
}
|
||||
fetch('/json/live')
|
||||
.then(res => {
|
||||
if (!res.ok) {
|
||||
clearTimeout(tmout);
|
||||
tmout = setTimeout(update, 2500);
|
||||
}
|
||||
return res.json();
|
||||
})
|
||||
.then(json => {
|
||||
var str = "linear-gradient(90deg,";
|
||||
var len = json.leds.length;
|
||||
for (i = 0; i < len; i++) {
|
||||
var leddata = json.leds[i];
|
||||
if (leddata.length > 6) leddata = leddata.substring(2);
|
||||
str += "#" + leddata;
|
||||
if (i < len -1) str += ","
|
||||
}
|
||||
str += ")";
|
||||
document.getElementById("canv").style.background = str;
|
||||
clearTimeout(tmout);
|
||||
tmout = setTimeout(update, 40);
|
||||
})
|
||||
.catch(function (error) {
|
||||
clearTimeout(tmout);
|
||||
tmout = setTimeout(update, 2500);
|
||||
})
|
||||
}
|
||||
</script>
|
||||
</body></html>)=====";
|
||||
|
||||
|
||||
|
@ -121,7 +121,7 @@ Color order:
|
||||
<select name=CO>
|
||||
<option value=0>GRB</option>
|
||||
<option value=1>RGB</option>
|
||||
<option value=2 disabled>BRG</option>
|
||||
<option value=2>BRG</option>
|
||||
<option value=3>RBG</option>
|
||||
</select>
|
||||
<h3>Defaults</h3>
|
||||
@ -287,7 +287,7 @@ Clock Overlay:
|
||||
<select name="OL" onchange="Cs()">
|
||||
<option value="0" id="cn" selected>None</option>
|
||||
<option value="1" id="ca">Analog Clock</option>
|
||||
<option value="2">Single Digit Clock</option>
|
||||
<option value="2" disabled>-</option>
|
||||
<option value="3" id="cc">Cronixie Clock</option>
|
||||
</select><br>
|
||||
<div id="coc">
|
||||
@ -365,7 +365,7 @@ HTTP traffic is unencrypted. An attacker in the same network can intercept form
|
||||
<button type="button" onclick="U()">Manual OTA Update</button><br>
|
||||
Enable ArduinoOTA: <input type="checkbox" name="AO"><br>
|
||||
<h3>About</h3>
|
||||
<a href="https://github.com/Aircoookie/WLED" target="_blank">WLED</a> version 0.9.0-dev<br><br>
|
||||
<a href="https://github.com/Aircoookie/WLED" target="_blank">WLED</a> version 0.9.0-b1<br><br>
|
||||
<a href="https://github.com/Aircoookie/WLED/wiki/Contributors-&-About" target="_blank">Contributors, dependencies and special thanks</a><br>
|
||||
A huge thank you to everyone who helped me create WLED!<br><br>
|
||||
(c) 2016-2019 Christian Schwinne <br>
|
||||
|
2900
wled00/html_ui.h
2900
wled00/html_ui.h
File diff suppressed because it is too large
Load Diff
@ -3,7 +3,7 @@
|
||||
*/
|
||||
/*
|
||||
* @title WLED project sketch
|
||||
* @version 0.9.0-dev
|
||||
* @version 0.9.0-b1
|
||||
* @author Christian Schwinne
|
||||
*/
|
||||
|
||||
@ -14,15 +14,16 @@
|
||||
//Uncomment some of the following lines to disable features to compile for ESP8266-01 (max flash size 434kB):
|
||||
|
||||
//You are required to disable over-the-air updates:
|
||||
//#define WLED_DISABLE_OTA
|
||||
//#define WLED_DISABLE_OTA //saves 14kb
|
||||
|
||||
//You need to choose some of these features to disable:
|
||||
//#define WLED_DISABLE_ALEXA
|
||||
//#define WLED_DISABLE_BLYNK
|
||||
//#define WLED_DISABLE_CRONIXIE
|
||||
//#define WLED_DISABLE_HUESYNC
|
||||
//#define WLED_DISABLE_INFRARED //there is no pin left for this on ESP8266-01
|
||||
#define WLED_ENABLE_ADALIGHT //only saves about 500b
|
||||
//#define WLED_DISABLE_ALEXA //saves 11kb
|
||||
//#define WLED_DISABLE_BLYNK //saves 6kb
|
||||
//#define WLED_DISABLE_CRONIXIE //saves 3kb
|
||||
//#define WLED_DISABLE_HUESYNC //saves 4kb
|
||||
//#define WLED_DISABLE_INFRARED //there is no pin left for this on ESP8266-01, saves 25kb (!)
|
||||
#define WLED_ENABLE_MQTT //saves 12kb
|
||||
#define WLED_ENABLE_ADALIGHT //saves 500b only
|
||||
|
||||
#define WLED_DISABLE_FILESYSTEM //SPIFFS is not used by any WLED feature yet
|
||||
//#define WLED_ENABLE_FS_SERVING //Enable sending html file from SPIFFS before serving progmem version
|
||||
@ -97,8 +98,8 @@
|
||||
|
||||
|
||||
//version code in format yymmddb (b = daily build)
|
||||
#define VERSION 1912051
|
||||
char versionString[] = "0.9.0-dev";
|
||||
#define VERSION 1912111
|
||||
char versionString[] = "0.9.0-b1";
|
||||
|
||||
|
||||
//AP and OTA default passwords (for maximum change them!)
|
||||
@ -328,11 +329,6 @@ byte overlayCurrent = overlayDefault;
|
||||
byte overlaySpeed = 200;
|
||||
unsigned long overlayRefreshMs = 200;
|
||||
unsigned long overlayRefreshedTime;
|
||||
int overlayArr[6];
|
||||
uint16_t overlayDur[6];
|
||||
uint16_t overlayPauseDur[6];
|
||||
int nixieClockI = -1;
|
||||
bool nixiePause = false;
|
||||
|
||||
//cronixie
|
||||
byte dP[]{0,0,0,0,0,0};
|
||||
@ -482,7 +478,7 @@ void reset()
|
||||
|
||||
|
||||
//append new c string to temp buffer efficiently
|
||||
bool oappend(char* txt)
|
||||
bool oappend(const char* txt)
|
||||
{
|
||||
uint16_t len = strlen(txt);
|
||||
if (olen + len >= OMAX) return false; //buffer full
|
||||
|
@ -495,6 +495,7 @@ void loadSettingsFromEEPROM(bool first)
|
||||
//1024-2047 reserved
|
||||
|
||||
readStringFromEEPROM(2220, blynkApiKey, 35);
|
||||
if (strlen(blynkApiKey) < 25) blynkApiKey[0] = 0;
|
||||
|
||||
//user MOD memory
|
||||
//2944 - 3071 reserved
|
||||
|
@ -82,7 +82,7 @@ char* XML_response(AsyncWebServerRequest *request, char* dest = nullptr)
|
||||
}
|
||||
|
||||
//append a numeric setting to string buffer
|
||||
void sappend(char stype, char* key, int val)
|
||||
void sappend(char stype, const char* key, int val)
|
||||
{
|
||||
char ds[] = "d.Sf.";
|
||||
|
||||
@ -113,7 +113,7 @@ void sappend(char stype, char* key, int val)
|
||||
}
|
||||
|
||||
//append a string setting to buffer
|
||||
void sappends(char stype, char* key, char* val)
|
||||
void sappends(char stype, const char* key, char* val)
|
||||
{
|
||||
switch(stype)
|
||||
{
|
||||
@ -269,6 +269,8 @@ void getSettingsJS(byte subPage, char* dest)
|
||||
sappends('s',"AI",alexaInvocationName);
|
||||
sappend('c',"SA",notifyAlexa);
|
||||
sappends('s',"BK",(char*)((blynkEnabled)?"Hidden":""));
|
||||
|
||||
#ifdef WLED_ENABLE_MQTT
|
||||
sappends('s',"MS",mqttServer);
|
||||
sappend('v',"MQPORT",mqttPort);
|
||||
sappends('s',"MQUSER",mqttUser);
|
||||
@ -281,6 +283,11 @@ void getSettingsJS(byte subPage, char* dest)
|
||||
sappends('s',"MQCID",mqttClientID);
|
||||
sappends('s',"MD",mqttDeviceTopic);
|
||||
sappends('s',"MG",mqttGroupTopic);
|
||||
#endif
|
||||
|
||||
#ifdef WLED_DISABLE_HUESYNC
|
||||
sappends('m',"(\"hms\")[0]","Unsupported in build");
|
||||
#else
|
||||
sappend('v',"H0",hueIP[0]);
|
||||
sappend('v',"H1",hueIP[1]);
|
||||
sappend('v',"H2",hueIP[2]);
|
||||
@ -292,6 +299,7 @@ void getSettingsJS(byte subPage, char* dest)
|
||||
sappend('c',"HB",hueApplyBri);
|
||||
sappend('c',"HC",hueApplyColor);
|
||||
sappends('m',"(\"hms\")[0]",hueError);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (subPage == 5)
|
||||
|
@ -14,6 +14,16 @@ void _setRandomColor(bool _sec,bool fromButton=false)
|
||||
}
|
||||
|
||||
|
||||
bool isAsterisksOnly(const char* str, byte maxLen)
|
||||
{
|
||||
for (byte i = 0; i < maxLen; i++) {
|
||||
if (str[i] == 0) break;
|
||||
if (str[i] != '*') return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//called upon POST settings form submit
|
||||
void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
|
||||
{
|
||||
@ -24,7 +34,8 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
|
||||
if (subPage == 1)
|
||||
{
|
||||
strlcpy(clientSSID,request->arg("CS").c_str(), 33);
|
||||
if (request->arg("CP").charAt(0) != '*') strlcpy(clientPass, request->arg("CP").c_str(), 65);
|
||||
|
||||
if (!isAsterisksOnly(request->arg("CP").c_str(), 65)) strlcpy(clientPass, request->arg("CP").c_str(), 65);
|
||||
|
||||
strlcpy(cmDNS, request->arg("CM").c_str(), 33);
|
||||
|
||||
@ -32,7 +43,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
|
||||
strlcpy(apSSID, request->arg("AS").c_str(), 33);
|
||||
apHide = request->hasArg("AH");
|
||||
int passlen = request->arg("AP").length();
|
||||
if (passlen == 0 || (passlen > 7 && request->arg("AP").charAt(0) != '*')) strlcpy(apPass, request->arg("AP").c_str(), 65);
|
||||
if (passlen == 0 || (passlen > 7 && !isAsterisksOnly(request->arg("AP").c_str(), 65))) strlcpy(apPass, request->arg("AP").c_str(), 65);
|
||||
int t = request->arg("AC").toInt(); if (t > 0 && t < 14) apChannel = t;
|
||||
|
||||
char k[3]; k[2] = 0;
|
||||
@ -141,15 +152,18 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
|
||||
strlcpy(blynkApiKey, request->arg("BK").c_str(), 36); initBlynk(blynkApiKey);
|
||||
}
|
||||
|
||||
#ifdef WLED_ENABLE_MQTT
|
||||
strlcpy(mqttServer, request->arg("MS").c_str(), 33);
|
||||
t = request->arg("MQPORT").toInt();
|
||||
if (t > 0) mqttPort = t;
|
||||
strlcpy(mqttUser, request->arg("MQUSER").c_str(), 41);
|
||||
if (request->arg("MQPASS").charAt(0) != '*') strlcpy(mqttPass, request->arg("MQPASS").c_str(), 41);
|
||||
if (!isAsterisksOnly(request->arg("MQPASS").c_str(), 41)) strlcpy(mqttPass, request->arg("MQPASS").c_str(), 41);
|
||||
strlcpy(mqttClientID, request->arg("MQCID").c_str(), 41);
|
||||
strlcpy(mqttDeviceTopic, request->arg("MD").c_str(), 33);
|
||||
strlcpy(mqttGroupTopic, request->arg("MG").c_str(), 33);
|
||||
#endif
|
||||
|
||||
#ifndef WLED_DISABLE_HUESYNC
|
||||
for (int i=0;i<4;i++){
|
||||
String a = "H"+String(i);
|
||||
hueIP[i] = request->arg(a).toInt();
|
||||
@ -167,6 +181,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
|
||||
huePollingEnabled = request->hasArg("HP");
|
||||
hueStoreAllowed = true;
|
||||
reconnectHue();
|
||||
#endif
|
||||
}
|
||||
|
||||
//TIME
|
||||
|
@ -140,7 +140,10 @@ void initAP(bool resetAP=false){
|
||||
if (udpPort > 0 && udpPort != ntpLocalPort)
|
||||
{
|
||||
udpConnected = notifierUdp.begin(udpPort);
|
||||
if (udpConnected && udpRgbPort != udpPort) udpRgbConnected = rgbUdp.begin(udpRgbPort);
|
||||
}
|
||||
if (udpRgbPort > 0 && udpRgbPort != ntpLocalPort && udpRgbPort != udpPort)
|
||||
{
|
||||
udpRgbConnected = rgbUdp.begin(udpRgbPort);
|
||||
}
|
||||
|
||||
dnsServer.setErrorReplyCode(DNSReplyCode::NoError);
|
||||
@ -231,7 +234,7 @@ void initInterfaces() {
|
||||
if (ntpEnabled) ntpConnected = ntpUdp.begin(ntpLocalPort);
|
||||
|
||||
initBlynk(blynkApiKey);
|
||||
Serial.println(e131.begin((e131Multicast) ? E131_MULTICAST : E131_UNICAST , e131Universe, E131_MAX_UNIVERSE_COUNT));
|
||||
e131.begin((e131Multicast) ? E131_MULTICAST : E131_UNICAST , e131Universe, E131_MAX_UNIVERSE_COUNT);
|
||||
reconnectHue();
|
||||
initMqtt();
|
||||
interfacesInited = true;
|
||||
@ -239,11 +242,25 @@ void initInterfaces() {
|
||||
}
|
||||
|
||||
byte stacO = 0;
|
||||
uint32_t lastHeap;
|
||||
unsigned long heapTime = 0;
|
||||
|
||||
void handleConnection() {
|
||||
//TODO: reconnect if heap <8000
|
||||
if (millis() < 2000 && (!WLED_WIFI_CONFIGURED || apBehavior == 2)) return;
|
||||
if (lastReconnectAttempt == 0) initConnection();
|
||||
|
||||
//reconnect WiFi to clear stale allocations if heap gets too low
|
||||
if (millis() - heapTime > 5000)
|
||||
{
|
||||
uint32_t heap = ESP.getFreeHeap();
|
||||
if (heap < 9000 && lastHeap < 9000) {
|
||||
DEBUG_PRINT("Heap too low! ");
|
||||
DEBUG_PRINTLN(heap);
|
||||
forceReconnect = true;
|
||||
}
|
||||
lastHeap = heap;
|
||||
heapTime = millis();
|
||||
}
|
||||
|
||||
byte stac = 0;
|
||||
if (apActive) {
|
||||
|
@ -120,7 +120,6 @@ void handleNotifications()
|
||||
{
|
||||
e131NewData = false;
|
||||
strip.show();
|
||||
Serial.println("Show");
|
||||
}
|
||||
|
||||
//unlock strip when realtime UDP times out
|
||||
|
@ -17,107 +17,6 @@ void initCronixie()
|
||||
}
|
||||
|
||||
|
||||
void _nixieDisplay(int num[], uint16_t dur[], uint16_t pausedur[], byte cnt)
|
||||
{
|
||||
strip.setRange(overlayMin, overlayMax, 0);
|
||||
if (num[nixieClockI] >= 0 && !nixiePause)
|
||||
{
|
||||
strip.setIndividual(num[nixieClockI],((uint32_t)colT[3] << 24)| ((uint32_t)colT[0] << 16) | ((uint32_t)colT[1] << 8) | colT[2]);
|
||||
strip.unlock(num[nixieClockI]);
|
||||
}
|
||||
if (!nixiePause)
|
||||
{
|
||||
overlayRefreshMs = dur[nixieClockI];
|
||||
} else
|
||||
{
|
||||
overlayRefreshMs = pausedur[nixieClockI];
|
||||
}
|
||||
if (pausedur[nixieClockI] > 0 && !nixiePause)
|
||||
{
|
||||
nixiePause = true;
|
||||
} else {
|
||||
if (nixieClockI < cnt -1)
|
||||
{
|
||||
nixieClockI++;
|
||||
} else
|
||||
{
|
||||
nixieClockI = -1;
|
||||
}
|
||||
nixiePause = false;
|
||||
}
|
||||
}
|
||||
|
||||
void _nixieNumber(int number, int dur)
|
||||
{
|
||||
if (nixieClockI < 0)
|
||||
{
|
||||
DEBUG_PRINT(number);
|
||||
int digitCnt = -1;
|
||||
int digits[4];
|
||||
digits[3] = number/1000;
|
||||
digits[2] = (number/100)%10;
|
||||
digits[1] = (number/10)%10;
|
||||
digits[0] = number%10;
|
||||
if (number > 999) //four digits
|
||||
{
|
||||
digitCnt = 4;
|
||||
} else if (number > 99) //three digits
|
||||
{
|
||||
digitCnt = 3;
|
||||
} else if (number > 9) //two digits
|
||||
{
|
||||
digitCnt = 2;
|
||||
} else { //single digit
|
||||
digitCnt = 1;
|
||||
}
|
||||
DEBUG_PRINT(" ");
|
||||
for (int i = 0; i < digitCnt; i++)
|
||||
{
|
||||
DEBUG_PRINT(digits[i]);
|
||||
overlayArr[digitCnt-1-i] = digits[i];
|
||||
overlayDur[digitCnt-1-i] = ((dur/4)*3)/digitCnt;
|
||||
overlayPauseDur[digitCnt-1-i] = 0;
|
||||
}
|
||||
DEBUG_PRINTLN(" ");
|
||||
for (int i = 1; i < digitCnt; i++)
|
||||
{
|
||||
if (overlayArr[i] == overlayArr[i-1])
|
||||
{
|
||||
overlayPauseDur[i-1] = dur/12;
|
||||
overlayDur[i-1] = overlayDur[i-1]-dur/12;
|
||||
}
|
||||
}
|
||||
for (int i = digitCnt; i < 6; i++)
|
||||
{
|
||||
overlayArr[i] = -1;
|
||||
overlayDur[i] = 0;
|
||||
overlayPauseDur[i] = 0;
|
||||
}
|
||||
overlayPauseDur[5] = dur/4;
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
if (overlayArr[i] != -1)
|
||||
{
|
||||
overlayArr[i] = overlayArr[i] + overlayMin;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i <6; i++)
|
||||
{
|
||||
DEBUG_PRINT(overlayArr[i]);
|
||||
DEBUG_PRINT(" ");
|
||||
DEBUG_PRINT(overlayDur[i]);
|
||||
DEBUG_PRINT(" ");
|
||||
DEBUG_PRINT(overlayPauseDur[i]);
|
||||
DEBUG_PRINT(" ");
|
||||
}
|
||||
DEBUG_PRINTLN(" ");
|
||||
nixieClockI = 0;
|
||||
} else {
|
||||
_nixieDisplay(overlayArr, overlayDur, overlayPauseDur, 6);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void handleOverlays()
|
||||
{
|
||||
if (millis() - overlayRefreshedTime > overlayRefreshMs)
|
||||
@ -129,14 +28,15 @@ void handleOverlays()
|
||||
{
|
||||
case 0: break;//no overlay
|
||||
case 1: _overlayAnalogClock(); break;//2 analog clock
|
||||
case 2: _overlayNixieClock(); break;//nixie 1-digit
|
||||
case 2: break;//nixie 1-digit, removed
|
||||
case 3: _overlayCronixie();//Diamex cronixie clock kit
|
||||
}
|
||||
if (!countdownMode || overlayCurrent < 2) checkCountdown(); //countdown macro activation must work
|
||||
if (!countdownMode || overlayCurrent < 3) checkCountdown(); //countdown macro activation must work
|
||||
overlayRefreshedTime = millis();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void _overlayAnalogClock()
|
||||
{
|
||||
int overlaySize = overlayMax - overlayMin +1;
|
||||
@ -182,98 +82,6 @@ void _overlayAnalogClock()
|
||||
overlayRefreshMs = 998;
|
||||
}
|
||||
|
||||
void _overlayNixieClock()
|
||||
{
|
||||
#ifdef WLED_DISABLE_CRONIXIE
|
||||
if (countdownMode) checkCountdown();
|
||||
#else
|
||||
|
||||
if (countdownMode)
|
||||
{
|
||||
_overlayNixieCountdown(); return;
|
||||
}
|
||||
if (nixieClockI < 0)
|
||||
{
|
||||
overlayArr[0] = hour(local);
|
||||
if (useAMPM) overlayArr[0] = overlayArr[0]%12;
|
||||
overlayArr[1] = -1;
|
||||
if (overlayArr[0] > 9)
|
||||
{
|
||||
overlayArr[1] = overlayArr[0]%10;
|
||||
overlayArr[0] = overlayArr[0]/10;
|
||||
}
|
||||
overlayArr[2] = minute(local);
|
||||
overlayArr[3] = overlayArr[2]%10;
|
||||
overlayArr[2] = overlayArr[2]/10;
|
||||
overlayArr[4] = -1;
|
||||
overlayArr[5] = -1;
|
||||
if (analogClockSecondsTrail)
|
||||
{
|
||||
overlayArr[4] = second(local);
|
||||
overlayArr[5] = overlayArr[4]%10;
|
||||
overlayArr[4] = overlayArr[4]/10;
|
||||
}
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
if (overlayArr[i] != -1)
|
||||
{
|
||||
overlayArr[i] = overlayArr[i] + overlayMin;
|
||||
}
|
||||
}
|
||||
overlayDur[0] = 12 + 12*(255 - overlaySpeed);
|
||||
if (overlayArr[1] == overlayArr[0])
|
||||
{
|
||||
overlayPauseDur[0] = 3 + 3*(255 - overlaySpeed);
|
||||
} else
|
||||
{
|
||||
overlayPauseDur[0] = 0;
|
||||
}
|
||||
if (overlayArr[1] == -1)
|
||||
{
|
||||
overlayDur[1] = 0;
|
||||
} else
|
||||
{
|
||||
overlayDur[1] = 12 + 12*(255 - overlaySpeed);
|
||||
}
|
||||
overlayPauseDur[1] = 9 + 9*(255 - overlaySpeed);
|
||||
|
||||
overlayDur[2] = 12 + 12*(255 - overlaySpeed);
|
||||
if (overlayArr[2] == overlayArr[3])
|
||||
{
|
||||
overlayPauseDur[2] = 3 + 3*(255 - overlaySpeed);
|
||||
} else
|
||||
{
|
||||
overlayPauseDur[2] = 0;
|
||||
}
|
||||
overlayDur[3] = 12 + 12*(255 - overlaySpeed);
|
||||
overlayPauseDur[3] = 9 + 9*(255 - overlaySpeed);
|
||||
|
||||
if (overlayArr[4] == -1)
|
||||
{
|
||||
overlayDur[4] = 0;
|
||||
overlayPauseDur[4] = 0;
|
||||
overlayDur[5] = 0;
|
||||
} else
|
||||
{
|
||||
overlayDur[4] = 12 + 12*(255 - overlaySpeed);
|
||||
if (overlayArr[5] == overlayArr[4])
|
||||
{
|
||||
overlayPauseDur[4] = 3 + 3*(255 - overlaySpeed);
|
||||
} else
|
||||
{
|
||||
overlayPauseDur[4] = 0;
|
||||
}
|
||||
overlayDur[5] = 12 + 12*(255 - overlaySpeed);
|
||||
}
|
||||
overlayPauseDur[5] = 22 + 22*(255 - overlaySpeed);
|
||||
|
||||
nixieClockI = 0;
|
||||
} else
|
||||
{
|
||||
_nixieDisplay(overlayArr, overlayDur, overlayPauseDur, 6);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void _overlayAnalogCountdown()
|
||||
{
|
||||
@ -319,33 +127,3 @@ void _overlayAnalogCountdown()
|
||||
}
|
||||
overlayRefreshMs = 998;
|
||||
}
|
||||
|
||||
|
||||
void _overlayNixieCountdown()
|
||||
{
|
||||
if (now() >= countdownTime)
|
||||
{
|
||||
if (checkCountdown())
|
||||
{
|
||||
_nixieNumber(2019, 2019);
|
||||
}
|
||||
} else
|
||||
{
|
||||
long diff = countdownTime - now();
|
||||
if (diff > 86313600L) //display in years if more than 999 days
|
||||
{
|
||||
diff = diff/31557600L;
|
||||
} else if (diff > 3596400) //display in days if more than 999 hours
|
||||
{
|
||||
diff = diff/86400;
|
||||
} else if (diff > 59940) //display in hours if more than 999 minutes
|
||||
{
|
||||
diff = diff/1440;
|
||||
} else if (diff > 999) //display in minutes if more than 999 seconds
|
||||
{
|
||||
diff = diff/60;
|
||||
}
|
||||
_nixieNumber(diff, 800);
|
||||
}
|
||||
overlayRefreshMs = 998;
|
||||
}
|
||||
|
@ -2,6 +2,8 @@
|
||||
* MQTT communication protocol for home automation
|
||||
*/
|
||||
|
||||
#ifdef WLED_ENABLE_MQTT
|
||||
|
||||
void parseMQTTBriPayload(char* payload)
|
||||
{
|
||||
if (strstr(payload, "ON") || strstr(payload, "on") || strstr(payload, "true")) {bri = briLast; colorUpdated(1);}
|
||||
@ -130,3 +132,8 @@ bool initMqtt()
|
||||
mqtt->connect();
|
||||
return true;
|
||||
}
|
||||
|
||||
#else
|
||||
bool initMqtt(){return false;}
|
||||
void publishMqtt(){}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user