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

19 {
20 if (context.leds == nullptr || mNumLeds == 0) {
21 return;
22 }
23
24 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 (uint16_t 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 >= int16_t(mNumLeds)) {
44 position = mNumLeds - 2;
45 reverse = true;
46 }
47 }
48 }
CRGB leds[NUM_LEDS]
Definition Apa102.ino:11
uint8_t fade_amount
Definition cylon.h:55
bool reverse
Definition cylon.h:57
uint8_t hue
Definition cylon.h:53
int16_t position
Definition cylon.h:58
uint16_t mNumLeds
Definition fx.h:53
CRGB & nscale8(uint8_t scaledown)
Scale down a RGB to N/256ths of its current brightness, using "plain math" dimming rules.
Definition crgb.cpp:88

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