FastLED 3.9.3
Loading...
Searching...
No Matches
noisewave.hpp
1#pragma once
2
3#include "FastLED.h"
4#include "fx/fx1d.h"
5#include "namespace.h"
6#include "noisegen.h"
7
8FASTLED_NAMESPACE_BEGIN
9
10FASTLED_SMART_REF(NoiseWave);
11
12class NoiseWave : public FxStrip {
13 public:
14 NoiseWave(uint16_t num_leds)
15 : FxStrip(num_leds), noiseGeneratorRed(500, 14),
16 noiseGeneratorBlue(500, 10) {}
17
18 void lazyInit() override { start_time = millis(); }
19
20 void draw(DrawContext context) override {
21 if (context.leds == nullptr || mNumLeds == 0) {
22 return;
23 }
24
25 unsigned long time_now = millis() - start_time;
26
27 for (int32_t i = 0; i < mNumLeds; ++i) {
28 int r = noiseGeneratorRed.LedValue(i, time_now);
29 int b = noiseGeneratorBlue.LedValue(i, time_now + 100000) >> 1;
30 int g = 0;
31 context.leds[i] = CRGB(r, g, b);
32 }
33 }
34
35 const char *fxName(int) const override { return "NoiseWave"; }
36
37 private:
38 NoiseGenerator noiseGeneratorRed;
39 NoiseGenerator noiseGeneratorBlue;
40 unsigned long start_time = 0;
41};
42
43FASTLED_NAMESPACE_END
central include file for FastLED, defines the CFastLED class/object
Definition fx1d.h:12
void draw(DrawContext context) override
Definition noisewave.hpp:20
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:39