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