FastLED 3.9.15
Loading...
Searching...
No Matches

◆ pacifica_loop()

void pacifica_loop ( )
Examples
Pacifica.ino.

Definition at line 77 of file Pacifica.ino.

78{
79 // Increment the four "color index start" counters, one for each wave layer.
80 // Each is incremented at a different speed, and the speeds vary over time.
81 static uint16_t sCIStart1, sCIStart2, sCIStart3, sCIStart4;
82 static uint32_t sLastms = 0;
83 uint32_t ms = GET_MILLIS();
84 uint32_t deltams = ms - sLastms;
85 sLastms = ms;
86 uint16_t speedfactor1 = beatsin16(3, 179, 269);
87 uint16_t speedfactor2 = beatsin16(4, 179, 269);
88 uint32_t deltams1 = (deltams * speedfactor1) / 256;
89 uint32_t deltams2 = (deltams * speedfactor2) / 256;
90 uint32_t deltams21 = (deltams1 + deltams2) / 2;
91 sCIStart1 += (deltams1 * beatsin88(1011,10,13));
92 sCIStart2 -= (deltams21 * beatsin88(777,8,11));
93 sCIStart3 -= (deltams1 * beatsin88(501,5,7));
94 sCIStart4 -= (deltams2 * beatsin88(257,4,6));
95
96 // Clear out the LED array to a dim background blue-green
97 fill_solid( leds, NUM_LEDS, CRGB( 2, 6, 10));
98
99 // Render each of four layers, with different scales and speeds, that vary over time
100 pacifica_one_layer( pacifica_palette_1, sCIStart1, beatsin16( 3, 11 * 256, 14 * 256), beatsin8( 10, 70, 130), 0-beat16( 301) );
101 pacifica_one_layer( pacifica_palette_2, sCIStart2, beatsin16( 4, 6 * 256, 9 * 256), beatsin8( 17, 40, 80), beat16( 401) );
102 pacifica_one_layer( pacifica_palette_3, sCIStart3, 6 * 256, beatsin8( 9, 10,38), 0-beat16(503));
103 pacifica_one_layer( pacifica_palette_3, sCIStart4, 5 * 256, beatsin8( 8, 10,28), beat16(601));
104
105 // Add brighter 'whitecaps' where the waves lines up more
107
108 // Deepen the blues and greens a bit
110}
CRGB leds[NUM_LEDS]
Definition Apa102.ino:11
#define NUM_LEDS
Definition Apa102.ino:6
void pacifica_deepen_colors()
Definition Pacifica.ino:149
CRGBPalette16 pacifica_palette_1
Definition Pacifica.ino:66
void pacifica_add_whitecaps()
Definition Pacifica.ino:131
void pacifica_one_layer(CRGBPalette16 &p, uint16_t cistart, uint16_t wavescale, uint8_t bri, uint16_t ioff)
Definition Pacifica.ino:113
CRGBPalette16 pacifica_palette_2
Definition Pacifica.ino:69
CRGBPalette16 pacifica_palette_3
Definition Pacifica.ino:72
LIB8STATIC uint16_t beatsin16(accum88 beats_per_minute, uint16_t lowest=0, uint16_t highest=65535, uint32_t timebase=0, uint16_t phase_offset=0)
Generates a 16-bit sine wave at a given BPM that oscillates within a given range.
Definition lib8tion.h:957
LIB8STATIC uint16_t beat16(accum88 beats_per_minute, uint32_t timebase=0)
Generates a 16-bit "sawtooth" wave at a given BPM.
Definition lib8tion.h:913
LIB8STATIC uint8_t beatsin8(accum88 beats_per_minute, uint8_t lowest=0, uint8_t highest=255, uint32_t timebase=0, uint8_t phase_offset=0)
Generates an 8-bit sine wave at a given BPM that oscillates within a given range.
Definition lib8tion.h:975
LIB8STATIC uint16_t beatsin88(accum88 beats_per_minute_88, uint16_t lowest=0, uint16_t highest=65535, uint32_t timebase=0, uint16_t phase_offset=0)
Generates a 16-bit sine wave at a given BPM that oscillates within a given range.
Definition lib8tion.h:939
void fill_solid(struct CRGB *targetArray, int numToFill, const struct CRGB &color)
Fill a range of LEDs with a solid color.
#define GET_MILLIS
The a number of functions need access to a millisecond counter in order to keep time.
Definition lib8tion.h:837
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:54

References beat16(), beatsin16(), beatsin8(), beatsin88(), fill_solid(), GET_MILLIS, leds, NUM_LEDS, pacifica_add_whitecaps(), pacifica_deepen_colors(), pacifica_one_layer(), pacifica_palette_1, pacifica_palette_2, and pacifica_palette_3.

Referenced by loop().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: