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

◆ pacifica_loop()

void pacifica_loop ( )
Examples
Pacifica.ino.

Definition at line 87 of file Pacifica.ino.

88{
89 // Increment the four "color index start" counters, one for each wave layer.
90 // Each is incremented at a different speed, and the speeds vary over time.
91 static uint16_t sCIStart1, sCIStart2, sCIStart3, sCIStart4;
92 static uint32_t sLastms = 0;
93 uint32_t ms = GET_MILLIS();
94 uint32_t deltams = ms - sLastms;
95 sLastms = ms;
96 uint16_t speedfactor1 = beatsin16(3, 179, 269);
97 uint16_t speedfactor2 = beatsin16(4, 179, 269);
98 uint32_t deltams1 = (deltams * speedfactor1) / 256;
99 uint32_t deltams2 = (deltams * speedfactor2) / 256;
100 uint32_t deltams21 = (deltams1 + deltams2) / 2;
101 sCIStart1 += (deltams1 * beatsin88(1011,10,13));
102 sCIStart2 -= (deltams21 * beatsin88(777,8,11));
103 sCIStart3 -= (deltams1 * beatsin88(501,5,7));
104 sCIStart4 -= (deltams2 * beatsin88(257,4,6));
105
106 // Clear out the LED array to a dim background blue-green
107 fill_solid( leds, NUM_LEDS, CRGB( 2, 6, 10));
108
109 // Render each of four layers, with different scales and speeds, that vary over time
110 pacifica_one_layer( pacifica_palette_1, sCIStart1, beatsin16( 3, 11 * 256, 14 * 256), beatsin8( 10, 70, 130), 0-beat16( 301) );
111 pacifica_one_layer( pacifica_palette_2, sCIStart2, beatsin16( 4, 6 * 256, 9 * 256), beatsin8( 17, 40, 80), beat16( 401) );
112 pacifica_one_layer( pacifica_palette_3, sCIStart3, 6 * 256, beatsin8( 9, 10,38), 0-beat16(503));
113 pacifica_one_layer( pacifica_palette_3, sCIStart4, 5 * 256, beatsin8( 8, 10,28), beat16(601));
114
115 // Add brighter 'whitecaps' where the waves lines up more
117
118 // Deepen the blues and greens a bit
120}
CRGB leds[NUM_LEDS]
#define NUM_LEDS
void pacifica_deepen_colors()
Definition Pacifica.ino:159
CRGBPalette16 pacifica_palette_1
Definition Pacifica.ino:75
void pacifica_add_whitecaps()
Definition Pacifica.ino:141
void pacifica_one_layer(CRGBPalette16 &p, uint16_t cistart, uint16_t wavescale, uint8_t bri, uint16_t ioff)
Definition Pacifica.ino:123
CRGBPalette16 pacifica_palette_2
Definition Pacifica.ino:78
CRGBPalette16 pacifica_palette_3
Definition Pacifica.ino:81
void fill_solid(struct CRGB *targetArray, int numToFill, const struct CRGB &color)
Fill a range of LEDs with a solid color.
Definition fill.cpp:9
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:819
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:775
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:837
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:801
#define GET_MILLIS
The a number of functions need access to a millisecond counter in order to keep time.
Definition lib8tion.h:699
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:86

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: