From 8bfae2fa7468d444776253d10e3d9bea9acda7e0 Mon Sep 17 00:00:00 2001 From: pille Date: Tue, 21 Apr 2020 22:56:14 +0200 Subject: [PATCH 1/3] implement DMX proxy mode via MAX485 output a configurable universe (E1.31 or ArtNet) via MAX485 module that connects its DI to D4 on d1_mini. as this function competes with DMX output for the same hardware, the universe to proxy acts as a switch. 0 = DMX OUTPUT (of configured WLED LEDs, which is the classic behaviour) 1-63999 = DMX PROXY (selected universe, ArtNet is limited up to 32768) --- wled00/data/settings_sync.htm | 1 + wled00/dmx.cpp | 5 +++-- wled00/e131.cpp | 9 +++++++++ wled00/html_settings.h | 2 ++ wled00/set.cpp | 4 ++++ wled00/wled.h | 8 ++++++++ wled00/wled_eeprom.cpp | 15 ++++++++++++++- wled00/xml.cpp | 3 +++ 8 files changed, 44 insertions(+), 3 deletions(-) diff --git a/wled00/data/settings_sync.htm b/wled00/data/settings_sync.htm index 91fe8992..4beba9d6 100644 --- a/wled00/data/settings_sync.htm +++ b/wled00/data/settings_sync.htm @@ -47,6 +47,7 @@ Type:
Port:
Multicast:
+Proxy Universe to DMX via MAX485 DI pin connected to D4 (0=disabled, compile with WLED_ENABLE_DMX)
Start universe:
Reboot required. Check out LedFx!
Skip out-of-sequence packets:
diff --git a/wled00/dmx.cpp b/wled00/dmx.cpp index ccd3b064..7fef5666 100644 --- a/wled00/dmx.cpp +++ b/wled00/dmx.cpp @@ -8,11 +8,12 @@ */ #ifdef WLED_ENABLE_DMX -#include "src/dependencies/dmx/ESPDMX.h" -DMXESPSerial dmx; void handleDMX() { + // don't act, when in DMX Proxy mode + if (e131ProxyUniverse != 0) return; + // TODO: calculate brightness manually if no shutter channel is set uint8_t brightness = strip.getBrightness(); diff --git a/wled00/e131.cpp b/wled00/e131.cpp index 6e774194..2b00b736 100644 --- a/wled00/e131.cpp +++ b/wled00/e131.cpp @@ -25,6 +25,15 @@ void handleE131Packet(e131_packet_t* p, IPAddress clientIP, bool isArtnet){ seq = p->sequence_number; } + #ifdef WLED_ENABLE_DMX + // does not act on out-of-order packets yet + if (e131ProxyUniverse > 0 && uni == e131ProxyUniverse) { + for (uint16_t i = 1; i <= dmxChannels; i++) + dmx.write(i, e131_data[i]); + dmx.update(); + } + #endif + // only listen for universes we're handling & allocated memory if (uni >= (e131Universe + E131_MAX_UNIVERSE_COUNT)) return; diff --git a/wled00/html_settings.h b/wled00/html_settings.h index 009dda50..ad47da4f 100644 --- a/wled00/html_settings.h +++ b/wled00/html_settings.h @@ -212,6 +212,7 @@ function S(){GCH(15);GetV();mMap();}function H(){window.open("https://github.com

Imma firin ma lazer (if it has DMX support)

