Skip to content

Commit 7f1ec48

Browse files
authored
Merge pull request #4137 from felddy/feature/toggle_pallet_sync
Add the ability to toggle the reception of palette synchronizations
2 parents d5777b7 + 8ae09c3 commit 7f1ec48

File tree

7 files changed

+19
-8
lines changed

7 files changed

+19
-8
lines changed

wled00/cfg.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,7 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
482482
CJSON(receiveNotificationBrightness, if_sync_recv["bri"]);
483483
CJSON(receiveNotificationColor, if_sync_recv["col"]);
484484
CJSON(receiveNotificationEffects, if_sync_recv["fx"]);
485+
CJSON(receiveNotificationPalette, if_sync_recv["pal"]);
485486
CJSON(receiveGroups, if_sync_recv["grp"]);
486487
CJSON(receiveSegmentOptions, if_sync_recv["seg"]);
487488
CJSON(receiveSegmentBounds, if_sync_recv["sb"]);
@@ -969,6 +970,7 @@ void serializeConfig() {
969970
if_sync_recv["bri"] = receiveNotificationBrightness;
970971
if_sync_recv["col"] = receiveNotificationColor;
971972
if_sync_recv["fx"] = receiveNotificationEffects;
973+
if_sync_recv["pal"] = receiveNotificationPalette;
972974
if_sync_recv["grp"] = receiveGroups;
973975
if_sync_recv["seg"] = receiveSegmentOptions;
974976
if_sync_recv["sb"] = receiveSegmentBounds;

wled00/data/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3201,7 +3201,7 @@ function simplifyUI() {
32013201
createDropdown("palw", "Change palette");
32023202
createDropdown("fx", "Change effect", [gId("fxFind"), gId("fxlist")]);
32033203

3204-
// Hide pallete label
3204+
// Hide palette label
32053205
gId("pall").style.display = "none";
32063206
gId("Colors").insertBefore(document.createElement("br"), gId("pall"));
32073207
// Hide effect label

wled00/data/settings_sync.htm

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ <h3>Sync groups</h3>
138138
</tr>
139139
</table>
140140
<h3>Receive</h3>
141-
<nowrap><input type="checkbox" name="RB">Brightness,</nowrap> <nowrap><input type="checkbox" name="RC">Color,</nowrap> <nowrap>and <input type="checkbox" name="RX">Effects</nowrap><br>
141+
<nowrap><input type="checkbox" name="RB">Brightness,</nowrap> <nowrap><input type="checkbox" name="RC">Color,</nowrap> <nowrap><input type="checkbox" name="RX">Effects,</nowrap> <nowrap>and <input type="checkbox" name="RP">Palette</nowrap><br>
142142
<input type="checkbox" name="SO"> Segment options, <input type="checkbox" name="SG"> bounds
143143
<h3>Send</h3>
144144
Enable Sync on start: <input type="checkbox" name="SS"><br>

wled00/set.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
379379
receiveNotificationBrightness = request->hasArg(F("RB"));
380380
receiveNotificationColor = request->hasArg(F("RC"));
381381
receiveNotificationEffects = request->hasArg(F("RX"));
382+
receiveNotificationPalette = request->hasArg(F("RP"));
382383
receiveSegmentOptions = request->hasArg(F("SO"));
383384
receiveSegmentBounds = request->hasArg(F("SG"));
384385
sendNotifications = request->hasArg(F("SS"));

wled00/udp.cpp

+11-6
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ void parseNotifyPacket(uint8_t *udpIn) {
221221
if (!(receiveGroups & 0x01)) return;
222222
} else if (!(receiveGroups & udpIn[36])) return;
223223

224-
bool someSel = (receiveNotificationBrightness || receiveNotificationColor || receiveNotificationEffects);
224+
bool someSel = (receiveNotificationBrightness || receiveNotificationColor || receiveNotificationEffects || receiveNotificationPalette);
225225

226226
// set transition time before making any segment changes
227227
if (version > 3) {
@@ -311,6 +311,9 @@ void parseNotifyPacket(uint8_t *udpIn) {
311311
selseg.setMode(udpIn[11+ofs]);
312312
selseg.speed = udpIn[12+ofs];
313313
selseg.intensity = udpIn[13+ofs];
314+
}
315+
if (receiveNotificationPalette || !someSel) {
316+
DEBUG_PRINTF_P(PSTR("Apply palette: %u\n"), id);
314317
selseg.palette = udpIn[14+ofs];
315318
}
316319
if (receiveNotificationColor || !someSel) {
@@ -352,14 +355,16 @@ void parseNotifyPacket(uint8_t *udpIn) {
352355
}
353356

354357
// simple effect sync, applies to all selected segments
355-
if (applyEffects && (version < 11 || !receiveSegmentOptions)) {
358+
if ((applyEffects || receiveNotificationPalette) && (version < 11 || !receiveSegmentOptions)) {
356359
for (size_t i = 0; i < strip.getSegmentsNum(); i++) {
357360
Segment& seg = strip.getSegment(i);
358361
if (!seg.isActive() || !seg.isSelected()) continue;
359-
seg.setMode(udpIn[8]);
360-
seg.speed = udpIn[9];
361-
if (version > 2) seg.intensity = udpIn[16];
362-
if (version > 4) seg.setPalette(udpIn[19]);
362+
if (applyEffects) {
363+
seg.setMode(udpIn[8]);
364+
seg.speed = udpIn[9];
365+
if (version > 2) seg.intensity = udpIn[16];
366+
}
367+
if (version > 4 && receiveNotificationPalette) seg.setPalette(udpIn[19]);
363368
}
364369
stateChanged = true;
365370
}

wled00/wled.h

+2
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,7 @@ WLED_GLOBAL send_notification_t notifyG _INIT(0b00001111);
676676
#define receiveNotificationBrightness receiveN.Brightness
677677
#define receiveNotificationColor receiveN.Color
678678
#define receiveNotificationEffects receiveN.Effects
679+
#define receiveNotificationPalette receiveN.Palette
679680
#define receiveSegmentOptions receiveN.SegmentOptions
680681
#define receiveSegmentBounds receiveN.SegmentBounds
681682
#define receiveDirect receiveN.Direct
@@ -687,6 +688,7 @@ WLED_GLOBAL send_notification_t notifyG _INIT(0b00001111);
687688
WLED_GLOBAL bool receiveNotificationBrightness _INIT(true); // apply brightness from incoming notifications
688689
WLED_GLOBAL bool receiveNotificationColor _INIT(true); // apply color
689690
WLED_GLOBAL bool receiveNotificationEffects _INIT(true); // apply effects setup
691+
WLED_GLOBAL bool receiveNotificationPalette _INIT(true); // apply palette
690692
WLED_GLOBAL bool receiveSegmentOptions _INIT(false); // apply segment options
691693
WLED_GLOBAL bool receiveSegmentBounds _INIT(false); // apply segment bounds (start, stop, offset)
692694
WLED_GLOBAL bool receiveDirect _INIT(true); // receive UDP/Hyperion realtime

wled00/xml.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -484,6 +484,7 @@ void getSettingsJS(byte subPage, char* dest)
484484
sappend('c',SET_F("RB"),receiveNotificationBrightness);
485485
sappend('c',SET_F("RC"),receiveNotificationColor);
486486
sappend('c',SET_F("RX"),receiveNotificationEffects);
487+
sappend('c',SET_F("RP"),receiveNotificationPalette);
487488
sappend('c',SET_F("SO"),receiveSegmentOptions);
488489
sappend('c',SET_F("SG"),receiveSegmentBounds);
489490
sappend('c',SET_F("SS"),sendNotifications);

0 commit comments

Comments
 (0)