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 43 of file pacifica.h.

43 {
44 fl::span<CRGB> leds = ctx.leds;
45 fl::u32 now = ctx.now;
46 if (leds.empty() || mNumLeds == 0) {
47 return;
48 }
49
50 // Update the hue each time through the loop
51 fl::u32 ms = now;
52 fl::u32 deltams = ms - sLastms;
53 sLastms = ms;
54 u16 speedfactor1 = beatsin16(3, 179, 269);
55 u16 speedfactor2 = beatsin16(4, 179, 269);
56 fl::u32 deltams1 = (deltams * speedfactor1) / 256;
57 fl::u32 deltams2 = (deltams * speedfactor2) / 256;
58 fl::u32 deltams21 = (deltams1 + deltams2) / 2;
59 sCIStart1 += (deltams1 * beatsin88(1011, 10, 13));
60 sCIStart2 -= (deltams21 * beatsin88(777, 8, 11));
61 sCIStart3 -= (deltams1 * beatsin88(501, 5, 7));
62 sCIStart4 -= (deltams2 * beatsin88(257, 4, 6));
63
64 // Clear out the LED array to a dim background blue-green
65 fill_solid(leds, CRGB(2, 6, 10));
66
67 // Render each of four layers, with different scales and speeds, that vary
68 // over time
70 beatsin16(3, 11 * 256, 14 * 256), beatsin8(10, 70, 130),
71 0 - beat16(301));
73 beatsin16(4, 6 * 256, 9 * 256), beatsin8(17, 40, 80),
74 beat16(401));
76 beatsin8(9, 10, 38), 0 - beat16(503));
78 beatsin8(8, 10, 28), beat16(601));
79
80 // Add brighter 'whitecaps' where the waves lines up more
82
83 // Deepen the blues and greens a bit
85}
fl::CRGB leds[NUM_LEDS]
void pacifica_deepen_colors()
Definition Pacifica.ino:162
void pacifica_add_whitecaps()
Definition Pacifica.ino:144
u16 mNumLeds
Definition fx.h:53
u16 sCIStart4
Definition pacifica.h:21
CRGBPalette16 pacifica_palette_1
Definition pacifica.h:24
fl::u32 sLastms
Definition pacifica.h:22
u16 sCIStart3
Definition pacifica.h:21
CRGBPalette16 pacifica_palette_3
Definition pacifica.h:32
u16 sCIStart2
Definition pacifica.h:21
CRGBPalette16 pacifica_palette_2
Definition pacifica.h:28
void pacifica_one_layer(fl::span< CRGB > leds, CRGBPalette16 &p, u16 cistart, u16 wavescale, u8 bri, u16 ioff)
Definition pacifica.h:88
u16 sCIStart1
Definition pacifica.h:21
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
void fill_solid(CRGB *targetArray, int numToFill, const CRGB &color)
Fill a range of LEDs with a solid color.
Definition fill.cpp.hpp:9
fl::CRGB CRGB
Definition video.h:15

References fl::beat16(), fl::beatsin16(), fl::beatsin8(), fl::beatsin88(), fl::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: