-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.ino
36 lines (27 loc) · 865 Bytes
/
main.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
uint8_t animation;
uint8_t animationsOffset;
uint8_t frame = 0;
void setup() {
FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS);
FastLED.setBrightness(BRIGHTNESS);
// start code at random animation
animationsOffset = random(ANIMATIONS);
}
void loop() {
// change animation (every 10s) and frame (every loop)
animation = (millis() / 10000 + animationsOffset) % ANIMATIONS;
frame = (frame + 1) % frameCounts[animation];
uint8_t rgb8bit;
uint8_t r, g, b;
for (uint8_t i = 0; i < NUM_LEDS; i++){
// get correct pixel
rgb8bit = *((uint8_t*)animations[animation] + frame * NUM_LEDS + i);
// parse colors from 8-bit to 24-bit RGB
r = rgb8bit & 0b11100000;
g = (rgb8bit & 0b00011100) << 3;
b = (rgb8bit & 0b00000011) << 6;
leds[i].setRGB(r, g, b);
}
FastLED.show();
delay(speeds[animation]);
}