FastLED 3.9.15
Loading...
Searching...
No Matches
FxNoisePlusPalette.ino
Go to the documentation of this file.
1
10
11#include <FastLED.h>
12
13#if !SKETCH_HAS_LOTS_OF_MEMORY
14// Don't compile this for AVR microcontrollers (like Arduino Uno) because they typically
15// don't have enough memory to handle this complex animation.
16// Instead, we provide empty setup/loop functions so the sketch will compile but do nothing.
17void setup() {}
18void loop() {}
19#else // For all other platforms with more memory (ESP32, Teensy, etc.)
20#include "fx/2d/noisepalette.h"
21#include "fl/ui.h"
22
23using namespace fl;
24
25#define LED_PIN 3
26#define BRIGHTNESS 96
27#define LED_TYPE WS2811
28#define COLOR_ORDER GRB
29
30#define MATRIX_WIDTH 16
31#define MATRIX_HEIGHT 16
32
33#if __EMSCRIPTEN__
34#define GRID_SERPENTINE 0
35#else
36#define GRID_SERPENTINE 1
37#endif
38
39#define NUM_LEDS (MATRIX_WIDTH * MATRIX_HEIGHT)
40
41// This example combines two features of FastLED to produce a remarkable range
42// of effects from a relatively small amount of code. This example combines
43// FastLED's color palette lookup functions with FastLED's Perlin noise
44// generator, and the combination is extremely powerful.
45//
46// You might want to look at the "ColorPalette" and "Noise" examples separately
47// if this example code seems daunting.
48//
49//
50// The basic setup here is that for each frame, we generate a new array of
51// 'noise' data, and then map it onto the LED matrix through a color palette.
52//
53// Periodically, the color palette is changed, and new noise-generation
54// parameters are chosen at the same time. In this example, specific
55// noise-generation values have been selected to match the given color palettes;
56// some are faster, or slower, or larger, or smaller than others, but there's no
57// reason these parameters can't be freely mixed-and-matched.
58//
59// In addition, this example includes some fast automatic 'data smoothing' at
60// lower noise speeds to help produce smoother animations in those cases.
61//
62// The FastLED built-in color palettes (Forest, Clouds, Lava, Ocean, Party) are
63// used, as well as some 'hand-defined' ones, and some proceedurally generated
64// palettes.
65
66// Scale determines how far apart the pixels in our noise matrix are. Try
67// changing these values around to see how it affects the motion of the display.
68// The higher the value of scale, the more "zoomed out" the noise iwll be. A
69// value of 1 will be so zoomed in, you'll mostly see solid colors.
70
71UISlider SCALE("SCALE", 20, 1, 100, 1);
72
73// We're using the x/y dimensions to map to the x/y pixels on the matrix. We'll
74// use the z-axis for "time". speed determines how fast time moves forward. Try
75// 1 for a very slow moving effect, or 60 for something that ends up looking
76// like water.
77UISlider SPEED("SPEED", 30, 1, 60, 1);
78
82
83void setup() {
84 delay(1000); // sanity delay
86 .setCorrection(TypicalLEDStrip);
87 FastLED.setBrightness(96);
88 noisePalette.setSpeed(SPEED);
89 noisePalette.setScale(SCALE);
90}
91
92void loop() {
93 noisePalette.setSpeed(SPEED);
94 noisePalette.setScale(SCALE);
95 EVERY_N_MILLISECONDS(5000) { noisePalette.changeToRandomPalette(); }
96
97 noisePalette.draw(Fx::DrawContext(millis(), leds));
98 FastLED.show();
99}
100
101#endif // End of the non-AVR code section
CRGB leds[NUM_LEDS]
#define NUM_LEDS
fl::XYMap xyMap
Definition ColorBoost.h:61
#define MATRIX_HEIGHT
Definition EaseInOut.h:19
#define MATRIX_WIDTH
Definition EaseInOut.h:18
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
Definition FastLED.cpp:74
central include file for FastLED, defines the CFastLED class/object
void setup()
void loop()
#define COLOR_ORDER
Definition advanced.h:42
#define LED_TYPE
Definition advanced.h:41
#define LED_PIN
Definition advanced.h:40
_DrawContext DrawContext
Definition fx.h:21
CRGBPalette16 noisePalette
Definition curr.h:255
@ TypicalLEDStrip
Typical values for SMD5050 LEDs.
Definition color.h:19
#define EVERY_N_MILLISECONDS(N)
Alias for EVERY_N_MILLIS.
Definition lib8tion.h:1221
IMPORTANT!
Definition crgb.h:20
Demonstrates how to mix noise generation with color palettes on a 2D LED matrix.
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:86
#define GRID_SERPENTINE
Definition wasm_impl.h:32
#define SCALE
Definition wasm_impl.h:65
#define SPEED
Definition wasm_impl.h:71