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

20 {
21 if (context.leds == nullptr || mNumLeds == 0) {
22 return;
23 }
24
25 CRGB *leds = context.leds;
26
27 // Set the current LED to the current hue
28 leds[position] = CHSV(hue++, 255, 255);
29
30 // Fade all LEDs
31 for (uint16_t i = 0; i < mNumLeds; i++) {
33 }
34
35 // Move the position
36 if (reverse) {
37 position--;
38 if (position < 0) {
39 position = 1;
40 reverse = false;
41 }
42 } else {
43 position++;
44 if (position >= int16_t(mNumLeds)) {
45 position = mNumLeds - 2;
46 reverse = true;
47 }
48 }
49 }
CRGB leds[NUM_LEDS]
Definition Apa102.ino:11
uint8_t fade_amount
Definition cylon.h:56
bool reverse
Definition cylon.h:58
uint8_t hue
Definition cylon.h:54
int16_t position
Definition cylon.h:59
uint16_t mNumLeds
Definition fx.h:50
CRGB & nscale8(uint8_t scaledown)
Scale down a RGB to N/256ths of its current brightness, using "plain math" dimming rules.
Definition crgb.cpp:72

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