More filtering options.

Palette loading bugfix.
This commit is contained in:
Blaz Kristan 2022-07-27 17:00:55 +02:00
parent 1b64747c2b
commit 3b2573afed
6 changed files with 1870 additions and 1859 deletions

View File

@ -1366,11 +1366,17 @@ void WS2812FX::setTransitionMode(bool t)
void WS2812FX::load_gradient_palette(uint8_t index) void WS2812FX::load_gradient_palette(uint8_t index)
{ {
// NOTE: due to constant execution (in every effect update) of this code
// if loading from FS is requested it will produce excessive flickering
// loading of palette into RAM from FS should be optimised in such case
// (it is mandatory to load palettes in each service() as each segment can
// have its own palette)
byte tcp[72]; //support gradient palettes with up to 18 entries byte tcp[72]; //support gradient palettes with up to 18 entries
if (index>127) { if (index>114) {
char fileName[32]; char fileName[32];
strcpy_P(fileName, PSTR("/palette")); strcpy_P(fileName, PSTR("/palette"));
if (index>128) sprintf(fileName +7, "%d", index-127); sprintf(fileName +8, "%d", index-115); // palette ID == 128
strcat(fileName, ".json"); strcat(fileName, ".json");
if (WLED_FS.exists(fileName)) { if (WLED_FS.exists(fileName)) {
@ -1392,7 +1398,6 @@ void WS2812FX::load_gradient_palette(uint8_t index)
targetPalette.loadDynamicGradientPalette(tcp); targetPalette.loadDynamicGradientPalette(tcp);
} }
} }
releaseJSONBufferLock();
} }
} else { } else {
byte i = constrain(index, 0, GRADIENT_PALETTE_COUNT -1); byte i = constrain(index, 0, GRADIENT_PALETTE_COUNT -1);

View File

@ -393,9 +393,9 @@ button {
border-radius: 26px; border-radius: 26px;
height: 26px; height: 26px;
margin: 0 auto; /* 8px if you want space */ margin: 0 auto; /* 8px if you want space */
padding: 8px; padding: 8px 2px;
position: relative; position: relative;
width: 260px; /*width: 260px;*/
/*transition: opacity 1s;*/ /*transition: opacity 1s;*/
/*opacity: 1;*/ /*opacity: 1;*/
} }
@ -1204,7 +1204,7 @@ TD .checkmark, TD .radiomark {
.filter .fchkl { .filter .fchkl {
display: inline-block; display: inline-block;
min-width: 1em; min-width: 0.7em;
padding: 4px 4px 4px 32px; padding: 4px 4px 4px 32px;
text-align: left; text-align: left;
line-height: 24px; line-height: 24px;

View File

@ -222,6 +222,10 @@
<input type="checkbox" id="filterPal" data-flt="&#127912;" onchange="filterFx(this)"> <input type="checkbox" id="filterPal" data-flt="&#127912;" onchange="filterFx(this)">
<span class="checkmark"></span> <span class="checkmark"></span>
</label> </label>
<label class="check fchkl">1D
<input type="checkbox" id="filter1D" data-flt="*" onchange="filterFx(this)">
<span class="checkmark"></span>
</label>
<label class="check fchkl">2D<!-- &#8862; --> <label class="check fchkl">2D<!-- &#8862; -->
<input type="checkbox" id="filter2D" data-flt="2D" onchange="filterFx(this)"> <input type="checkbox" id="filter2D" data-flt="2D" onchange="filterFx(this)">
<span class="checkmark"></span> <span class="checkmark"></span>

View File

@ -167,12 +167,12 @@ function loadBg(iUrl)
img.src = iUrl; img.src = iUrl;
if (iUrl == "" || iUrl==="https://picsum.photos/1920/1080") { if (iUrl == "" || iUrl==="https://picsum.photos/1920/1080") {
var today = new Date(); var today = new Date();
for (var i=0; i<hol.length; i++) { for (var h of (hol||[])) {
var yr = hol[i][0]==0 ? today.getFullYear() : hol[i][0]; var yr = h[0]==0 ? today.getFullYear() : h[0];
var hs = new Date(yr,hol[i][1],hol[i][2]); var hs = new Date(yr,h[1],h[2]);
var he = new Date(hs); var he = new Date(hs);
he.setDate(he.getDate() + hol[i][3]); he.setDate(he.getDate() + h[3]);
if (today>=hs && today<=he) img.src = hol[i][4]; if (today>=hs && today<=he) img.src = h[4];
} }
} }
img.addEventListener('load', (e) => { img.addEventListener('load', (e) => {
@ -671,11 +671,9 @@ function populateSegments(s)
let li = lastinfo; let li = lastinfo;
segCount = 0; lowestUnused = 0; lSeg = 0; segCount = 0; lowestUnused = 0; lSeg = 0;
for (var y = 0; y < (s.seg||[]).length; y++) for (var inst of (s.seg||[])) {
{
segCount++; segCount++;
var inst = s.seg[y];
let i = parseInt(inst.id); let i = parseInt(inst.id);
if (i == lowestUnused) lowestUnused = i+1; if (i == lowestUnused) lowestUnused = i+1;
if (i > lSeg) lSeg = i; if (i > lSeg) lSeg = i;
@ -797,27 +795,33 @@ function populateEffects()
var effects = eJson; var effects = eJson;
var html = ""; var html = "";
effects.shift(); // remove solid effects.shift(); // temporary remove solid
for (let i = 0; i < effects.length; i++) effects[i] = {id: effects[i][0], name:effects[i][1]}; for (let i = 0; i < effects.length; i++) {
effects[i] = {
id: effects[i][0],
name:effects[i][1]
};
}
effects.sort((a,b) => (a.name).localeCompare(b.name)); effects.sort((a,b) => (a.name).localeCompare(b.name));
effects.unshift({ effects.unshift({
"id": 0, "id": 0,
"name": "Solid" "name": "Solid"
}); });
for (let i = 0; i < effects.length; i++) { for (let ef of effects) {
// WLEDSR: add slider and color control to setX (used by requestjson) // WLEDSR: add slider and color control to setX (used by requestjson)
let id = effects[i].id; let id = ef.id;
let nm = effects[i].name; let nm = ef.name;
let fd = ""; let fd = "";
if (ef.name.indexOf("Reserved") < 0) {
if (Array.isArray(fxdata) && fxdata.length>id) { if (Array.isArray(fxdata) && fxdata.length>id) {
fd = fxdata[id].substr(1); fd = fxdata[id].substr(1);
var eP = (fd == '')?[]:fd.split(";"); var eP = (fd == '')?[]:fd.split(";");
var p = (eP.length<3 || eP[2]==='')?[]:eP[2].split(","); var p = (eP.length<3 || eP[2]==='')?[]:eP[2].split(",");
if (p.length>0 && p[0].substr(0,1) === "!") nm += " 🎨"; var m = (eP.length<4 || eP[3]==='')?[]:eP[3].split(",");
if (m.length>0) for (let r of m) { if (r.substring(0,4)=="mp12") nm += " *"; }
if (p.length>0 && p[0].substring(0,1) === "!") nm += " 🎨";
} }
if (effects[i].name.indexOf("Reserved") < 0) {
html += generateListItemHtml('fx',id,nm,'setX','',fd); html += generateListItemHtml('fx',id,nm,'setX','',fd);
} }
} }
@ -828,7 +832,7 @@ function populateEffects()
function populatePalettes() function populatePalettes()
{ {
var palettes = lJson; var palettes = lJson;
palettes.shift(); // remove default palettes.shift(); // temporary remove default
for (let i = 0; i < palettes.length; i++) { for (let i = 0; i < palettes.length; i++) {
palettes[i] = { palettes[i] = {
"id": palettes[i][0], "id": palettes[i][0],
@ -836,20 +840,19 @@ function populatePalettes()
}; };
} }
palettes.sort((a,b) => (a.name).localeCompare(b.name)); palettes.sort((a,b) => (a.name).localeCompare(b.name));
palettes.unshift({ palettes.unshift({
"id": 0, "id": 0,
"name": "Default" "name": "Default"
}); });
var html = ""; var html = "";
for (let i = 0; i < palettes.length; i++) { for (let pa of palettes) {
html += generateListItemHtml( html += generateListItemHtml(
'palette', 'palette',
palettes[i].id, pa.id,
palettes[i].name, pa.name,
'setPalette', 'setPalette',
`<div class="lstIprev" style="${genPalPrevCss(palettes[i].id)}"></div>` `<div class="lstIprev" style="${genPalPrevCss(pa.id)}"></div>`
); );
} }
@ -952,8 +955,7 @@ function populateNodes(i,n)
var nnodes = 0; var nnodes = 0;
if (n.nodes) { if (n.nodes) {
n.nodes.sort((a,b) => (a.name).localeCompare(b.name)); n.nodes.sort((a,b) => (a.name).localeCompare(b.name));
for (var x=0;x<n.nodes.length;x++) { for (var o of n.nodes) {
var o = n.nodes[x];
if (o.name) { if (o.name) {
var url = `<button class="btn" title="${o.ip}" onclick="location.assign('http://${o.ip}');">${bname(o)}</button>`; var url = `<button class="btn" title="${o.ip}" onclick="location.assign('http://${o.ip}');">${bname(o)}</button>`;
urows += inforow(url,`${btype(o.type)}<br><i>${o.vid==0?"N/A":o.vid}</i>`); urows += inforow(url,`${btype(o.type)}<br><i>${o.vid==0?"N/A":o.vid}</i>`);
@ -1615,10 +1617,10 @@ function makePlSel(el, incPl=false) {
var plSelContent = ""; var plSelContent = "";
delete pJson["0"]; // remove filler preset delete pJson["0"]; // remove filler preset
var arr = Object.entries(pJson); var arr = Object.entries(pJson);
for (var i = 0; i < arr.length; i++) { for (var a of arr) {
var n = arr[i][1].n ? arr[i][1].n : "Preset " + arr[i][0]; var n = a[1].n ? a[1].n : "Preset " + a[0];
if (!incPl && arr[i][1].playlist && arr[i][1].playlist.ps) continue; // remove playlists, sub-playlists not yet supported if (!incPl && a[1].playlist && a[1].playlist.ps) continue; // remove playlists, sub-playlists not yet supported
plSelContent += `<option value="${arr[i][0]}" ${arr[i][0]==el?"selected":""}>${n}</option>` plSelContent += `<option value="${a[0]}" ${a[0]==el?"selected":""}>${n}</option>`
} }
return plSelContent; return plSelContent;
} }

File diff suppressed because it is too large Load Diff

View File

@ -8,7 +8,7 @@
*/ */
// version code in format yymmddb (b = daily build) // version code in format yymmddb (b = daily build)
#define VERSION 2207251 #define VERSION 2207271
//uncomment this if you have a "my_config.h" file you'd like to use //uncomment this if you have a "my_config.h" file you'd like to use
//#define WLED_USE_MY_CONFIG //#define WLED_USE_MY_CONFIG