From 2fdbc88d8c597772fe42914b46270344ffbb1178 Mon Sep 17 00:00:00 2001 From: Blaz Kristan Date: Sun, 23 May 2021 01:11:35 +0200 Subject: [PATCH] Bugfixes. - PWM bus not loading on boot - analog 0 not turning Off - conditional compile for Blynk - segment name --- wled00/blynk.cpp | 2 + wled00/bus_manager.h | 4 +- wled00/button.cpp | 5 +- wled00/cfg.cpp | 3 +- wled00/data/index.css | 2 +- wled00/data/index.js | 5 +- wled00/data/settings_leds.htm | 59 +- wled00/fcn_declare.h | 2 + wled00/html_settings.h | 2 +- wled00/html_ui.h | 3274 ++++++++++++++++----------------- wled00/led.cpp | 4 + wled00/wled.cpp | 55 +- wled00/wled.h | 3 +- 13 files changed, 1697 insertions(+), 1723 deletions(-) diff --git a/wled00/blynk.cpp b/wled00/blynk.cpp index ef53ca9b2..f74b5012d 100644 --- a/wled00/blynk.cpp +++ b/wled00/blynk.cpp @@ -1,5 +1,7 @@ #include "wled.h" +#ifndef WLED_DISABLE_BLYNK #include "src/dependencies/blynk/Blynk/BlynkHandlers.h" +#endif /* * Remote light control with the free Blynk app diff --git a/wled00/bus_manager.h b/wled00/bus_manager.h index b6f6b101e..68cf35446 100644 --- a/wled00/bus_manager.h +++ b/wled00/bus_manager.h @@ -239,7 +239,9 @@ class BusPwm : public Bus { for (uint8_t i = 0; i < numPins; i++) { _pins[i] = bc.pins[i]; if (!pinManager.allocatePin(_pins[i])) { - _pins[i] = 255; return; + _pins[i] = 255; + deallocatePins(); + return; } #ifdef ESP8266 pinMode(_pins[i], OUTPUT); diff --git a/wled00/button.cpp b/wled00/button.cpp index ced017815..7016a4fe4 100644 --- a/wled00/button.cpp +++ b/wled00/button.cpp @@ -84,7 +84,10 @@ void handleAnalog(uint8_t b) // if "double press" macro is 250 or greater use global brightness if (macroDoublePress[b]>=250) { // if change in analog read was detected change global brightness - bri = aRead; + if (aRead == 0) + toggleOnOff(); + else + bri = aRead; } else { // otherwise use "double press" for segment selection //uint8_t mainSeg = strip.getMainSegmentId(); diff --git a/wled00/cfg.cpp b/wled00/cfg.cpp index c9e0b13b4..bb7f33c7e 100644 --- a/wled00/cfg.cpp +++ b/wled00/cfg.cpp @@ -104,7 +104,7 @@ bool deserializeConfig(JsonObject doc, bool fromFS) { uint16_t length = elm[F("len")]; if (length==0 || length+lC > MAX_LEDS) continue; // zero length or we reached max. number of LEDs, just stop uint16_t start = elm[F("start")] | 0; - if (start >= lC+length) continue; // something is very wrong :) + if (start > lC+length) continue; // something is very wrong :) uint8_t colorOrder = elm[F("order")]; uint8_t skipFirst = elm[F("skip")]; uint8_t ledType = elm["type"] | TYPE_WS2812_RGB; @@ -117,7 +117,6 @@ bool deserializeConfig(JsonObject doc, bool fromFS) { if (mem <= MAX_LED_MEMORY && busses.getNumBusses() <= WLED_MAX_BUSSES) busses.add(bc); // finalization will be done in WLED::beginStrip() } // finalization done in beginStrip() - //strip.finalizeInit(); } if (lC > ledCount) ledCount = lC; // fix incorrect total length (honour analog setup) diff --git a/wled00/data/index.css b/wled00/data/index.css index 2be56d25a..ab8d7b0bf 100644 --- a/wled00/data/index.css +++ b/wled00/data/index.css @@ -1033,7 +1033,7 @@ input[type="text"].fnd:not(:placeholder-shown) { } .segin { - padding: 8px 8px 4px 8px; + padding: 4px 8px 4px 8px; display: none; /*margin: 24px 0 0;*/ } diff --git a/wled00/data/index.js b/wled00/data/index.js index fc7d0e4c7..bf06beb26 100644 --- a/wled00/data/index.js +++ b/wled00/data/index.js @@ -1241,11 +1241,8 @@ function makeSeg() if (pend < ledCount) ns = pend; } var cn = `
-
- New segment ${lowestUnused} -
-
+
diff --git a/wled00/data/settings_leds.htm b/wled00/data/settings_leds.htm index 94ab99f3f..684b0d35d 100644 --- a/wled00/data/settings_leds.htm +++ b/wled00/data/settings_leds.htm @@ -26,14 +26,14 @@ for (i=0; ie==parseInt(LCs[i].value,10))) {alert(`Sorry, pins ${JSON.stringify(d.um_p)} can't be used.`);LCs[i].value="";LCs[i].focus();return false;} else if (LCs[i].value > 5 && LCs[i].value < 12) {alert("Sorry, pins 6-11 can not be used.");LCs[i].value="";LCs[i].focus();return false;} for (j=i+1; j 0) laprev = d.Sf.LA.value; + // enable/disable LED fields var s = d.getElementsByTagName("select"); for (i=0; i 49) ? "Data:" : (type >41) ? "Pins:" : "Pin:"; gId("p1d"+n).innerHTML = (type > 49) ? "Clk:" : ""; - var LK = d.getElementsByName("L1"+n)[0]; + var LK = d.getElementsByName("L1"+n)[0]; // clock pin - memu += getMem(type, d.getElementsByName("LC"+n)[0].value, d.getElementsByName("L0"+n)[0].value); + memu += getMem(type, d.getElementsByName("LC"+n)[0].value, d.getElementsByName("L0"+n)[0].value); // calc memory + // enumerate pins for (p=1; p<5; p++) { - var LK = d.getElementsByName("L"+p+n)[0]; + var LK = d.getElementsByName("L"+p+n)[0]; // secondary pins if (!LK) continue; if ((type>49 && p==1) || (type>41 && type < 50 && (p+40 < type))) // TYPE_xxxx values from const.h { + // display pin field LK.style.display = "inline"; LK.required = true; } else { + // hide pin field LK.style.display = "none"; LK.required = false; LK.value=""; } } - gId("ls"+n).readOnly = !(type > 31 && type < 48); // not analog - gId("LC").readOnly = !(type > 31 && type < 48); // not analog +// gId("ls"+n).readOnly = !(type > 31 && type < 48); // if analog, allow editing LED start +// gId("LC").readOnly = !(type > 31 && type < 48); // if analog, allow editing total LED count if (change) { // gId("ew"+n).checked = (type == 30 || type == 31 || type == 44 || type == 45); // RGBW checkbox, TYPE_xxxx values from const.h - gId("ls"+n).value = n+1; + gId("ls"+n).value = n+1; // set LED start + if (type > 31 && type < 48) d.getElementsByName("LC"+n)[0].value = 1; // for sanity change analog count just to 1 LED } // gId("ew"+n).onclick = (type > 31 && type < 48) ? (function(){return false}) : (function(){}); // prevent change for analog // isRGBW |= gId("ew"+n).checked; isRGBW |= (type == 30 || type == 31 || type == 44 || type == 45); // RGBW checkbox, TYPE_xxxx values from const.h - gId("dig"+n).style.display = (type > 31 && type < 48) ? "none":"inline"; - gId("psd"+n).innerHTML = (type > 31 && type < 48) ? "Index:":"Start:"; + gId("dig"+n).style.display = (type > 31 && type < 48) ? "none":"inline"; // hide reverse, skip 1st & count for analog + gId("psd"+n).innerHTML = (type > 31 && type < 48) ? "Index:":"Start:"; // change analog start description } } - + // display white channel calculation method var myC = d.querySelectorAll('.wc'), l = myC.length; for (i = 0; i < l; i++) { myC[i].style.display = (isRGBW) ? 'inline':'none'; } - + // check for pin conflicts var LCs = d.getElementsByTagName("input"); var sLC = 0, maxLC = 0; for (i=0; imaxLC)maxLC=c;} + /*if(gId("ls"+n).readOnly)*/ gId("ls"+n).value=sLC; // update led start field + if(c){sLC+=c;if(c>maxLC)maxLC=c;} // increase led count continue; } + // do we have led pins for digital leds if (nm=="L0" || nm=="L1") { var lc=d.getElementsByName("LC"+LCs[i].name.substring(2))[0]; - lc.max=maxPB; + lc.max=maxPB; // update max led count value } - if (nm=="L0" || nm=="L1" || nm=="L2" || nm=="L3" || nm=="L4" || nm=="RL" || nm=="BT" || nm=="IR" || nm=="AX") + // for pins check conflicts + if (nm=="L0" || nm=="L1" || nm=="L2" || nm=="L3" || nm=="L4" || nm=="RL" || nm=="BT" || nm=="IR") if (LCs[i].value!="" && LCs[i].value!="-1") { - var p = []; - if (d.um_p && Array.isArray(d.um_p)) for (k=0;ke==parseInt(LCs[i].value,10))) LCs[i].style.color="red"; else LCs[i].style.color="#fff"; } } - + // update total led count if (gId("LC").readOnly) d.getElementsByName("LC")[0].value = sLC; + // if we are changing total led count update led count for 1st strip if (d.activeElement == d.getElementsByName("LC")[0]) { var o = d.getElementsByClassName("iST"); var i = o.length; if (i == 1) d.getElementsByName("LC0")[0].value = d.getElementsByName("LC")[0].value; } + // memory usage and warnings gId('m0').innerHTML = memu; bquot = memu / maxM * 100; gId('dbar').style.background = `linear-gradient(90deg, ${bquot > 60 ? (bquot > 90 ? "red":"orange"):"#ccc"} 0 ${bquot}%%, #444 ${bquot}%% 100%%)`; gId('ledwarning').style.display = (sLC > maxPB || maxLC > 800 || bquot > 80) ? 'inline':'none'; gId('ledwarning').style.color = (sLC > maxPB || maxLC > maxPB || bquot > 100) ? 'red':'orange'; gId('wreason').innerHTML = (bquot > 80) ? "80% of max. LED memory" +(bquot>100 ? ` (WARNING: Using over ${maxM}B!)` : "") : "800 LEDs per pin"; - + // calculate power var val = Math.ceil((100 + sLC * laprev)/500)/2; val = (val > 5) ? Math.ceil(val) : val; var s = ""; @@ -265,7 +277,7 @@ Color Order:
-Start:   +Start:  
Count:
Reverse (rotated 180°): @@ -295,7 +307,6 @@ Reverse (rotated 180°): c += ``; c += ``; c += ``; - c += ``; c += ``; c += ` ×
`; gId("btns").innerHTML = c; diff --git a/wled00/fcn_declare.h b/wled00/fcn_declare.h index 913a16842..27b68c753 100644 --- a/wled00/fcn_declare.h +++ b/wled00/fcn_declare.h @@ -15,9 +15,11 @@ void handleAlexa(); void onAlexaChange(EspalexaDevice* dev); //blynk.cpp +#ifndef WLED_DISABLE_BLYNK void initBlynk(const char* auth, const char* host, uint16_t port); void handleBlynk(); void updateBlynk(); +#endif //button.cpp void shortPressAction(uint8_t b=0); diff --git a/wled00/html_settings.h b/wled00/html_settings.h index 602ed9383..c0226b6c2 100644 --- a/wled00/html_settings.h +++ b/wled00/html_settings.h @@ -74,7 +74,7 @@ Do not enable if WiFi is working correctly, increases power consumption.
LED Settings
Start LED