forked from FastLED/FastLED
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dmx.h
65 lines (51 loc) · 1.5 KB
/
dmx.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#ifndef __INC_DMX_H
#define __INC_DMX_H
#include "FastLED.h"
#ifdef DmxSimple_h
#include <DmxSimple.h>
#define HAS_DMX_SIMPLE
///@ingroup chipsets
///@{
FASTLED_NAMESPACE_BEGIN
// note - dmx simple must be included before FastSPI for this code to be enabled
template <uint8_t DATA_PIN, EOrder RGB_ORDER = RGB> class DMXSimpleController : public CPixelLEDController<RGB_ORDER> {
public:
// initialize the LED controller
virtual void init() { DmxSimple.usePin(DATA_PIN); }
protected:
virtual void showPixels(PixelController<RGB_ORDER> & 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
#ifdef DmxSerial_h
#include <DMXSerial.h>
FASTLED_NAMESPACE_BEGIN
template <EOrder RGB_ORDER = RGB> class DMXSerialController : public CPixelLEDController<RGB_ORDER> {
public:
// initialize the LED controller
virtual void init() { DMXSerial.init(DMXController); }
virtual void showPixels(PixelController<RGB_ORDER> & 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
///@}
#define HAS_DMX_SERIAL
#endif
#endif