PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
1.5KB

  1. #ifndef __INC_DMX_H
  2. #define __INC_DMX_H
  3. #include "FastLED.h"
  4. #ifdef DmxSimple_h
  5. #include <DmxSimple.h>
  6. #define HAS_DMX_SIMPLE
  7. ///@ingroup chipsets
  8. ///@{
  9. FASTLED_NAMESPACE_BEGIN
  10. // note - dmx simple must be included before FastSPI for this code to be enabled
  11. template <uint8_t DATA_PIN, EOrder RGB_ORDER = RGB> class DMXSimpleController : public CPixelLEDController<RGB_ORDER> {
  12. public:
  13. // initialize the LED controller
  14. virtual void init() { DmxSimple.usePin(DATA_PIN); }
  15. protected:
  16. virtual void showPixels(PixelController<RGB_ORDER> & pixels) {
  17. int iChannel = 1;
  18. while(pixels.has(1)) {
  19. DmxSimple.write(iChannel++, pixels.loadAndScale0());
  20. DmxSimple.write(iChannel++, pixels.loadAndScale1());
  21. DmxSimple.write(iChannel++, pixels.loadAndScale2());
  22. pixels.advanceData();
  23. pixels.stepDithering();
  24. }
  25. }
  26. };
  27. FASTLED_NAMESPACE_END
  28. #endif
  29. #ifdef DmxSerial_h
  30. #include <DMXSerial.h>
  31. FASTLED_NAMESPACE_BEGIN
  32. template <EOrder RGB_ORDER = RGB> class DMXSerialController : public CPixelLEDController<RGB_ORDER> {
  33. public:
  34. // initialize the LED controller
  35. virtual void init() { DMXSerial.init(DMXController); }
  36. virtual void showPixels(PixelController<RGB_ORDER> & pixels) {
  37. int iChannel = 1;
  38. while(pixels.has(1)) {
  39. DMXSerial.write(iChannel++, pixels.loadAndScale0());
  40. DMXSerial.write(iChannel++, pixels.loadAndScale1());
  41. DMXSerial.write(iChannel++, pixels.loadAndScale2());
  42. pixels.advanceData();
  43. pixels.stepDithering();
  44. }
  45. }
  46. };
  47. FASTLED_NAMESPACE_END
  48. ///@}
  49. #define HAS_DMX_SERIAL
  50. #endif
  51. #endif