FastLED 3.10.8
Loading...
Searching...
No Matches
noisewave.h
Go to the documentation of this file.
1#pragma once
2
3#include "fl/stl/noexcept.h"
4
5#include "fl/fx/fx1d.h"
6#include "noisegen.h"
7
8namespace fl {
9
11
12class NoiseWave : public Fx1d {
13 public:
14 NoiseWave(u16 num_leds) FL_NO_EXCEPT
15 : Fx1d(num_leds), noiseGeneratorRed(500, 14),
16 noiseGeneratorBlue(500, 10) {}
17
18 void draw(DrawContext context) FL_NO_EXCEPT override {
19 if (context.leds.empty() || mNumLeds == 0) {
20 return;
21 }
22 if (start_time == 0) {
23 start_time = context.now;
24 }
25
26 unsigned long time_now = fl::millis() - start_time;
27
28 for (i32 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::string fxName() const FL_NO_EXCEPT override { return "NoiseWave"; }
37
38 private:
41 fl::u32 start_time = 0;
42};
43
44} // namespace fl
Fx1d(u16 numLeds) FL_NO_EXCEPT
Definition fx1d.h:13
u16 mNumLeds
Definition fx.h:53
fl::u32 start_time
Definition noisewave.h:41
void draw(DrawContext context) FL_NO_EXCEPT override
Definition noisewave.h:18
NoiseGenerator noiseGeneratorBlue
Definition noisewave.h:40
fl::string fxName() const FL_NO_EXCEPT override
Definition noisewave.h:36
NoiseGenerator noiseGeneratorRed
Definition noisewave.h:39
NoiseWave(u16 num_leds) FL_NO_EXCEPT
Definition noisewave.h:14
fl::CRGB CRGB
Definition video.h:18
u8 u8 fract8 blur_amount FL_NO_EXCEPT
Definition blur.h:186
fl::u32 millis() FL_NO_EXCEPT
Universal millisecond timer - returns milliseconds since system startup.
InputGamut g
Definition rgbw.h:125
Base definition for an LED controller.
Definition crgb.hpp:179
Noise generation classes.
#define FASTLED_SHARED_PTR(type)
Definition shared_ptr.h:577