+This functionality may be disabled by DMX Proxy Universe ≠ 0 on sync settings page
Number of fixtures is taken from LED config page
Channels per fixture (15 max):
@@ -293,6 +294,7 @@ Type:
Port:
Multicast:
+Proxy Universe to DMX via MAX485 DI pin connected to D4 (0=disabled, compile with WLED_ENABLE_DMX)
Start universe:
Reboot required. Check out LedFx!
Skip out-of-sequence packets:
diff --git a/wled00/set.cpp b/wled00/set.cpp index b568dff2..60958259 100644 --- a/wled00/set.cpp +++ b/wled00/set.cpp @@ -144,6 +144,10 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage) e131Multicast = request->hasArg("EM"); t = request->arg("EP").toInt(); if (t > 0) e131Port = t; + #ifdef WLED_ENABLE_DMX // include only if DMX is enabled + t = request->arg("PU").toInt(); + if (t >= 0 && t <= 63999) e131ProxyUniverse = t; + #endif t = request->arg("EU").toInt(); if (t >= 0 && t <= 63999) e131Universe = t; t = request->arg("DA").toInt(); diff --git a/wled00/wled.h b/wled00/wled.h index 10343cc0..f1122b11 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -76,6 +76,10 @@ #include "src/dependencies/blynk/BlynkSimpleEsp.h" #endif +#ifdef WLED_ENABLE_DMX + #include "src/dependencies/dmx/ESPDMX.h" +#endif + #include "src/dependencies/e131/ESPAsyncE131.h" #include "src/dependencies/async-mqtt-client/AsyncMqttClient.h" #include "src/dependencies/json/AsyncJson-v6.h" @@ -226,6 +230,10 @@ WLED_GLOBAL bool receiveDirect _INIT(true); // receive UDP WLED_GLOBAL bool arlsDisableGammaCorrection _INIT(true); // activate if gamma correction is handled by the source WLED_GLOBAL bool arlsForceMaxBri _INIT(false); // enable to force max brightness if source has very dark colors that would be black +#ifdef WLED_ENABLE_DMX +WLED_GLOBAL DMXESPSerial dmx; +WLED_GLOBAL uint16_t e131ProxyUniverse _INIT(0); // output this E1.31 (sACN) / ArtNet universe via MAX485 (0 = disabled) +#endif WLED_GLOBAL uint16_t e131Universe _INIT(1); // settings for E1.31 (sACN) protocol (only DMX_MODE_MULTIPLE_* can span over consequtive universes) WLED_GLOBAL uint16_t e131Port _INIT(5568); // DMX in port. E1.31 default is 5568, Art-Net is 6454 WLED_GLOBAL byte DMXMode _INIT(DMX_MODE_MULTIPLE_RGB); // DMX mode (s.a.) diff --git a/wled00/wled_eeprom.cpp b/wled00/wled_eeprom.cpp index 2bf7eeff..599303d7 100644 --- a/wled00/wled_eeprom.cpp +++ b/wled00/wled_eeprom.cpp @@ -7,7 +7,7 @@ */ //eeprom Version code, enables default settings instead of 0 init on update -#define EEPVER 19 +#define EEPVER 20 //0 -> old version, default //1 -> 0.4p 1711272 and up //2 -> 0.4p 1711302 and up @@ -28,6 +28,7 @@ //17-> 0.9.1-dmx //18-> 0.9.1-e131 //19-> 0.9.1n +//20-> 0.9.1p void commit() { @@ -211,6 +212,11 @@ void saveSettingsToEEPROM() EEPROM.write(2181, macroNl); EEPROM.write(2182, macroDoublePress); + #ifdef WLED_ENABLE_DMX + EEPROM.write(2185, e131ProxyUniverse & 0xFF); + EEPROM.write(2186, (e131ProxyUniverse >> 8) & 0xFF); + #endif + EEPROM.write(2187, e131Port & 0xFF); EEPROM.write(2188, (e131Port >> 8) & 0xFF); @@ -524,6 +530,13 @@ void loadSettingsFromEEPROM(bool first) e131Port = EEPROM.read(2187) + ((EEPROM.read(2188) << 8) & 0xFF00); } + #ifdef WLED_ENABLE_DMX + if (lastEEPROMversion > 19) + { + e131ProxyUniverse = EEPROM.read(2185) + ((EEPROM.read(2186) << 8) & 0xFF00); + } + #endif + receiveDirect = !EEPROM.read(2200); notifyMacro = EEPROM.read(2201); diff --git a/wled00/xml.cpp b/wled00/xml.cpp index 6edf8aa7..ce082cb2 100644 --- a/wled00/xml.cpp +++ b/wled00/xml.cpp @@ -330,6 +330,9 @@ void getSettingsJS(byte subPage, char* dest) sappend('v',"EP",e131Port); sappend('c',"ES",e131SkipOutOfSequence); sappend('c',"EM",e131Multicast); + #ifdef WLED_ENABLE_DMX + sappend('v',"PU",e131ProxyUniverse); + #endif sappend('v',"EU",e131Universe); sappend('v',"DA",DMXAddress); sappend('v',"DM",DMXMode); From fd06ff08c7f0109eaa3649decc6249d83367ed5f Mon Sep 17 00:00:00 2001 From: cschwinne Date: Mon, 11 May 2020 11:51:11 +0200 Subject: [PATCH 2/3] Move DMX proxy setting from sync to DMX settings --- wled00/html_settings.h | 4 ++-- wled00/set.cpp | 9 ++++----- wled00/xml.cpp | 5 ++--- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/wled00/html_settings.h b/wled00/html_settings.h index 915f206c..2aeb60b3 100644 --- a/wled00/html_settings.h +++ b/wled00/html_settings.h @@ -212,7 +212,8 @@ function S(){GCH(15);GetV();mMap();}function H(){window.open("https://github.com

