FastLED 3.10.8
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 fl::span<CRGB> leds = ctx.leds;
47 fl::u32 now = ctx.now;
48 if (leds.empty() || mNumLeds == 0) {
49 return;
50 }
51
52 // Update the hue each time through the loop
53 fl::u32 ms = now;
54 fl::u32 deltams = ms - sLastms;
55 sLastms = ms;
56 u16 speedfactor1 = beatsin16(3, 179, 269);
57 u16 speedfactor2 = beatsin16(4, 179, 269);
58 fl::u32 deltams1 = (deltams * speedfactor1) / 256;
59 fl::u32 deltams2 = (deltams * speedfactor2) / 256;
60 fl::u32 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, 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[1]
void pacifica_deepen_colors()
Definition Pacifica.ino:162
void pacifica_add_whitecaps()
Definition Pacifica.ino:144
u16 mNumLeds
Definition fx.h:53
void pacifica_one_layer(fl::span< CRGB > leds, CRGBPalette16 &p, u16 cistart, u16 wavescale, u8 bri, u16 ioff) FL_NO_EXCEPT
Definition pacifica.h:90
u16 sCIStart4
Definition pacifica.h:23
CRGBPalette16 pacifica_palette_1
Definition pacifica.h:26
fl::u32 sLastms
Definition pacifica.h:24
u16 sCIStart3
Definition pacifica.h:23
CRGBPalette16 pacifica_palette_3
Definition pacifica.h:34
u16 sCIStart2
Definition pacifica.h:23
CRGBPalette16 pacifica_palette_2
Definition pacifica.h:30
u16 sCIStart1
Definition pacifica.h:23
LIB8STATIC u16 beatsin88(accum88 beats_per_minute_88, u16 lowest=0, u16 highest=65535, u32 timebase=0, u16 phase_offset=0) FL_NO_EXCEPT
Generates a 16-bit sine wave at a given BPM that oscillates within a given range.
Definition beat.h:63
LIB8STATIC u16 beatsin16(accum88 beats_per_minute, u16 lowest=0, u16 highest=65535, u32 timebase=0, u16 phase_offset=0) FL_NO_EXCEPT
Generates a 16-bit sine wave at a given BPM that oscillates within a given range.
Definition beat.h:84
LIB8STATIC u8 beatsin8(accum88 beats_per_minute, u8 lowest=0, u8 highest=255, u32 timebase=0, u8 phase_offset=0) FL_NO_EXCEPT
Generates an 8-bit sine wave at a given BPM that oscillates within a given range.
Definition beat.h:105
LIB8STATIC u16 beat16(accum88 beats_per_minute, u32 timebase=0) FL_NO_EXCEPT
Generates a 16-bit "sawtooth" wave at a given BPM.
Definition beat.h:41
void fill_solid(CRGB *targetArray, int numToFill, const CRGB &color) FL_NO_EXCEPT
Fill a range of LEDs with a solid color.
Definition fill.cpp.hpp:10
fl::CRGB CRGB
Definition video.h:18

References fl::beat16(), fl::beatsin16(), fl::beatsin8(), fl::beatsin88(), fl::fill_solid(), fl::FL_NO_EXCEPT, leds, fl::Fx::mNumLeds, 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: