diff --git a/wled00/cfg.cpp b/wled00/cfg.cpp index 7c7fbc4d..4bd251e3 100644 --- a/wled00/cfg.cpp +++ b/wled00/cfg.cpp @@ -261,6 +261,7 @@ bool deserializeConfig(JsonObject doc, bool fromFS) { CJSON(receiveNotificationEffects, if_sync_recv["fx"]); CJSON(receiveGroups, if_sync_recv["grp"]); CJSON(receiveSegmentOptions, if_sync_recv["seg"]); + CJSON(receiveSegmentBounds, if_sync_recv["sb"]); //! following line might be a problem if called after boot receiveNotifications = (receiveNotificationBrightness || receiveNotificationColor || receiveNotificationEffects || receiveSegmentOptions); @@ -673,9 +674,10 @@ void serializeConfig() { JsonObject if_sync_recv = if_sync.createNestedObject("recv"); if_sync_recv["bri"] = receiveNotificationBrightness; if_sync_recv["col"] = receiveNotificationColor; - if_sync_recv["fx"] = receiveNotificationEffects; + if_sync_recv["fx"] = receiveNotificationEffects; if_sync_recv["grp"] = receiveGroups; if_sync_recv["seg"] = receiveSegmentOptions; + if_sync_recv["sb"] = receiveSegmentBounds; JsonObject if_sync_send = if_sync.createNestedObject("send"); if_sync_send[F("dir")] = notifyDirect; diff --git a/wled00/data/settings_sync.htm b/wled00/data/settings_sync.htm index bb5b740e..308ba121 100644 --- a/wled00/data/settings_sync.htm +++ b/wled00/data/settings_sync.htm @@ -83,7 +83,7 @@ UDP Port:
Receive: Brightness, Color, and Effects
- Segment options
+ Segment options, bounds
Send notifications on direct change:
Send notifications on button press or IR:
Send Alexa notifications:
diff --git a/wled00/html_other.h b/wled00/html_other.h index be5df94d..65b2139c 100644 --- a/wled00/html_other.h +++ b/wled00/html_other.h @@ -85,7 +85,7 @@ charset="utf-8"> WLED Live Preview
)====="; diff --git a/wled00/html_settings.h b/wled00/html_settings.h index 84d859e6..6fe033ce 100644 --- a/wled00/html_settings.h +++ b/wled00/html_settings.h @@ -276,9 +276,10 @@ type="checkbox" id="R7" name="R7">
Receive: Brightness, Color, and Effects
- Segment options
Send notifications on direct change:
Send notifications on button press or IR:
Send Alexa notifications:
+ Segment options, bounds
+Send notifications on direct change:
+Send notifications on button press or IR:
+Send Alexa notifications:
Send Philips Hue change notifications:
Send Macro notifications:
Send notifications twice:
diff --git a/wled00/set.cpp b/wled00/set.cpp index 2d2c9cf7..a2a5812e 100644 --- a/wled00/set.cpp +++ b/wled00/set.cpp @@ -233,6 +233,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage) receiveNotificationColor = request->hasArg(F("RC")); receiveNotificationEffects = request->hasArg(F("RX")); receiveSegmentOptions = request->hasArg(F("SO")); + receiveSegmentBounds = request->hasArg(F("SG")); receiveNotifications = (receiveNotificationBrightness || receiveNotificationColor || receiveNotificationEffects || receiveSegmentOptions); notifyDirectDefault = request->hasArg(F("SD")); notifyDirect = notifyDirectDefault; diff --git a/wled00/udp.cpp b/wled00/udp.cpp index f04a6e78..03205851 100644 --- a/wled00/udp.cpp +++ b/wled00/udp.cpp @@ -322,16 +322,20 @@ void handleNotifications() if (version < 200) { if (applyEffects && currentPlaylist >= 0) unloadPlaylist(); - if (version > 10 && receiveSegmentOptions) { - //does not sync start & stop - uint8_t srcSegs = udpIn[39]; - //if (srcSegs > strip.getMaxSegments()) srcSegs = strip.getMaxSegments(); - for (uint8_t i = 0; i < srcSegs; i++) { + if (version > 10 && (receiveSegmentOptions || receiveSegmentBounds)) { + uint8_t numSrcSegs = udpIn[39]; + for (uint8_t i = 0; i < numSrcSegs; i++) { uint16_t ofs = 41 + i*udpIn[40]; //start of segment offset byte uint8_t id = udpIn[0 +ofs]; if (id > strip.getMaxSegments()) continue; 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 selseg.setOpacity(udpIn[10+ofs], id); 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.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(); effectChanged = 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]; effectSpeed = udpIn[9]; if (version > 2) effectIntensity = udpIn[16]; @@ -400,6 +411,7 @@ void handleNotifications() if (nightlightActive) nightlightDelayMins = udpIn[7]; if (receiveNotificationBrightness || !someSel) bri = udpIn[2]; + strip.applyToAllSelected = !(version > 10 && receiveSegmentOptions); colorUpdated(CALL_MODE_NOTIFICATION); return; } diff --git a/wled00/wled.h b/wled00/wled.h index 3f151280..fce155b8 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -315,6 +315,7 @@ WLED_GLOBAL bool receiveNotificationBrightness _INIT(true); // apply brigh WLED_GLOBAL bool receiveNotificationColor _INIT(true); // apply color WLED_GLOBAL bool receiveNotificationEffects _INIT(true); // apply effects setup 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 notifyButton _INIT(false); // send if updated by button or infrared remote WLED_GLOBAL bool notifyAlexa _INIT(false); // send notification if updated via Alexa diff --git a/wled00/xml.cpp b/wled00/xml.cpp index d126b3be..03da27fc 100644 --- a/wled00/xml.cpp +++ b/wled00/xml.cpp @@ -480,6 +480,7 @@ void getSettingsJS(byte subPage, char* dest) sappend('c',SET_F("RC"),receiveNotificationColor); sappend('c',SET_F("RX"),receiveNotificationEffects); sappend('c',SET_F("SO"),receiveSegmentOptions); + sappend('c',SET_F("SG"),receiveSegmentBounds); sappend('c',SET_F("SD"),notifyDirectDefault); sappend('c',SET_F("SB"),notifyButton); sappend('c',SET_F("SH"),notifyHue);