diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index 76b964eee..26118bdf0 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -1204,6 +1204,7 @@ void WS2812FX::finalizeInit(void) { // for the lack of better place enumerate ledmaps here // if we do it in json.cpp (serializeInfo()) we are getting flashes on LEDs // unfortunately this means we do not get updates after uploads + // the other option is saving UI settings which will cause enumeration enumerateLedmaps(); _hasWhiteChannel = _isOffRefreshRequired = false; @@ -1247,11 +1248,12 @@ void WS2812FX::finalizeInit(void) { unsigned busEnd = bus->getStart() + bus->getLength(); if (busEnd > _length) _length = busEnd; #ifdef ESP8266 - if ((!IS_DIGITAL(bus->getType()) || IS_2PIN(bus->getType()))) continue; - uint8_t pins[5]; - if (!bus->getPins(pins)) continue; - BusDigital* bd = static_cast(bus); - if (pins[0] == 3) bd->reinit(); + // why do we need to reinitialise GPIO3??? + //if ((!IS_DIGITAL(bus->getType()) || IS_2PIN(bus->getType()))) continue; + //uint8_t pins[5]; + //if (!bus->getPins(pins)) continue; + //BusDigital* bd = static_cast(bus); + //if (pins[0] == 3) bd->reinit(); #endif } @@ -1767,13 +1769,15 @@ bool WS2812FX::deserializeMap(uint8_t n) { bool isFile = WLED_FS.exists(fileName); customMappingSize = 0; // prevent use of mapping if anything goes wrong + currentLedmap = 0; + if (n == 0 || isFile) interfaceUpdateCallMode = CALL_MODE_WS_SEND; // schedule WS update (to inform UI) if (!isFile && n==0 && isMatrix) { setUpMatrix(); return false; } - if (!isFile || !requestJSONBufferLock(7)) return false; // this will trigger setUpMatrix() when called from wled.cpp + if (!isFile || !requestJSONBufferLock(7)) return false; if (!readObjectFromFile(fileName, nullptr, pDoc)) { DEBUG_PRINT(F("ERROR Invalid ledmap in ")); DEBUG_PRINTLN(fileName); @@ -1797,6 +1801,7 @@ bool WS2812FX::deserializeMap(uint8_t n) { if (!map.isNull() && map.size()) { // not an empty map customMappingSize = min((unsigned)map.size(), (unsigned)getLengthTotal()); for (unsigned i=0; i 13 || apChannel < 1) apChannel = 1; - CJSON(apHide, ap[F("hide")]); if (apHide > 1) apHide = 1; - CJSON(apBehavior, ap[F("behav")]); - /* JsonArray ap_ip = ap["ip"]; for (byte i = 0; i < 4; i++) { @@ -95,9 +91,14 @@ bool deserializeConfig(JsonObject doc, bool fromFS) { } */ - noWifiSleep = doc[F("wifi")][F("sleep")] | !noWifiSleep; // inverted - noWifiSleep = !noWifiSleep; - force802_3g = doc[F("wifi")][F("phy")] | force802_3g; //force phy mode g? + JsonObject wifi = doc[F("wifi")]; + noWifiSleep = !(wifi[F("sleep")] | !noWifiSleep); // inverted + //noWifiSleep = !noWifiSleep; + CJSON(force802_3g, wifi[F("phy")]); //force phy mode g? +#ifdef ARDUINO_ARCH_ESP32 + CJSON(txPower, wifi[F("txpwr")]); + txPower = min(max((int)txPower, (int)WIFI_POWER_2dBm), (int)WIFI_POWER_19_5dBm); +#endif JsonObject hw = doc[F("hw")]; @@ -774,8 +775,11 @@ void serializeConfig() { JsonObject wifi = root.createNestedObject(F("wifi")); wifi[F("sleep")] = !noWifiSleep; wifi[F("phy")] = force802_3g; +#ifdef ARDUINO_ARCH_ESP32 + wifi[F("txpwr")] = txPower; +#endif - #ifdef WLED_USE_ETHERNET +#ifdef WLED_USE_ETHERNET JsonObject ethernet = root.createNestedObject("eth"); ethernet["type"] = ethernetType; if (ethernetType != WLED_ETH_NONE && ethernetType < WLED_NUM_ETH_TYPES) { @@ -797,7 +801,7 @@ void serializeConfig() { break; } } - #endif +#endif JsonObject hw = root.createNestedObject(F("hw")); diff --git a/wled00/data/index.htm b/wled00/data/index.htm index 4a532abb7..86b3b1879 100644 --- a/wled00/data/index.htm +++ b/wled00/data/index.htm @@ -126,9 +126,10 @@
+ - +

Color palette

diff --git a/wled00/data/index.js b/wled00/data/index.js index a76cf6c86..aaf4ef14a 100644 --- a/wled00/data/index.js +++ b/wled00/data/index.js @@ -669,18 +669,15 @@ function parseInfo(i) { //syncTglRecv = i.str; maxSeg = i.leds.maxseg; pmt = i.fs.pmt; + if (pcMode && !i.wifi.ap) gId('edit').classList.remove("hide"); else gId('edit').classList.add("hide"); gId('buttonNodes').style.display = lastinfo.ndc > 0 ? null:"none"; // do we have a matrix set-up mw = i.leds.matrix ? i.leds.matrix.w : 0; mh = i.leds.matrix ? i.leds.matrix.h : 0; isM = mw>0 && mh>0; if (!isM) { - //gId("filter0D").classList.remove('hide'); - //gId("filter1D").classList.add('hide'); gId("filter2D").classList.add('hide'); } else { - //gId("filter0D").classList.add('hide'); - //gId("filter1D").classList.remove('hide'); gId("filter2D").classList.remove('hide'); } // if (i.noaudio) { @@ -745,10 +742,10 @@ ${inforow("Environment",i.arch + " " + i.core + " (" + i.lwip + ")")} `; gId('kv').innerHTML = cn; // update all sliders in Info - for (let sd of (d.querySelectorAll('#kv .sliderdisplay')||[])) { + d.querySelectorAll('#kv .sliderdisplay').forEach((sd,i) => { let s = sd.previousElementSibling; if (s) updateTrail(s); - } + }); } function populateSegments(s) @@ -895,8 +892,8 @@ function populateSegments(s) gId('segutil2').style.display = (segCount > 1) ? "block":"none"; // rsbtn parent if (Array.isArray(li.maps) && li.maps.length>1) { - let cont = `Ledmap: `; + for (const k of li.maps) cont += ``; cont += "
"; gId("ledmap").innerHTML = cont; gId("ledmap").classList.remove('hide'); @@ -991,13 +988,12 @@ function populatePalettes() function redrawPalPrev() { - let palettes = d.querySelectorAll('#pallist .lstI'); - for (var pal of (palettes||[])) { + d.querySelectorAll('#pallist .lstI').forEach((pal,i) =>{ let lP = pal.querySelector('.lstIprev'); if (lP) { lP.style = genPalPrevCss(pal.dataset.id); } - } + }); } function genPalPrevCss(id) @@ -1358,10 +1354,12 @@ function updateSelectedFx() } // hide 2D mapping and/or sound simulation options - var segs = gId("segcont").querySelectorAll(`div[data-map="map2D"]`); - for (const seg of segs) if (selectedName.indexOf("\u25A6")<0) seg.classList.remove('hide'); else seg.classList.add('hide'); - var segs = gId("segcont").querySelectorAll(`div[data-snd="si"]`); - for (const seg of segs) if (selectedName.indexOf("\u266A")<0 && selectedName.indexOf("\u266B")<0) seg.classList.add('hide'); else seg.classList.remove('hide'); // also "♫ "? + gId("segcont").querySelectorAll(`div[data-map="map2D"]`).forEach((seg)=>{ + if (selectedName.indexOf("\u25A6")<0) seg.classList.remove('hide'); else seg.classList.add('hide'); + }); + gId("segcont").querySelectorAll(`div[data-snd="si"]`).forEach((seg)=>{ + if (selectedName.indexOf("\u266A")<0 && selectedName.indexOf("\u266B")<0) seg.classList.add('hide'); else seg.classList.remove('hide'); // also "♫ "? + }); } } @@ -1568,8 +1566,7 @@ function setEffectParameters(idx) var paOnOff = (effectPars.length<3 || effectPars[2]=='')?[]:effectPars[2].split(","); // set html slider items on/off - let sliders = d.querySelectorAll("#sliders .sliderwrap"); - sliders.forEach((slider, i)=>{ + d.querySelectorAll("#sliders .sliderwrap").forEach((slider, i)=>{ let text = slider.getAttribute("title"); if ((!controlDefined && i<((idx<128)?2:nSliders)) || (slOnOff.length>i && slOnOff[i]!="")) { if (slOnOff.length>i && slOnOff[i]!="!") text = slOnOff[i]; @@ -1583,8 +1580,7 @@ function setEffectParameters(idx) if (slOnOff.length > 5) { // up to 3 checkboxes gId('fxopt').classList.remove('fade'); - let checks = d.querySelectorAll("#sliders .ochkl"); - checks.forEach((check, i)=>{ + d.querySelectorAll("#sliders .ochkl").forEach((check, i)=>{ let text = check.getAttribute("title"); if (5+i5+i && slOnOff[5+i]!="!") text = slOnOff[5+i]; @@ -2031,7 +2027,7 @@ ${makePlSel(plJson[i].end?plJson[i].end:0, true)} `; if (Array.isArray(lastinfo.maps) && lastinfo.maps.length>1) { content += `
Ledmap: 
"; } } @@ -2179,13 +2175,12 @@ function selGrp(g) { event.preventDefault(); event.stopPropagation(); - var sel = gId(`segcont`).querySelectorAll(`div[data-set="${g}"]`); var obj = {"seg":[]}; for (let i=0; i<=lSeg; i++) if (gId(`seg${i}`)) obj.seg.push({"id":i,"sel":false}); - for (let s of (sel||[])) { + gId(`segcont`).querySelectorAll(`div[data-set="${g}"]`).forEach((s)=>{ let i = parseInt(s.id.substring(3)); obj.seg[i] = {"id":i,"sel":true}; - } + }); if (obj.seg.length) requestJson(obj); } @@ -2839,15 +2834,14 @@ function search(field, listId = null) { // do not search if filter is active if (gId("filters").querySelectorAll("input[type=checkbox]:checked").length) return; - const listItems = gId(listId).querySelectorAll('.lstI'); // filter list items but leave (Default & Solid) always visible - for (i = (listId === 'pcont' ? 0 : 1); i < listItems.length; i++) { - const listItem = listItems[i]; + gId(listId).querySelectorAll('.lstI').forEach((listItem,i)=>{ + if (listId!=='pcont' && i===0) return; const listItemName = listItem.querySelector('.lstIname').innerText.toUpperCase(); const searchIndex = listItemName.indexOf(field.value.toUpperCase()); listItem.style.display = (searchIndex < 0) ? 'none' : ''; listItem.dataset.searchIndex = searchIndex; - } + }); // sort list items by search index and name const sortedListItems = Array.from(listItems).sort((a, b) => { @@ -2908,14 +2902,12 @@ function filterFx() { inputField.value = ''; inputField.focus(); clean(inputField.nextElementSibling); - const listItems = gId("fxlist").querySelectorAll('.lstI'); - for (let i = 1; i < listItems.length; i++) { - const listItem = listItems[i]; + gId("fxlist").querySelectorAll('.lstI').forEach((listItem,i) => { const listItemName = listItem.querySelector('.lstIname').innerText; let hide = false; gId("filters").querySelectorAll("input[type=checkbox]").forEach((e) => { if (e.checked && !listItemName.includes(e.dataset.flt)) hide = true; }); listItem.style.display = hide ? 'none' : ''; - } + }); } function preventBlur(e) { @@ -3066,6 +3058,7 @@ function size() function togglePcMode(fromB = false) { + let ap = (fromB && !lastinfo) || (lastinfo && lastinfo.wifi && lastinfo.witi.ap); if (fromB) { pcModeA = !pcModeA; localStorage.setItem('pcm', pcModeA); @@ -3075,6 +3068,7 @@ function togglePcMode(fromB = false) if (!fromB && ((wW < 1024 && lastw < 1024) || (wW >= 1024 && lastw >= 1024))) return; // no change in size and called from size() if (pcMode) openTab(0, true); gId('buttonPcm').className = (pcMode) ? "active":""; + if (pcMode && !ap) gId('edit').classList.remove("hide"); else gId('edit').classList.add("hide"); gId('bot').style.height = (pcMode && !cfg.comp.pcmbot) ? "0":"auto"; sCol('--bh', gId('bot').clientHeight + "px"); _C.style.width = (pcMode || simplifiedUI)?'100%':'400%'; @@ -3100,8 +3094,7 @@ function mergeDeep(target, ...sources) function tooltip(cont=null) { - const elements = d.querySelectorAll((cont?cont+" ":"")+"[title]"); - elements.forEach((element)=>{ + d.querySelectorAll((cont?cont+" ":"")+"[title]").forEach((element)=>{ element.addEventListener("mouseover", ()=>{ // save title element.setAttribute("data-title", element.getAttribute("title")); @@ -3128,8 +3121,7 @@ function tooltip(cont=null) }); element.addEventListener("mouseout", ()=>{ - const tooltips = d.querySelectorAll('.tooltip'); - tooltips.forEach((tooltip)=>{ + d.querySelectorAll('.tooltip').forEach((tooltip)=>{ tooltip.classList.remove("visible"); d.body.removeChild(tooltip); }); diff --git a/wled00/data/settings_leds.htm b/wled00/data/settings_leds.htm index cffa73563..063acf2db 100644 --- a/wled00/data/settings_leds.htm +++ b/wled00/data/settings_leds.htm @@ -6,6 +6,7 @@ LED Settings