Skip to content

Commit 551b8af

Browse files
committed
Hide 2D effects on 1D segments
1 parent 887254f commit 551b8af

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

wled00/data/index.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//page js
22
var loc = false, locip, locproto = "http:";
33
var isOn = false, nlA = false, isLv = false, isInfo = false, isNodes = false, syncSend = false/*, syncTglRecv = true*/;
4-
var hasWhite = false, hasRGB = false, hasCCT = false;
4+
var hasWhite = false, hasRGB = false, hasCCT = false, has2D = false;
55
var nlDur = 60, nlTar = 0;
66
var nlMode = false;
77
var segLmax = 0; // size (in pixels) of largest selected segment
@@ -1339,7 +1339,7 @@ function updateSelectedFx()
13391339
if (ds.id>0) {
13401340
if (segLmax==0) fx.classList.add('hide'); // none of the segments selected (hide all effects)
13411341
else {
1342-
if ((segLmax==1 && (!opts[3] || opts[3].indexOf("0")<0)) || (!isM && opts[3] && ((opts[3].indexOf("2")>=0 && opts[3].indexOf("1")<0)))) fx.classList.add('hide');
1342+
if ((segLmax==1 && (!opts[3] || opts[3].indexOf("0")<0)) || (!has2D && opts[3] && ((opts[3].indexOf("2")>=0 && opts[3].indexOf("1")<0)))) fx.classList.add('hide');
13431343
else fx.classList.remove('hide');
13441344
}
13451345
}
@@ -1441,7 +1441,7 @@ function readState(s,command=false)
14411441
populateSegments(s);
14421442
var selc=0;
14431443
var sellvl=0; // 0: selc is invalid, 1: selc is mainseg, 2: selc is first selected
1444-
hasRGB = hasWhite = hasCCT = false;
1444+
hasRGB = hasWhite = hasCCT = has2D = false;
14451445
segLmax = 0;
14461446
for (let i = 0; i < (s.seg||[]).length; i++)
14471447
{
@@ -1452,20 +1452,23 @@ function readState(s,command=false)
14521452
if (s.seg[i].sel) {
14531453
if (sellvl < 2) selc = i; // get first selected segment
14541454
sellvl = 2;
1455-
var lc = lastinfo.leds.seglc[i];
1455+
let w = (s.seg[i].stop - s.seg[i].start);
1456+
let h = s.seg[i].stopY ? (s.seg[i].stopY - s.seg[i].startY) : 1;
1457+
let lc = lastinfo.leds.seglc[i];
14561458
hasRGB |= !!(lc & 0x01);
14571459
hasWhite |= !!(lc & 0x02);
14581460
hasCCT |= !!(lc & 0x04);
1459-
let sLen = (s.seg[i].stop - s.seg[i].start)*(s.seg[i].stopY?(s.seg[i].stopY - s.seg[i].startY):1);
1460-
segLmax = segLmax < sLen ? sLen : segLmax;
1461+
has2D |= w > 1 && h > 1;
1462+
if (w*h > segLmax) segLmax = w*h;
14611463
}
14621464
}
14631465
var i=s.seg[selc];
14641466
if (sellvl == 1) {
1465-
var lc = lastinfo.leds.seglc[selc];
1467+
let lc = lastinfo.leds.seglc[selc];
14661468
hasRGB = !!(lc & 0x01);
14671469
hasWhite = !!(lc & 0x02);
14681470
hasCCT = !!(lc & 0x04);
1471+
has2D = (i.stop - i.start) > 1 && (i.stopY ? (i.stopY - i.startY) : 1) > 1;
14691472
}
14701473
if (!i) {
14711474
showToast('No Segments!', true);

0 commit comments

Comments
 (0)