From a36c731d15c07038633734bcb3cf2b7846ae8951 Mon Sep 17 00:00:00 2001 From: ezcGman Date: Thu, 23 Nov 2023 17:13:13 +0100 Subject: [PATCH] En-/disable LED maps when receiving realtime data --- wled00/FX.h | 3 +- wled00/FX_2Dfcn.cpp | 4 +- wled00/FX_fcn.cpp | 16 +- wled00/cfg.cpp | 2 + wled00/data/settings_sync.htm | 5 +- wled00/html_settings.h | 437 +++++++++++++++++----------------- wled00/set.cpp | 5 + wled00/wled.h | 7 +- wled00/xml.cpp | 3 +- 9 files changed, 250 insertions(+), 232 deletions(-) diff --git a/wled00/FX.h b/wled00/FX.h index c9306e80a..963471b01 100644 --- a/wled00/FX.h +++ b/wled00/FX.h @@ -821,7 +821,8 @@ class WS2812FX { // 96 bytes currentMilliamps, getLengthPhysical(void), getLengthTotal(void), // will include virtual/nonexistent pixels in matrix - getFps(); + getFps(), + getMappedPixelIndex(uint16_t index); inline uint16_t getFrameTime(void) { return _frametime; } inline uint16_t getMinShowDelay(void) { return MIN_SHOW_DELAY; } diff --git a/wled00/FX_2Dfcn.cpp b/wled00/FX_2Dfcn.cpp index 60a7e68fd..562ee0ecd 100644 --- a/wled00/FX_2Dfcn.cpp +++ b/wled00/FX_2Dfcn.cpp @@ -164,7 +164,7 @@ void /*IRAM_ATTR*/ WS2812FX::setPixelColorXY(int x, int y, uint32_t col) #else uint16_t index = x; #endif - if (index < customMappingSize) index = customMappingTable[index]; + index = getMappedPixelIndex(index); if (index >= _length) return; busses.setPixelColor(index, col); } @@ -176,7 +176,7 @@ uint32_t WS2812FX::getPixelColorXY(uint16_t x, uint16_t y) { #else uint16_t index = x; #endif - if (index < customMappingSize) index = customMappingTable[index]; + index = getMappedPixelIndex(index); if (index >= _length) return 0; return busses.getPixelColor(index); } diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index dc4f32117..101616bfd 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -898,8 +898,7 @@ void Segment::refreshLightCapabilities() { if (start < Segment::maxWidth * Segment::maxHeight) { // we are withing 2D matrix (includes 1D segments) for (int y = startY; y < stopY; y++) for (int x = start; x < stop; x++) { - uint16_t index = x + Segment::maxWidth * y; - if (index < strip.customMappingSize) index = strip.customMappingTable[index]; // convert logical address to physical + uint16_t index = strip.getMappedPixelIndex(x + Segment::maxWidth * y); // convert logical address to physical if (index < 0xFFFFU) { if (segStartIdx > index) segStartIdx = index; if (segStopIdx < index) segStopIdx = index; @@ -1289,14 +1288,14 @@ void WS2812FX::service() { void IRAM_ATTR WS2812FX::setPixelColor(int i, uint32_t col) { - if (i < customMappingSize) i = customMappingTable[i]; + i = getMappedPixelIndex(i); if (i >= _length) return; busses.setPixelColor(i, col); } uint32_t WS2812FX::getPixelColor(uint16_t i) { - if (i < customMappingSize) i = customMappingTable[i]; + i = getMappedPixelIndex(i); if (i >= _length) return 0; return busses.getPixelColor(i); } @@ -1599,7 +1598,7 @@ void WS2812FX::setSegment(uint8_t segId, uint16_t i1, uint16_t i2, uint8_t group _queuedChangesSegId = segId; return; // queued changes are applied immediately after effect function returns } - + _segments[segId].setUp(i1, i2, grouping, spacing, offset, startY, stopY); } @@ -1875,6 +1874,13 @@ bool WS2812FX::deserializeMap(uint8_t n) { return true; } +uint16_t WS2812FX::getMappedPixelIndex(uint16_t index) { + if ((realtimeMode == REALTIME_MODE_INACTIVE || realtimeRespectLedMaps) + && index < customMappingSize) index = strip.customMappingTable[index]; // convert logical address to physical + + return index; +} + WS2812FX* WS2812FX::instance = nullptr; diff --git a/wled00/cfg.cpp b/wled00/cfg.cpp index 4234d9b01..44f4fea98 100644 --- a/wled00/cfg.cpp +++ b/wled00/cfg.cpp @@ -411,6 +411,7 @@ bool deserializeConfig(JsonObject doc, bool fromFS) { JsonObject if_live = interfaces["live"]; CJSON(receiveDirect, if_live["en"]); CJSON(useMainSegmentOnly, if_live[F("mso")]); + CJSON(realtimeRespectLedMaps, if_live[F("rlm")]); CJSON(e131Port, if_live["port"]); // 5568 if (e131Port == DDP_DEFAULT_PORT) e131Port = E131_DEFAULT_PORT; // prevent double DDP port allocation CJSON(e131Multicast, if_live[F("mc")]); @@ -872,6 +873,7 @@ void serializeConfig() { JsonObject if_live = interfaces.createNestedObject("live"); if_live["en"] = receiveDirect; if_live[F("mso")] = useMainSegmentOnly; + if_live[F("rlm")] = realtimeRespectLedMaps; if_live["port"] = e131Port; if_live[F("mc")] = e131Multicast; diff --git a/wled00/data/settings_sync.htm b/wled00/data/settings_sync.htm index 0a579f0f0..42b3bdc57 100644 --- a/wled00/data/settings_sync.htm +++ b/wled00/data/settings_sync.htm @@ -19,7 +19,7 @@ scE.setAttribute("type", "text/javascript"); scE.setAttribute("async", async); d.body.appendChild(scE); - // success event + // success event scE.addEventListener("load", () => { //console.log("File loaded"); GetV();SetVal(); @@ -145,7 +145,8 @@ Make this instance discoverable:

Realtime

Receive UDP realtime:
-Use main segment only:

+Use main segment only:
+Respect LED Maps:

Network DMX input
Type: