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)
{
// 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
if (index>127) {
if (index>114) {
char fileName[32];
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");
if (WLED_FS.exists(fileName)) {
@ -1392,7 +1398,6 @@ void WS2812FX::load_gradient_palette(uint8_t index)
targetPalette.loadDynamicGradientPalette(tcp);
}
}
releaseJSONBufferLock();
}
} else {
byte i = constrain(index, 0, GRADIENT_PALETTE_COUNT -1);

View File

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

View File

@ -222,6 +222,10 @@
<input type="checkbox" id="filterPal" data-flt="&#127912;" onchange="filterFx(this)">
<span class="checkmark"></span>
</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; -->
<input type="checkbox" id="filter2D" data-flt="2D" onchange="filterFx(this)">
<span class="checkmark"></span>

View File

@ -167,12 +167,12 @@ function loadBg(iUrl)
img.src = iUrl;
if (iUrl == "" || iUrl==="https://picsum.photos/1920/1080") {
var today = new Date();
for (var i=0; i<hol.length; i++) {
var yr = hol[i][0]==0 ? today.getFullYear() : hol[i][0];
var hs = new Date(yr,hol[i][1],hol[i][2]);
for (var h of (hol||[])) {
var yr = h[0]==0 ? today.getFullYear() : h[0];
var hs = new Date(yr,h[1],h[2]);
var he = new Date(hs);
he.setDate(he.getDate() + hol[i][3]);
if (today>=hs && today<=he) img.src = hol[i][4];
he.setDate(he.getDate() + h[3]);
if (today>=hs && today<=he) img.src = h[4];
}
}
img.addEventListener('load', (e) => {
@ -671,11 +671,9 @@ function populateSegments(s)
let li = lastinfo;
segCount = 0; lowestUnused = 0; lSeg = 0;
for (var y = 0; y < (s.seg||[]).length; y++)
{
for (var inst of (s.seg||[])) {
segCount++;
var inst = s.seg[y];
let i = parseInt(inst.id);
if (i == lowestUnused) lowestUnused = i+1;
if (i > lSeg) lSeg = i;
@ -797,27 +795,33 @@ function populateEffects()
var effects = eJson;
var html = "";
effects.shift(); // remove solid
for (let i = 0; i < effects.length; i++) effects[i] = {id: effects[i][0], name:effects[i][1]};
effects.shift(); // temporary remove solid
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.unshift({
"id": 0,
"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)
let id = effects[i].id;
let nm = effects[i].name;
let id = ef.id;
let nm = ef.name;
let fd = "";
if (Array.isArray(fxdata) && fxdata.length>id) {
fd = fxdata[id].substr(1);
var eP = (fd == '')?[]:fd.split(";");
var p = (eP.length<3 || eP[2]==='')?[]:eP[2].split(",");
if (p.length>0 && p[0].substr(0,1) === "!") nm += " 🎨";
}
if (effects[i].name.indexOf("Reserved") < 0) {
if (ef.name.indexOf("Reserved") < 0) {
if (Array.isArray(fxdata) && fxdata.length>id) {
fd = fxdata[id].substr(1);
var eP = (fd == '')?[]:fd.split(";");
var p = (eP.length<3 || eP[2]==='')?[]:eP[2].split(",");
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 += " 🎨";
}
html += generateListItemHtml('fx',id,nm,'setX','',fd);
}
}
@ -828,7 +832,7 @@ function populateEffects()
function populatePalettes()
{
var palettes = lJson;
palettes.shift(); // remove default
palettes.shift(); // temporary remove default
for (let i = 0; i < palettes.length; i++) {
palettes[i] = {
"id": palettes[i][0],
@ -836,20 +840,19 @@ function populatePalettes()
};
}
palettes.sort((a,b) => (a.name).localeCompare(b.name));
palettes.unshift({
"id": 0,
"name": "Default"
});
var html = "";
for (let i = 0; i < palettes.length; i++) {
for (let pa of palettes) {
html += generateListItemHtml(
'palette',
palettes[i].id,
palettes[i].name,
pa.id,
pa.name,
'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;
if (n.nodes) {
n.nodes.sort((a,b) => (a.name).localeCompare(b.name));
for (var x=0;x<n.nodes.length;x++) {
var o = n.nodes[x];
for (var o of n.nodes) {
if (o.name) {
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>`);
@ -1615,10 +1617,10 @@ function makePlSel(el, incPl=false) {
var plSelContent = "";
delete pJson["0"]; // remove filler preset
var arr = Object.entries(pJson);
for (var i = 0; i < arr.length; i++) {
var n = arr[i][1].n ? arr[i][1].n : "Preset " + arr[i][0];
if (!incPl && arr[i][1].playlist && arr[i][1].playlist.ps) continue; // remove playlists, sub-playlists not yet supported
plSelContent += `<option value="${arr[i][0]}" ${arr[i][0]==el?"selected":""}>${n}</option>`
for (var a of arr) {
var n = a[1].n ? a[1].n : "Preset " + a[0];
if (!incPl && a[1].playlist && a[1].playlist.ps) continue; // remove playlists, sub-playlists not yet supported
plSelContent += `<option value="${a[0]}" ${a[0]==el?"selected":""}>${n}</option>`
}
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)
#define VERSION 2207251
#define VERSION 2207271
//uncomment this if you have a "my_config.h" file you'd like to use
//#define WLED_USE_MY_CONFIG