FastLED 3.6.0
Loading...
Searching...
No Matches
dmx.h
Go to the documentation of this file.
1
3
4#ifndef __INC_DMX_H
5#define __INC_DMX_H
6
7#include "FastLED.h"
8
11
14
15#if defined(DmxSimple_h) || defined(FASTLED_DOXYGEN)
16#include <DmxSimple.h>
17
19#define HAS_DMX_SIMPLE
20
21FASTLED_NAMESPACE_BEGIN
22
29template <uint8_t DATA_PIN, EOrder RGB_ORDER = RGB> class DMXSimpleController : public CPixelLEDController<RGB_ORDER> {
30public:
32 virtual void init() { DmxSimple.usePin(DATA_PIN); }
33
34protected:
36 virtual void showPixels(PixelController<RGB_ORDER> & pixels) {
37 int iChannel = 1;
38 while(pixels.has(1)) {
39 DmxSimple.write(iChannel++, pixels.loadAndScale0());
40 DmxSimple.write(iChannel++, pixels.loadAndScale1());
41 DmxSimple.write(iChannel++, pixels.loadAndScale2());
42 pixels.advanceData();
43 pixels.stepDithering();
44 }
45 }
46};
47
48FASTLED_NAMESPACE_END
49
50#endif
51
52#if defined(DmxSerial_h) || defined(FASTLED_DOXYGEN)
53#include <DMXSerial.h>
54
56#define HAS_DMX_SERIAL
57
58FASTLED_NAMESPACE_BEGIN
59
65template <EOrder RGB_ORDER = RGB> class DMXSerialController : public CPixelLEDController<RGB_ORDER> {
66public:
68 virtual void init() { DMXSerial.init(DMXController); }
69
71 virtual void showPixels(PixelController<RGB_ORDER> & pixels) {
72 int iChannel = 1;
73 while(pixels.has(1)) {
74 DMXSerial.write(iChannel++, pixels.loadAndScale0());
75 DMXSerial.write(iChannel++, pixels.loadAndScale1());
76 DMXSerial.write(iChannel++, pixels.loadAndScale2());
77 pixels.advanceData();
78 pixels.stepDithering();
79 }
80 }
81};
82
83FASTLED_NAMESPACE_END
84
87
88#endif
89
90#endif
central include file for FastLED, defines the CFastLED class/object
Template extension of the CLEDController class.
Definition controller.h:616
DMX512 based LED controller class, using the DMXSerial library.
Definition dmx.h:65
virtual void init()
Initialize the LED controller.
Definition dmx.h:68
virtual void showPixels(PixelController< RGB_ORDER > &pixels)
Send the LED data to the strip.
Definition dmx.h:71
DMX512 based LED controller class, using the DmxSimple library.
Definition dmx.h:29
virtual void init()
Initialize the LED controller.
Definition dmx.h:32
virtual void showPixels(PixelController< RGB_ORDER > &pixels)
Send the LED data to the strip.
Definition dmx.h:36
Pixel controller class.
Definition controller.h:259
void stepDithering()
Step the dithering forward.
Definition controller.h:461
uint8_t loadAndScale0(int lane, uint8_t scale)
non-template alias of loadAndScale<0>()
Definition controller.h:589
void advanceData()
Advance the data pointer forward, adjust position counter.
Definition controller.h:457
uint8_t loadAndScale1(int lane, uint8_t scale)
non-template alias of loadAndScale<1>()
Definition controller.h:590
uint8_t loadAndScale2(int lane, uint8_t scale)
non-template alias of loadAndScale<2>()
Definition controller.h:591
bool has(int n)
Do we have n pixels left to process?
Definition controller.h:428