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

◆ draw()

void fl::Cylon::draw ( DrawContext context)
inlineoverridevirtual
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 17 of file cylon.h.

17 {
18 if (context.leds.empty() || mNumLeds == 0) {
19 return;
20 }
21
22 fl::span<CRGB> leds = context.leds;
23
24 // Set the current LED to the current hue
25 leds[position] = CHSV(hue++, 255, 255);
26
27 // Fade all LEDs
28 for (u16 i = 0; i < mNumLeds; i++) {
30 }
31
32 // Move the position
33 if (reverse) {
34 position--;
35 if (position < 0) {
36 position = 1;
37 reverse = false;
38 }
39 } else {
40 position++;
41 if (position >= i16(mNumLeds)) {
42 position = mNumLeds - 2;
43 reverse = true;
44 }
45 }
46 }
fl::CRGB leds[NUM_LEDS]
u8 fade_amount
Definition cylon.h:53
bool reverse
Definition cylon.h:55
i16 position
Definition cylon.h:56
u8 hue
Definition cylon.h:51
u16 mNumLeds
Definition fx.h:53
fl::hsv8 CHSV
Definition chsv.h:11
CRGB & nscale8(u8 scaledown) FL_NOEXCEPT
Scale down a RGB to N/256ths of its current brightness, using "plain math" dimming rules.
Definition crgb.cpp.hpp:88

References fade_amount, hue, fl::DrawContext::leds, leds, fl::Fx::mNumLeds, position, and reverse.