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

◆ draw()

void fl::NoiseWave::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 16 of file noisewave.h.

16 {
17 if (context.leds.empty() || mNumLeds == 0) {
18 return;
19 }
20 if (start_time == 0) {
21 start_time = context.now;
22 }
23
24 unsigned long time_now = fl::millis() - start_time;
25
26 for (i32 i = 0; i < mNumLeds; ++i) {
27 int r = noiseGeneratorRed.LedValue(i, time_now);
28 int b = noiseGeneratorBlue.LedValue(i, time_now + 100000) >> 1;
29 int g = 0;
30 context.leds[i] = CRGB(r, g, b);
31 }
32 }
u16 mNumLeds
Definition fx.h:53
fl::u32 start_time
Definition noisewave.h:39
NoiseGenerator noiseGeneratorBlue
Definition noisewave.h:38
NoiseGenerator noiseGeneratorRed
Definition noisewave.h:37
fl::CRGB CRGB
Definition video.h:15
fl::u32 millis()
Universal millisecond timer - returns milliseconds since system startup.

References fl::DrawContext::leds, fl::millis(), fl::Fx::mNumLeds, noiseGeneratorBlue, noiseGeneratorRed, fl::DrawContext::now, and start_time.

+ Here is the call graph for this function: