Files
G.U.L.L.S/src/main.cpp

103 lines
4.0 KiB
C++

#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"
#include "SmartMatrixPhysicalMatrix.h"
#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
const uint8_t kMatrixHeight = 64; // known working: 16, 32, 48, 64
const uint8_t kRefreshDepth = 36; // known working: 24, 36, 48
const uint8_t kDmaBufferRows = 4; // known working: 2-4, use 2 to save memory, more to keep from dropping frames and automatically lowering refresh rate
const uint8_t kPanelType = SMARTMATRIX_HUB75_32ROW_MOD16SCAN; // use SMARTMATRIX_HUB75_16ROW_MOD8SCAN for common 16x32 panels
const uint8_t kMatrixOptions = SMARTMATRIX_OPTIONS_BOTTOM_TO_TOP_STACKING; // see http://docs.pixelmatix.com/SmartMatrix for options
const uint8_t kBackgroundLayerOptions = (SM_BACKGROUND_OPTIONS_NONE);
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 = 0;
void setup() {
Serial.begin(115200);
while(!Serial) {}
Serial.println(F("STARTUP!"));
CLEDController* controller = &FastLED.addLeds<NEOPIXEL, 6>(leds, NUMLEDS);
controller->setCorrection(TypicalLEDStrip);
hal2D = new CLEDControllerPhysicalMatrix(controller, "Matrix", ArrangementType::HORIZONTALSCAN, 32, 32);
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",
200, false, 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();
}