Freeze/unfreeze for mainseg UDP.

This commit is contained in:
Blaz Kristan 2022-03-28 22:36:58 +02:00
parent ba6a01408d
commit 955bb51f11
7 changed files with 1725 additions and 1710 deletions

View File

@ -131,7 +131,8 @@ void WS2812FX::service() {
for(uint8_t i=0; i < MAX_NUM_SEGMENTS; i++) for(uint8_t i=0; i < MAX_NUM_SEGMENTS; i++)
{ {
if (realtimeMode && useMainSegmentOnly && i == getMainSegmentId()) continue; // freezing main segment will acheve the same as following
//if (realtimeMode && useMainSegmentOnly && i == getMainSegmentId()) continue;
_segment_index = i; _segment_index = i;

View File

@ -98,11 +98,12 @@ button {
#namelabel { #namelabel {
position: fixed; position: fixed;
bottom: calc(var(--bh) + 6px); bottom: var(--bh);
right: 6px; right: 0;
color: var(--c-b); color: var(--c-d);
cursor: pointer; cursor: pointer;
writing-mode: vertical-rl; /* writing-mode: vertical-rl; */
transform: rotate(-90deg) translate(30px,20px);
} }
.bri { .bri {
@ -934,6 +935,18 @@ textarea {
right: 8px; right: 8px;
} }
.frz {
left: 36px;
position: absolute;
top: -3px;
cursor: pointer;
padding: 8px;
}
.expanded .frz {
display: none;
}
/* radiobuttons and checkmarks */ /* radiobuttons and checkmarks */
.check, .radio { .check, .radio {
display: block; display: block;

View File

@ -583,18 +583,18 @@ function populatePresets(fromls)
populateQL(); populateQL();
} }
function parseInfo() { function parseInfo(i) {
var li = lastinfo; lastinfo = i;
var name = li.name; var name = i.name;
gId('namelabel').innerHTML = name; gId('namelabel').innerHTML = name;
//if (name === "Dinnerbone") d.documentElement.style.transform = "rotate(180deg)"; //if (name === "Dinnerbone") d.documentElement.style.transform = "rotate(180deg)";
if (li.live) name = "(Live) " + name; if (i.live) name = "(Live) " + name;
if (loc) name = "(L) " + name; if (loc) name = "(L) " + name;
d.title = name; d.title = name;
ledCount = li.leds.count; ledCount = i.leds.count;
syncTglRecv = li.str; syncTglRecv = i.str;
maxSeg = li.leds.maxseg; maxSeg = i.leds.maxseg;
pmt = li.fs.pmt; pmt = i.fs.pmt;
} }
function populateInfo(i) function populateInfo(i)
@ -639,6 +639,7 @@ ${inforow("Environment",i.arch + " " + i.core + " (" + i.lwip + ")")}
function populateSegments(s) function populateSegments(s)
{ {
var cn = ""; var cn = "";
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 y = 0; y < (s.seg||[]).length; y++)
@ -665,6 +666,7 @@ function populateSegments(s)
<input type="checkbox" id="seg${i}sel" onchange="selSeg(${i})" ${inst.sel ? "checked":""}> <input type="checkbox" id="seg${i}sel" onchange="selSeg(${i})" ${inst.sel ? "checked":""}>
<span class="checkmark schk"></span> <span class="checkmark schk"></span>
</label> </label>
<i class="icons e-icon frz" id="seg${i}frz" onclick="event.preventDefault();tglFreeze(${i});">&#x${inst.frz ? (li.live && li.liveseg==i?'e410':'e0e8') : 'e325'};</i>
<div class="segname" onclick="selSegEx(${i})"> <div class="segname" onclick="selSegEx(${i})">
${inst.n ? inst.n : "Segment "+i} ${inst.n ? inst.n : "Segment "+i}
<i class="icons edit-icon" id="seg${i}nedit" onclick="tglSegn(${i})">&#xe2c6;</i> <i class="icons edit-icon" id="seg${i}nedit" onclick="tglSegn(${i})">&#xe2c6;</i>
@ -1079,7 +1081,7 @@ function updateSelectedFx()
function displayRover(i,s) function displayRover(i,s)
{ {
gId('rover').style.transform = (i.live && s.lor == 0) ? "translateY(0px)":"translateY(100%)"; gId('rover').style.transform = (i.live && s.lor == 0 && i.liveseg<0) ? "translateY(0px)":"translateY(100%)";
var sour = i.lip ? i.lip:""; if (sour.length > 2) sour = " from " + sour; var sour = i.lip ? i.lip:""; if (sour.length > 2) sour = " from " + sour;
gId('lv').innerHTML = `WLED is receiving live ${i.lm} data${sour}`; gId('lv').innerHTML = `WLED is receiving live ${i.lm} data${sour}`;
gId('roverstar').style.display = (i.live && s.lor) ? "block":"none"; gId('roverstar').style.display = (i.live && s.lor) ? "block":"none";
@ -1113,8 +1115,7 @@ function makeWS() {
// json object should contain json.info AND json.state (but may not) // json object should contain json.info AND json.state (but may not)
var i = json.info; var i = json.info;
if (i) { if (i) {
lastinfo = i; parseInfo(i);
parseInfo();
showNodes(); showNodes();
if (isInfo) populateInfo(i); if (isInfo) populateInfo(i);
} else } else
@ -1425,8 +1426,7 @@ function requestJson(command=null)
if (!json) { showToast('Empty response', true); return; } if (!json) { showToast('Empty response', true); return; }
if (json.success) return; if (json.success) return;
if (json.info) { if (json.info) {
lastinfo = json.info; parseInfo(json.info);
parseInfo();
if (isInfo) populateInfo(lastinfo); if (isInfo) populateInfo(lastinfo);
} }
var s = json.state ? json.state : json; var s = json.state ? json.state : json;
@ -1894,7 +1894,7 @@ function setSegBri(s)
function tglFreeze(s=null) function tglFreeze(s=null)
{ {
var obj = {"seg": {"frz": "t"}}; // toggle var obj = {"seg": {"frz": "t"}}; // toggle
if (s!==null) obj.id = s; if (s!==null) obj.seg.id = s;
requestJson(obj); requestJson(obj);
} }
@ -1951,8 +1951,6 @@ function setIntensity()
function setLor(i) function setLor(i)
{ {
var obj = {"lor": i}; var obj = {"lor": i};
// allow canceling live mode (if sender crashes)
if (i===0 && lastinfo.live && ["","Hyperion","UDP"].includes(lastinfo.lm)) { obj.live = false; obj.v = true; }
requestJson(obj); requestJson(obj);
} }
@ -2376,8 +2374,6 @@ function expand(i)
gId('seg' +i).innerHTML = ""; gId('seg' +i).innerHTML = "";
gId('putil').classList.add("staybot"); gId('putil').classList.add("staybot");
} }
// } else {
// gId('segutil').classList.toggle("staybot");
} }
seg.scrollIntoView({ seg.scrollIntoView({

File diff suppressed because it is too large Load Diff

View File

@ -213,8 +213,8 @@ void deserializeSegment(JsonObject elem, byte it, byte presetId)
} }
strip.setPixelSegment(oldSegId); strip.setPixelSegment(oldSegId);
strip.trigger(); strip.trigger();
} else if (!elem["frz"] && iarr.isNull()) { //return to regular effect // } else if (!elem["frz"] && iarr.isNull()) { //return to regular effect
seg.setOption(SEG_OPTION_FREEZE, false); // seg.setOption(SEG_OPTION_FREEZE, false);
} }
// send UDP if not in preset and something changed that is not just selection // send UDP if not in preset and something changed that is not just selection
//if (!presetId && (seg.differs(prev) & 0x7F)) stateChanged = true; //if (!presetId && (seg.differs(prev) & 0x7F)) stateChanged = true;
@ -453,7 +453,7 @@ void serializeState(JsonObject root, bool forPreset, bool includeBri, bool segme
udpn["send"] = notifyDirect; udpn["send"] = notifyDirect;
udpn["recv"] = receiveNotifications; udpn["recv"] = receiveNotifications;
root[F("lor")] = realtimeOverride || (realtimeMode && useMainSegmentOnly); root[F("lor")] = realtimeOverride;
} }
root[F("mainseg")] = strip.getMainSegmentId(); root[F("mainseg")] = strip.getMainSegmentId();
@ -507,7 +507,8 @@ void serializeInfo(JsonObject root)
root[F("name")] = serverDescription; root[F("name")] = serverDescription;
root[F("udpport")] = udpPort; root[F("udpport")] = udpPort;
root["live"] = (bool)realtimeMode; root["live"] = (bool)realtimeMode;
root[F("mso")] = useMainSegmentOnly; // using main segment only for live root[F("liveseg")] = useMainSegmentOnly ? strip.getMainSegmentId() : -1; // if using main segment only for live
// root[F("mso")] = useMainSegmentOnly; // using main segment only for live
switch (realtimeMode) { switch (realtimeMode) {
case REALTIME_MODE_INACTIVE: root["lm"] = ""; break; case REALTIME_MODE_INACTIVE: root["lm"] = ""; break;

View File

@ -146,6 +146,7 @@ void realtimeLock(uint32_t timeoutMs, byte md)
WS2812FX::Segment& mainseg = strip.getMainSegment(); WS2812FX::Segment& mainseg = strip.getMainSegment();
start = mainseg.start; start = mainseg.start;
stop = mainseg.stop; stop = mainseg.stop;
mainseg.setOption(SEG_OPTION_FREEZE, true, strip.getMainSegmentId());
} else { } else {
start = 0; start = 0;
stop = strip.getLengthTotal(); stop = strip.getLengthTotal();
@ -155,8 +156,8 @@ void realtimeLock(uint32_t timeoutMs, byte md)
// if WLED was off and using main segment only, turn non-main segments off // if WLED was off and using main segment only, turn non-main segments off
if (useMainSegmentOnly && bri == 0) { if (useMainSegmentOnly && bri == 0) {
for (uint8_t s=0; s < strip.getMaxSegments(); s++) { for (uint8_t s=0; s < strip.getMaxSegments(); s++) {
if (s != strip.getMainSegmentId()) strip.getSegment(s).setOption(SEG_OPTION_ON, 0, s); if (s != strip.getMainSegmentId()) strip.getSegment(s).setOption(SEG_OPTION_ON, false, s);
else strip.getSegment(s).setOption(SEG_OPTION_ON, 1, s); else strip.getSegment(s).setOption(SEG_OPTION_ON, true, s);
} }
} }
} }
@ -205,6 +206,7 @@ void handleNotifications()
if (realtimeMode && millis() > realtimeTimeout) if (realtimeMode && millis() > realtimeTimeout)
{ {
if (realtimeOverride == REALTIME_OVERRIDE_ONCE) realtimeOverride = REALTIME_OVERRIDE_NONE; if (realtimeOverride == REALTIME_OVERRIDE_ONCE) realtimeOverride = REALTIME_OVERRIDE_NONE;
if (useMainSegmentOnly) strip.getMainSegment().setOption(SEG_OPTION_FREEZE, false, strip.getMainSegmentId());
strip.setBrightness(scaledBri(bri)); strip.setBrightness(scaledBri(bri));
realtimeMode = REALTIME_MODE_INACTIVE; realtimeMode = REALTIME_MODE_INACTIVE;
realtimeIP[0] = 0; realtimeIP[0] = 0;

View File

@ -8,7 +8,7 @@
*/ */
// version code in format yymmddb (b = daily build) // version code in format yymmddb (b = daily build)
#define VERSION 2203261 #define VERSION 2203281
//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