-
Notifications
You must be signed in to change notification settings - Fork 0
/
mode_raw.ino
42 lines (37 loc) · 1.24 KB
/
mode_raw.ino
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
const int numberOfChannels = numLeds * 3; // Total number of channels you want to receive (1 led = 3 channels)
const int maxUniverses = numberOfChannels / 512 + ((numberOfChannels % 512) ? 1 : 0);
bool universesReceived[maxUniverses];
bool sendFrame = 1;
int previousDataLength = 0;
void raw_mode(const uint32_t universe, const uint8_t* data, const uint16_t length) {
sendFrame = 1;
// set brightness of the whole strip
/*
if (universe == 15) {
leds.setBrightness(data[0]);
leds.show();
}
*/
// Store which universe has got in
if ((universe - startUniverse) < maxUniverses)
universesReceived[universe - startUniverse] = 1;
for (int i = 0 ; i < maxUniverses ; i++) {
if (universesReceived[i] == 0) {
//Serial.println("Broke");
sendFrame = 0;
break;
}
}
// read universe and put into the right part of the display buffer
for (int i = 0; i < length / 3; i++) {
int led = i + (universe - startUniverse) * (previousDataLength / 3);
if (led < numLeds)
leds.setPixelColor(led, data[i * 3], data[i * 3 + 1], data[i * 3 + 2]);
}
previousDataLength = length;
if (sendFrame) {
leds.show();
// Reset universeReceived to 0
memset(universesReceived, 0, maxUniverses);
}
}