FastLED 3.9.15
Loading...
Searching...
No Matches
Animartrix.ino
Go to the documentation of this file.
1
6
7/*
8This demo is best viewed using the FastLED compiler.
9
10Windows/MacOS binaries: https://github.com/FastLED/FastLED/releases
11
12Python
13
14Install: pip install fastled
15Run: fastled <this sketch directory>
16This will compile and preview the sketch in the browser, and enable
17all the UI elements you see below.
18
19
20
21OVERVIEW:
22This is the famouse Animartrix demo by Stefan Petrick. The effects are generated
23using polor polar coordinates. The effects are very complex and powerful.
24*/
25
26#if !SKETCH_HAS_LOTS_OF_MEMORY
27// Platform does not have enough memory
28void setup() {}
29void loop() {}
30#else
31
32
33#include <stdio.h>
34#include <string>
35
36#include <FastLED.h>
37#include "fl/json.h"
38#include "fl/slice.h"
39#include "fx/fx_engine.h"
40
41#include "fx/2d/animartrix.hpp"
42#include "fl/ui.h"
43
44using namespace fl;
45
46
47#define LED_PIN 3
48#define BRIGHTNESS 96
49#define COLOR_ORDER GRB
50
51#define MATRIX_WIDTH 32
52#define MATRIX_HEIGHT 32
53
54#define NUM_LEDS (MATRIX_WIDTH * MATRIX_HEIGHT)
55
56#define FIRST_ANIMATION POLAR_WAVES
57
58// This is purely use for the web compiler to display the animartrix effects.
59// This small led was chosen because otherwise the bloom effect is too strong.
60#define LED_DIAMETER 0.15 // .15 cm or 1.5mm
61
62
65
66
67UITitle title("Animartrix");
68UIDescription description("Demo of the Animatrix effects. @author of fx is StefanPetrick");
69
70UISlider brightness("Brightness", 255, 0, 255);
71UINumberField fxIndex("Animartrix - index", 0, 0, NUM_ANIMATIONS - 1);
72UINumberField colorOrder("Color Order", 0, 0, 5);
73UISlider timeSpeed("Time Speed", 1, -10, 10, .1);
74
75Animartrix animartrix(xyMap, FIRST_ANIMATION);
77
78
79void setup() {
80 auto screen_map = xyMap.toScreenMap();
81 screen_map.setDiameter(LED_DIAMETER);
83 .setCorrection(TypicalLEDStrip)
84 .setScreenMap(screen_map);
85 FastLED.setBrightness(brightness);
86 fxEngine.addFx(animartrix);
87
88 colorOrder.onChanged([](int value) {
89 switch(value) {
90 case 0: value = RGB; break;
91 case 1: value = RBG; break;
92 case 2: value = GRB; break;
93 case 3: value = GBR; break;
94 case 4: value = BRG; break;
95 case 5: value = BGR; break;
96 }
97 animartrix.setColorOrder(static_cast<EOrder>(value));
98 });
99}
100
101void loop() {
102 FastLED.setBrightness(brightness);
103 fxEngine.setSpeed(timeSpeed);
104 static int lastFxIndex = -1;
105 if (fxIndex.value() != lastFxIndex) {
106 lastFxIndex = fxIndex;
107 animartrix.fxSet(fxIndex);
108 }
109 fxEngine.draw(millis(), leds);
110 FastLED.show();
111}
112
113
114#endif // __AVR__
void setup()
void loop()
CRGB leds[NUM_LEDS]
Definition Apa102.ino:11
#define NUM_LEDS
Definition Apa102.ino:6
UITitle title("Chromancer")
#define COLOR_ORDER
#define LED_PIN
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
Definition FastLED.cpp:62
central include file for FastLED, defines the CFastLED class/object
#define MATRIX_HEIGHT
Definition FxEngine.ino:28
FxEngine fxEngine(NUM_LEDS)
#define MATRIX_WIDTH
Definition FxEngine.ino:27
UISlider brightness("Brightness", 1, 0, 1)
Definition ui.h:25
WS2811 controller class.
Definition FastLED.h:258
static XYMap constructRectangularGrid(uint16_t width, uint16_t height, uint16_t offset=0)
Definition xymap.cpp:36
Definition xymap.h:43
Manages and renders multiple visual effects (Fx) for LED strips.
Definition fx_engine.h:36
EOrder
RGB color channel orderings, used when instantiating controllers to determine what order the controll...
Definition eorder.h:14
@ RGB
Red, Green, Blue (0012)
Definition eorder.h:15
@ BGR
Blue, Green, Red (0210)
Definition eorder.h:20
@ BRG
Blue, Red, Green (0201)
Definition eorder.h:19
@ GRB
Green, Red, Blue (0102)
Definition eorder.h:17
@ RBG
Red, Blue, Green (0021)
Definition eorder.h:16
@ GBR
Green, Blue, Red (0120)
Definition eorder.h:18
XYMap xyMap
Definition gfx.cpp:8
@ TypicalLEDStrip
Typical values for SMD5050 LEDs.
Definition color.h:19
@ NUM_ANIMATIONS
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:55
UISlider timeSpeed("Time Speed", 1, -10, 10,.1)
UINumberField fxIndex("Animartrix - index", 0, 0, NUM_ANIMATIONS)
Animartrix animartrix(xyMap, POLAR_WAVES)
UIDescription description("Advanced layered and blended wave effects.")