Good news, 1 out of every 2 animations (roughly) is working

This commit is contained in:
Bradley Bickford 2025-09-18 18:31:47 -04:00
parent 1a19425592
commit 1ed3c99141
3 changed files with 53 additions and 16 deletions

View File

@ -2,6 +2,7 @@
#define SMARTMATRIXPHYSICALMATRIX_H
#ifdef CORE_TEENSY
#ifdef ENABLE_TEENSY_SMARTMATRIX
#include "SmartMatrix.h"
#include "LEDHAL2D.h"
@ -45,5 +46,6 @@ class SmartMatrixPhysicalMatrix : public LEDHAL2D {
SMLayerBackground<rgb24, 0>* layer;
};
#endif
#endif
#endif

View File

@ -9,31 +9,26 @@
; https://docs.platformio.org/page/projectconf.html
[platformio]
default_envs =
uno
teensy36
mega2560
default_envs =
esp32
[common]
[env:teensy36]
platform = teensy
framework = arduino
board = teensy36
framework = arduino
lib_deps =
fastled/FastLED@^3.7.0
pixelmatix/SmartMatrix@^4.0.3
fastled/FastLED@3.10.1
pfeerick/elapsedMillis@^1.0.6
adafruit/Adafruit GFX Library@^1.11.9
arduino-libraries/SD@^1.3.0
[env:uno]
platform = atmelavr
board = uno
framework = arduino
lib_deps =
fastled/FastLED@^3.7.0
fastled/FastLED@3.10.1
pfeerick/elapsedMillis@^1.0.6
adafruit/Adafruit GFX Library@^1.11.9
arduino-libraries/SD@^1.3.0
@ -43,7 +38,7 @@ platform = atmelavr
board = megaatmega2560
framework = arduino
lib_deps =
fastled/FastLED@^3.7.0
fastled/FastLED@3.10.1
pfeerick/elapsedMillis@^1.0.6
adafruit/Adafruit GFX Library@^1.11.9
arduino-libraries/SD@^1.3.0
@ -53,6 +48,6 @@ platform = espressif32
board = adafruit_feather_esp32s3_nopsram
framework = arduino
lib_deps =
fastled/FastLED@^3.7.0
fastled/FastLED@3.10.1
pfeerick/elapsedMillis@^1.0.6
adafruit/Adafruit GFX Library@^1.11.9

View File

@ -1,14 +1,24 @@
#include <Arduino.h>
#ifdef CORE_TEENSY
#ifdef ENABLE_TEENSY_SMARTMATRIX
#include "MatrixHardware_Teensy3_ShieldV1toV3.h"
#include "SmartMatrix.h"
#endif
#endif
#include "FastLED.h"
#include "LEDHAL.h"
#include "LEDHAL2D.h"
#include "MatrixAnimation.h"
#include "AlternateMatrix.h"
#include "CollisionMatrix.h"
#include "ColorRandomizerMatrix.h"
#include "CycleLightMatrix.h"
#include "FireworksMatrix.h"
#include "FluidColorMatrix.h"
#include "RicochetMatrix.h"
#include "CycloneMatrix.h"
#include "PlasmaMatrix.h"
#include "CLEDControllerPhysicalStrip.h"
#include "CLEDControllerPhysicalMatrix.h"
@ -17,6 +27,7 @@
#define NUMLEDS 1024
#ifdef CORE_TEENSY
#ifdef ENABLE_TEENSY_SMARTMATRIX
#define COLOR_DEPTH 24 // known working: 24, 48 - If the sketch uses type `rgb24` directly, COLOR_DEPTH must be 24
const uint8_t kMatrixWidth = 96; // known working: 32, 64, 96, 128
@ -31,26 +42,55 @@ const uint8_t kScrollingLayerOptions = (SM_SCROLLING_OPTIONS_NONE);
SMARTMATRIX_ALLOCATE_BUFFERS(matrix, kMatrixWidth, kMatrixHeight, kRefreshDepth, kDmaBufferRows, kPanelType, kMatrixOptions);
SMARTMATRIX_ALLOCATE_BACKGROUND_LAYER(backgroundLayer, kMatrixWidth, kMatrixHeight, COLOR_DEPTH, kBackgroundLayerOptions);
#endif
#endif
CRGB leds[NUMLEDS];
CRGB rainbow[] = {CRGB::Red, CRGB(255, 45, 0), CRGB::Yellow, CRGB::Green, CRGB::Blue, CRGB::Purple};
LEDHAL2D* hal2D;
MatrixAnimation* animation;
int animationCode = 8;
void setup() {
CLEDController* controller = &FastLED.addLeds<NEOPIXEL, 6>(leds, NUMLEDS);
controller->setCorrection(TypicalLEDStrip);
hal2D = new CLEDControllerPhysicalMatrix(controller, "Matrix", ArrangementType::HORIZONTALSCAN, 32, 32);
animation = new PlasmaMatrix(hal2D, "Plasma Matrix", 10);
if(animationCode == 0) {
animation = new PlasmaMatrix(hal2D, "Plasma Matrix", 10);
} else if(animationCode == 1) {
animation = new AlternateMatrix(hal2D, "Alternate Matrix", 125, rainbow, 6, AlternateType::HORIZONTAL_ALTERNATE);
} else if(animationCode == 2) {
animation = new CollisionMatrix(hal2D, "Collision Matrix", 125, CRGB(255, 45, 0), CRGB::Green, CollisionType::HORIZONTAL_COLLISION);
} else if(animationCode == 3) {
//Doesn't work, causing heap corruption
animation = new ColorRandomizerMatrix(hal2D, "Color Randomizer Matrix",
40, true, 6, rainbow, ColorRandomizerType::HORIZONTAL_COLORRANDOMIZER);
} else if(animationCode == 4) {
animation = new CycleLightMatrix(hal2D, "Cycle Light Matrix", 100, rainbow, 6, CycleLightType::HORIZONTAL_CYCLELIGHT);
} else if(animationCode == 5) {
//Doesn't work, unhandled exception?
animation = new FireworksMatrix(hal2D, "Fireworks Matrix", 40, rainbow, 6, 6, 15);
} else if(animationCode == 6) {
//Sort of works, mathematical issues exist when using anything other than full color resolution
animation = new FluidColorMatrix(hal2D, "Fluid Color Matrix", 20, FluidColorType::HORIZONTAL_FLUIDCOLOR, FluidColorResolution::QUATER_FLUIDCOLOR);
} else if(animationCode == 7) {
//Doesn't work, causing heap corruption
animation = new RicochetMatrix(hal2D, "Ricochet Matrix", 50, 16, rainbow, 6);
} else if(animationCode == 8) {
//It works, kinda? It doesn't look like the original version of the animation
animation = new CycloneMatrix(hal2D, "Cyclone Matrix", 100, 16, 16, 4, 16, 6, rainbow);
}
animation->enable();
}
void loop() {
animation->update();
//hal2D->show();
FastLED.delay(1);
hal2D->show();
}