Skip to content

Commit

Permalink
Live mainseg improvements
Browse files Browse the repository at this point in the history
Make override work in mainseg mode
Move unfreeze on turn on from UI to JSON parser
Fix mainseg not unfreezing on timeout
  • Loading branch information
Aircoookie committed Mar 31, 2022
1 parent ae90aa4 commit 958cd35
Show file tree
Hide file tree
Showing 9 changed files with 2,279 additions and 2,261 deletions.
3 changes: 2 additions & 1 deletion wled00/data/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -867,11 +867,12 @@ input[type=number]::-webkit-outer-spin-button {
.frz {
left: 36px;
position: absolute;
top: -2px;
top: 0px;
cursor: pointer;
padding: 8px;
}

/* TODO expanded does not seem to apply to .frz, what is this for? */
.expanded .frz {
display: none;
}
Expand Down
2 changes: 1 addition & 1 deletion wled00/data/index.htm
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
<div id="Effects" class="tabcontent">
<p class="labels">Effect speed</p>
<div class="staytop">
<i class="icons slider-icon" style="cursor: pointer;" onclick="tglFreeze()">&#xe325;</i>
<i class="icons slider-icon" style="cursor: pointer;" title="Freeze" onclick="tglFreeze()">&#xe325;</i>
<div class="sliderwrap il">
<input id="sliderSpeed" class="noslide" onchange="setSpeed()" oninput="updateTrail(this)" max="255" min="0" type="range" value="128" />
<output class="sliderbubble hidden"></output>
Expand Down
13 changes: 6 additions & 7 deletions wled00/data/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,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>
<i class="icons e-icon frz" id="seg${i}frz" onclick="event.preventDefault();tglFreeze(${i});" style="display:${inst.frz?"inline":"none"}">&#x${li.live && li.liveseg==i?'e410':'e325'};</i>
<div class="segname">
<div class="segntxt" onclick="selSegEx(${i})">${inst.n ? inst.n : "Segment "+i}</div>
<i class="icons edit-icon ${expanded[i] ? "expanded":""}" id="seg${i}nedit" onclick="tglSegn(${i})">&#xe2c6;</i>
Expand Down Expand Up @@ -1254,11 +1254,6 @@ function requestJson(command, rinfo = true) {
function togglePower() {
isOn = !isOn;
var obj = {"on": isOn};
if (isOn && lastinfo && lastinfo.live && lastinfo.liveseg>=0) {
obj.live = false;
obj.seg = [];
obj.seg[0] ={"id": lastinfo.liveseg, "frz": false};
}
requestJson(obj);
}

Expand Down Expand Up @@ -1650,7 +1645,11 @@ function setSegBri(s){
function tglFreeze(s=null)
{
var obj = {"seg": {"frz": "t"}}; // toggle
if (s!==null) obj.seg.id = s;
if (s!==null) {
obj.seg.id = s;
// if live segment, enter live override (which also unfreezes)
if (lastinfo && s==lastinfo.liveseg && lastinfo.live) obj = {"lor":1};
}
requestJson(obj);
}

Expand Down
8 changes: 4 additions & 4 deletions wled00/e131.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void handleDDPPacket(e131_packet_t* p) {

realtimeLock(realtimeTimeoutMs, REALTIME_MODE_DDP);

if (!realtimeOverride || (realtimeMode && useMainSegmentOnly)) {
if (!realtimeOverride) {
for (uint16_t i = start; i < stop; i++) {
setRealtimePixel(i, data[c], data[c+1], data[c+2], 0);
c+=3;
Expand Down Expand Up @@ -115,7 +115,7 @@ void handleE131Packet(e131_packet_t* p, IPAddress clientIP, byte protocol){
if (uni != e131Universe) return;
if (dmxChannels-DMXAddress+1 < 3) return;
realtimeLock(realtimeTimeoutMs, mde);
if (realtimeOverride && !(realtimeMode && useMainSegmentOnly)) return;
if (realtimeOverride) return;
wChannel = (dmxChannels-DMXAddress+1 > 3) ? e131_data[DMXAddress+3] : 0;
for (uint16_t i = 0; i < totalLen; i++)
setRealtimePixel(i, e131_data[DMXAddress+0], e131_data[DMXAddress+1], e131_data[DMXAddress+2], wChannel);
Expand All @@ -125,7 +125,7 @@ void handleE131Packet(e131_packet_t* p, IPAddress clientIP, byte protocol){
if (uni != e131Universe) return;
if (dmxChannels-DMXAddress+1 < 4) return;
realtimeLock(realtimeTimeoutMs, mde);
if (realtimeOverride && !(realtimeMode && useMainSegmentOnly)) return;
if (realtimeOverride) return;
wChannel = (dmxChannels-DMXAddress+1 > 4) ? e131_data[DMXAddress+4] : 0;
if (DMXOldDimmer != e131_data[DMXAddress+0]) {
DMXOldDimmer = e131_data[DMXAddress+0];
Expand Down Expand Up @@ -176,7 +176,7 @@ void handleE131Packet(e131_packet_t* p, IPAddress clientIP, byte protocol){
bool is4Chan = (DMXMode == DMX_MODE_MULTIPLE_RGBW);
const uint16_t dmxChannelsPerLed = is4Chan ? 4 : 3;
const uint16_t ledsPerUniverse = is4Chan ? MAX_4_CH_LEDS_PER_UNIVERSE : MAX_3_CH_LEDS_PER_UNIVERSE;
if (realtimeOverride && !(realtimeMode && useMainSegmentOnly)) return;
if (realtimeOverride) return;
uint16_t previousLeds, dmxOffset;
if (previousUniverses == 0) {
if (dmxChannels-DMXAddress < 1) return;
Expand Down
1 change: 1 addition & 0 deletions wled00/fcn_declare.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ bool updateVal(const String* req, const char* key, byte* val, byte minv=0, byte
void notify(byte callMode, bool followUp=false);
uint8_t realtimeBroadcast(uint8_t type, IPAddress client, uint16_t length, byte *buffer, uint8_t bri=255, bool isRGBW=false);
void realtimeLock(uint32_t timeoutMs, byte md = REALTIME_MODE_GENERIC);
void exitRealtime();
void handleNotifications();
void setRealtimePixel(uint16_t i, byte r, byte g, byte b, byte w);
void refreshNodeList();
Expand Down
Loading

0 comments on commit 958cd35

Please sign in to comment.