Skip to content

Commit

Permalink
Merge pull request #3554 from ezcGman/ledmaps-realtime
Browse files Browse the repository at this point in the history
En-/disable LED maps when receiving realtime data
  • Loading branch information
blazoncek committed Jan 10, 2024
2 parents 2683764 + ff59dcd commit 5fc0084
Show file tree
Hide file tree
Showing 8 changed files with 260 additions and 245 deletions.
3 changes: 2 additions & 1 deletion wled00/FX.h
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,8 @@ class WS2812FX { // 96 bytes
uint16_t
getLengthPhysical(void),
getLengthTotal(void), // will include virtual/nonexistent pixels in matrix
getFps();
getFps(),
getMappedPixelIndex(uint16_t index);

inline uint16_t getFrameTime(void) { return _frametime; } // returns amount of time a frame should take (in ms)
inline uint16_t getMinShowDelay(void) { return MIN_SHOW_DELAY; } // returns minimum amount of time strip.service() can be delayed (constant)
Expand Down
15 changes: 11 additions & 4 deletions wled00/FX_fcn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -886,8 +886,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;
Expand Down Expand Up @@ -1212,13 +1211,13 @@ void WS2812FX::service() {
}

void IRAM_ATTR WS2812FX::setPixelColor(unsigned i, uint32_t col) {
if (i < customMappingSize) i = customMappingTable[i];
i = getMappedPixelIndex(i);
if (i >= _length) return;
BusManager::setPixelColor(i, col);
}

uint32_t IRAM_ATTR WS2812FX::getPixelColor(uint16_t i) {
if (i < customMappingSize) i = customMappingTable[i];
i = getMappedPixelIndex(i);
if (i >= _length) return 0;
return BusManager::getPixelColor(i);
}
Expand Down Expand Up @@ -1691,6 +1690,14 @@ bool WS2812FX::deserializeMap(uint8_t n) {
return true;
}

uint16_t IRAM_ATTR WS2812FX::getMappedPixelIndex(uint16_t index) {
// convert logical address to physical
if (index < customMappingSize
&& (realtimeMode == REALTIME_MODE_INACTIVE || realtimeRespectLedMaps)) index = customMappingTable[index];

return index;
}


WS2812FX* WS2812FX::instance = nullptr;

Expand Down
2 changes: 2 additions & 0 deletions wled00/cfg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
JsonObject if_live = interfaces["live"];
CJSON(receiveDirect, if_live["en"]); // UDP/Hyperion realtime
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")]);
Expand Down Expand Up @@ -896,6 +897,7 @@ void serializeConfig() {
JsonObject if_live = interfaces.createNestedObject("live");
if_live["en"] = receiveDirect; // UDP/Hyperion realtime
if_live[F("mso")] = useMainSegmentOnly;
if_live[F("rlm")] = realtimeRespectLedMaps;
if_live["port"] = e131Port;
if_live[F("mc")] = e131Multicast;

Expand Down
5 changes: 3 additions & 2 deletions wled00/data/settings_sync.htm
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -156,7 +156,8 @@ <h3>Instance List</h3>
<hr class="sml">
<h3>Realtime</h3>
Receive UDP realtime: <input type="checkbox" name="RD"><br>
Use main segment only: <input type="checkbox" name="MO"><br><br>
Use main segment only: <input type="checkbox" name="MO"><br>
Respect LED Maps: <input type="checkbox" name="RLM"><br><br>
<i>Network DMX input</i><br>
Type:
<select name=DI onchange="SP(); adj();">
Expand Down
471 changes: 236 additions & 235 deletions wled00/html_settings.h

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions wled00/set.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)

receiveDirect = request->hasArg(F("RD")); // UDP realtime
useMainSegmentOnly = request->hasArg(F("MO"));
realtimeRespectLedMaps = request->hasArg(F("RLM"));
e131SkipOutOfSequence = request->hasArg(F("ES"));
e131Multicast = request->hasArg(F("EM"));
t = request->arg(F("EP")).toInt();
Expand Down
7 changes: 4 additions & 3 deletions wled00/wled.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
#ifndef WLED_DISABLE_MQTT
#define WLED_ENABLE_MQTT // saves 12kb
#endif
#ifndef WLED_DISABLE_ADALIGHT // can be used to disable reading commands from serial RX pin (see issue #3128).
#define WLED_ENABLE_ADALIGHT // disable saves 5Kb (uses GPIO3 (RX) for serial). Related serial protocols: Adalight/TPM2, Improv, Serial JSON, Continuous Serial Streaming
#ifndef WLED_DISABLE_ADALIGHT // can be used to disable reading commands from serial RX pin (see issue #3128).
#define WLED_ENABLE_ADALIGHT // disable saves 5Kb (uses GPIO3 (RX) for serial). Related serial protocols: Adalight/TPM2, Improv, Serial JSON, Continuous Serial Streaming
#else
#undef WLED_ENABLE_ADALIGHT // disable has priority over enable
#endif
Expand All @@ -44,7 +44,7 @@
#define WLED_ENABLE_WEBSOCKETS
#endif

//#define WLED_DISABLE_ESPNOW // Removes dependence on esp now
//#define WLED_DISABLE_ESPNOW // Removes dependence on esp now

#define WLED_ENABLE_FS_EDITOR // enable /edit page for editing FS content. Will also be disabled with OTA lock

Expand Down Expand Up @@ -635,6 +635,7 @@ WLED_GLOBAL unsigned long realtimeTimeout _INIT(0);
WLED_GLOBAL uint8_t tpmPacketCount _INIT(0);
WLED_GLOBAL uint16_t tpmPayloadFrameSize _INIT(0);
WLED_GLOBAL bool useMainSegmentOnly _INIT(false);
WLED_GLOBAL bool realtimeRespectLedMaps _INIT(true); // Respect LED maps when receiving realtime data

WLED_GLOBAL unsigned long lastInterfaceUpdate _INIT(0);
WLED_GLOBAL byte interfaceUpdateCallMode _INIT(CALL_MODE_INIT);
Expand Down
1 change: 1 addition & 0 deletions wled00/xml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,7 @@ void getSettingsJS(byte subPage, char* dest)

sappend('c',SET_F("RD"),receiveDirect);
sappend('c',SET_F("MO"),useMainSegmentOnly);
sappend('c',SET_F("RLM"),realtimeRespectLedMaps);
sappend('v',SET_F("EP"),e131Port);
sappend('c',SET_F("ES"),e131SkipOutOfSequence);
sappend('c',SET_F("EM"),e131Multicast);
Expand Down

0 comments on commit 5fc0084

Please sign in to comment.