diff --git a/wled00/html_settings.h b/wled00/html_settings.h
index 284d9b30f..7def2314d 100644
--- a/wled00/html_settings.h
+++ b/wled00/html_settings.h
@@ -218,7 +218,13 @@ channels per fixture (15 max):
spacing between start channels: [ info ]
WARNING: Channel gap is lower than channels per fixture. This will cause overlap.
-
+
+
+If wanting to use DMX together with LEDs. Number of fixtures will also depend on the segment and start LED settings below
+Using these settings, you can position your fixtures anywhere you want on the LED strip
+which segment should DMX use:
+start LED from the above channel from which DMX fixtures should start:
+
channel functions
diff --git a/wled00/wled00.ino b/wled00/wled00.ino
index 728c5ef66..851a9c45d 100644
--- a/wled00/wled00.ino
+++ b/wled00/wled00.ino
@@ -23,7 +23,7 @@
//#define WLED_DISABLE_INFRARED //there is no pin left for this on ESP8266-01, saves 12kb
#define WLED_ENABLE_MQTT //saves 12kb
#define WLED_ENABLE_ADALIGHT //saves 500b only
-//#define WLED_ENABLE_DMX //uses 3.5kb
+//#define WLED_ENABLE_DMX //uses 3.5kb, if wanting to use DMX together with LEDs, you should change the LEDPIN to something other than 2 in NpbWrapper.h
#define WLED_DISABLE_FILESYSTEM //SPIFFS is not used by any WLED feature yet
//#define WLED_ENABLE_FS_SERVING //Enable sending html file from SPIFFS before serving progmem version
@@ -277,6 +277,8 @@ uint16_t userVar0 = 0, userVar1 = 0;
// assigns the different channels to different functions. See wled21_dmx.ino for more information.
uint16_t DMXGap = 10; // gap between the fixtures. makes addressing easier because you don't have to memorize odd numbers when climbing up onto a rig.
uint16_t DMXStart = 10; // start address of the first fixture
+ uint16_t DMXSegment = 0; // segment which DMX fixtures use
+ uint16_t DMXStartLED = 0; // start LED from which DMX fixtures should start
#endif
diff --git a/wled00/wled01_eeprom.ino b/wled00/wled01_eeprom.ino
index 1f0e8426f..c741d4e3f 100644
--- a/wled00/wled01_eeprom.ino
+++ b/wled00/wled01_eeprom.ino
@@ -270,6 +270,9 @@ void saveSettingsToEEPROM()
for (int i=0; i<15; i++) {
EEPROM.write(2535+i, DMXFixtureMap[i]);
} // last used: 2549. maybe leave a few bytes for future expansion and go on with 2600 kthxbye.
+
+ EEPROM.write(2550, DMXSegment);
+ EEPROM.write(2551, DMXStartLED);
#endif
commit();
@@ -551,6 +554,8 @@ void loadSettingsFromEEPROM(bool first)
DMXChannels = EEPROM.read(2530);
DMXGap = EEPROM.read(2531) + ((EEPROM.read(2532) << 8) & 0xFF00);
DMXStart = EEPROM.read(2533) + ((EEPROM.read(2534) << 8) & 0xFF00);
+ DMXSegment = EEPROM.read(2550);
+ DMXStartLED = EEPROM.read(2551);
for (int i=0;i<15;i++) {
DMXFixtureMap[i] = EEPROM.read(2535+i);
diff --git a/wled00/wled02_xml.ino b/wled00/wled02_xml.ino
index 100be4822..a05c1e97b 100644
--- a/wled00/wled02_xml.ino
+++ b/wled00/wled02_xml.ino
@@ -455,6 +455,8 @@ void getSettingsJS(byte subPage, char* dest)
sappend('v',"CN",DMXChannels);
sappend('v',"CG",DMXGap);
sappend('v',"CS",DMXStart);
+ sappend('v',"SEG",DMXSegment);
+ sappend('v',"SL",DMXStartLED);
sappend('i',"CH1",DMXFixtureMap[0]);
sappend('i',"CH2",DMXFixtureMap[1]);
diff --git a/wled00/wled03_set.ino b/wled00/wled03_set.ino
index fc82256d2..088f31ad3 100644
--- a/wled00/wled03_set.ino
+++ b/wled00/wled03_set.ino
@@ -310,6 +310,14 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
t = request->arg(argname).toInt();
DMXFixtureMap[i] = t;
}
+ t = request->arg("SEG").toInt();
+ if (t>=0 && t<10) {
+ DMXSegment = t;
+ }
+ t = request->arg("SL").toInt();
+ if (t>=0 && t<1500) {
+ DMXStartLED = t;
+ }
}
#endif
diff --git a/wled00/wled21_dmx.ino b/wled00/wled21_dmx.ino
index 4230f07d8..e48b051a0 100644
--- a/wled00/wled21_dmx.ino
+++ b/wled00/wled21_dmx.ino
@@ -5,20 +5,27 @@
*/
#ifdef WLED_ENABLE_DMX
-void handleDMX() {
+void handleDMX() {
+ WS2812FX::Segment& seg = strip.getSegment(DMXSegment);
+
+ if (!seg.isActive()) {
+ return;
+ }
+
// TODO: calculate brightness manually if no shutter channel is set
-
uint8_t brightness = strip.getBrightness();
- for (int i = 0; i < ledCount; i++) { // uses the amount of LEDs as fixture count
+ // Calculate the start LED depending on segment and DMXStartLED config
+ uint8_t startLed = seg.start + DMXStartLED;
+ for (int i = startLed; i < seg.stop; i++) {
uint32_t in = strip.getPixelColor(i); // time to get the colors for the individual fixtures as suggested by AirCookie at issue #462
byte w = in >> 24 & 0xFF;
byte r = in >> 16 & 0xFF;
byte g = in >> 8 & 0xFF;
byte b = in & 0xFF;
- int DMXFixtureStart = DMXStart + (DMXGap * i);
+ int DMXFixtureStart = DMXStart + (DMXGap * (i - startLed));
for (int j = 0; j < DMXChannels; j++) {
int DMXAddr = DMXFixtureStart + j;
switch (DMXFixtureMap[j]) {