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

34 {
35 if (ctx.leds == nullptr || mNumLeds == 0) {
36 return;
37 }
38
39 uint8_t sat8 = beatsin88(87, 220, 250);
40 uint8_t brightdepth = beatsin88(341, 96, 224);
41 uint16_t brightnessthetainc16 = beatsin88(203, (25 * 256), (40 * 256));
42 uint8_t msmultiplier = beatsin88(147, 23, 60);
43
44 uint16_t hue16 = mHue16;
45 uint16_t hueinc16 = beatsin88(113, 1, 3000);
46
47 uint16_t ms = millis();
48 uint16_t deltams = ms - mLastMillis;
49 mLastMillis = ms;
50 mPseudotime += deltams * msmultiplier;
51 mHue16 += deltams * beatsin88(400, 5, 9);
52 uint16_t brightnesstheta16 = mPseudotime;
53
54 // set master brightness control
55 for (uint16_t i = 0; i < mNumLeds; i++) {
56 hue16 += hueinc16;
57 uint8_t hue8 = hue16 / 256;
58
59 brightnesstheta16 += brightnessthetainc16;
60 uint16_t b16 = sin16(brightnesstheta16) + 32768;
61
62 uint16_t bri16 = (uint32_t)((uint32_t)b16 * (uint32_t)b16) / 65536;
63 uint8_t bri8 = (uint32_t)(((uint32_t)bri16) * brightdepth) / 65536;
64 bri8 += (255 - brightdepth);
65
66 CRGB newcolor = CHSV(hue8, sat8, bri8);
67
68 uint16_t pixelnumber = (mNumLeds - 1) - i;
69
70 nblend(ctx.leds[pixelnumber], newcolor, 64);
71 }
72}
uint16_t mNumLeds
Definition fx.h:53
uint16_t mPseudotime
Definition pride2015.h:27
uint16_t mHue16
Definition pride2015.h:29
uint16_t mLastMillis
Definition pride2015.h:28
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:921
#define sin16
Platform-independent alias of the fast sin implementation.
Definition trig8.h:103
CRGB & nblend(CRGB &existing, const CRGB &overlay, fract8 amountOfOverlay)

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

+ Here is the call graph for this function: