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++)
{
if (realtimeMode && useMainSegmentOnly && i == getMainSegmentId()) continue;
// freezing main segment will acheve the same as following
//if (realtimeMode && useMainSegmentOnly && i == getMainSegmentId()) continue;
_segment_index = i;

View File

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

View File

@ -583,18 +583,18 @@ function populatePresets(fromls)
populateQL();
}
function parseInfo() {
var li = lastinfo;
var name = li.name;
function parseInfo(i) {
lastinfo = i;
var name = i.name;
gId('namelabel').innerHTML = name;
//if (name === "Dinnerbone") d.documentElement.style.transform = "rotate(180deg)";
if (li.live) name = "(Live) " + name;
if (loc) name = "(L) " + name;
if (i.live) name = "(Live) " + name;
if (loc) name = "(L) " + name;
d.title = name;
ledCount = li.leds.count;
syncTglRecv = li.str;
maxSeg = li.leds.maxseg;
pmt = li.fs.pmt;
ledCount = i.leds.count;
syncTglRecv = i.str;
maxSeg = i.leds.maxseg;
pmt = i.fs.pmt;
}
function populateInfo(i)
@ -639,6 +639,7 @@ ${inforow("Environment",i.arch + " " + i.core + " (" + i.lwip + ")")}
function populateSegments(s)
{
var cn = "";
let li = lastinfo;
segCount = 0; lowestUnused = 0; lSeg = 0;
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":""}>
<span class="checkmark schk"></span>
</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})">
${inst.n ? inst.n : "Segment "+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)
{
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;
gId('lv').innerHTML = `WLED is receiving live ${i.lm} data${sour}`;
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)
var i = json.info;
if (i) {
lastinfo = i;
parseInfo();
parseInfo(i);
showNodes();
if (isInfo) populateInfo(i);
} else
@ -1425,8 +1426,7 @@ function requestJson(command=null)
if (!json) { showToast('Empty response', true); return; }
if (json.success) return;
if (json.info) {
lastinfo = json.info;
parseInfo();
parseInfo(json.info);
if (isInfo) populateInfo(lastinfo);
}
var s = json.state ? json.state : json;
@ -1894,7 +1894,7 @@ function setSegBri(s)
function tglFreeze(s=null)
{
var obj = {"seg": {"frz": "t"}}; // toggle
if (s!==null) obj.id = s;
if (s!==null) obj.seg.id = s;
requestJson(obj);
}
@ -1951,8 +1951,6 @@ function setIntensity()
function setLor(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);
}
@ -2376,8 +2374,6 @@ function expand(i)
gId('seg' +i).innerHTML = "";
gId('putil').classList.add("staybot");
}
// } else {
// gId('segutil').classList.toggle("staybot");
}
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.trigger();
} else if (!elem["frz"] && iarr.isNull()) { //return to regular effect
seg.setOption(SEG_OPTION_FREEZE, false);
// } else if (!elem["frz"] && iarr.isNull()) { //return to regular effect
// seg.setOption(SEG_OPTION_FREEZE, false);
}
// send UDP if not in preset and something changed that is not just selection
//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["recv"] = receiveNotifications;
root[F("lor")] = realtimeOverride || (realtimeMode && useMainSegmentOnly);
root[F("lor")] = realtimeOverride;
}
root[F("mainseg")] = strip.getMainSegmentId();
@ -507,7 +507,8 @@ void serializeInfo(JsonObject root)
root[F("name")] = serverDescription;
root[F("udpport")] = udpPort;
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) {
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();
start = mainseg.start;
stop = mainseg.stop;
mainseg.setOption(SEG_OPTION_FREEZE, true, strip.getMainSegmentId());
} else {
start = 0;
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 (useMainSegmentOnly && bri == 0) {
for (uint8_t s=0; s < strip.getMaxSegments(); s++) {
if (s != strip.getMainSegmentId()) strip.getSegment(s).setOption(SEG_OPTION_ON, 0, s);
else strip.getSegment(s).setOption(SEG_OPTION_ON, 1, s);
if (s != strip.getMainSegmentId()) strip.getSegment(s).setOption(SEG_OPTION_ON, false, s);
else strip.getSegment(s).setOption(SEG_OPTION_ON, true, s);
}
}
}
@ -205,6 +206,7 @@ void handleNotifications()
if (realtimeMode && millis() > realtimeTimeout)
{
if (realtimeOverride == REALTIME_OVERRIDE_ONCE) realtimeOverride = REALTIME_OVERRIDE_NONE;
if (useMainSegmentOnly) strip.getMainSegment().setOption(SEG_OPTION_FREEZE, false, strip.getMainSegmentId());
strip.setBrightness(scaledBri(bri));
realtimeMode = REALTIME_MODE_INACTIVE;
realtimeIP[0] = 0;

View File

@ -8,7 +8,7 @@
*/
// 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
//#define WLED_USE_MY_CONFIG