Imma firin ma lazer (if it has DMX support)

-This functionality may be disabled by DMX Proxy Universe ≠ 0 on sync settings page
+Proxy Universe from E1.31 to DMX (0=disabled)
+This will disable the LED data output to DMX configurable below

Number of fixtures is taken from LED config page
Channels per fixture (15 max):
@@ -294,7 +295,6 @@ Type:
Port:
Multicast:
-Proxy Universe to DMX via MAX485 DI pin connected to D4 (0=disabled, compile with WLED_ENABLE_DMX)
Start universe:
Reboot required. Check out LedFx!
Skip out-of-sequence packets:
diff --git a/wled00/set.cpp b/wled00/set.cpp index 803bd8cd..54581d01 100644 --- a/wled00/set.cpp +++ b/wled00/set.cpp @@ -144,10 +144,6 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage) e131Multicast = request->hasArg("EM"); t = request->arg("EP").toInt(); if (t > 0) e131Port = t; - #ifdef WLED_ENABLE_DMX // include only if DMX is enabled - t = request->arg("PU").toInt(); - if (t >= 0 && t <= 63999) e131ProxyUniverse = t; - #endif t = request->arg("EU").toInt(); if (t >= 0 && t <= 63999) e131Universe = t; t = request->arg("DA").toInt(); @@ -301,7 +297,10 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage) #ifdef WLED_ENABLE_DMX // include only if DMX is enabled if (subPage == 7) { - int t = request->arg("CN").toInt(); + int t = request->arg("PU").toInt(); + if (t >= 0 && t <= 63999) e131ProxyUniverse = t; + + t = request->arg("CN").toInt(); if (t>0 && t<16) { DMXChannels = t; } diff --git a/wled00/xml.cpp b/wled00/xml.cpp index 6ae8a31f..c03240e0 100644 --- a/wled00/xml.cpp +++ b/wled00/xml.cpp @@ -330,9 +330,6 @@ void getSettingsJS(byte subPage, char* dest) sappend('v',"EP",e131Port); sappend('c',"ES",e131SkipOutOfSequence); sappend('c',"EM",e131Multicast); - #ifdef WLED_ENABLE_DMX - sappend('v',"PU",e131ProxyUniverse); - #endif sappend('v',"EU",e131Universe); sappend('v',"DA",DMXAddress); sappend('v',"DM",DMXMode); @@ -459,6 +456,8 @@ void getSettingsJS(byte subPage, char* dest) #ifdef WLED_ENABLE_DMX // include only if DMX is enabled if (subPage == 7) { + sappend('v',"PU",e131ProxyUniverse); + sappend('v',"CN",DMXChannels); sappend('v',"CG",DMXGap); sappend('v',"CS",DMXStart); From d9104433a8f35073d2b5774c3fbbf7b47f6ab34e Mon Sep 17 00:00:00 2001 From: cschwinne Date: Mon, 11 May 2020 12:07:33 +0200 Subject: [PATCH 3/3] Remove proxy setting from sync settings file --- wled00/data/settings_sync.htm | 1 - 1 file changed, 1 deletion(-) diff --git a/wled00/data/settings_sync.htm b/wled00/data/settings_sync.htm index 4beba9d6..91fe8992 100644 --- a/wled00/data/settings_sync.htm +++ b/wled00/data/settings_sync.htm @@ -47,7 +47,6 @@ Type:
Port:
Multicast:
-Proxy Universe to DMX via MAX485 DI pin connected to D4 (0=disabled, compile with WLED_ENABLE_DMX)
Start universe:
Reboot required. Check out LedFx!
Skip out-of-sequence packets: