-
Notifications
You must be signed in to change notification settings - Fork 4
/
RGBPrograms.h
48 lines (36 loc) · 1.22 KB
/
RGBPrograms.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
void RGBProgramRainbow(uint8_t speed, uint8_t brightness) {
static uint8_t startIndex = 0;
static unsigned long lastmillis = millis();
if (millis() - lastmillis > speed) {
startIndex = startIndex + 1;
for ( int i = 0; i < WSNUM_LEDS; i++) {
leds[i] = ColorFromPalette( RainbowColors_p, startIndex, brightness, LINEARBLEND);
}
lastmillis = millis();
}
}
void RGBProgramFire(uint8_t brightness) {
static unsigned long lastmillis = millis();
if (millis() - lastmillis > 15) {
static byte heat[WSNUM_LEDS];
for ( int i = 0; i < WSNUM_LEDS; i++) {
heat[i] = qsub8( heat[i], random8(0, ((FIRE_PROGRAM_COOLING * 10) / WSNUM_LEDS) + 2));
}
for ( int k = WSNUM_LEDS - 1; k >= 2; k--) {
heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2] ) / 3;
}
if ( random8() < FIRE_PROGRAM_SPARKLING ) {
int y = random8(7);
heat[y] = qadd8( heat[y], random8(160, 255) );
}
for ( int j = 0; j < WSNUM_LEDS; j++) {
CRGB color = HeatColor( heat[j]);
int pixelnumber;
pixelnumber = j;
leds[pixelnumber] = color;
}
lastmillis = millis();
}
}
void RGBProgramWaterfall (uint8_t brightness) {}
void RGBProgramTVSimulation (uint8_t brightness) {}