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

◆ draw()

void fl::Pride2015::draw ( Fx::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 32 of file pride2015.h.

32 {
33 if (ctx.leds.empty() || mNumLeds == 0) {
34 return;
35 }
36
37 u8 sat8 = beatsin88(87, 220, 250);
38 u8 brightdepth = beatsin88(341, 96, 224);
39 u16 brightnessthetainc16 = beatsin88(203, (25 * 256), (40 * 256));
40 u8 msmultiplier = beatsin88(147, 23, 60);
41
42 u16 hue16 = mHue16;
43 u16 hueinc16 = beatsin88(113, 1, 3000);
44
45 u16 ms = fl::millis();
46 u16 deltams = ms - mLastMillis;
47 mLastMillis = ms;
48 mPseudotime += deltams * msmultiplier;
49 mHue16 += deltams * beatsin88(400, 5, 9);
50 u16 brightnesstheta16 = mPseudotime;
51
52 // set master brightness control
53 for (u16 i = 0; i < mNumLeds; i++) {
54 hue16 += hueinc16;
55 u8 hue8 = hue16 / 256;
56
57 brightnesstheta16 += brightnessthetainc16;
58 u16 b16 = sin16(brightnesstheta16) + 32768;
59
60 u16 bri16 = (fl::u32)((fl::u32)b16 * (fl::u32)b16) / 65536;
61 u8 bri8 = (fl::u32)(((fl::u32)bri16) * brightdepth) / 65536;
62 bri8 += (255 - brightdepth);
63
64 CRGB newcolor = CHSV(hue8, sat8, bri8);
65
66 u16 pixelnumber = (mNumLeds - 1) - i;
67
68 nblend(ctx.leds[pixelnumber], newcolor, 64);
69 }
70}
u16 mNumLeds
Definition fx.h:53
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
fl::hsv8 CHSV
Definition chsv.h:11
unsigned char u8
Definition stdint.h:131
fl::CRGB CRGB
Definition video.h:15
fl::u32 millis()
Universal millisecond timer - returns milliseconds since system startup.
CRGB & nblend(CRGB &existing, const CRGB &overlay, fract8 amountOfOverlay)

References fl::beatsin88(), fl::DrawContext::leds, mHue16, fl::millis(), mLastMillis, fl::Fx::mNumLeds, mPseudotime, and fl::nblend().

+ Here is the call graph for this function: