From 83699bc5c3b0ddd569dd64ab26c45264c71d06f9 Mon Sep 17 00:00:00 2001 From: Felddy Date: Tue, 10 Sep 2024 18:02:29 +0000 Subject: [PATCH 1/2] Add support for toggle of palette sync --- wled00/cfg.cpp | 2 ++ wled00/data/index.js | 2 +- wled00/data/settings_sync.htm | 2 +- wled00/set.cpp | 1 + wled00/udp.cpp | 17 +++++++++++------ wled00/wled.h | 2 ++ wled00/xml.cpp | 1 + 7 files changed, 19 insertions(+), 8 deletions(-) diff --git a/wled00/cfg.cpp b/wled00/cfg.cpp index a6c3ab74de..c77d87acf7 100644 --- a/wled00/cfg.cpp +++ b/wled00/cfg.cpp @@ -486,6 +486,7 @@ bool deserializeConfig(JsonObject doc, bool fromFS) { CJSON(receiveNotificationBrightness, if_sync_recv["bri"]); CJSON(receiveNotificationColor, if_sync_recv["col"]); CJSON(receiveNotificationEffects, if_sync_recv["fx"]); + CJSON(receiveNotificationPalette, if_sync_recv["pal"]); CJSON(receiveGroups, if_sync_recv["grp"]); CJSON(receiveSegmentOptions, if_sync_recv["seg"]); CJSON(receiveSegmentBounds, if_sync_recv["sb"]); @@ -973,6 +974,7 @@ void serializeConfig() { if_sync_recv["bri"] = receiveNotificationBrightness; if_sync_recv["col"] = receiveNotificationColor; if_sync_recv["fx"] = receiveNotificationEffects; + if_sync_recv["pal"] = receiveNotificationPalette; if_sync_recv["grp"] = receiveGroups; if_sync_recv["seg"] = receiveSegmentOptions; if_sync_recv["sb"] = receiveSegmentBounds; diff --git a/wled00/data/index.js b/wled00/data/index.js index 447bf03a66..25ade11639 100644 --- a/wled00/data/index.js +++ b/wled00/data/index.js @@ -3201,7 +3201,7 @@ function simplifyUI() { createDropdown("palw", "Change palette"); createDropdown("fx", "Change effect", [gId("fxFind"), gId("fxlist")]); - // Hide pallete label + // Hide palette label gId("pall").style.display = "none"; gId("Colors").insertBefore(document.createElement("br"), gId("pall")); // Hide effect label diff --git a/wled00/data/settings_sync.htm b/wled00/data/settings_sync.htm index b8bb5e9716..848bf4f2d9 100755 --- a/wled00/data/settings_sync.htm +++ b/wled00/data/settings_sync.htm @@ -138,7 +138,7 @@

Sync groups

Receive

-Brightness, Color, and Effects
+Brightness, Color, Effects, and Palette
Segment options, bounds

Send

Enable Sync on start:
diff --git a/wled00/set.cpp b/wled00/set.cpp index 7814e55d96..fa0732fae3 100644 --- a/wled00/set.cpp +++ b/wled00/set.cpp @@ -380,6 +380,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage) receiveNotificationBrightness = request->hasArg(F("RB")); receiveNotificationColor = request->hasArg(F("RC")); receiveNotificationEffects = request->hasArg(F("RX")); + receiveNotificationPalette = request->hasArg(F("RP")); receiveSegmentOptions = request->hasArg(F("SO")); receiveSegmentBounds = request->hasArg(F("SG")); sendNotifications = request->hasArg(F("SS")); diff --git a/wled00/udp.cpp b/wled00/udp.cpp index d030b66559..8cf733dffc 100644 --- a/wled00/udp.cpp +++ b/wled00/udp.cpp @@ -221,7 +221,7 @@ void parseNotifyPacket(uint8_t *udpIn) { if (!(receiveGroups & 0x01)) return; } else if (!(receiveGroups & udpIn[36])) return; - bool someSel = (receiveNotificationBrightness || receiveNotificationColor || receiveNotificationEffects); + bool someSel = (receiveNotificationBrightness || receiveNotificationColor || receiveNotificationEffects || receiveNotificationPalette); // set transition time before making any segment changes if (version > 3) { @@ -311,6 +311,9 @@ void parseNotifyPacket(uint8_t *udpIn) { selseg.setMode(udpIn[11+ofs]); selseg.speed = udpIn[12+ofs]; selseg.intensity = udpIn[13+ofs]; + } + if (receiveNotificationPalette || !someSel) { + DEBUG_PRINTF_P(PSTR("Apply palette: %u\n"), id); selseg.palette = udpIn[14+ofs]; } if (receiveNotificationColor || !someSel) { @@ -352,14 +355,16 @@ void parseNotifyPacket(uint8_t *udpIn) { } // simple effect sync, applies to all selected segments - if (applyEffects && (version < 11 || !receiveSegmentOptions)) { + if ((applyEffects || receiveNotificationPalette) && (version < 11 || !receiveSegmentOptions)) { for (size_t i = 0; i < strip.getSegmentsNum(); i++) { Segment& seg = strip.getSegment(i); if (!seg.isActive() || !seg.isSelected()) continue; - seg.setMode(udpIn[8]); - seg.speed = udpIn[9]; - if (version > 2) seg.intensity = udpIn[16]; - if (version > 4) seg.setPalette(udpIn[19]); + if (applyEffects) { + seg.setMode(udpIn[8]); + seg.speed = udpIn[9]; + if (version > 2) seg.intensity = udpIn[16]; + } + if (version > 4 && receiveNotificationPalette) seg.setPalette(udpIn[19]); } stateChanged = true; } diff --git a/wled00/wled.h b/wled00/wled.h index 99c5f42263..e5cd7fd487 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -676,6 +676,7 @@ WLED_GLOBAL send_notification_t notifyG _INIT(0b00001111); #define receiveNotificationBrightness receiveN.Brightness #define receiveNotificationColor receiveN.Color #define receiveNotificationEffects receiveN.Effects +#define receiveNotificationPalette receiveN.Palette #define receiveSegmentOptions receiveN.SegmentOptions #define receiveSegmentBounds receiveN.SegmentBounds #define receiveDirect receiveN.Direct @@ -687,6 +688,7 @@ WLED_GLOBAL send_notification_t notifyG _INIT(0b00001111); WLED_GLOBAL bool receiveNotificationBrightness _INIT(true); // apply brightness from incoming notifications WLED_GLOBAL bool receiveNotificationColor _INIT(true); // apply color WLED_GLOBAL bool receiveNotificationEffects _INIT(true); // apply effects setup +WLED_GLOBAL bool receiveNotificationPalette _INIT(true); // apply palette WLED_GLOBAL bool receiveSegmentOptions _INIT(false); // apply segment options WLED_GLOBAL bool receiveSegmentBounds _INIT(false); // apply segment bounds (start, stop, offset) WLED_GLOBAL bool receiveDirect _INIT(true); // receive UDP/Hyperion realtime diff --git a/wled00/xml.cpp b/wled00/xml.cpp index 6c3ee83dc7..e151f412c8 100644 --- a/wled00/xml.cpp +++ b/wled00/xml.cpp @@ -506,6 +506,7 @@ void getSettingsJS(byte subPage, char* dest) sappend('c',SET_F("RB"),receiveNotificationBrightness); sappend('c',SET_F("RC"),receiveNotificationColor); sappend('c',SET_F("RX"),receiveNotificationEffects); + sappend('c',SET_F("RP"),receiveNotificationPalette); sappend('c',SET_F("SO"),receiveSegmentOptions); sappend('c',SET_F("SG"),receiveSegmentBounds); sappend('c',SET_F("SS"),sendNotifications); From 8ae09c3d0299737786a77e96d56dbb277ff9112f Mon Sep 17 00:00:00 2001 From: Felddy Date: Tue, 10 Sep 2024 18:16:00 +0000 Subject: [PATCH 2/2] Fix comment alignment --- wled00/wled.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wled00/wled.h b/wled00/wled.h index e5cd7fd487..9db6928a4c 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -688,7 +688,7 @@ WLED_GLOBAL send_notification_t notifyG _INIT(0b00001111); WLED_GLOBAL bool receiveNotificationBrightness _INIT(true); // apply brightness from incoming notifications WLED_GLOBAL bool receiveNotificationColor _INIT(true); // apply color WLED_GLOBAL bool receiveNotificationEffects _INIT(true); // apply effects setup -WLED_GLOBAL bool receiveNotificationPalette _INIT(true); // apply palette +WLED_GLOBAL bool receiveNotificationPalette _INIT(true); // apply palette WLED_GLOBAL bool receiveSegmentOptions _INIT(false); // apply segment options WLED_GLOBAL bool receiveSegmentBounds _INIT(false); // apply segment bounds (start, stop, offset) WLED_GLOBAL bool receiveDirect _INIT(true); // receive UDP/Hyperion realtime