mirror of
https://github.com/wled/WLED.git
synced 2025-07-08 11:26:33 +00:00
Manual advance playlist
This commit is contained in:
parent
409b4b1963
commit
7ce96c190f
@ -1974,6 +1974,13 @@ function pleDur(p,i,field)
|
||||
|
||||
function pleTr(p,i,field)
|
||||
{
|
||||
const du = gId(`pl${p}du${i}`);
|
||||
const dv = parseFloat(du.value);
|
||||
if (dv > 0) {
|
||||
field.max = dv;
|
||||
if (parseFloat(field.value) > dv)
|
||||
field.value = du.value;
|
||||
}
|
||||
if (field.validity.valid)
|
||||
plJson[p].transition[i] = Math.floor(field.value*10);
|
||||
}
|
||||
@ -1993,6 +2000,17 @@ function plR(p)
|
||||
}
|
||||
}
|
||||
|
||||
function plM(p)
|
||||
{
|
||||
const man = gId(`pl${p}manual`).checked;
|
||||
plJson[p].dur.forEach((e,i)=>{
|
||||
const d = gId(`pl${p}du${i}`);
|
||||
plJson[p].dur[i] = e = man ? 0 : 100;
|
||||
d.value = e/10; // 10s default
|
||||
d.readOnly = man;
|
||||
});
|
||||
}
|
||||
|
||||
function makeP(i,pl)
|
||||
{
|
||||
var content = "";
|
||||
@ -2006,12 +2024,17 @@ function makeP(i,pl)
|
||||
r: false,
|
||||
end: 0
|
||||
};
|
||||
var rep = plJson[i].repeat ? plJson[i].repeat : 0;
|
||||
const rep = plJson[i].repeat ? plJson[i].repeat : 0;
|
||||
const man = plJson[i].dur == 0;
|
||||
content =
|
||||
`<div id="ple${i}" style="margin-top:10px;"></div><label class="check revchkl">Shuffle
|
||||
<input type="checkbox" id="pl${i}rtgl" onchange="plR(${i})" ${plJson[i].r||rep<0?"checked":""}>
|
||||
<span class="checkmark"></span>
|
||||
</label>
|
||||
<label class="check revchkl">Manual advance
|
||||
<input type="checkbox" id="pl${i}manual" onchange="plM(${i})" ${man?"checked":""}>
|
||||
<span class="checkmark"></span>
|
||||
</label>
|
||||
<label class="check revchkl">Repeat indefinitely
|
||||
<input type="checkbox" id="pl${i}rptgl" onchange="plR(${i})" ${rep>0?"":"checked"}>
|
||||
<span class="checkmark"></span>
|
||||
@ -2095,6 +2118,7 @@ function makePUtil()
|
||||
|
||||
function makePlEntry(p,i)
|
||||
{
|
||||
const man = gId(`pl${p}manual`).checked;
|
||||
return `<div class="plentry">
|
||||
<div class="hrz"></div>
|
||||
<table>
|
||||
@ -2107,13 +2131,13 @@ function makePlEntry(p,i)
|
||||
<td class="c"><button class="btn btn-pl-add" onclick="addPl(${p},${i})"><i class="icons btn-icon"></i></button></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="c">Duration</td>
|
||||
<td class="c">Duration <i style="font-size:70%;">(0=inf.)</i></td>
|
||||
<td class="c">Transition</td>
|
||||
<td class="c">#${i+1}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="c" width="40%"><input class="segn" type="number" placeholder="Duration" max=6553.0 min=0.2 step=0.1 oninput="pleDur(${p},${i},this)" value="${plJson[p].dur[i]/10.0}">s</td>
|
||||
<td class="c" width="40%"><input class="segn" type="number" placeholder="Transition" max=65.0 min=0.0 step=0.1 oninput="pleTr(${p},${i},this)" value="${plJson[p].transition[i]/10.0}">s</td>
|
||||
<td class="c" width="40%"><input class="segn" type="number" placeholder="Duration" max=6553.0 min=0.0 step=0.1 oninput="pleDur(${p},${i},this)" value="${plJson[p].dur[i]/10.0}" id="pl${p}du${i}" ${man?"readonly":""}>s</td>
|
||||
<td class="c" width="40%"><input class="segn" type="number" placeholder="Transition" max=65.0 min=0.0 step=0.1 oninput="pleTr(${p},${i},this)" onfocus="pleTr(${p},${i},this)" value="${plJson[p].transition[i]/10.0}">s</td>
|
||||
<td class="c"><button class="btn btn-pl-del" onclick="delPl(${p},${i})"><i class="icons btn-icon"></i></button></div></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
@ -85,7 +85,7 @@ int16_t loadPlaylist(JsonObject playlistObj, byte presetId) {
|
||||
} else {
|
||||
for (int dur : durations) {
|
||||
if (it >= playlistLen) break;
|
||||
playlistEntries[it].dur = (dur > 1) ? dur : 100;
|
||||
playlistEntries[it].dur = constrain(dur, 0, 65530);
|
||||
it++;
|
||||
}
|
||||
}
|
||||
@ -146,7 +146,7 @@ void handlePlaylist() {
|
||||
static unsigned long presetCycledTime = 0;
|
||||
if (currentPlaylist < 0 || playlistEntries == nullptr) return;
|
||||
|
||||
if (millis() - presetCycledTime > (100 * playlistEntryDur) || doAdvancePlaylist) {
|
||||
if ((playlistEntryDur < UINT16_MAX && millis() - presetCycledTime > 100 * playlistEntryDur) || doAdvancePlaylist) {
|
||||
presetCycledTime = millis();
|
||||
if (bri == 0 || nightlightActive) return;
|
||||
|
||||
@ -169,7 +169,7 @@ void handlePlaylist() {
|
||||
|
||||
jsonTransitionOnce = true;
|
||||
strip.setTransition(playlistEntries[playlistIndex].tr * 100);
|
||||
playlistEntryDur = playlistEntries[playlistIndex].dur;
|
||||
playlistEntryDur = playlistEntries[playlistIndex].dur > 0 ? playlistEntries[playlistIndex].dur : UINT16_MAX;
|
||||
applyPresetFromPlaylist(playlistEntries[playlistIndex].preset);
|
||||
doAdvancePlaylist = false;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user