FastLED 3.10.8
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 19 of file cylon.h.

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

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