FastLED 3.9.15
Loading...
Searching...
No Matches
FxNoisePlusPalette.ino
Go to the documentation of this file.
1// @filter: (memory is large)
2
12
13#include <FastLED.h>
15#include "fl/ui/ui.h"
16
17#define LED_PIN 3
18#define BRIGHTNESS 96
19#define LED_TYPE WS2811
20#define COLOR_ORDER GRB
21
22#define MATRIX_WIDTH 16
23#define MATRIX_HEIGHT 16
24
25#if __EMSCRIPTEN__
26#define GRID_SERPENTINE 0
27#else
28#define GRID_SERPENTINE 1
29#endif
30
31#define NUM_LEDS (MATRIX_WIDTH * MATRIX_HEIGHT)
32
33// This example combines two features of FastLED to produce a remarkable range
34// of effects from a relatively small amount of code. This example combines
35// FastLED's color palette lookup functions with FastLED's Perlin noise
36// generator, and the combination is extremely powerful.
37//
38// You might want to look at the "ColorPalette" and "Noise" examples separately
39// if this example code seems daunting.
40//
41//
42// The basic setup here is that for each frame, we generate a new array of
43// 'noise' data, and then map it onto the LED matrix through a color palette.
44//
45// Periodically, the color palette is changed, and new noise-generation
46// parameters are chosen at the same time. In this example, specific
47// noise-generation values have been selected to match the given color palettes;
48// some are faster, or slower, or larger, or smaller than others, but there's no
49// reason these parameters can't be freely mixed-and-matched.
50//
51// In addition, this example includes some fast automatic 'data smoothing' at
52// lower noise speeds to help produce smoother animations in those cases.
53//
54// The FastLED built-in color palettes (Forest, Clouds, Lava, Ocean, Party) are
55// used, as well as some 'hand-defined' ones, and some proceedurally generated
56// palettes.
57
58// Scale determines how far apart the pixels in our noise matrix are. Try
59// changing these values around to see how it affects the motion of the display.
60// The higher the value of scale, the more "zoomed out" the noise iwll be. A
61// value of 1 will be so zoomed in, you'll mostly see solid colors.
62
63fl::UISlider SCALE("SCALE", 20, 1, 100, 1);
64
65// We're using the x/y dimensions to map to the x/y pixels on the matrix. We'll
66// use the z-axis for "time". speed determines how fast time moves forward. Try
67// 1 for a very slow moving effect, or 60 for something that ends up looking
68// like water.
69fl::UISlider SPEED("SPEED", 30, 1, 60, 1);
70
74
75void setup() {
76 delay(1000); // sanity delay
78 .setCorrection(TypicalLEDStrip);
79 FastLED.setBrightness(96);
80 noisePalette.setSpeed(SPEED);
81 noisePalette.setScale(SCALE);
82}
83
84void loop() {
85 noisePalette.setSpeed(SPEED);
86 noisePalette.setScale(SCALE);
87 EVERY_N_MILLISECONDS(5000) { noisePalette.changeToRandomPalette(); }
88
90 FastLED.show();
91}
#define COLOR_ORDER
#define MATRIX_HEIGHT
fl::XYMap xyMap
#define NUM_LEDS
fl::CRGB leds[NUM_LEDS]
#define LED_PIN
#define MATRIX_WIDTH
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
#define GRID_SERPENTINE
void setup()
fl::UISlider SCALE("SCALE", 20, 1, 100, 1)
fl::XYMap xyMap(MATRIX_WIDTH, MATRIX_HEIGHT, GRID_SERPENTINE)
fl::UISlider SPEED("SPEED", 30, 1, 60, 1)
void loop()
fl::NoisePalette noisePalette(xyMap)
#define SCALE
Definition Overclock.ino:68
#define SPEED
Definition Overclock.ino:74
#define LED_TYPE
::fl::DrawContext DrawContext
Definition fx.h:21
fl::CRGBPalette16 noisePalette
Definition curr.h:243
@ TypicalLEDStrip
Typical values for SMD5050 LEDs.
Definition color.h:15
#define EVERY_N_MILLISECONDS(N)
Alias for EVERY_N_MILLIS.
Definition lib8tion.h:1045
fl::u32 millis()
Universal millisecond timer - returns milliseconds since system startup.
Demonstrates how to mix noise generation with color palettes on a 2D LED matrix.
Representation of an 8-bit RGB pixel (Red, Green, Blue)
Definition crgb.h:38
Aggregator header for the fl/ui/ family of per-element UI types.