Segment bounds sync option
This commit is contained in:
parent
447b811fa0
commit
7aef551292
@ -261,6 +261,7 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
|
|||||||
CJSON(receiveNotificationEffects, if_sync_recv["fx"]);
|
CJSON(receiveNotificationEffects, if_sync_recv["fx"]);
|
||||||
CJSON(receiveGroups, if_sync_recv["grp"]);
|
CJSON(receiveGroups, if_sync_recv["grp"]);
|
||||||
CJSON(receiveSegmentOptions, if_sync_recv["seg"]);
|
CJSON(receiveSegmentOptions, if_sync_recv["seg"]);
|
||||||
|
CJSON(receiveSegmentBounds, if_sync_recv["sb"]);
|
||||||
//! following line might be a problem if called after boot
|
//! following line might be a problem if called after boot
|
||||||
receiveNotifications = (receiveNotificationBrightness || receiveNotificationColor || receiveNotificationEffects || receiveSegmentOptions);
|
receiveNotifications = (receiveNotificationBrightness || receiveNotificationColor || receiveNotificationEffects || receiveSegmentOptions);
|
||||||
|
|
||||||
@ -673,9 +674,10 @@ void serializeConfig() {
|
|||||||
JsonObject if_sync_recv = if_sync.createNestedObject("recv");
|
JsonObject if_sync_recv = if_sync.createNestedObject("recv");
|
||||||
if_sync_recv["bri"] = receiveNotificationBrightness;
|
if_sync_recv["bri"] = receiveNotificationBrightness;
|
||||||
if_sync_recv["col"] = receiveNotificationColor;
|
if_sync_recv["col"] = receiveNotificationColor;
|
||||||
if_sync_recv["fx"] = receiveNotificationEffects;
|
if_sync_recv["fx"] = receiveNotificationEffects;
|
||||||
if_sync_recv["grp"] = receiveGroups;
|
if_sync_recv["grp"] = receiveGroups;
|
||||||
if_sync_recv["seg"] = receiveSegmentOptions;
|
if_sync_recv["seg"] = receiveSegmentOptions;
|
||||||
|
if_sync_recv["sb"] = receiveSegmentBounds;
|
||||||
|
|
||||||
JsonObject if_sync_send = if_sync.createNestedObject("send");
|
JsonObject if_sync_send = if_sync.createNestedObject("send");
|
||||||
if_sync_send[F("dir")] = notifyDirect;
|
if_sync_send[F("dir")] = notifyDirect;
|
||||||
|
@ -83,7 +83,7 @@ UDP Port: <input name="UP" type="number" min="1" max="65535" class="d5" required
|
|||||||
</tr>
|
</tr>
|
||||||
</table><br>
|
</table><br>
|
||||||
Receive: <input type="checkbox" name="RB"> Brightness, <input type="checkbox" name="RC"> Color, and <input type="checkbox" name="RX"> Effects<br>
|
Receive: <input type="checkbox" name="RB"> Brightness, <input type="checkbox" name="RC"> Color, and <input type="checkbox" name="RX"> Effects<br>
|
||||||
<input type="checkbox" name="SO"> Segment options<br>
|
<input type="checkbox" name="SO"> Segment options, <input type="checkbox" name="SG"> bounds<br>
|
||||||
Send notifications on direct change: <input type="checkbox" name="SD"><br>
|
Send notifications on direct change: <input type="checkbox" name="SD"><br>
|
||||||
Send notifications on button press or IR: <input type="checkbox" name="SB"><br>
|
Send notifications on button press or IR: <input type="checkbox" name="SB"><br>
|
||||||
Send Alexa notifications: <input type="checkbox" name="SA"><br>
|
Send Alexa notifications: <input type="checkbox" name="SA"><br>
|
||||||
|
@ -85,7 +85,7 @@ charset="utf-8"><meta name="theme-color" content="#222222"><title>
|
|||||||
WLED Live Preview</title><style>
|
WLED Live Preview</title><style>
|
||||||
body{margin:0}#canv{background:#000;filter:brightness(175%);width:100%;height:100%;position:absolute}
|
body{margin:0}#canv{background:#000;filter:brightness(175%);width:100%;height:100%;position:absolute}
|
||||||
</style></head><body><div id="canv"><script>
|
</style></head><body><div id="canv"><script>
|
||||||
function updatePreview(e){var n="linear-gradient(90deg,",t=e.length;for(i=2;i<t;i+=3)n+=`rgb(${e[i]},${e[i+1]},${e[i+2]})`,i<t-3&&(n+=",");n+=")",document.getElementById("canv").style.background=n}function getLiveJson(e){try{if(e.data instanceof ArrayBuffer||"[object ArrayBuffer]"===toString.call(e.data)){let e=new Uint8Array(event.data);if(76!=e[0])return;updatePreview(e)}}catch(e){console.error("Peek WS error:",e)}}var ws=top.window.ws;ws&&ws.readyState===WebSocket.OPEN?(console.info("Peek uses top WS"),ws.send("{'lv':true}")):(console.info("Peek WS opening"),(ws=new WebSocket("ws://"+document.location.host+"/ws")).onopen=function(){console.info("Peek WS open"),ws.send("{'lv':true}")}),ws.binaryType="arraybuffer",ws.addEventListener("message",getLiveJson)
|
function updatePreview(e){var n="linear-gradient(90deg,",t=e.length;for(i=2;i<t;i+=3)n+=`rgb(${e[i]},${e[i+1]},${e[i+2]})`,i<t-3&&(n+=",");n+=")",document.getElementById("canv").style.background=n}function getLiveJson(e){try{if("[object ArrayBuffer]"===toString.call(e.data)){let e=new Uint8Array(event.data);if(76!=e[0])return;updatePreview(e)}}catch(e){console.error("Peek WS error:",e)}}var ws=top.window.ws;ws&&ws.readyState===WebSocket.OPEN?(console.info("Peek uses top WS"),ws.send("{'lv':true}")):(console.info("Peek WS opening"),(ws=new WebSocket("ws://"+document.location.host+"/ws")).onopen=function(){console.info("Peek WS open"),ws.send("{'lv':true}")}),ws.binaryType="arraybuffer",ws.addEventListener("message",getLiveJson)
|
||||||
</script></body></html>)=====";
|
</script></body></html>)=====";
|
||||||
|
|
||||||
|
|
||||||
|
@ -276,9 +276,10 @@ type="checkbox" id="R7" name="R7"></td><td><input type="checkbox" id="R8"
|
|||||||
name="R8"></td></tr></table><br>Receive: <input type="checkbox" name="RB">
|
name="R8"></td></tr></table><br>Receive: <input type="checkbox" name="RB">
|
||||||
Brightness, <input type="checkbox" name="RC"> Color, and <input
|
Brightness, <input type="checkbox" name="RC"> Color, and <input
|
||||||
type="checkbox" name="RX"> Effects<br><input type="checkbox" name="SO">
|
type="checkbox" name="RX"> Effects<br><input type="checkbox" name="SO">
|
||||||
Segment options<br>Send notifications on direct change: <input type="checkbox"
|
Segment options, <input type="checkbox" name="SG"> bounds<br>
|
||||||
name="SD"><br>Send notifications on button press or IR: <input type="checkbox"
|
Send notifications on direct change: <input type="checkbox" name="SD"><br>
|
||||||
name="SB"><br>Send Alexa notifications: <input type="checkbox" name="SA"><br>
|
Send notifications on button press or IR: <input type="checkbox" name="SB"><br>
|
||||||
|
Send Alexa notifications: <input type="checkbox" name="SA"><br>
|
||||||
Send Philips Hue change notifications: <input type="checkbox" name="SH"><br>
|
Send Philips Hue change notifications: <input type="checkbox" name="SH"><br>
|
||||||
Send Macro notifications: <input type="checkbox" name="SM"><br>
|
Send Macro notifications: <input type="checkbox" name="SM"><br>
|
||||||
Send notifications twice: <input type="checkbox" name="S2"><br><i>
|
Send notifications twice: <input type="checkbox" name="S2"><br><i>
|
||||||
|
@ -233,6 +233,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
|
|||||||
receiveNotificationColor = request->hasArg(F("RC"));
|
receiveNotificationColor = request->hasArg(F("RC"));
|
||||||
receiveNotificationEffects = request->hasArg(F("RX"));
|
receiveNotificationEffects = request->hasArg(F("RX"));
|
||||||
receiveSegmentOptions = request->hasArg(F("SO"));
|
receiveSegmentOptions = request->hasArg(F("SO"));
|
||||||
|
receiveSegmentBounds = request->hasArg(F("SG"));
|
||||||
receiveNotifications = (receiveNotificationBrightness || receiveNotificationColor || receiveNotificationEffects || receiveSegmentOptions);
|
receiveNotifications = (receiveNotificationBrightness || receiveNotificationColor || receiveNotificationEffects || receiveSegmentOptions);
|
||||||
notifyDirectDefault = request->hasArg(F("SD"));
|
notifyDirectDefault = request->hasArg(F("SD"));
|
||||||
notifyDirect = notifyDirectDefault;
|
notifyDirect = notifyDirectDefault;
|
||||||
|
@ -322,16 +322,20 @@ void handleNotifications()
|
|||||||
if (version < 200)
|
if (version < 200)
|
||||||
{
|
{
|
||||||
if (applyEffects && currentPlaylist >= 0) unloadPlaylist();
|
if (applyEffects && currentPlaylist >= 0) unloadPlaylist();
|
||||||
if (version > 10 && receiveSegmentOptions) {
|
if (version > 10 && (receiveSegmentOptions || receiveSegmentBounds)) {
|
||||||
//does not sync start & stop
|
uint8_t numSrcSegs = udpIn[39];
|
||||||
uint8_t srcSegs = udpIn[39];
|
for (uint8_t i = 0; i < numSrcSegs; i++) {
|
||||||
//if (srcSegs > strip.getMaxSegments()) srcSegs = strip.getMaxSegments();
|
|
||||||
for (uint8_t i = 0; i < srcSegs; i++) {
|
|
||||||
uint16_t ofs = 41 + i*udpIn[40]; //start of segment offset byte
|
uint16_t ofs = 41 + i*udpIn[40]; //start of segment offset byte
|
||||||
uint8_t id = udpIn[0 +ofs];
|
uint8_t id = udpIn[0 +ofs];
|
||||||
if (id > strip.getMaxSegments()) continue;
|
if (id > strip.getMaxSegments()) continue;
|
||||||
WS2812FX::Segment& selseg = strip.getSegment(id);
|
WS2812FX::Segment& selseg = strip.getSegment(id);
|
||||||
//bytes 1+2 contain start, 3+4 stop, unused at this time
|
uint16_t start = (udpIn[1+ofs] << 8 | udpIn[2+ofs]);
|
||||||
|
uint16_t stop = (udpIn[3+ofs] << 8 | udpIn[4+ofs]);
|
||||||
|
uint16_t offset = (udpIn[7+ofs] << 8 | udpIn[8+ofs]);
|
||||||
|
if (!receiveSegmentOptions) {
|
||||||
|
strip.setSegment(id, start, stop, selseg.grouping, selseg.spacing, offset);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
for (uint8_t j = 0; j<4; j++) selseg.setOption(j, (udpIn[9 +ofs] >> j) & 0x01); //only take into account mirrored, selected, on, reversed
|
for (uint8_t j = 0; j<4; j++) selseg.setOption(j, (udpIn[9 +ofs] >> j) & 0x01); //only take into account mirrored, selected, on, reversed
|
||||||
selseg.setOpacity(udpIn[10+ofs], id);
|
selseg.setOpacity(udpIn[10+ofs], id);
|
||||||
if (applyEffects) {
|
if (applyEffects) {
|
||||||
@ -346,12 +350,19 @@ void handleNotifications()
|
|||||||
selseg.setColor(2, RGBW32(udpIn[23+ofs],udpIn[24+ofs],udpIn[25+ofs],udpIn[26+ofs]), id);
|
selseg.setColor(2, RGBW32(udpIn[23+ofs],udpIn[24+ofs],udpIn[25+ofs],udpIn[26+ofs]), id);
|
||||||
selseg.setCCT(udpIn[27+ofs], id);
|
selseg.setCCT(udpIn[27+ofs], id);
|
||||||
}
|
}
|
||||||
strip.setSegment(id, selseg.start, selseg.stop, udpIn[5+ofs], udpIn[6+ofs], (udpIn[7+ofs]<<8 | udpIn[8+ofs])); //also properly resets segments
|
//setSegment() also properly resets segments
|
||||||
|
if (receiveSegmentBounds) {
|
||||||
|
strip.setSegment(id, start, stop, udpIn[5+ofs], udpIn[6+ofs], offset);
|
||||||
|
} else {
|
||||||
|
strip.setSegment(id, selseg.start, selseg.stop, udpIn[5+ofs], udpIn[6+ofs], selseg.offset);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
setValuesFromMainSeg();
|
setValuesFromMainSeg();
|
||||||
effectChanged = true;
|
effectChanged = true;
|
||||||
colorChanged = true;
|
colorChanged = true;
|
||||||
} else if (applyEffects) { //simple effect sync, applies to all selected
|
}
|
||||||
|
|
||||||
|
if (applyEffects && (version < 11 || !receiveSegmentOptions)) { //simple effect sync, applies to all selected
|
||||||
if (udpIn[8] < strip.getModeCount()) effectCurrent = udpIn[8];
|
if (udpIn[8] < strip.getModeCount()) effectCurrent = udpIn[8];
|
||||||
effectSpeed = udpIn[9];
|
effectSpeed = udpIn[9];
|
||||||
if (version > 2) effectIntensity = udpIn[16];
|
if (version > 2) effectIntensity = udpIn[16];
|
||||||
@ -400,6 +411,7 @@ void handleNotifications()
|
|||||||
if (nightlightActive) nightlightDelayMins = udpIn[7];
|
if (nightlightActive) nightlightDelayMins = udpIn[7];
|
||||||
|
|
||||||
if (receiveNotificationBrightness || !someSel) bri = udpIn[2];
|
if (receiveNotificationBrightness || !someSel) bri = udpIn[2];
|
||||||
|
strip.applyToAllSelected = !(version > 10 && receiveSegmentOptions);
|
||||||
colorUpdated(CALL_MODE_NOTIFICATION);
|
colorUpdated(CALL_MODE_NOTIFICATION);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -315,6 +315,7 @@ WLED_GLOBAL bool receiveNotificationBrightness _INIT(true); // apply brigh
|
|||||||
WLED_GLOBAL bool receiveNotificationColor _INIT(true); // apply color
|
WLED_GLOBAL bool receiveNotificationColor _INIT(true); // apply color
|
||||||
WLED_GLOBAL bool receiveNotificationEffects _INIT(true); // apply effects setup
|
WLED_GLOBAL bool receiveNotificationEffects _INIT(true); // apply effects setup
|
||||||
WLED_GLOBAL bool receiveSegmentOptions _INIT(false); // apply segment options
|
WLED_GLOBAL bool receiveSegmentOptions _INIT(false); // apply segment options
|
||||||
|
WLED_GLOBAL bool receiveSegmentBounds _INIT(false); // apply segment bounds (start, stop, offset)
|
||||||
WLED_GLOBAL bool notifyDirect _INIT(false); // send notification if change via UI or HTTP API
|
WLED_GLOBAL bool notifyDirect _INIT(false); // send notification if change via UI or HTTP API
|
||||||
WLED_GLOBAL bool notifyButton _INIT(false); // send if updated by button or infrared remote
|
WLED_GLOBAL bool notifyButton _INIT(false); // send if updated by button or infrared remote
|
||||||
WLED_GLOBAL bool notifyAlexa _INIT(false); // send notification if updated via Alexa
|
WLED_GLOBAL bool notifyAlexa _INIT(false); // send notification if updated via Alexa
|
||||||
|
@ -480,6 +480,7 @@ void getSettingsJS(byte subPage, char* dest)
|
|||||||
sappend('c',SET_F("RC"),receiveNotificationColor);
|
sappend('c',SET_F("RC"),receiveNotificationColor);
|
||||||
sappend('c',SET_F("RX"),receiveNotificationEffects);
|
sappend('c',SET_F("RX"),receiveNotificationEffects);
|
||||||
sappend('c',SET_F("SO"),receiveSegmentOptions);
|
sappend('c',SET_F("SO"),receiveSegmentOptions);
|
||||||
|
sappend('c',SET_F("SG"),receiveSegmentBounds);
|
||||||
sappend('c',SET_F("SD"),notifyDirectDefault);
|
sappend('c',SET_F("SD"),notifyDirectDefault);
|
||||||
sappend('c',SET_F("SB"),notifyButton);
|
sappend('c',SET_F("SB"),notifyButton);
|
||||||
sappend('c',SET_F("SH"),notifyHue);
|
sappend('c',SET_F("SH"),notifyHue);
|
||||||
|
Loading…
Reference in New Issue
Block a user