FastLED 3.9.7
Loading...
Searching...
No Matches
FxEngine.ino
#include <FastLED.h>
using namespace fl;
#if defined(__AVR__)
// __AVR__: Not enough memory enough for the FxEngine, so skipping this example
void setup() {}
void loop() {}
#else
#include "fx/2d/animartrix.hpp"
#include "fx/fx_engine.h"
#include "fl/ui.h"
#define LED_PIN 2
#define BRIGHTNESS 96
#define LED_TYPE WS2811
#define COLOR_ORDER GRB
#define MATRIX_WIDTH 22
#define MATRIX_HEIGHT 22
#define NUM_LEDS (MATRIX_WIDTH * MATRIX_HEIGHT)
#ifdef __EMSCRIPTEN__
#define IS_SERPINTINE false
#else
#define IS_SERPINTINE true
#endif
Slider SCALE("SCALE", 20, 20, 100);
Slider SPEED("SPEED", 30, 20, 100);
CRGB leds[NUM_LEDS];
XYMap xyMap(MATRIX_WIDTH, MATRIX_HEIGHT, IS_SERPINTINE); // No serpentine
NoisePalette noisePalette1(xyMap);
NoisePalette noisePalette2(xyMap);
FxEngine fxEngine(NUM_LEDS);
Checkbox switchFx("Switch Fx", true);
void setup() {
delay(1000); // sanity delay
FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS)
.setCorrection(TypicalLEDStrip)
.setScreenMap(MATRIX_WIDTH, MATRIX_HEIGHT);
noisePalette1.setPalettePreset(2);
noisePalette2.setPalettePreset(4);
fxEngine.addFx(noisePalette1);
fxEngine.addFx(noisePalette2);
}
void loop() {
noisePalette1.setSpeed(SPEED);
noisePalette1.setScale(SCALE);
noisePalette2.setSpeed(SPEED);
noisePalette2.setScale(int(SCALE) * 3 / 2); // Make the different.
if (switchFx) {
fxEngine.nextFx(500);
}
}
fxEngine.draw(millis(), leds);
}
#endif // __AVR__
CFastLED FastLED
Global LED strip management instance.
Definition FastLED.cpp:45
central include file for FastLED, defines the CFastLED class/object
void setBrightness(uint8_t scale)
Set the global brightness scaling.
Definition FastLED.h:723
void show(uint8_t scale)
Update all our controllers with the current led colors, using the passed in brightness.
Definition FastLED.cpp:94
static CLEDController & addLeds(CLEDController *pLed, struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
Add a CLEDController instance to the world.
Definition FastLED.cpp:79
Manages and renders multiple visual effects (Fx) for LED strips.
Definition fx_engine.h:38
@ TypicalLEDStrip
Typical values for SMD5050 LEDs.
Definition color.h:19
#define EVERY_N_SECONDS(N)
Checks whether to execute a block of code every N seconds.
Definition lib8tion.h:1283
Implements a simple red square effect for 2D LED grids.
Definition crgb.h:16
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:54