19#include "fx/fx_engine.h"
21#include "fx/2d/animartrix.hpp"
29#define COLOR_ORDER GRB
31#define MATRIX_WIDTH 100
32#define MATRIX_HEIGHT 100
33#define GRID_SERPENTINE false
35#define NUM_LEDS (MATRIX_WIDTH * MATRIX_HEIGHT)
75XYMap xyMap = XYMap::constructRectangularGrid(MATRIX_WIDTH, MATRIX_HEIGHT);
78Title title(
"FastLED Wasm Demo");
79Description description(
"This example combines two features of FastLED to produce a remarkable range of effects from a relatively small amount of code. This example combines FastLED's color palette lookup functions with FastLED's Perlin noise generator, and the combination is extremely powerful");
81Slider brightness(
"Brightness", 255, 0, 255);
83Slider speed(
"Noise - Speed", 15, 1, 50);
84Checkbox changePallete(
"Noise - Auto Palette",
true);
85Slider changePalletTime(
"Noise - Time until next random Palette", 5, 1, 100);
86Slider scale(
"Noise - Scale", 20, 1, 100);
87Button changePalette(
"Noise - Next Palette");
88Button changeFx(
"Switch between Noise & Animartrix");
89NumberField fxIndex(
"Animartrix - index", 0, 0, NUM_ANIMATIONS);
90Slider timeSpeed(
"Time Speed", 1, -10, 10, .1);
97 Serial.println(
"Sketch setup");
100 .setScreenMap(xyMap);
101 Serial.println(
"FastLED setup done");
104 noisePalette.setScale(scale);
105 fxEngine.
addFx(animartrix);
106 fxEngine.
addFx(noisePalette);
107 Serial.println(
"Sketch setup done");
112 noisePalette.setSpeed(speed);
113 noisePalette.setScale(scale);
119 static int frame = 0;
122 noisePalette.changeToRandomPalette();
127 noisePalette.changeToRandomPalette();
130 static int lastFxIndex = -1;
131 if (fxIndex.value() != lastFxIndex) {
132 lastFxIndex = fxIndex;
133 animartrix.fxSet(fxIndex);
137 fxEngine.
draw(millis(), leds);
CFastLED FastLED
Global LED strip management instance.
central include file for FastLED, defines the CFastLED class/object
void setBrightness(uint8_t scale)
Set the global brightness scaling.
void show(uint8_t scale)
Update all our controllers with the current led colors, using the passed in brightness.
static CLEDController & addLeds(CLEDController *pLed, struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
Add a CLEDController instance to the world.
Manages and renders multiple visual effects (Fx) for LED strips.
int addFx(FxPtr effect)
Adds a new effect to the engine.
void setSpeed(float scale)
Sets the speed of the fx engine, which will impact the speed of all effects.
bool nextFx(uint16_t transition_ms=500)
Transitions to the next effect in the sequence.
bool draw(uint32_t now, CRGB *outputBuffer)
Renders the current effect or transition to the output buffer.
@ TypicalLEDStrip
Typical values for SMD5050 LEDs.
#define EVERY_N_MILLISECONDS_DYNAMIC(PERIOD_FUNC)
Checks whether to execute a block of code every N milliseconds, where N is determined dynamically.
Implements a simple red square effect for 2D LED grids.
Demonstrates how to mix noise generation with color palettes on a 2D LED matrix.
Representation of an RGB pixel (Red, Green, Blue)