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

◆ draw()

void fl::Pacifica::draw ( DrawContext context)
overridevirtual
Parameters
nowThe current time in milliseconds. Fx writers are encouraged to use this instead of millis() directly as this will more deterministic behavior.

Implements fl::Fx.

Definition at line 45 of file pacifica.h.

45 {
46 CRGB *leds = ctx.leds;
47 uint32_t now = ctx.now;
48 if (leds == nullptr || mNumLeds == 0) {
49 return;
50 }
51
52 // Update the hue each time through the loop
53 uint32_t ms = now;
54 uint32_t deltams = ms - sLastms;
55 sLastms = ms;
56 uint16_t speedfactor1 = beatsin16(3, 179, 269);
57 uint16_t speedfactor2 = beatsin16(4, 179, 269);
58 uint32_t deltams1 = (deltams * speedfactor1) / 256;
59 uint32_t deltams2 = (deltams * speedfactor2) / 256;
60 uint32_t deltams21 = (deltams1 + deltams2) / 2;
61 sCIStart1 += (deltams1 * beatsin88(1011, 10, 13));
62 sCIStart2 -= (deltams21 * beatsin88(777, 8, 11));
63 sCIStart3 -= (deltams1 * beatsin88(501, 5, 7));
64 sCIStart4 -= (deltams2 * beatsin88(257, 4, 6));
65
66 // Clear out the LED array to a dim background blue-green
67 fill_solid(leds, mNumLeds, CRGB(2, 6, 10));
68
69 // Render each of four layers, with different scales and speeds, that vary
70 // over time
72 beatsin16(3, 11 * 256, 14 * 256), beatsin8(10, 70, 130),
73 0 - beat16(301));
75 beatsin16(4, 6 * 256, 9 * 256), beatsin8(17, 40, 80),
76 beat16(401));
78 beatsin8(9, 10, 38), 0 - beat16(503));
80 beatsin8(8, 10, 28), beat16(601));
81
82 // Add brighter 'whitecaps' where the waves lines up more
84
85 // Deepen the blues and greens a bit
87}
CRGB leds[NUM_LEDS]
Definition Apa102.ino:11
void pacifica_deepen_colors()
Definition Pacifica.ino:149
void pacifica_add_whitecaps()
Definition Pacifica.ino:131
uint16_t mNumLeds
Definition fx.h:50
CRGBPalette16 pacifica_palette_1
Definition pacifica.h:26
uint32_t sLastms
Definition pacifica.h:24
CRGBPalette16 pacifica_palette_3
Definition pacifica.h:34
uint16_t sCIStart4
Definition pacifica.h:23
CRGBPalette16 pacifica_palette_2
Definition pacifica.h:30
uint16_t sCIStart3
Definition pacifica.h:23
uint16_t sCIStart1
Definition pacifica.h:23
void pacifica_one_layer(CRGB *leds, CRGBPalette16 &p, uint16_t cistart, uint16_t wavescale, uint8_t bri, uint16_t ioff)
Definition pacifica.h:90
uint16_t sCIStart2
Definition pacifica.h:23
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.

References beat16(), beatsin16(), beatsin8(), beatsin88(), fill_solid(), fl::_DrawContext::leds, leds, fl::Fx::mNumLeds, fl::_DrawContext::now, pacifica_add_whitecaps(), pacifica_deepen_colors(), pacifica_one_layer(), pacifica_palette_1, pacifica_palette_2, pacifica_palette_3, sCIStart1, sCIStart2, sCIStart3, sCIStart4, and sLastms.

+ Here is the call graph for this function: