FastLED 3.9.7
Loading...
Searching...
No Matches
Animartrix.ino
Go to the documentation of this file.
1
10
11
12#include <stdio.h>
13#include <string>
14
15#include <FastLED.h>
16#include "fl/json.h"
17#include "fl/slice.h"
18#include "fx/fx_engine.h"
19
20#include "fx/2d/animartrix.hpp"
21#include "fl/ui.h"
22
23using namespace fl;
24
25
26#define LED_PIN 3
27#define BRIGHTNESS 96
28#define COLOR_ORDER GRB
29
30#define MATRIX_WIDTH 22
31#define MATRIX_HEIGHT 22
32
33#define NUM_LEDS (MATRIX_WIDTH * MATRIX_HEIGHT)
34
35#define FIRST_ANIMATION POLAR_WAVES
36
37
38CRGB leds[NUM_LEDS];
39XYMap xyMap = XYMap::constructRectangularGrid(MATRIX_WIDTH, MATRIX_HEIGHT);
40
41
42Title title("Animartrix");
43Description description("Demo of the Animatrix effects. @author of fx is StefanPetrick");
44
45Slider brightness("Brightness", 255, 0, 255);
46NumberField fxIndex("Animartrix - index", 0, 0, NUM_ANIMATIONS - 1);
47Slider timeSpeed("Time Speed", 1, -10, 10, .1);
48
49Animartrix animartrix(xyMap, FIRST_ANIMATION);
50FxEngine fxEngine(NUM_LEDS);
51
52void setup() {
53 FastLED.addLeds<WS2811, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS)
54 .setCorrection(TypicalLEDStrip)
55 .setScreenMap(xyMap);
56 FastLED.setBrightness(brightness);
57 fxEngine.addFx(animartrix);
58}
59
60void loop() {
61 FastLED.setBrightness(brightness);
62 fxEngine.setSpeed(timeSpeed);
63 static int lastFxIndex = -1;
64 if (fxIndex.value() != lastFxIndex) {
65 lastFxIndex = fxIndex;
66 animartrix.fxSet(fxIndex);
67 }
68 fxEngine.draw(millis(), leds);
69 FastLED.show();
70}
71
72
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
WS2811 controller class.
Definition FastLED.h:234
Manages and renders multiple visual effects (Fx) for LED strips.
Definition fx_engine.h:38
int addFx(FxPtr effect)
Adds a new effect to the engine.
Definition fx_engine.cpp:16
void setSpeed(float scale)
Sets the speed of the fx engine, which will impact the speed of all effects.
Definition fx_engine.h:116
bool draw(uint32_t now, CRGB *outputBuffer)
Renders the current effect or transition to the output buffer.
Definition fx_engine.cpp:84
@ TypicalLEDStrip
Typical values for SMD5050 LEDs.
Definition color.h:19
Implements a simple red square effect for 2D LED grids.
Definition crgb.h:16
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:54