-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathR4DMX.h
74 lines (62 loc) · 1.92 KB
/
R4DMX.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
66
67
68
69
70
71
72
73
74
#ifndef R4DMX_h
#define R4DMX_h
#include <Arduino.h>
#include <vector>
#include <map>
struct Color {
uint8_t r, g, b;
};
class R4DMX {
public:
R4DMX(int dirPin, int txPin, int rxPin);
void begin();
void loop();
void setChannel(int channel, uint8_t value);
void setColor(int startChannel, const String& colorName);
void startFade(int startChannel, const String& colorName, unsigned long durationMs);
void startStrobeEffect(int startChannel, const String& colorName, int frequency);
void stopStrobeEffect();
void startChaseEffect(const std::vector<String>& colorNames, unsigned long intervalMs);
void stopChaseEffect();
void startPulseEffect(int startChannel, const String& colorName);
void stopPulseEffect();
void clearAllChannels();
void locateFixture(int startChannel, int numChannels);
void printAvailableCommands();
private:
static const int DMX_UNIVERSE_SIZE = 513;
static const int REFRESH_RATE = 40;
static const long FRAME_TIME = 1000000 / REFRESH_RATE;
uint8_t dmxData[DMX_UNIVERSE_SIZE];
unsigned long lastFrameTime;
unsigned long lastDiagnosticTime;
unsigned long frameCount;
bool dmxError;
bool refreshRateStable;
int dmxDirPin;
int dmxTxPin;
int dmxRxPin;
bool isChaseRunning;
unsigned long chaseInterval;
unsigned long lastChaseUpdate;
size_t activeChaseStep;
std::vector<String> chaseColors;
bool isPulseRunning;
int pulseChannel;
unsigned long pulseStartTime;
Color pulseColor;
bool isStrobeRunning;
int strobeChannel;
int strobeFrequency;
Color strobeColor;
std::map<String, Color> predefinedColors;
void initPredefinedColors();
void sendDmxUniverse();
void performDiagnostic();
void updateChase();
void updatePulse();
void updateStrobe();
Color parseColorInput(const String& colorInput);
bool isNumeric(const String& str);
};
#endif