Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b335a63f61 | |||
| 54004e4e34 | |||
| c673e9a841 | |||
| 8f31919f62 | |||
| 02a0bfee2b |
16
README.md
16
README.md
@@ -1,5 +1,21 @@
|
|||||||
<img src="images/terrible logo.png" width="300" height="175"/><h1>Grand Unified LED Logic Software (G.U.L.L.S.)</h1>
|
<img src="images/terrible logo.png" width="300" height="175"/><h1>Grand Unified LED Logic Software (G.U.L.L.S.)</h1>
|
||||||
|
|
||||||
|
Tested
|
||||||
|
- Basic CLED Strip
|
||||||
|
- Basic CLED Matrix
|
||||||
|
- Basic Logical Matrix
|
||||||
|
- AlternateStrip
|
||||||
|
- AlternateMatrix
|
||||||
|
- CollisionStrip
|
||||||
|
- CollisionMatrix
|
||||||
|
- ColorRandomizerStrip (When used with ColorRandomizerMatrix, broken)
|
||||||
|
- ColorRanzomizerMatrix (When used with ColorRandomizerStrip, broken)
|
||||||
|
- CycleLightStrip
|
||||||
|
- CycleLightMatrix
|
||||||
|
- FluidColorMatrix
|
||||||
|
- RicochetMatrix (Broken)
|
||||||
|
|
||||||
|
|
||||||
*I need to write something here*
|
*I need to write something here*
|
||||||
|
|
||||||
##### LED Hardware Development Status
|
##### LED Hardware Development Status
|
||||||
|
|||||||
123
diagram.json
123
diagram.json
@@ -4,36 +4,125 @@
|
|||||||
"editor": "wokwi",
|
"editor": "wokwi",
|
||||||
"parts": [
|
"parts": [
|
||||||
{
|
{
|
||||||
"type": "board-xiao-esp32-s3",
|
"type": "wokwi-arduino-mega",
|
||||||
"id": "esp",
|
"id": "mega",
|
||||||
"top": 1000,
|
"top": 100,
|
||||||
"left": 13.78,
|
"left": 100.78,
|
||||||
"attrs": {
|
"attrs": {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "neopixels",
|
"id": "neopixels",
|
||||||
"type": "wokwi-neopixel-canvas",
|
"type": "wokwi-led-strip",
|
||||||
"top": 0,
|
"top": 0,
|
||||||
"left": 0,
|
"left": 0,
|
||||||
"attrs": {
|
"attrs": {
|
||||||
"rows": "32",
|
"pixels": "24"
|
||||||
"cols": "32",
|
|
||||||
"matrixBrightness": "10"
|
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "matrix",
|
||||||
|
"type": "wokwi-led-matrix",
|
||||||
|
"top": -200,
|
||||||
|
"left": 750,
|
||||||
|
"attrs": {
|
||||||
|
"rows": "6",
|
||||||
|
"cols": "6",
|
||||||
|
"layout": "serpentine",
|
||||||
|
"pixelShape": "circle"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "matrix2",
|
||||||
|
"type": "wokwi-led-matrix",
|
||||||
|
"top": -50,
|
||||||
|
"left": 750,
|
||||||
|
"attrs": {
|
||||||
|
"rows": "6",
|
||||||
|
"cols": "6",
|
||||||
|
"layout": "serpentine",
|
||||||
|
"pixelShape": "circle"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "matrix3",
|
||||||
|
"type": "wokwi-led-matrix",
|
||||||
|
"top": 100,
|
||||||
|
"left": 750,
|
||||||
|
"attrs": {
|
||||||
|
"rows": "6",
|
||||||
|
"cols": "6",
|
||||||
|
"layout": "serpentine",
|
||||||
|
"pixelShape": "circle"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "matrix4",
|
||||||
|
"type": "wokwi-led-matrix",
|
||||||
|
"top": 250,
|
||||||
|
"left": 750,
|
||||||
|
"attrs": {
|
||||||
|
"rows": "6",
|
||||||
|
"cols": "6",
|
||||||
|
"layout": "serpentine",
|
||||||
|
"pixelShape": "circle"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "matrix5",
|
||||||
|
"type": "wokwi-led-matrix",
|
||||||
|
"top": 400,
|
||||||
|
"left": 750,
|
||||||
|
"attrs": {
|
||||||
|
"rows": "6",
|
||||||
|
"cols": "6",
|
||||||
|
"layout": "serpentine",
|
||||||
|
"pixelShape": "circle"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "matrix6",
|
||||||
|
"type": "wokwi-led-matrix",
|
||||||
|
"top": 550,
|
||||||
|
"left": 750,
|
||||||
|
"attrs": {
|
||||||
|
"rows": "6",
|
||||||
|
"cols": "6",
|
||||||
|
"layout": "serpentine",
|
||||||
|
"pixelShape": "circle"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"connections": [
|
"connections": [
|
||||||
["esp32:TX0", "$serialMonitor:RX", "", []],
|
["mega:0", "$serialMonitor:TX", ""],
|
||||||
["esp32:RX0", "$serialMonitor:TX", "", []],
|
["mega:1", "$serialMonitor:RX", ""],
|
||||||
["esp:GND", "neopixels:VSS", "black"],
|
["mega:GND.2", "neopixels:VSS", "black"],
|
||||||
["esp:D5", "neopixels:DIN", "green"],
|
["mega:6", "neopixels:DIN", "green"],
|
||||||
["esp:5V", "neopixels:VDD", "red"]
|
["mega:5V", "neopixels:VDD", "red"],
|
||||||
|
["mega:7", "matrix:DIN", "yellow"],
|
||||||
|
["mega:5V", "matrix:VDD", "red"],
|
||||||
|
["mega:GND.3", "matrix:VSS", "black"],
|
||||||
|
["matrix:DOUT", "matrix2:DIN", "blue"],
|
||||||
|
["mega:5V", "matrix2:VDD", "red"],
|
||||||
|
["mega:GND.3", "matrix2:VSS", "black"],
|
||||||
|
["matrix2:DOUT", "matrix3:DIN", "blue"],
|
||||||
|
["mega:5V", "matrix3:VDD", "red"],
|
||||||
|
["mega:GND.3", "matrix3:VSS", "black"],
|
||||||
|
["matrix3:DOUT", "matrix4:DIN", "blue"],
|
||||||
|
["mega:5V", "matrix4:VDD", "red"],
|
||||||
|
["mega:GND.3", "matrix4:VSS", "black"],
|
||||||
|
["matrix4:DOUT", "matrix5:DIN", "blue"],
|
||||||
|
["mega:5V", "matrix5:VDD", "red"],
|
||||||
|
["mega:GND.3", "matrix5:VSS", "black"],
|
||||||
|
["matrix5:DOUT", "matrix6:DIN", "blue"],
|
||||||
|
["mega:5V", "matrix6:VDD", "red"],
|
||||||
|
["mega:GND.3", "matrix6:VSS", "black"]
|
||||||
],
|
],
|
||||||
|
"dependencies": {},
|
||||||
"serialMonitor": {
|
"serialMonitor": {
|
||||||
|
"collapse": false,
|
||||||
|
"convertEol": false,
|
||||||
"display": "always",
|
"display": "always",
|
||||||
"newline": "lf",
|
"newline": "lf"
|
||||||
"convertEol": false
|
}
|
||||||
},
|
|
||||||
"dependencies": {}
|
|
||||||
}
|
}
|
||||||
@@ -2,17 +2,11 @@
|
|||||||
#define CLEDCONTROLLERPHYSICALMATRIX_H
|
#define CLEDCONTROLLERPHYSICALMATRIX_H
|
||||||
|
|
||||||
#include "LEDHAL2D.h"
|
#include "LEDHAL2D.h"
|
||||||
|
#include "ILEDArrangement.h"
|
||||||
enum ArrangementType {
|
|
||||||
HORIZONTALSCAN,
|
|
||||||
HORIZONTALSERPENTINE,
|
|
||||||
COLUMNSCAN,
|
|
||||||
COLUMNSERPENTINE
|
|
||||||
};
|
|
||||||
|
|
||||||
class CLEDControllerPhysicalMatrix : public LEDHAL2D {
|
class CLEDControllerPhysicalMatrix : public LEDHAL2D {
|
||||||
public:
|
public:
|
||||||
CLEDControllerPhysicalMatrix(CLEDController* _controller, char* ledName, ArrangementType _arrangement,
|
CLEDControllerPhysicalMatrix(CLEDController* _controller, char* ledName, ILEDArrangement& _arrangement,
|
||||||
int16_t width, int16_t height): LEDHAL2D(width, height, ledName, true), controller(_controller), arrangement(_arrangement) {}
|
int16_t width, int16_t height): LEDHAL2D(width, height, ledName, true), controller(_controller), arrangement(_arrangement) {}
|
||||||
virtual ~CLEDControllerPhysicalMatrix() {}
|
virtual ~CLEDControllerPhysicalMatrix() {}
|
||||||
|
|
||||||
@@ -33,25 +27,7 @@ class CLEDControllerPhysicalMatrix : public LEDHAL2D {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int16_t XY(int16_t x, int16_t y) {
|
int16_t XY(int16_t x, int16_t y) {
|
||||||
if(arrangement == ArrangementType::HORIZONTALSCAN) {
|
return arrangement.XY(x, y, getWidth(), getHeight());
|
||||||
return getWidth() * y + x;
|
|
||||||
} else if(arrangement == ArrangementType::COLUMNSCAN) {
|
|
||||||
return getHeight() * x + y;
|
|
||||||
} else if(arrangement == ArrangementType::HORIZONTALSERPENTINE) {
|
|
||||||
if(y & 0x1) {
|
|
||||||
return y * getWidth() + (getWidth() - 1 - x);
|
|
||||||
} else {
|
|
||||||
return y * getWidth() + x;
|
|
||||||
}
|
|
||||||
} else if(arrangement == ArrangementType::COLUMNSERPENTINE) {
|
|
||||||
if(x & 0x1) {
|
|
||||||
return x * getHeight() + (getHeight() - 1 - y);
|
|
||||||
} else {
|
|
||||||
return x * getHeight() + y;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return 0; //How did you get here?
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t getNumLEDs() {
|
uint16_t getNumLEDs() {
|
||||||
@@ -66,7 +42,7 @@ class CLEDControllerPhysicalMatrix : public LEDHAL2D {
|
|||||||
private:
|
private:
|
||||||
CLEDController*
|
CLEDController*
|
||||||
controller;
|
controller;
|
||||||
ArrangementType
|
ILEDArrangement&
|
||||||
arrangement;
|
arrangement;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ class ColorRandomizerMatrix : public MatrixAnimation {
|
|||||||
uint8_t _numColors, CRGB* _colors, ColorRandomizerType _type) :
|
uint8_t _numColors, CRGB* _colors, ColorRandomizerType _type) :
|
||||||
MatrixAnimation(_matrix, _refName, _updateTime), numColors(_numColors),
|
MatrixAnimation(_matrix, _refName, _updateTime), numColors(_numColors),
|
||||||
colors(new CRGB[_numColors]), fade(_fade), colorRandomizerInt(0),
|
colors(new CRGB[_numColors]), fade(_fade), colorRandomizerInt(0),
|
||||||
scale(DEFAULT_MATRIX_FADER) {
|
scale(DEFAULT_MATRIX_FADER), type(_type) {
|
||||||
for(uint8_t i = 0; i < _numColors; i++) {
|
for(uint8_t i = 0; i < _numColors; i++) {
|
||||||
colors[i] = _colors[i];
|
colors[i] = _colors[i];
|
||||||
}
|
}
|
||||||
@@ -38,8 +38,6 @@ class ColorRandomizerMatrix : public MatrixAnimation {
|
|||||||
} else {
|
} else {
|
||||||
fadingValues = new CRGB[matrix->getWidth()];
|
fadingValues = new CRGB[matrix->getWidth()];
|
||||||
}
|
}
|
||||||
|
|
||||||
Serial.println("Initialize is ok");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void execute();
|
void execute();
|
||||||
|
|||||||
@@ -23,9 +23,9 @@ class CycloneHelper {
|
|||||||
|
|
||||||
for(uint8_t i = 0; i < numberOfTails; i++) {
|
for(uint8_t i = 0; i < numberOfTails; i++) {
|
||||||
tailColors[i] = CRGB(
|
tailColors[i] = CRGB(
|
||||||
min(round(redScaler * (i + 1)), (float)color.red),
|
min(round(redScaler * (i + 1)), color.red),
|
||||||
min(round(greenScaler * (i + 1)), (float)color.green),
|
min(round(greenScaler * (i + 1)), color.green),
|
||||||
min(round(blueScaler * (i + 1)), (float)color.blue)
|
min(round(blueScaler * (i + 1)), color.blue)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
15
include/ILEDArrangement.h
Normal file
15
include/ILEDArrangement.h
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
#ifndef ILEDARRANGEMENT_H
|
||||||
|
#define ILEDARRANGEMENT_H
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
|
||||||
|
// Interface is not pure virtual
|
||||||
|
class ILEDArrangement {
|
||||||
|
public:
|
||||||
|
ILEDArrangement() {}
|
||||||
|
virtual ~ILEDArrangement() {}
|
||||||
|
|
||||||
|
virtual int16_t XY(int16_t x, int16_t y, int16_t width, int16_t height) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -21,7 +21,6 @@ class LEDHAL {
|
|||||||
|
|
||||||
virtual void requestShow() { showRequested = true; }
|
virtual void requestShow() { showRequested = true; }
|
||||||
|
|
||||||
//TODO UnifiedColor should have constants
|
|
||||||
virtual void clearLEDs() {
|
virtual void clearLEDs() {
|
||||||
for(uint16_t i = 0; i < getNumLEDs(); i++) {
|
for(uint16_t i = 0; i < getNumLEDs(); i++) {
|
||||||
setColor(i, CRGB(0, 0, 0));
|
setColor(i, CRGB(0, 0, 0));
|
||||||
|
|||||||
56
include/Manager.h
Normal file
56
include/Manager.h
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
#ifndef MANAGER_H
|
||||||
|
#define MANAGER_H
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
#include <LinkedList.h>
|
||||||
|
#include <LEDHAL.h>
|
||||||
|
#include <AnimationBase.h>
|
||||||
|
|
||||||
|
class Manager {
|
||||||
|
public:
|
||||||
|
Manager() {}
|
||||||
|
virtual ~Manager() {} // TODO Cleanup linked lists?
|
||||||
|
|
||||||
|
void addLEDs(LEDHAL* hal) {
|
||||||
|
// TODO Duplicate name checks
|
||||||
|
|
||||||
|
ledHALs.add(hal);
|
||||||
|
}
|
||||||
|
|
||||||
|
LEDHAL* removeLEDsByName(char* name) {
|
||||||
|
for(uint16_t i = 0; i < ledHALs.size(); i++) {
|
||||||
|
if(strcmp(ledHALs.get(i)->getLEDName(), name) == 0) {
|
||||||
|
return ledHALs.remove(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void addAnimation(AnimationBase* animation) {
|
||||||
|
// TODO Duplicate name checks
|
||||||
|
|
||||||
|
animations.add(animation);
|
||||||
|
}
|
||||||
|
|
||||||
|
AnimationBase* removeAnimationByName(char* name) {
|
||||||
|
for(uint16_t i = 0; i < animations.size(); i++) {
|
||||||
|
return animations.remove(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void update() {
|
||||||
|
for(uint16_t i = 0; i < animations.size(); i++) {
|
||||||
|
animations.get(i)->update();
|
||||||
|
}
|
||||||
|
|
||||||
|
for(uint16_t i = 0; i < ledHALs.size(); i++) {
|
||||||
|
ledHALs.get(i)->show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
LinkedList<LEDHAL*>
|
||||||
|
ledHALs;
|
||||||
|
LinkedList<AnimationBase*>
|
||||||
|
animations;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -6,11 +6,38 @@
|
|||||||
|
|
||||||
class PlasmaMatrix : public MatrixAnimation {
|
class PlasmaMatrix : public MatrixAnimation {
|
||||||
public:
|
public:
|
||||||
PlasmaMatrix(LEDHAL2D* _matrix, char* _refName, long _updateTime);
|
PlasmaMatrix(LEDHAL2D* _matrix, char* _refName, long _updateTime) :
|
||||||
|
MatrixAnimation(_matrix, _refName, _updateTime), paletteShift(0), palette(new CRGB[256]) {
|
||||||
|
plasma = new uint8_t*[matrix->getWidth()];
|
||||||
|
|
||||||
virtual ~PlasmaMatrix();
|
for(uint16_t i = 0; i < matrix->getWidth(); i++) {
|
||||||
|
plasma[i] = new uint8_t[matrix->getHeight()];
|
||||||
|
}
|
||||||
|
|
||||||
void initialize();
|
for(uint16_t x = 0; x < matrix->getWidth(); x++) {
|
||||||
|
for(uint16_t y = 0; y < matrix->getHeight(); y++) {
|
||||||
|
plasma[x][y] = (uint8_t) ((128.0 + (128 * sinf(x / 8.0)) + 128 + (128.0 * sinf(y / 8.0))) / 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for(uint16_t i = 0; i < 256; i++) {
|
||||||
|
palette[i] = CRGB(CHSV(i, 255, 255));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~PlasmaMatrix() {
|
||||||
|
delete[] palette;
|
||||||
|
|
||||||
|
for(uint16_t i = 0; i < matrix->getWidth(); i++) {
|
||||||
|
delete[] plasma[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
delete[] plasma;
|
||||||
|
}
|
||||||
|
|
||||||
|
void initialize() {
|
||||||
|
paletteShift = 0;
|
||||||
|
}
|
||||||
|
|
||||||
void execute();
|
void execute();
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ class RicochetHelper {
|
|||||||
RicochetHelper() {}
|
RicochetHelper() {}
|
||||||
RicochetHelper(int16_t _startPosX, int16_t _startPosY, int16_t _width, int16_t _height,
|
RicochetHelper(int16_t _startPosX, int16_t _startPosY, int16_t _width, int16_t _height,
|
||||||
CRGB _color) : currentX(_startPosX), currentY(_startPosY), width(_width),
|
CRGB _color) : currentX(_startPosX), currentY(_startPosY), width(_width),
|
||||||
height(_height), xDir(random(0, 101) > 51 ? -1 : 1), yDir(random(0, 100) > 51 ? -1 : 1) {}
|
height(_height), xDir(random(0, 101) > 51 ? -1 : 1), yDir(random(0, 100) > 51 ? -1 : 1),
|
||||||
|
color(_color) {}
|
||||||
|
|
||||||
int16_t getCurrentXPos() { return currentX; }
|
int16_t getCurrentXPos() { return currentX; }
|
||||||
int16_t getCurrentYPos() { return currentY; }
|
int16_t getCurrentYPos() { return currentY; }
|
||||||
|
|||||||
24
include/ScanArrangement.h
Normal file
24
include/ScanArrangement.h
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
#ifndef SCANARRANGEMENT_H
|
||||||
|
#define SCANARRANGEMENT_H
|
||||||
|
|
||||||
|
#include "ILEDArrangement.h"
|
||||||
|
|
||||||
|
class ScanArrangement : public ILEDArrangement {
|
||||||
|
public:
|
||||||
|
ScanArrangement(bool _isColumnScan) : isColumnScan(_isColumnScan) {}
|
||||||
|
virtual ~ScanArrangement() {}
|
||||||
|
|
||||||
|
int16_t XY(int16_t x, int16_t y, int16_t width, int16_t height) {
|
||||||
|
if(isColumnScan) {
|
||||||
|
return height * x + y;
|
||||||
|
} else {
|
||||||
|
return width * y + x;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool
|
||||||
|
isColumnScan;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
31
include/SerpentineArrangement.h
Normal file
31
include/SerpentineArrangement.h
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
#ifndef SERPENTINEARRANGEMENT_H
|
||||||
|
#define SERPENTINEARRANGEMENT_H
|
||||||
|
|
||||||
|
#include "ILEDArrangement.h"
|
||||||
|
|
||||||
|
class SerpentineArrangement : public ILEDArrangement {
|
||||||
|
public:
|
||||||
|
SerpentineArrangement(bool _isColumnSerpentine) : isColumnSerpentine(_isColumnSerpentine) {}
|
||||||
|
virtual ~SerpentineArrangement() {}
|
||||||
|
|
||||||
|
int16_t XY(int16_t x, int16_t y, int16_t width, int16_t height) {
|
||||||
|
if(isColumnSerpentine) {
|
||||||
|
if(x & 0x1) {
|
||||||
|
return x * height + (height - 1 - y);
|
||||||
|
} else {
|
||||||
|
return x * height + y;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if(y & 0x1) {
|
||||||
|
return y * width + (width - 1 - x);
|
||||||
|
} else {
|
||||||
|
return y * width + x;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
bool
|
||||||
|
isColumnSerpentine;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -1,9 +1,6 @@
|
|||||||
#ifndef SMARTMATRIXPHYSICALMATRIX_H
|
#ifndef SMARTMATRIXPHYSICALMATRIX_H
|
||||||
#define SMARTMATRIXPHYSICALMATRIX_H
|
#define SMARTMATRIXPHYSICALMATRIX_H
|
||||||
|
|
||||||
#ifdef CORE_TEENSY
|
|
||||||
#ifdef ENABLE_TEENSY_SMARTMATRIX
|
|
||||||
|
|
||||||
#include "SmartMatrix.h"
|
#include "SmartMatrix.h"
|
||||||
#include "LEDHAL2D.h"
|
#include "LEDHAL2D.h"
|
||||||
|
|
||||||
@@ -46,6 +43,4 @@ class SmartMatrixPhysicalMatrix : public LEDHAL2D {
|
|||||||
SMLayerBackground<rgb24, 0>* layer;
|
SMLayerBackground<rgb24, 0>* layer;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
@@ -10,7 +10,6 @@ class StreamEvent
|
|||||||
handled = false;
|
handled = false;
|
||||||
|
|
||||||
code = _readFrom->read();
|
code = _readFrom->read();
|
||||||
subCode = _readFrom->read();
|
|
||||||
flags = _readFrom->read();
|
flags = _readFrom->read();
|
||||||
|
|
||||||
if (flags & 0x01 == 1) {
|
if (flags & 0x01 == 1) {
|
||||||
@@ -33,8 +32,6 @@ class StreamEvent
|
|||||||
|
|
||||||
uint8_t getCode() { return code; }
|
uint8_t getCode() { return code; }
|
||||||
|
|
||||||
uint8_t getSubCode() { return subCode; }
|
|
||||||
|
|
||||||
uint16_t getPayloadSize() { return payloadSize; }
|
uint16_t getPayloadSize() { return payloadSize; }
|
||||||
|
|
||||||
byte* getPayload() { return payload; }
|
byte* getPayload() { return payload; }
|
||||||
@@ -43,7 +40,7 @@ class StreamEvent
|
|||||||
bool isResponse() { return flags & 0x02 == 2; }
|
bool isResponse() { return flags & 0x02 == 2; }
|
||||||
bool isDescribeRequest() { return flags & 0x04 == 4; }
|
bool isDescribeRequest() { return flags & 0x04 == 4; }
|
||||||
|
|
||||||
~StreamEvent() { delete[] payload; }
|
virtual ~StreamEvent() { delete[] payload; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
byte*
|
byte*
|
||||||
@@ -52,7 +49,6 @@ class StreamEvent
|
|||||||
payloadSize;
|
payloadSize;
|
||||||
uint8_t
|
uint8_t
|
||||||
code,
|
code,
|
||||||
subCode,
|
|
||||||
flags;
|
flags;
|
||||||
bool
|
bool
|
||||||
handled;
|
handled;
|
||||||
|
|||||||
18
include/TerribleMap.h
Normal file
18
include/TerribleMap.h
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
#ifndef TERRIBLEMAP_H
|
||||||
|
#define TERRIBLEMAP_H
|
||||||
|
|
||||||
|
#include <LinkedList.h>
|
||||||
|
|
||||||
|
template <typename K, typename V>
|
||||||
|
struct Entry {
|
||||||
|
K key;
|
||||||
|
V value;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename K, typename V>
|
||||||
|
class TerribleMap {
|
||||||
|
private:
|
||||||
|
LinkedList<Entry<K,V>> mapList;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
46
include/TiledSerpentineArrangement.h
Normal file
46
include/TiledSerpentineArrangement.h
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
#ifndef TILEDSERPENTINEARRANGEMENT_H
|
||||||
|
#define TILEDSERPENTINEARRANGEMENT_H
|
||||||
|
|
||||||
|
#include "ILEDArrangement.h"
|
||||||
|
|
||||||
|
class TiledSerpentineArrangement : public ILEDArrangement {
|
||||||
|
public:
|
||||||
|
TiledSerpentineArrangement(bool _isColumnSerpentine, bool _isVerticallyTiled,
|
||||||
|
int16_t _tileWidth, int16_t _tileHeight) : isColumnSerpentine(_isColumnSerpentine),
|
||||||
|
isVerticallyTiled(_isVerticallyTiled), tileWidth(_tileWidth), tileHeight(_tileHeight) {}
|
||||||
|
virtual ~TiledSerpentineArrangement() {}
|
||||||
|
|
||||||
|
int16_t XY(int16_t x, int16_t y, int16_t width, int16_t height) {
|
||||||
|
int16_t tileNumber = isVerticallyTiled ? y / tileHeight : x / tileHeight;
|
||||||
|
|
||||||
|
int16_t modX = x % tileWidth;
|
||||||
|
int16_t modY = y % tileHeight;
|
||||||
|
|
||||||
|
int16_t tilePosition = 0;
|
||||||
|
|
||||||
|
if(isColumnSerpentine) {
|
||||||
|
if (x & 0x1) {
|
||||||
|
tilePosition = modX * tileHeight + (tileHeight - 1 - modY);
|
||||||
|
} else {
|
||||||
|
tilePosition = modX * tileHeight + modY;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (y & 0x1) {
|
||||||
|
tilePosition = modY * tileWidth + (tileWidth - 1 - modX);
|
||||||
|
} else {
|
||||||
|
tilePosition = modY * tileWidth + modX;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return tileWidth * tileHeight * tileNumber + tilePosition;
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
bool
|
||||||
|
isColumnSerpentine,
|
||||||
|
isVerticallyTiled;
|
||||||
|
int16_t
|
||||||
|
tileWidth,
|
||||||
|
tileHeight;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -9,19 +9,7 @@
|
|||||||
; https://docs.platformio.org/page/projectconf.html
|
; https://docs.platformio.org/page/projectconf.html
|
||||||
|
|
||||||
[platformio]
|
[platformio]
|
||||||
default_envs =
|
default_envs = mega
|
||||||
esp32
|
|
||||||
|
|
||||||
[common]
|
|
||||||
|
|
||||||
[env:teensy36]
|
|
||||||
platform = teensy
|
|
||||||
board = teensy36
|
|
||||||
framework = arduino
|
|
||||||
lib_deps =
|
|
||||||
fastled/FastLED@3.10.1
|
|
||||||
pfeerick/elapsedMillis@^1.0.6
|
|
||||||
adafruit/Adafruit GFX Library@^1.11.9
|
|
||||||
|
|
||||||
[env:uno]
|
[env:uno]
|
||||||
platform = atmelavr
|
platform = atmelavr
|
||||||
@@ -32,8 +20,10 @@ lib_deps =
|
|||||||
pfeerick/elapsedMillis@^1.0.6
|
pfeerick/elapsedMillis@^1.0.6
|
||||||
adafruit/Adafruit GFX Library@^1.11.9
|
adafruit/Adafruit GFX Library@^1.11.9
|
||||||
arduino-libraries/SD@^1.3.0
|
arduino-libraries/SD@^1.3.0
|
||||||
|
apechinsky/MemoryFree@^0.3.0
|
||||||
|
ivanseidel/LinkedList@0.0.0-alpha+sha.dac3874d28
|
||||||
|
|
||||||
[env:mega2560]
|
[env:mega]
|
||||||
platform = atmelavr
|
platform = atmelavr
|
||||||
board = megaatmega2560
|
board = megaatmega2560
|
||||||
framework = arduino
|
framework = arduino
|
||||||
@@ -42,12 +32,19 @@ lib_deps =
|
|||||||
pfeerick/elapsedMillis@^1.0.6
|
pfeerick/elapsedMillis@^1.0.6
|
||||||
adafruit/Adafruit GFX Library@^1.11.9
|
adafruit/Adafruit GFX Library@^1.11.9
|
||||||
arduino-libraries/SD@^1.3.0
|
arduino-libraries/SD@^1.3.0
|
||||||
|
apechinsky/MemoryFree@^0.3.0
|
||||||
|
ivanseidel/LinkedList@0.0.0-alpha+sha.dac3874d28
|
||||||
|
|
||||||
[env:esp32]
|
[common]
|
||||||
platform = espressif32
|
|
||||||
board = adafruit_feather_esp32s3_nopsram
|
[env:teensy36]
|
||||||
|
platform = teensy
|
||||||
framework = arduino
|
framework = arduino
|
||||||
|
board = teensy36
|
||||||
lib_deps =
|
lib_deps =
|
||||||
fastled/FastLED@3.10.1
|
fastled/FastLED@^3.7.0
|
||||||
|
pixelmatix/SmartMatrix@^4.0.3
|
||||||
pfeerick/elapsedMillis@^1.0.6
|
pfeerick/elapsedMillis@^1.0.6
|
||||||
adafruit/Adafruit GFX Library@^1.11.9
|
adafruit/Adafruit GFX Library@^1.11.9
|
||||||
|
apechinsky/MemoryFree@^0.3.0
|
||||||
|
ivanseidel/LinkedList@0.0.0-alpha+sha.dac3874d28
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
#include "ColorRandomizerMatrix.h"
|
#include "ColorRandomizerMatrix.h"
|
||||||
|
|
||||||
void ColorRandomizerMatrix::execute() {
|
void ColorRandomizerMatrix::execute() {
|
||||||
|
Serial.println("In Execute");
|
||||||
if(fade && isFading) {
|
if(fade && isFading) {
|
||||||
CRGB color;
|
CRGB color;
|
||||||
|
|
||||||
if(colorRandomizerInt == 0) {
|
if(colorRandomizerInt == 0) {
|
||||||
for(uint16_t i = 0; i < type == ColorRandomizerType::HORIZONTAL_COLORRANDOMIZER ? matrix->getHeight() : matrix->getWidth(); i++) {
|
for(uint16_t i = 0; i < (type == ColorRandomizerType::HORIZONTAL_COLORRANDOMIZER ? matrix->getHeight() : matrix->getWidth()); i++) {
|
||||||
if(type == ColorRandomizerType::HORIZONTAL_COLORRANDOMIZER) {
|
if(type == ColorRandomizerType::HORIZONTAL_COLORRANDOMIZER) {
|
||||||
color = matrix->getColor(0, i);
|
color = matrix->getColor(0, i);
|
||||||
} else {
|
} else {
|
||||||
@@ -19,7 +20,7 @@ void ColorRandomizerMatrix::execute() {
|
|||||||
|
|
||||||
colorRandomizerInt++;
|
colorRandomizerInt++;
|
||||||
} else if(colorRandomizerInt > 0 && colorRandomizerInt < scale + 1) {
|
} else if(colorRandomizerInt > 0 && colorRandomizerInt < scale + 1) {
|
||||||
for(uint16_t i = 0; i < type == ColorRandomizerType::HORIZONTAL_COLORRANDOMIZER ? matrix->getHeight() : matrix->getWidth(); i++) {
|
for(uint16_t i = 0; i < (type == ColorRandomizerType::HORIZONTAL_COLORRANDOMIZER ? matrix->getHeight() : matrix->getWidth()); i++) {
|
||||||
if(type == ColorRandomizerType::HORIZONTAL_COLORRANDOMIZER) {
|
if(type == ColorRandomizerType::HORIZONTAL_COLORRANDOMIZER) {
|
||||||
matrix->drawFastHLine(0, i, matrix->getWidth(), matrix->getColor(0, i) - fadingValues[i]);
|
matrix->drawFastHLine(0, i, matrix->getWidth(), matrix->getColor(0, i) - fadingValues[i]);
|
||||||
} else {
|
} else {
|
||||||
@@ -33,14 +34,17 @@ void ColorRandomizerMatrix::execute() {
|
|||||||
isFading = false;
|
isFading = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Serial.println("Setup Colors");
|
||||||
uint8_t rand;
|
uint8_t rand;
|
||||||
|
|
||||||
for(uint16_t i = 0; i < type == ColorRandomizerType::HORIZONTAL_COLORRANDOMIZER ? matrix->getHeight() : matrix->getWidth(); i++) {
|
for(uint16_t i = 0; i < (type == ColorRandomizerType::HORIZONTAL_COLORRANDOMIZER ? matrix->getHeight() : matrix->getWidth()); i++) {
|
||||||
rand = random(0, numColors);
|
rand = random(0, numColors);
|
||||||
|
|
||||||
if(type == ColorRandomizerType::HORIZONTAL_COLORRANDOMIZER) {
|
if(type == ColorRandomizerType::HORIZONTAL_COLORRANDOMIZER) {
|
||||||
|
Serial.println("Draw Horizontal");
|
||||||
matrix->drawFastHLine(0, i, matrix->getWidth(), colors[rand]);
|
matrix->drawFastHLine(0, i, matrix->getWidth(), colors[rand]);
|
||||||
} else {
|
} else {
|
||||||
|
Serial.println("Draw Vertical");
|
||||||
matrix->drawFastVLine(i, 0, matrix->getHeight(), colors[rand]);
|
matrix->drawFastVLine(i, 0, matrix->getHeight(), colors[rand]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,9 +8,9 @@ void ColorRandomizerStrip::execute() {
|
|||||||
for(uint16_t i = 0; i < strip->getNumLEDs(); i++) {
|
for(uint16_t i = 0; i < strip->getNumLEDs(); i++) {
|
||||||
color = strip->getColor(i);
|
color = strip->getColor(i);
|
||||||
|
|
||||||
fadingValues[i].red = (ceil((float)color.red/scale));
|
fadingValues[i].red = (uint8_t)(ceil((float)color.red/scale));
|
||||||
fadingValues[i].green = (ceil((float)color.green/scale));
|
fadingValues[i].green = (uint8_t)(ceil((float)color.green/scale));
|
||||||
fadingValues[i].blue = (ceil((float)color.blue/scale));
|
fadingValues[i].blue = (uint8_t)(ceil((float)color.blue/scale));
|
||||||
}
|
}
|
||||||
|
|
||||||
colorRandomizerInt++;
|
colorRandomizerInt++;
|
||||||
|
|||||||
@@ -1,38 +1,5 @@
|
|||||||
#include "PlasmaMatrix.h"
|
#include "PlasmaMatrix.h"
|
||||||
|
|
||||||
PlasmaMatrix::PlasmaMatrix(LEDHAL2D* _matrix, char* _refName, long _updateTime):
|
|
||||||
MatrixAnimation(_matrix, _refName, _updateTime), paletteShift(0), palette(new CRGB[256]) {
|
|
||||||
plasma = new uint8_t*[matrix->getWidth()];
|
|
||||||
|
|
||||||
for(uint16_t i = 0; i < matrix->getWidth(); i++) {
|
|
||||||
plasma[i] = new uint8_t[matrix->getHeight()];
|
|
||||||
}
|
|
||||||
|
|
||||||
for(uint16_t x = 0; x < matrix->getWidth(); x++) {
|
|
||||||
for(uint16_t y = 0; y < matrix->getHeight(); y++) {
|
|
||||||
plasma[x][y] = (uint8_t) ((128.0 + (128 * sinf(x / 8.0)) + 128 + (128.0 * sinf(y / 8.0))) / 2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for(uint16_t i = 0; i < 256; i++) {
|
|
||||||
palette[i] = CRGB(CHSV(i, 255, 255));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
PlasmaMatrix::~PlasmaMatrix() {
|
|
||||||
delete[] palette;
|
|
||||||
|
|
||||||
for(uint16_t i = 0; i < matrix->getWidth(); i++) {
|
|
||||||
delete[] plasma[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
delete[] plasma;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PlasmaMatrix::initialize() {
|
|
||||||
paletteShift = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PlasmaMatrix::execute() {
|
void PlasmaMatrix::execute() {
|
||||||
for(uint16_t x = 0; x < matrix->getWidth(); x++) {
|
for(uint16_t x = 0; x < matrix->getWidth(); x++) {
|
||||||
for(uint16_t y = 0; y < matrix->getHeight(); y++) {
|
for(uint16_t y = 0; y < matrix->getHeight(); y++) {
|
||||||
@@ -42,7 +9,5 @@ void PlasmaMatrix::execute() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
paletteShift++;
|
|
||||||
|
|
||||||
matrix->requestShow();
|
matrix->requestShow();
|
||||||
}
|
}
|
||||||
@@ -9,18 +9,37 @@ void RicochetMatrix::initialize() {
|
|||||||
randomSeed(random(0, 10000000));
|
randomSeed(random(0, 10000000));
|
||||||
balls[i] = new RicochetHelper(random(0, matrix->getWidth()), random(0, matrix->getHeight()),
|
balls[i] = new RicochetHelper(random(0, matrix->getWidth()), random(0, matrix->getHeight()),
|
||||||
matrix->getWidth(), matrix->getHeight(), colors[random(0, numColors)]);
|
matrix->getWidth(), matrix->getHeight(), colors[random(0, numColors)]);
|
||||||
|
|
||||||
|
Serial.print("Ball ");
|
||||||
|
Serial.println(i);
|
||||||
|
Serial.print("X ");
|
||||||
|
Serial.println(balls[i]->getCurrentXPos());
|
||||||
|
Serial.print("Y ");
|
||||||
|
Serial.println(balls[i]->getCurrentYPos());
|
||||||
|
Serial.print("CR ");
|
||||||
|
Serial.println(balls[i]->getCurrentColor().red);
|
||||||
|
Serial.print("CG ");
|
||||||
|
Serial.println(balls[i]->getCurrentColor().green);
|
||||||
|
Serial.print("CB ");
|
||||||
|
Serial.println(balls[i]->getCurrentColor().blue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RicochetMatrix::execute() {
|
void RicochetMatrix::execute() {
|
||||||
|
Serial.println("Pre Clear");
|
||||||
matrix->clearLEDs();
|
matrix->clearLEDs();
|
||||||
|
Serial.println("Post Clear");
|
||||||
|
|
||||||
|
Serial.println("Positional Updates");
|
||||||
for(uint16_t i = 0; i < numBalls; i++) {
|
for(uint16_t i = 0; i < numBalls; i++) {
|
||||||
balls[i]->updatePositions();
|
balls[i]->updatePositions();
|
||||||
|
|
||||||
matrix->drawPixel(balls[i]->getCurrentXPos(), balls[i]->getCurrentYPos(),
|
matrix->drawPixel(balls[i]->getCurrentXPos(), balls[i]->getCurrentYPos(),
|
||||||
balls[i]->getCurrentColor());
|
balls[i]->getCurrentColor());
|
||||||
}
|
}
|
||||||
|
Serial.println("Post Positional Updates");
|
||||||
|
|
||||||
|
Serial.println("Pre Request Show");
|
||||||
matrix->requestShow();
|
matrix->requestShow();
|
||||||
|
Serial.println("Post Request Show");
|
||||||
}
|
}
|
||||||
195
src/main.cpp
195
src/main.cpp
@@ -1,102 +1,143 @@
|
|||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
#ifdef CORE_TEENSY
|
|
||||||
#ifdef ENABLE_TEENSY_SMARTMATRIX
|
|
||||||
#include "MatrixHardware_Teensy3_ShieldV1toV3.h"
|
|
||||||
#include "SmartMatrix.h"
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "FastLED.h"
|
#include "FastLED.h"
|
||||||
#include "LEDHAL.h"
|
#include "LEDHAL.h"
|
||||||
#include "LEDHAL2D.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 "CLEDControllerPhysicalStrip.h"
|
||||||
#include "CLEDControllerPhysicalMatrix.h"
|
#include "CLEDControllerPhysicalMatrix.h"
|
||||||
#include "SmartMatrixPhysicalMatrix.h"
|
#include "SerpentineArrangement.h"
|
||||||
|
#include "TiledSerpentineArrangement.h"
|
||||||
#define NUMLEDS 1024
|
#include "MemoryFree.h"
|
||||||
|
#include "elapsedMillis.h"
|
||||||
#ifdef CORE_TEENSY
|
#include "LogicalMatrix.h"
|
||||||
#ifdef ENABLE_TEENSY_SMARTMATRIX
|
#include "AlternateStrip.h"
|
||||||
#define COLOR_DEPTH 24 // known working: 24, 48 - If the sketch uses type `rgb24` directly, COLOR_DEPTH must be 24
|
#include "AnimationBase.h"
|
||||||
|
#include "AlternateMatrix.h"
|
||||||
const uint8_t kMatrixWidth = 96; // known working: 32, 64, 96, 128
|
#include "CollisionStrip.h"
|
||||||
const uint8_t kMatrixHeight = 64; // known working: 16, 32, 48, 64
|
#include "CollisionMatrix.h"
|
||||||
const uint8_t kRefreshDepth = 36; // known working: 24, 36, 48
|
#include "ColorRandomizerMatrix.h"
|
||||||
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
|
#include "ColorRandomizerStrip.h"
|
||||||
const uint8_t kPanelType = SMARTMATRIX_HUB75_32ROW_MOD16SCAN; // use SMARTMATRIX_HUB75_16ROW_MOD8SCAN for common 16x32 panels
|
#include "CycleLightStrip.h"
|
||||||
const uint8_t kMatrixOptions = SMARTMATRIX_OPTIONS_BOTTOM_TO_TOP_STACKING; // see http://docs.pixelmatix.com/SmartMatrix for options
|
#include "CycleLightMatrix.h"
|
||||||
const uint8_t kBackgroundLayerOptions = (SM_BACKGROUND_OPTIONS_NONE);
|
#include "FluidColorMatrix.h"
|
||||||
const uint8_t kScrollingLayerOptions = (SM_SCROLLING_OPTIONS_NONE);
|
#include "RicochetMatrix.h"
|
||||||
|
|
||||||
SMARTMATRIX_ALLOCATE_BUFFERS(matrix, kMatrixWidth, kMatrixHeight, kRefreshDepth, kDmaBufferRows, kPanelType, kMatrixOptions);
|
|
||||||
SMARTMATRIX_ALLOCATE_BACKGROUND_LAYER(backgroundLayer, kMatrixWidth, kMatrixHeight, COLOR_DEPTH, kBackgroundLayerOptions);
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
#define NUMLEDS 24
|
||||||
|
#define WIDTH 6
|
||||||
|
#define HEIGHT 36
|
||||||
|
#define TILE_WIDTH 6
|
||||||
|
#define TILE_HEIGHT 6
|
||||||
|
|
||||||
CRGB leds[NUMLEDS];
|
CRGB leds[NUMLEDS];
|
||||||
CRGB rainbow[] = {CRGB::Red, CRGB(255, 45, 0), CRGB::Yellow, CRGB::Green, CRGB::Blue, CRGB::Purple};
|
CRGB leds2D[WIDTH * HEIGHT];
|
||||||
|
|
||||||
|
CRGB rainbow[] = {CRGB::Red, CRGB::Orange, CRGB::Yellow, CRGB::Green, CRGB::Blue, CRGB::Purple};
|
||||||
|
|
||||||
|
LEDHAL* hal;
|
||||||
LEDHAL2D* hal2D;
|
LEDHAL2D* hal2D;
|
||||||
|
LogicalMatrix* lm1;
|
||||||
|
LogicalMatrix* lm2;
|
||||||
|
AnimationBase* animation;
|
||||||
|
AnimationBase* animationMatrix;
|
||||||
|
AnimationBase* animationMatrix2;
|
||||||
|
|
||||||
MatrixAnimation* animation;
|
uint16_t shiftNumber = 0;
|
||||||
|
|
||||||
int animationCode = 0;
|
SerpentineArrangement arrangement(false);
|
||||||
|
TiledSerpentineArrangement tileArrangement(false, true, TILE_WIDTH, TILE_HEIGHT);
|
||||||
|
|
||||||
|
elapsedMillis memoryPrintTimer;
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
|
Serial.println("Hello World!");
|
||||||
while(!Serial) {}
|
|
||||||
|
|
||||||
Serial.println(F("STARTUP!"));
|
|
||||||
|
|
||||||
CLEDController* controller = &FastLED.addLeds<NEOPIXEL, 6>(leds, NUMLEDS);
|
CLEDController* controller = &FastLED.addLeds<NEOPIXEL, 6>(leds, NUMLEDS);
|
||||||
controller->setCorrection(TypicalLEDStrip);
|
CLEDController* controller2D = &FastLED.addLeds<NEOPIXEL, 7>(leds2D, WIDTH * HEIGHT);
|
||||||
|
|
||||||
hal2D = new CLEDControllerPhysicalMatrix(controller, "Matrix", ArrangementType::HORIZONTALSCAN, 32, 32);
|
hal = new CLEDControllerPhysicalStrip(controller, "Test Strip");
|
||||||
|
hal2D = new CLEDControllerPhysicalMatrix(controller2D, "Test Matrix", arrangement, WIDTH, HEIGHT);
|
||||||
if(animationCode == 0) {
|
lm1 = new LogicalMatrix("LM1", hal2D, 0, 0, 6, HEIGHT / 2);
|
||||||
animation = new PlasmaMatrix(hal2D, "Plasma Matrix", 10);
|
lm2 = new LogicalMatrix("LM2", hal2D, 0, HEIGHT / 2, 6, HEIGHT);
|
||||||
} else if(animationCode == 1) {
|
|
||||||
animation = new AlternateMatrix(hal2D, "Alternate Matrix", 125, rainbow, 6, AlternateType::HORIZONTAL_ALTERNATE);
|
/*animation = new AlternateStrip(hal, "Alternate Strip", 150, rainbow, 6);
|
||||||
} 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();
|
animation->enable();
|
||||||
|
|
||||||
|
animationMatrix = new AlternateMatrix(lm1, "Alternate Matrix", 150, rainbow, 6, AlternateType::HORIZONTAL_ALTERNATE);
|
||||||
|
animationMatrix->enable();
|
||||||
|
|
||||||
|
animationMatrix2 = new AlternateMatrix(lm2, "Alternate Matrix 2", 150, rainbow, 6, AlternateType::VERTICAL_ALTERNATE);
|
||||||
|
animationMatrix2->enable();
|
||||||
|
|
||||||
|
/*animation = new CollisionStrip(hal, "Collision Strip", 150, CRGB::Orange, CRGB::Green);
|
||||||
|
animation->enable();
|
||||||
|
|
||||||
|
animationMatrix = new CollisionMatrix(lm1, "Collision Matrix", 1000, CRGB::Orange, CRGB::Green, CollisionType::HORIZONTAL_COLLISION);
|
||||||
|
animationMatrix->enable();
|
||||||
|
|
||||||
|
animationMatrix2 = new CollisionMatrix(lm2, "Collision Matrix 2", 1000, CRGB::Orange, CRGB::Green, CollisionType::VERTICAL_COLLISION);
|
||||||
|
animationMatrix2->enable();
|
||||||
|
|
||||||
|
animation = new ColorRandomizerStrip(hal, "Color Randomizer Strip", 50, true, 6, rainbow);
|
||||||
|
animation->enable();
|
||||||
|
|
||||||
|
animationMatrix = new ColorRandomizerMatrix(lm1, "Color Randomizer Matrix", 300, false, 6, rainbow, ColorRandomizerType::HORIZONTAL_COLORRANDOMIZER);
|
||||||
|
animationMatrix->enable();
|
||||||
|
|
||||||
|
animationMatrix2 = new ColorRandomizerMatrix(lm2, "Color Randomizer Matrix 2", 300, false, 6, rainbow, ColorRandomizerType::VERTICAL_COLORRANDOMIZER);
|
||||||
|
animationMatrix2->enable();
|
||||||
|
|
||||||
|
animation = new CycleLightStrip(hal, "Cycle Light Strip", 250, 6, rainbow);
|
||||||
|
animation->enable();
|
||||||
|
|
||||||
|
animationMatrix = new CycleLightMatrix(lm1, "Cycle Light Matrix", 250, rainbow, 6, CycleLightType::HORIZONTAL_CYCLELIGHT);
|
||||||
|
animationMatrix->enable();
|
||||||
|
|
||||||
|
animationMatrix2 = new CycleLightMatrix(lm2, "Cycle Light Matrix 2", 250, rainbow, 6, CycleLightType::VERTICAL_CYCLELIGHT);
|
||||||
|
animationMatrix2->enable();
|
||||||
|
|
||||||
|
animationMatrix = new FluidColorMatrix(lm1, "Fluid Color", 30, FluidColorType::PIXEL_BY_PIXEL_FLUIDCOLOR, FluidColorResolution::FULL_FLUIDCOLOR);
|
||||||
|
animationMatrix->enable();
|
||||||
|
|
||||||
|
animationMatrix2 = new FluidColorMatrix(lm2, "Fluid Color 2", 30, FluidColorType::VERTICAL_FLUIDCOLOR, FluidColorResolution::FULL_FLUIDCOLOR);
|
||||||
|
animationMatrix2->enable();*/
|
||||||
|
|
||||||
|
animationMatrix = new RicochetMatrix(hal2D, "Ricochet Matrix", 150, 10, rainbow, 6);
|
||||||
|
animationMatrix->enable();
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
animation->update();
|
/*for(uint8_t i = 0; i < NUMLEDS; i++) {
|
||||||
|
hal->setColor(i, rainbow[(i + shiftNumber) % 6]);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
//animation->update();
|
||||||
|
animationMatrix->update();
|
||||||
|
//animationMatrix2->update();
|
||||||
|
|
||||||
|
/*for(uint16_t i = 0; i < WIDTH * HEIGHT; i++) {
|
||||||
|
hal2D->setColor(i, CRGB::Red);
|
||||||
|
delay(1000);
|
||||||
|
hal2D->requestShow();
|
||||||
|
hal2D->show();
|
||||||
|
}*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
for(uint8_t i = 0; i < HEIGHT; i++) {
|
||||||
|
hal2D->drawFastHLine(0, i, WIDTH, rainbow[(i + shiftNumber) % 6]);
|
||||||
|
} */
|
||||||
|
|
||||||
|
/*for(uint8_t i = 0; i < HEIGHT / 2; i++) {
|
||||||
|
lm1->drawFastHLine(0, i, WIDTH, rainbow[(i + shiftNumber) % 6]);
|
||||||
|
lm2->drawFastHLine(0, HEIGHT / 2 - 1 - i, WIDTH, rainbow[(i + shiftNumber) % 6]);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
hal->requestShow();
|
||||||
|
hal->show();
|
||||||
|
hal2D->requestShow();
|
||||||
hal2D->show();
|
hal2D->show();
|
||||||
|
//shiftNumber++;
|
||||||
|
|
||||||
|
if(memoryPrintTimer >= 1000) {
|
||||||
|
Serial.println(freeMemory());
|
||||||
|
memoryPrintTimer = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
[wokwi]
|
[wokwi]
|
||||||
version = 1
|
version = 1
|
||||||
firmware = '.pio/build/esp32/firmware.bin'
|
firmware = '.pio/build/mega/firmware.hex'
|
||||||
elf = '.pio/build/esp32/firmware.elf'
|
elf = '.pio/build/mega/firmware.elf'
|
||||||
gdbServerPort=3333
|
gdbServerPort=3333
|
||||||
Reference in New Issue
Block a user