-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdrip.ino
65 lines (59 loc) · 1.51 KB
/
drip.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
void drip(int wait) {
boolean done = true;
boolean move_step = false;
static double state[6][7];
random16_add_entropy( random());
// fade to black
if (love_mode == 0 ) {
for(int x = 0;x < 7;x++) {
for(int y = 0;y < 6;y++) {
state[y][x] = -3.0;
}
}
for(int pixel = 0;pixel < PIXEL_COUNT;pixel++) {
leds[pixel].fadeToBlackBy( 8 );
if (leds[pixel]) {
done = false;
}
}
if (done) {
love_mode = 2;
}
} else if (love_mode == 2) {
for(int x = 0;x < 7;x++) {
boolean new_drip = false;
if(random16() < 500) {
new_drip = true;
}
for(int y = 0;y < 6;y++) {
if (state[y][x] < -2.0 && new_drip) {
state[y][x] = -1.0;
new_drip = false;
} else if (state[y][x] > -2.0) {
state[y][x] += 0.002*wait;
}
if (state[y][x] > 8.0) {
state[y][x] = -3.0;
}
int pixel = layout[y][x];
if (pixel != INUL) {
leds[pixel] = CRGB::Black;
}
}
}
for(int x = 0;x < 7;x++) {
for(int y = 0;y < 6;y++) {
if (state[y][x] > -2.0) {
for(int i = max(0, floor(state[y][x]) - 1);i <= min(5, floor(state[y][x]) + 2);i++) {
int pixel = layout[i][x];
if (i >= 0 && pixel != INUL) {
leds[pixel] += CHSV( 160, 255, ease8InOutCubic(255-128*abs(state[y][x]-i)));
}
}
}
}
}
}
FastLED.show();
FastLED.delay(wait);
}