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

◆ pacifica_loop()

void pacifica_loop ( )
Examples
Pacifica.ino.

Definition at line 90 of file Pacifica.ino.

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

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: