FastLED 3.9.3
Loading...
Searching...
No Matches
FxEngine.ino
1
4
5
6#include <FastLED.h>
7
8#include "fx/2d/noisepalette.hpp"
9#include "fx/2d/animartrix.hpp"
10#include "fx/fx_engine.h"
11#include "fx/storage/sd.h"
12#include "ui.h"
13
14#define LED_PIN 2
15#define BRIGHTNESS 96
16#define LED_TYPE WS2811
17#define COLOR_ORDER GRB
18
19#define MATRIX_WIDTH 22
20#define MATRIX_HEIGHT 22
21
22#define NUM_LEDS (MATRIX_WIDTH * MATRIX_HEIGHT)
23
24#ifdef __EMSCRIPTEN__
25#define IS_SERPINTINE false
26#else
27#define IS_SERPINTINE true
28#endif
29
30
31Slider SCALE("SCALE", 20, 20, 100);
32Slider SPEED("SPEED", 30, 20, 100);
33
34CRGB leds[NUM_LEDS];
35XYMap xyMap(MATRIX_WIDTH, MATRIX_HEIGHT, IS_SERPINTINE); // No serpentine
36NoisePalette noisePalette(xyMap);
37Animartrix animartrix(xyMap, POLAR_WAVES);
38FxEngine fxEngine(NUM_LEDS);
39Checkbox switchFx("Switch Fx", true);
40
41void setup() {
42 delay(1000); // sanity delay
43 FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS)
44 .setCorrection(TypicalLEDStrip)
45 .setScreenMap(MATRIX_WIDTH, MATRIX_HEIGHT);
47 noisePalette.lazyInit();
48 noisePalette.setPalettePreset(2);
49 fxEngine.addFx(noisePalette);
50 fxEngine.addFx(animartrix);
51}
52
53void loop() {
54 noisePalette.setSpeed(SPEED);
55 noisePalette.setScale(SCALE);
57 if (switchFx) {
58 fxEngine.nextFx(500);
59 }
60 }
61 fxEngine.draw(millis(), leds);
62 FastLED.show();
63}
CFastLED FastLED
Global LED strip management instance.
Definition FastLED.cpp:33
central include file for FastLED, defines the CFastLED class/object
void setBrightness(uint8_t scale)
Set the global brightness scaling.
Definition FastLED.h:722
void show(uint8_t scale)
Update all our controllers with the current led colors, using the passed in brightness.
Definition FastLED.cpp:82
static CLEDController & addLeds(CLEDController *pLed, struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
Add a CLEDController instance to the world.
Definition FastLED.cpp:67
Definition ui.h:83
Manages and renders multiple visual effects (Fx) for LED strips.
Definition fx_engine.h:37
int addFx(FxRef effect)
Adds a new effect to the engine.
Definition fx_engine.h:145
bool nextFx(uint16_t transition_ms=500)
Transitions to the next effect in the sequence.
Definition fx_engine.h:164
bool draw(uint32_t now, CRGB *outputBuffer)
Renders the current effect or transition to the output buffer.
Definition fx_engine.h:213
Definition ui.h:40
Definition xymap.h:39
@ 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:1288
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:39