/// @file dmx.h /// Defines the DMX512-based LED controllers. #pragma once #include "FastLED.h" /// @addtogroup Chipsets /// @{ /// @addtogroup ClocklessChipsets /// @{ #if defined(DmxSimple_h) || defined(FASTLED_DOXYGEN) #include /// Flag set when the DmxSimple library is included #define HAS_DMX_SIMPLE FASTLED_NAMESPACE_BEGIN /// DMX512 based LED controller class, using the DmxSimple library /// @tparam DATA_PIN the data pin for the output of the DMX bus /// @tparam RGB_ORDER the RGB ordering for these LEDs /// @see https://www.pjrc.com/teensy/td_libs_DmxSimple.html /// @see https://github.com/PaulStoffregen/DmxSimple /// @see https://en.wikipedia.org/wiki/DMX512 template class DMXSimpleController : public CPixelLEDController { public: /// Initialize the LED controller virtual void init() { DmxSimple.usePin(DATA_PIN); } protected: /// @copydoc CPixelLEDController::showPixels() virtual void showPixels(PixelController & pixels) { int iChannel = 1; while(pixels.has(1)) { DmxSimple.write(iChannel++, pixels.loadAndScale0()); DmxSimple.write(iChannel++, pixels.loadAndScale1()); DmxSimple.write(iChannel++, pixels.loadAndScale2()); pixels.advanceData(); pixels.stepDithering(); } } }; FASTLED_NAMESPACE_END #endif #if defined(DmxSerial_h) || defined(FASTLED_DOXYGEN) #include /// Flag set when the DMXSerial library is included #define HAS_DMX_SERIAL FASTLED_NAMESPACE_BEGIN /// DMX512 based LED controller class, using the DMXSerial library /// @tparam RGB_ORDER the RGB ordering for these LEDs /// @see http://www.mathertel.de/Arduino/DMXSerial.aspx /// @see https://github.com/mathertel/DMXSerial /// @see https://en.wikipedia.org/wiki/DMX512 template class DMXSerialController : public CPixelLEDController { public: /// Initialize the LED controller virtual void init() { DMXSerial.init(DMXController); } /// @copydoc CPixelLEDController::showPixels() virtual void showPixels(PixelController & pixels) { int iChannel = 1; while(pixels.has(1)) { DMXSerial.write(iChannel++, pixels.loadAndScale0()); DMXSerial.write(iChannel++, pixels.loadAndScale1()); DMXSerial.write(iChannel++, pixels.loadAndScale2()); pixels.advanceData(); pixels.stepDithering(); } } }; FASTLED_NAMESPACE_END /// @} DMXControllers /// @} Chipsets #endif