diff --git a/wled00/FX.cpp b/wled00/FX.cpp index 27bd730d9..6852674e4 100644 --- a/wled00/FX.cpp +++ b/wled00/FX.cpp @@ -1265,7 +1265,7 @@ uint16_t WS2812FX::police_base(uint32_t color1, uint32_t color2, bool all) for (uint16_t i = idexB; i < idexR; i++) setPixelColor(i, color2); } } else { //regular dot-only mode - uint8_t size = 1 + SEGMENT.intensity >> 3; + uint8_t size = 1 + (SEGMENT.intensity >> 3); if (size > SEGLEN/2) size = 1+ SEGLEN/2; for (uint8_t i=0; i <= size; i++) { setPixelColor(idexR+i, color1); diff --git a/wled00/cfg.cpp b/wled00/cfg.cpp index 8c184d7aa..9e8a29123 100644 --- a/wled00/cfg.cpp +++ b/wled00/cfg.cpp @@ -12,6 +12,48 @@ void getStringFromJson(char* dest, const char* src, size_t len) { if (src != nullptr) strlcpy(dest, src, len); } +//populates bus objects from instance JsonArray, called by deserializeConfig() and by doInitStrip +bool initBusInstances(JsonArray ins) { + uint8_t s = 0; + useRGBW = false; + busses.removeAll(); + for (JsonObject elm : ins) { + if (s >= WLED_MAX_BUSSES) break; + uint8_t pins[5] = {255, 255, 255, 255, 255}; + JsonArray pinArr = elm[F("pin")]; + if (pinArr.size() == 0) continue; + pins[0] = pinArr[0]; + uint8_t i = 0; + for (int p : pinArr) { + pins[i] = p; + i++; + if (i>4) break; + } + + uint16_t length = elm[F("len")]; + if (length==0) continue; + uint8_t colorOrder = (int)elm[F("order")]; + //only use skip from the first strip (this shouldn't have been in ins obj. but remains here for compatibility) + if (s==0) skipFirstLed = elm[F("skip")]; + uint16_t start = elm[F("start")] | 0; + if (start >= ledCount) continue; + //limit length of strip if it would exceed total configured LEDs + if (start + length > ledCount) length = ledCount - start; + uint8_t ledType = elm[F("type")] | TYPE_WS2812_RGB; + bool reversed = elm[F("rev")]; + //RGBW mode is enabled if at least one of the strips is RGBW + useRGBW = (useRGBW || BusManager::isRgbw(ledType)); + s++; + busses.add(ledType, pins, start, ledCount, colorOrder, reversed); + } + //if no bus inited successfully (empty cfg or invalid), init default + if (s==0) { + uint8_t defPin[] = {LEDPIN}; + busses.add(TYPE_WS2812_RGB, defPin, 0, ledCount, COL_ORDER_GRB); + } + return s; +} + void deserializeConfig() { bool fromeep = false; bool success = deserializeConfigSec(); @@ -101,46 +143,7 @@ void deserializeConfig() { CJSON(strip.rgbwMode, hw_led[F("rgbwm")]); JsonVariant strVar = hw_led["ins"]; - if (strVar.is()) { - // some safety measures here? - } else { - JsonArray elms = strVar.as(); - uint8_t s = 0; - useRGBW = false; - busses.removeAll(); - for (JsonObject elm : elms) { - if (s >= WLED_MAX_BUSSES) break; - uint8_t pins[5] = {255, 255, 255, 255, 255}; - JsonArray pinArr = elm[F("pin")]; - if (pinArr.size() == 0) continue; - pins[0] = pinArr[0]; - uint8_t i = 0; - for (int p : pinArr) { - pins[i] = p; - i++; - if (i>4) break; - } - - uint16_t length = elm[F("len")]; - if (length==0) continue; - uint8_t colorOrder = (int)elm[F("order")]; - //only use skip from the first strip (this shouldn't have been in ins obj. but remains here for compatibility) - if (s==0) skipFirstLed = elm[F("skip")]; - uint16_t start = elm[F("start")] | 0; - if (start >= ledCount) continue; - //limit length of strip if it would exceed total configured LEDs - if (start + length > ledCount) length = ledCount - start; - uint8_t ledType = elm[F("type")] | TYPE_WS2812_RGB; - bool reversed = elm[F("rev")]; - //RGBW mode is enabled if at least one of the strips is RGBW - useRGBW = (useRGBW || BusManager::isRgbw(ledType)); - busses.add(ledType, pins, start, ledCount, colorOrder, reversed); - } - //if no bus inited successfully (empty cfg or invalid), init default - uint8_t defPin[] = {LEDPIN}; - busses.add(TYPE_WS2812_RGB, defPin, 0, ledCount, COL_ORDER_GRB); - } - if (ledCount > MAX_LEDS) ledCount = MAX_LEDS; + initBusInstances(strVar.as()); JsonObject hw_btn_ins_0 = hw[F("btn")][F("ins")][0]; CJSON(buttonEnabled, hw_btn_ins_0[F("type")]); diff --git a/wled00/data/settings_leds.htm b/wled00/data/settings_leds.htm index 30a6d0318..4671f4e36 100644 --- a/wled00/data/settings_leds.htm +++ b/wled00/data/settings_leds.htm @@ -144,12 +144,12 @@ d.getElementById('m0').innerHTML = memu; bquot = memu / bmax * 100; - d.getElementById('dbar').style.background = `linear-gradient(90deg, ${bquot > 60 ? bquot > 90 ? "red":"orange":"#ccc"} 0 ${bquot}%, #444 ${bquot}% 100%)`; + d.getElementById('dbar').style.background = `linear-gradient(90deg, ${bquot > 60 ? bquot > 90 ? "red":"orange":"#ccc"} 0 ${bquot}%%, #444 ${bquot}%% 100%%)`; d.getElementById('ledwarning').style.display = (maxLC > 800 || bquot > 80) ? 'inline':'none'; //TODO add warning "Recommended pins on ESP8266 are 1 and 2 (3 only with low LED count)" //TODO add overmemory warning //TODO block disallowed pins 6-11 - d.getElementById('wreason').innerHTML = (bquot > 80) ? "than 60% of max. LED memory" : "800 LEDs per pin"; + d.getElementById('wreason').innerHTML = (bquot > 80) ? "than 60%% of max. LED memory" : "800 LEDs per pin"; //var val = Math.ceil((100 + d.Sf.LC.value * laprev)/500)/2; var val = Math.ceil((100 + sLC * laprev)/500)/2; diff --git a/wled00/fcn_declare.h b/wled00/fcn_declare.h index d9e5b8b63..ffed26c22 100644 --- a/wled00/fcn_declare.h +++ b/wled00/fcn_declare.h @@ -26,6 +26,7 @@ void handleButton(); void handleIO(); //cfg.cpp +bool initBusInstances(JsonArray ins); void deserializeConfig(); bool deserializeConfigSec(); void serializeConfig(); diff --git a/wled00/html_settings.h b/wled00/html_settings.h index a469b067d..de5a07279 100644 --- a/wled00/html_settings.h +++ b/wled00/html_settings.h @@ -71,7 +71,7 @@ Do not enable if WiFi is working correctly, increases power consumption.
LED Settings