-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathplasma.h
33 lines (22 loc) · 1.57 KB
/
plasma.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
#ifndef PLASMA_H
#define PLASMA_H
void plasma() {
// Persistent local variables
static int16_t thisphase = 0; // Phase of a cubicwave8.
static int16_t thatphase = 0; // Phase of the cos8.
// Temporary local variables
uint16_t thisbright;
uint16_t colorIndex;
timeval = 20; // Our EVERY_N_MILLIS_I timer value.
thisphase += beatsin8(6,-4,4); // You can change direction and speed individually.
thatphase += beatsin8(7,-4,4); // Two phase values to make a complex pattern. By Andrew Tuline.
for (int k=0; k<NUM_LEDS; k++) { // For each of the LED's in the strand, set a brightness based on a wave as follows.
thisbright = cubicwave8((k*8)+thisphase)/2;
thisbright += cos8((k*10)+thatphase)/2; // Let's munge the brightness a bit and animate it all with the phases.
colorIndex=thisbright;
thisbright = qsuba(thisbright, 255-sampleavg); // qsuba chops off values below a threshold defined by sampleavg. Gives a cool effect.
leds[k] = ColorFromPalette( currentPalette, colorIndex, thisbright, currentBlending); // Let's now add the foreground colour.
}
addGlitter(sampleavg/2); // Add glitter based on sampleavg.
} // plasma()
#endif