15#include "fl/scoped_ptr.h"
19#define ANIMARTRIX_INTERNAL
20#include "animartrix_detail.hpp"
24FASTLED_SMART_PTR(Animartrix);
69 MODULE_EXPERIMENT_SM1,
70 MODULE_EXPERIMENT_SM2,
71 MODULE_EXPERIMENT_SM3,
72 MODULE_EXPERIMENT_SM4,
73 MODULE_EXPERIMENT_SM5,
74 MODULE_EXPERIMENT_SM6,
75 MODULE_EXPERIMENT_SM8,
76 MODULE_EXPERIMENT_SM9,
77 MODULE_EXPERIMENT_SM10,
83class FastLEDANIMartRIX;
88 this->current_animation = which_animation;
89 mXyMap.convertToLookUpTable();
94 int fxNum()
const {
return NUM_ANIMATIONS; }
96 int fxGet()
const {
return static_cast<int>(current_animation); }
97 Str fxName()
const override {
100 void fxNext(
int fx = 1) { fxSet(fxGet() + fx); }
103 friend void AnimartrixLoop(
Animartrix &self, uint32_t now);
105 static const char *getAnimationName(AnimartrixAnim animation);
106 AnimartrixAnim prev_animation = NUM_ANIMATIONS;
108 CRGB *leds =
nullptr;
109 AnimartrixAnim current_animation = RGB_BLOBS5;
112void AnimartrixLoop(
Animartrix &self, uint32_t now);
132 this->init(data->getWidth(), data->getWidth());
135 void setPixelColor(
int x,
int y,
CRGB pixel) {
136 data->leds[xyMap(x, y)] = pixel;
139 setPixelColor(x, y,
CRGB(pixel.red, pixel.green, pixel.blue));
142 uint16_t xyMap(uint16_t x, uint16_t y)
override {
143 return data->xyMap(x, y);
149void Animartrix::fxSet(
int fx) {
154 fx = NUM_ANIMATIONS - 1;
157 fx = fx % NUM_ANIMATIONS;
158 current_animation =
static_cast<AnimartrixAnim
>(fx);
159 FASTLED_DBG(
"Setting animation to " << getAnimationName(current_animation));
162void AnimartrixLoop(Animartrix &self, uint32_t now) {
163 if (self.prev_animation != self.current_animation) {
166 self.impl->init(self.getWidth(), self.getHeight());
168 self.prev_animation = self.current_animation;
171 self.impl.reset(
new FastLEDANIMartRIX(&self));
173 self.impl->setTime(now);
177static const AnimartrixEntry ANIMATION_TABLE[] = {
178 {RGB_BLOBS5,
"RGB_BLOBS5", &FastLEDANIMartRIX::RGB_Blobs5},
179 {RGB_BLOBS4,
"RGB_BLOBS4", &FastLEDANIMartRIX::RGB_Blobs4},
180 {RGB_BLOBS3,
"RGB_BLOBS3", &FastLEDANIMartRIX::RGB_Blobs3},
181 {RGB_BLOBS2,
"RGB_BLOBS2", &FastLEDANIMartRIX::RGB_Blobs2},
182 {RGB_BLOBS,
"RGB_BLOBS", &FastLEDANIMartRIX::RGB_Blobs},
183 {POLAR_WAVES,
"POLAR_WAVES", &FastLEDANIMartRIX::Polar_Waves},
184 {SLOW_FADE,
"SLOW_FADE", &FastLEDANIMartRIX::Slow_Fade},
185 {ZOOM2,
"ZOOM2", &FastLEDANIMartRIX::Zoom2},
186 {ZOOM,
"ZOOM", &FastLEDANIMartRIX::Zoom},
187 {HOT_BLOB,
"HOT_BLOB", &FastLEDANIMartRIX::Hot_Blob},
188 {SPIRALUS2,
"SPIRALUS2", &FastLEDANIMartRIX::Spiralus2},
189 {SPIRALUS,
"SPIRALUS", &FastLEDANIMartRIX::Spiralus},
190 {YVES,
"YVES", &FastLEDANIMartRIX::Yves},
191 {SCALEDEMO1,
"SCALEDEMO1", &FastLEDANIMartRIX::Scaledemo1},
192 {LAVA1,
"LAVA1", &FastLEDANIMartRIX::Lava1},
193 {CALEIDO3,
"CALEIDO3", &FastLEDANIMartRIX::Caleido3},
194 {CALEIDO2,
"CALEIDO2", &FastLEDANIMartRIX::Caleido2},
195 {CALEIDO1,
"CALEIDO1", &FastLEDANIMartRIX::Caleido1},
196 {DISTANCE_EXPERIMENT,
"DISTANCE_EXPERIMENT", &FastLEDANIMartRIX::Distance_Experiment},
197 {CENTER_FIELD,
"CENTER_FIELD", &FastLEDANIMartRIX::Center_Field},
198 {WAVES,
"WAVES", &FastLEDANIMartRIX::Waves},
199 {CHASING_SPIRALS,
"CHASING_SPIRALS", &FastLEDANIMartRIX::Chasing_Spirals},
200 {ROTATING_BLOB,
"ROTATING_BLOB", &FastLEDANIMartRIX::Rotating_Blob},
201 {RINGS,
"RINGS", &FastLEDANIMartRIX::Rings},
202 {COMPLEX_KALEIDO,
"COMPLEX_KALEIDO", &FastLEDANIMartRIX::Complex_Kaleido},
203 {COMPLEX_KALEIDO_2,
"COMPLEX_KALEIDO_2", &FastLEDANIMartRIX::Complex_Kaleido_2},
204 {COMPLEX_KALEIDO_3,
"COMPLEX_KALEIDO_3", &FastLEDANIMartRIX::Complex_Kaleido_3},
205 {COMPLEX_KALEIDO_4,
"COMPLEX_KALEIDO_4", &FastLEDANIMartRIX::Complex_Kaleido_4},
206 {COMPLEX_KALEIDO_5,
"COMPLEX_KALEIDO_5", &FastLEDANIMartRIX::Complex_Kaleido_5},
207 {COMPLEX_KALEIDO_6,
"COMPLEX_KALEIDO_6", &FastLEDANIMartRIX::Complex_Kaleido_6},
208 {WATER,
"WATER", &FastLEDANIMartRIX::Water},
209 {PARAMETRIC_WATER,
"PARAMETRIC_WATER", &FastLEDANIMartRIX::Parametric_Water},
210 {MODULE_EXPERIMENT1,
"MODULE_EXPERIMENT1", &FastLEDANIMartRIX::Module_Experiment1},
211 {MODULE_EXPERIMENT2,
"MODULE_EXPERIMENT2", &FastLEDANIMartRIX::Module_Experiment2},
212 {MODULE_EXPERIMENT3,
"MODULE_EXPERIMENT3", &FastLEDANIMartRIX::Module_Experiment3},
213 {MODULE_EXPERIMENT4,
"MODULE_EXPERIMENT4", &FastLEDANIMartRIX::Module_Experiment4},
214 {MODULE_EXPERIMENT5,
"MODULE_EXPERIMENT5", &FastLEDANIMartRIX::Module_Experiment5},
215 {MODULE_EXPERIMENT6,
"MODULE_EXPERIMENT6", &FastLEDANIMartRIX::Module_Experiment6},
216 {MODULE_EXPERIMENT7,
"MODULE_EXPERIMENT7", &FastLEDANIMartRIX::Module_Experiment7},
217 {MODULE_EXPERIMENT8,
"MODULE_EXPERIMENT8", &FastLEDANIMartRIX::Module_Experiment8},
218 {MODULE_EXPERIMENT9,
"MODULE_EXPERIMENT9", &FastLEDANIMartRIX::Module_Experiment9},
219 {MODULE_EXPERIMENT10,
"MODULE_EXPERIMENT10", &FastLEDANIMartRIX::Module_Experiment10},
220 {MODULE_EXPERIMENT_SM1,
"MODULE_EXPERIMENT_SM1", &FastLEDANIMartRIX::SM1},
221 {MODULE_EXPERIMENT_SM2,
"MODULE_EXPERIMENT_SM2", &FastLEDANIMartRIX::SM2},
222 {MODULE_EXPERIMENT_SM3,
"MODULE_EXPERIMENT_SM3", &FastLEDANIMartRIX::SM3},
223 {MODULE_EXPERIMENT_SM4,
"MODULE_EXPERIMENT_SM4", &FastLEDANIMartRIX::SM4},
224 {MODULE_EXPERIMENT_SM5,
"MODULE_EXPERIMENT_SM5", &FastLEDANIMartRIX::SM5},
225 {MODULE_EXPERIMENT_SM6,
"MODULE_EXPERIMENT_SM6", &FastLEDANIMartRIX::SM6},
226 {MODULE_EXPERIMENT_SM8,
"MODULE_EXPERIMENT_SM8", &FastLEDANIMartRIX::SM8},
227 {MODULE_EXPERIMENT_SM9,
"MODULE_EXPERIMENT_SM9", &FastLEDANIMartRIX::SM9},
228 {MODULE_EXPERIMENT_SM10,
"MODULE_EXPERIMENT_SM10", &FastLEDANIMartRIX::SM10},
231void FastLEDANIMartRIX::loop() {
232 for (
const auto& entry : ANIMATION_TABLE) {
233 if (entry.anim == data->current_animation) {
234 (this->*entry.func)();
239 FASTLED_DBG(
"Animation not found for " <<
int(data->current_animation));
242const char* Animartrix::getAnimationName(AnimartrixAnim animation) {
243 for (
const auto& entry : ANIMATION_TABLE) {
244 if (entry.anim == animation) {
248 FASTLED_DBG(
"Animation not found for " <<
int(animation));
253 this->leds = ctx.leds;
254 AnimartrixLoop(*
this, ctx.now);
255 this->leds =
nullptr;
void draw(DrawContext context) override
Defines the red, green, and blue (RGB) pixel struct.
Implements the FastLED namespace macros.
Implements a simple red square effect for 2D LED grids.
Representation of an RGB pixel (Red, Green, Blue)
################################################## Details with the implementation of Animartrix