Skip to content

Commit c0d662a

Browse files
committed
Swap DMX output to also use esp_dmx
1 parent 6e9dc18 commit c0d662a

File tree

5 files changed

+56
-238
lines changed

5 files changed

+56
-238
lines changed

wled00/dmx_output.cpp

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
#include "wled.h"
2-
2+
#include "dmx_output.h"
33
/*
44
* Support for DMX output via serial (e.g. MAX485).
55
* Change the output pin in src/dependencies/ESPDMX.cpp, if needed (ESP8266)
6-
* Change the output pin in src/dependencies/SparkFunDMX.cpp, if needed (ESP32)
76
* ESP8266 Library from:
87
* https://github.com/Rickgg/ESP-Dmx
98
* ESP32 Library from:
10-
* https://github.com/sparkfun/SparkFunDMX
9+
* https://github.com/someweisguy/esp_dmx
1110
*/
1211

1312
#ifdef WLED_ENABLE_DMX
@@ -72,9 +71,25 @@ void initDMXOutput() {
7271
#if defined(ESP8266) || defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32S2)
7372
dmx.init(512); // initialize with bus length
7473
#else
75-
dmx.initWrite(512); // initialize with bus length
74+
7675
#endif
7776
}
77+
78+
void DMXOutput::init(uint8_t txPin)
79+
{
80+
dmx_config_t config = DMX_CONFIG_DEFAULT;
81+
dmx_driver_install(dmxPort, &config, DMX_INTR_FLAGS_DEFAULT);
82+
dmx_set_pin(dmxPort, txPin, -1, -1);
83+
}
84+
void DMXOutput::write(uint8_t channel, uint8_t value)
85+
{
86+
dmxdata[channel] = value;
87+
}
88+
void DMXOutput::update()
89+
{
90+
dmx_send(dmxPort, DMX_PACKET_SIZE);
91+
}
92+
7893
#else
7994
void initDMXOutput(){}
8095
void handleDMXOutput() {}

wled00/dmx_output.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
//
2+
// Created by will on 1/10/26.
3+
//
4+
5+
#ifndef DMX_OUTPUT_H
6+
#define DMX_OUTPUT_H
7+
8+
#if defined(ESP8266)
9+
#include "src/dependencies/dmx/ESPDMX.h"
10+
DMXESPSerial dmx;
11+
#else
12+
#include <esp_dmx.h>
13+
/**
14+
* Support for DMX Output via serial (e.g. max485) on ESP32
15+
* ESP32 Library from:
16+
* https://github.com/someweisguy/esp_dmx
17+
*/
18+
class DMXOutput
19+
{
20+
public:
21+
void init(uint8_t txPin);
22+
void write(uint8_t channel, uint8_t value);
23+
void update();
24+
private:
25+
byte dmxdata[DMX_PACKET_SIZE];
26+
/* Next, lets decide which DMX port to use. The ESP32 has either 2 or 3 ports.
27+
Port 0 is typically used to transmit serial data back to your Serial Monitor,
28+
so we shouldn't use that port. Lets use port 1! */
29+
dmx_port_t dmxPort = 1;
30+
};
31+
32+
DMXOutput dmx;
33+
#endif
34+
35+
36+
#endif //DMX_OUTPUT_H

wled00/src/dependencies/dmx/SparkFunDMX.cpp

Lines changed: 0 additions & 182 deletions
This file was deleted.

wled00/src/dependencies/dmx/SparkFunDMX.h

Lines changed: 0 additions & 42 deletions
This file was deleted.

wled00/wled.h

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,7 @@
139139
#endif
140140

141141
#ifdef WLED_ENABLE_DMX
142-
#if defined(ESP8266) || defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32S2)
143-
#include "src/dependencies/dmx/ESPDMX.h"
144-
#else //ESP32
145-
#include "src/dependencies/dmx/SparkFunDMX.h"
146-
#endif
142+
#include "dmx_output.h"
147143
#endif
148144

149145
#ifdef WLED_ENABLE_DMX_INPUT
@@ -454,11 +450,6 @@ WLED_GLOBAL bool arlsDisableGammaCorrection _INIT(true); // activate if
454450
WLED_GLOBAL bool arlsForceMaxBri _INIT(false); // enable to force max brightness if source has very dark colors that would be black
455451

456452
#ifdef WLED_ENABLE_DMX
457-
#if defined(ESP8266) || defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32S2)
458-
WLED_GLOBAL DMXESPSerial dmx;
459-
#else //ESP32
460-
WLED_GLOBAL SparkFunDMX dmx;
461-
#endif
462453
WLED_GLOBAL uint16_t e131ProxyUniverse _INIT(0); // output this E1.31 (sACN) / ArtNet universe via MAX485 (0 = disabled)
463454
// dmx CONFIG
464455
WLED_GLOBAL byte DMXChannels _INIT(7); // number of channels per fixture

0 commit comments

Comments
 (0)