17#define ANIMARTRIX_INTERNAL
18#include "animartrix_detail.hpp"
20FASTLED_NAMESPACE_BEGIN
75 this->current_animation = which_animation;
79 void lazyInit()
override { this->mXyMap.convertToLookUpTable(); }
81 int fxNum()
const override {
return NUM_ANIMATIONS; }
82 void fxSet(
int fx)
override;
83 int fxGet()
const override {
return static_cast<int>(current_animation); }
84 const char *fxName(
int which)
const override {
85 return getAnimationName(which != -1 ?
static_cast<AnimartrixAnim
>(which) : current_animation);
87 void fxNext(
int fx = 1)
override { fxSet(fxGet() + fx); }
90 friend void AnimartrixLoop(
Animartrix &self, uint32_t now);
92 static const char *getAnimationName(AnimartrixAnim animation);
93 AnimartrixAnim prev_animation = NUM_ANIMATIONS;
96 AnimartrixAnim current_animation = RGB_BLOBS5;
99void AnimartrixLoop(
Animartrix &self, uint32_t now);
104const char *Animartrix::getAnimationName(AnimartrixAnim animation) {
117 return "POLAR_WAVES";
142 case DISTANCE_EXPERIMENT:
143 return "DISTANCE_EXPERIMENT";
145 return "CENTER_FIELD";
148 case CHASING_SPIRALS:
149 return "CHASING_SPIRALS";
151 return "ROTATING_BLOB";
154 case COMPLEX_KALEIDO:
155 return "COMPLEX_KALEIDO";
156 case COMPLEX_KALEIDO_2:
157 return "COMPLEX_KALEIDO_2";
158 case COMPLEX_KALEIDO_3:
159 return "COMPLEX_KALEIDO_3";
160 case COMPLEX_KALEIDO_4:
161 return "COMPLEX_KALEIDO_4";
162 case COMPLEX_KALEIDO_5:
163 return "COMPLEX_KALEIDO_5";
164 case COMPLEX_KALEIDO_6:
165 return "COMPLEX_KALEIDO_6";
168 case PARAMETRIC_WATER:
169 return "PARAMETRIC_WATER";
170 case MODULE_EXPERIMENT1:
171 return "MODULE_EXPERIMENT1";
172 case MODULE_EXPERIMENT2:
173 return "MODULE_EXPERIMENT2";
174 case MODULE_EXPERIMENT3:
175 return "MODULE_EXPERIMENT3";
176 case MODULE_EXPERIMENT4:
177 return "MODULE_EXPERIMENT4";
178 case MODULE_EXPERIMENT5:
179 return "MODULE_EXPERIMENT5";
180 case MODULE_EXPERIMENT6:
181 return "MODULE_EXPERIMENT6";
182 case MODULE_EXPERIMENT7:
183 return "MODULE_EXPERIMENT7";
184 case MODULE_EXPERIMENT8:
185 return "MODULE_EXPERIMENT8";
186 case MODULE_EXPERIMENT9:
187 return "MODULE_EXPERIMENT9";
188 case MODULE_EXPERIMENT10:
189 return "MODULE_EXPERIMENT10";
191 return "NUM_ANIMATIONS";
203 this->init(data->getWidth(), data->getWidth());
206 void setPixelColor(
int x,
int y,
CRGB pixel) {
207 data->leds[xyMap(x, y)] = pixel;
210 setPixelColor(x, y,
CRGB(pixel.red, pixel.green, pixel.blue));
213 uint16_t xyMap(uint16_t x, uint16_t y)
override {
214 return data->xyMap(x, y);
218 switch (data->current_animation) {
273 case DISTANCE_EXPERIMENT:
274 Distance_Experiment();
282 case CHASING_SPIRALS:
291 case COMPLEX_KALEIDO:
294 case COMPLEX_KALEIDO_2:
297 case COMPLEX_KALEIDO_3:
300 case COMPLEX_KALEIDO_4:
303 case COMPLEX_KALEIDO_5:
306 case COMPLEX_KALEIDO_6:
312 case PARAMETRIC_WATER:
315 case MODULE_EXPERIMENT1:
316 Module_Experiment1();
318 case MODULE_EXPERIMENT2:
319 Module_Experiment2();
321 case MODULE_EXPERIMENT3:
322 Module_Experiment3();
324 case MODULE_EXPERIMENT4:
325 Module_Experiment4();
327 case MODULE_EXPERIMENT5:
328 Module_Experiment5();
330 case MODULE_EXPERIMENT6:
331 Module_Experiment6();
333 case MODULE_EXPERIMENT7:
334 Module_Experiment7();
336 case MODULE_EXPERIMENT8:
337 Module_Experiment8();
339 case MODULE_EXPERIMENT9:
340 Module_Experiment9();
342 case MODULE_EXPERIMENT10:
343 Module_Experiment10();
351void Animartrix::fxSet(
int fx) {
356 fx = NUM_ANIMATIONS - 1;
359 fx = fx % NUM_ANIMATIONS;
360 current_animation =
static_cast<AnimartrixAnim
>(fx);
363void AnimartrixLoop(
Animartrix &self, uint32_t now) {
364 if (self.prev_animation != self.current_animation) {
367 self.impl->init(self.getWidth(), self.getHeight());
369 self.prev_animation = self.current_animation;
374 self.impl->setTime(now);
379 this->leds = ctx.leds;
380 AnimartrixLoop(*
this, ctx.now);
381 this->leds =
nullptr;
void draw(DrawContext context) override
Representation of an RGB pixel (Red, Green, Blue)