FastLED 3.9.15
Loading...
Searching...
No Matches
noisewave.h
Go to the documentation of this file.
1#pragma once
2
3#include "fl/fx/fx1d.h"
4#include "noisegen.h"
5
6namespace fl {
7
9
10class NoiseWave : public Fx1d {
11 public:
12 NoiseWave(u16 num_leds)
13 : Fx1d(num_leds), noiseGeneratorRed(500, 14),
14 noiseGeneratorBlue(500, 10) {}
15
16 void draw(DrawContext context) override {
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 }
33
34 fl::string fxName() const override { return "NoiseWave"; }
35
36 private:
39 fl::u32 start_time = 0;
40};
41
42} // namespace fl
Fx1d(u16 numLeds)
Definition fx1d.h:12
u16 mNumLeds
Definition fx.h:53
fl::u32 start_time
Definition noisewave.h:39
NoiseWave(u16 num_leds)
Definition noisewave.h:12
NoiseGenerator noiseGeneratorBlue
Definition noisewave.h:38
NoiseGenerator noiseGeneratorRed
Definition noisewave.h:37
void draw(DrawContext context) override
Definition noisewave.h:16
fl::string fxName() const override
Definition noisewave.h:34
fl::CRGB CRGB
Definition video.h:15
fl::u32 millis()
Universal millisecond timer - returns milliseconds since system startup.
Base definition for an LED controller.
Definition crgb.hpp:179
Noise generation classes.
#define FASTLED_SHARED_PTR(type)
Definition shared_ptr.h:535
fl::span< CRGB > leds