Allow different 1st segment.

This commit is contained in:
Blaž Kristan 2021-11-26 09:39:49 +01:00
parent ac0a853030
commit 49f79a331c
3 changed files with 882 additions and 880 deletions

View File

@ -696,7 +696,7 @@ function populateSegments(s)
{
segCount++;
var inst=s.seg[y];
var inst = s.seg[y];
let i = parseInt(inst.id);
powered[i] = inst.on;
if (i == lowestUnused) lowestUnused = i+1;
@ -755,7 +755,7 @@ function populateSegments(s)
<input type="checkbox" id="seg${i}mi" onchange="setMi(${i})" ${inst.mi ? "checked":""}>
<span class="checkmark schk"></span>
</label>
${i===0 ? '<button id="btnrpt" class="btn btn-xs del" title="Repeat until end" onclick="rptSeg(0)"><i class="icons btn-icon">&#xe22d;</i></button>' : ''}
<div id="btn${i}rpt"></div>
</div>
</div>`;
}
@ -768,8 +768,9 @@ function populateSegments(s)
resetUtil();
noNewSegs = false;
}
if (lSeg>0 || parseInt(gId("seg0e").value)>=(ledCount-(cfg.comp.seglen?inst.start:0))) gId("btnrpt").style.display = "none";
console.log(lSeg);
if (!noNewSegs && (cfg.comp.seglen?parseInt(gId(`seg${lSeg}s`).value):0)+parseInt(gId(`seg${lSeg}e`).value)<ledCount) {
gId(`btn${lSeg}rpt`).innerHTML = `<button class="btn btn-xs del" style="right:56px;" title="Repeat until end" onclick="rptSeg(${lSeg})"><i class="icons btn-icon">&#xe22d;</i></button>`;
}
for (var i = 0; i <= lSeg; i++) {
updateLen(i);
updateTrail(gId(`seg${i}bri`));
@ -1763,7 +1764,7 @@ function rptSeg(s)
obj.seg.of = ofs;
}
obj.seg.rpt = true;
expand(0);
expand(s);
requestJson(obj);
}

File diff suppressed because it is too large Load Diff

View File

@ -22,13 +22,14 @@ void deserializeSegment(JsonObject elem, byte it, byte presetId)
stop = (len > 0) ? start + len : seg.stop;
}
// multiply segment 0 (?) if requested untill all LEDs are used
bool repeat = elem["rpt"] | false;
if (repeat && stop>0) {
elem.remove("id"); // remove for recursive call
elem.remove("rpt"); // remove for recursive call
elem.remove("n"); // remove for recursive call
uint16_t len = stop - start;
for (byte i=1; i<strip.getMaxSegments(); i++) {
for (byte i=id+1; i<strip.getMaxSegments(); i++) {
start = start + len;
if (start >= strip.getLengthTotal()) break;
elem["start"] = start;