From d2f55e1064a1188f0b831979c4e9ddde96c29a53 Mon Sep 17 00:00:00 2001 From: Travis J Dean Date: Mon, 30 Mar 2020 03:55:44 -0400 Subject: [PATCH] Make dmx.h header only. --- wled00/dmx.cpp | 52 ----------------------------------------------- wled00/dmx.h | 55 +++++++++++++++++++++++++++++++++++++++++++++++++- wled00/wled.h | 4 ---- 3 files changed, 54 insertions(+), 57 deletions(-) delete mode 100644 wled00/dmx.cpp diff --git a/wled00/dmx.cpp b/wled00/dmx.cpp deleted file mode 100644 index d024ac71..00000000 --- a/wled00/dmx.cpp +++ /dev/null @@ -1,52 +0,0 @@ -#include "dmx.h" -#include "wled.h" - -#ifdef WLED_ENABLE_DMX -void handleDMX() { - // 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 - - 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); - for (int j = 0; j < DMXChannels; j++) { - int DMXAddr = DMXFixtureStart + j; - switch (DMXFixtureMap[j]) { - case 0: // Set this channel to 0. Good way to tell strobe- and fade-functions to fuck right off. - dmx.write(DMXAddr, 0); - break; - case 1: // Red - dmx.write(DMXAddr, r); - break; - case 2: // Green - dmx.write(DMXAddr, g); - break; - case 3: // Blue - dmx.write(DMXAddr, b); - break; - case 4: // White - dmx.write(DMXAddr, w); - break; - case 5: // Shutter channel. Controls the brightness. - dmx.write(DMXAddr, brightness); - break; - case 6:// Sets this channel to 255. Like 0, but more wholesome. - dmx.write(DMXAddr, 255); - break; - } - } - } - - dmx.update(); // update the DMX bus -} - -#else -void handleDMX() {} -#endif diff --git a/wled00/dmx.h b/wled00/dmx.h index 707dec91..76aab484 100644 --- a/wled00/dmx.h +++ b/wled00/dmx.h @@ -1,11 +1,64 @@ #ifndef WLED_DMX_H #define WLED_DMX_H +#include "wled.h" /* * Support for DMX via MAX485. * Needs the espdmx library. You might have to change the output pin within the library. Sketchy, i know. * https://github.com/Rickgg/ESP-Dmx */ -void handleDMX(); +#ifdef WLED_ENABLE_DMX +#include +DMXESPSerial dmx; + +#ifdef WLED_ENABLE_DMX +void handleDMX() { + // 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 + + 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); + for (int j = 0; j < DMXChannels; j++) { + int DMXAddr = DMXFixtureStart + j; + switch (DMXFixtureMap[j]) { + case 0: // Set this channel to 0. Good way to tell strobe- and fade-functions to fuck right off. + dmx.write(DMXAddr, 0); + break; + case 1: // Red + dmx.write(DMXAddr, r); + break; + case 2: // Green + dmx.write(DMXAddr, g); + break; + case 3: // Blue + dmx.write(DMXAddr, b); + break; + case 4: // White + dmx.write(DMXAddr, w); + break; + case 5: // Shutter channel. Controls the brightness. + dmx.write(DMXAddr, brightness); + break; + case 6:// Sets this channel to 255. Like 0, but more wholesome. + dmx.write(DMXAddr, 255); + break; + } + } + } + + dmx.update(); // update the DMX bus +} + +#else +void handleDMX() {} +#endif #endif //WLED_DMX_H \ No newline at end of file diff --git a/wled00/wled.h b/wled00/wled.h index c6f791cd..e5c4f493 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -37,10 +37,6 @@ //library inclusions #include -#ifdef WLED_ENABLE_DMX -#include -DMXESPSerial dmx; -#endif #ifdef ESP8266 #include #include