FastLED 3.10.8
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 34 of file pride2015.h.

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

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

+ Here is the call graph for this function: