Compare commits
8 Commits
rework
...
referentia
| Author | SHA1 | Date | |
|---|---|---|---|
| f1251f433e | |||
| ef3eded08d | |||
| 1ed3c99141 | |||
| 1a19425592 | |||
| 8a00b69e9e | |||
| c5f0dc66cb | |||
| 42949bd10b | |||
| 67ac7aa752 |
16
README.md
16
README.md
@@ -1,21 +1,5 @@
|
||||
<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*
|
||||
|
||||
##### LED Hardware Development Status
|
||||
|
||||
118
diagram.json
118
diagram.json
@@ -4,125 +4,33 @@
|
||||
"editor": "wokwi",
|
||||
"parts": [
|
||||
{
|
||||
"type": "wokwi-arduino-mega",
|
||||
"id": "mega",
|
||||
"top": 100,
|
||||
"left": 100.78,
|
||||
"type": "board-xiao-esp32-s3",
|
||||
"id": "esp",
|
||||
"top": 1000,
|
||||
"left": 13.78,
|
||||
"attrs": {
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "neopixels",
|
||||
"type": "wokwi-led-strip",
|
||||
"type": "wokwi-neopixel-canvas",
|
||||
"top": 0,
|
||||
"left": 0,
|
||||
"attrs": {
|
||||
"pixels": "24"
|
||||
"rows": "32",
|
||||
"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": [
|
||||
["mega:0", "$serialMonitor:TX", ""],
|
||||
["mega:1", "$serialMonitor:RX", ""],
|
||||
["mega:GND.2", "neopixels:VSS", "black"],
|
||||
["mega:6", "neopixels:DIN", "green"],
|
||||
["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"]
|
||||
["esp:GND", "neopixels:VSS", "black"],
|
||||
["esp:D5", "neopixels:DIN", "green"],
|
||||
["esp:5V", "neopixels:VDD", "red"]
|
||||
],
|
||||
"dependencies": {},
|
||||
"serialMonitor": {
|
||||
"collapse": false,
|
||||
"convertEol": false,
|
||||
"display": "always",
|
||||
"newline": "lf"
|
||||
}
|
||||
},
|
||||
"dependencies": {}
|
||||
}
|
||||
@@ -2,11 +2,17 @@
|
||||
#define CLEDCONTROLLERPHYSICALMATRIX_H
|
||||
|
||||
#include "LEDHAL2D.h"
|
||||
#include "ILEDArrangement.h"
|
||||
|
||||
enum ArrangementType {
|
||||
HORIZONTALSCAN,
|
||||
HORIZONTALSERPENTINE,
|
||||
COLUMNSCAN,
|
||||
COLUMNSERPENTINE
|
||||
};
|
||||
|
||||
class CLEDControllerPhysicalMatrix : public LEDHAL2D {
|
||||
public:
|
||||
CLEDControllerPhysicalMatrix(CLEDController* _controller, char* ledName, ILEDArrangement& _arrangement,
|
||||
CLEDControllerPhysicalMatrix(CLEDController* _controller, char* ledName, ArrangementType _arrangement,
|
||||
int16_t width, int16_t height): LEDHAL2D(width, height, ledName, true), controller(_controller), arrangement(_arrangement) {}
|
||||
virtual ~CLEDControllerPhysicalMatrix() {}
|
||||
|
||||
@@ -27,7 +33,25 @@ class CLEDControllerPhysicalMatrix : public LEDHAL2D {
|
||||
}
|
||||
|
||||
int16_t XY(int16_t x, int16_t y) {
|
||||
return arrangement.XY(x, y, getWidth(), getHeight());
|
||||
if(arrangement == ArrangementType::HORIZONTALSCAN) {
|
||||
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() {
|
||||
@@ -42,7 +66,7 @@ class CLEDControllerPhysicalMatrix : public LEDHAL2D {
|
||||
private:
|
||||
CLEDController*
|
||||
controller;
|
||||
ILEDArrangement&
|
||||
ArrangementType
|
||||
arrangement;
|
||||
};
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ class ColorRandomizerMatrix : public MatrixAnimation {
|
||||
uint8_t _numColors, CRGB* _colors, ColorRandomizerType _type) :
|
||||
MatrixAnimation(_matrix, _refName, _updateTime), numColors(_numColors),
|
||||
colors(new CRGB[_numColors]), fade(_fade), colorRandomizerInt(0),
|
||||
scale(DEFAULT_MATRIX_FADER), type(_type) {
|
||||
scale(DEFAULT_MATRIX_FADER) {
|
||||
for(uint8_t i = 0; i < _numColors; i++) {
|
||||
colors[i] = _colors[i];
|
||||
}
|
||||
@@ -38,6 +38,8 @@ class ColorRandomizerMatrix : public MatrixAnimation {
|
||||
} else {
|
||||
fadingValues = new CRGB[matrix->getWidth()];
|
||||
}
|
||||
|
||||
Serial.println("Initialize is ok");
|
||||
}
|
||||
|
||||
void execute();
|
||||
|
||||
@@ -23,9 +23,9 @@ class CycloneHelper {
|
||||
|
||||
for(uint8_t i = 0; i < numberOfTails; i++) {
|
||||
tailColors[i] = CRGB(
|
||||
min(round(redScaler * (i + 1)), color.red),
|
||||
min(round(greenScaler * (i + 1)), color.green),
|
||||
min(round(blueScaler * (i + 1)), color.blue)
|
||||
min(round(redScaler * (i + 1)), (float)color.red),
|
||||
min(round(greenScaler * (i + 1)), (float)color.green),
|
||||
min(round(blueScaler * (i + 1)), (float)color.blue)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
#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,6 +21,7 @@ class LEDHAL {
|
||||
|
||||
virtual void requestShow() { showRequested = true; }
|
||||
|
||||
//TODO UnifiedColor should have constants
|
||||
virtual void clearLEDs() {
|
||||
for(uint16_t i = 0; i < getNumLEDs(); i++) {
|
||||
setColor(i, CRGB(0, 0, 0));
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
#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,38 +6,11 @@
|
||||
|
||||
class PlasmaMatrix : public MatrixAnimation {
|
||||
public:
|
||||
PlasmaMatrix(LEDHAL2D* _matrix, char* _refName, long _updateTime) :
|
||||
MatrixAnimation(_matrix, _refName, _updateTime), paletteShift(0), palette(new CRGB[256]) {
|
||||
plasma = new uint8_t*[matrix->getWidth()];
|
||||
PlasmaMatrix(LEDHAL2D* _matrix, char* _refName, long _updateTime);
|
||||
|
||||
for(uint16_t i = 0; i < matrix->getWidth(); i++) {
|
||||
plasma[i] = new uint8_t[matrix->getHeight()];
|
||||
}
|
||||
virtual ~PlasmaMatrix();
|
||||
|
||||
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 initialize();
|
||||
|
||||
void execute();
|
||||
|
||||
|
||||
@@ -9,8 +9,7 @@ class RicochetHelper {
|
||||
RicochetHelper() {}
|
||||
RicochetHelper(int16_t _startPosX, int16_t _startPosY, int16_t _width, int16_t _height,
|
||||
CRGB _color) : currentX(_startPosX), currentY(_startPosY), width(_width),
|
||||
height(_height), xDir(random(0, 101) > 51 ? -1 : 1), yDir(random(0, 100) > 51 ? -1 : 1),
|
||||
color(_color) {}
|
||||
height(_height), xDir(random(0, 101) > 51 ? -1 : 1), yDir(random(0, 100) > 51 ? -1 : 1) {}
|
||||
|
||||
int16_t getCurrentXPos() { return currentX; }
|
||||
int16_t getCurrentYPos() { return currentY; }
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
#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
|
||||
@@ -1,31 +0,0 @@
|
||||
#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,6 +1,9 @@
|
||||
#ifndef SMARTMATRIXPHYSICALMATRIX_H
|
||||
#define SMARTMATRIXPHYSICALMATRIX_H
|
||||
|
||||
#ifdef CORE_TEENSY
|
||||
#ifdef ENABLE_TEENSY_SMARTMATRIX
|
||||
|
||||
#include "SmartMatrix.h"
|
||||
#include "LEDHAL2D.h"
|
||||
|
||||
@@ -44,3 +47,5 @@ class SmartMatrixPhysicalMatrix : public LEDHAL2D {
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
@@ -10,6 +10,7 @@ class StreamEvent
|
||||
handled = false;
|
||||
|
||||
code = _readFrom->read();
|
||||
subCode = _readFrom->read();
|
||||
flags = _readFrom->read();
|
||||
|
||||
if (flags & 0x01 == 1) {
|
||||
@@ -32,6 +33,8 @@ class StreamEvent
|
||||
|
||||
uint8_t getCode() { return code; }
|
||||
|
||||
uint8_t getSubCode() { return subCode; }
|
||||
|
||||
uint16_t getPayloadSize() { return payloadSize; }
|
||||
|
||||
byte* getPayload() { return payload; }
|
||||
@@ -40,7 +43,7 @@ class StreamEvent
|
||||
bool isResponse() { return flags & 0x02 == 2; }
|
||||
bool isDescribeRequest() { return flags & 0x04 == 4; }
|
||||
|
||||
virtual ~StreamEvent() { delete[] payload; }
|
||||
~StreamEvent() { delete[] payload; }
|
||||
|
||||
private:
|
||||
byte*
|
||||
@@ -49,6 +52,7 @@ class StreamEvent
|
||||
payloadSize;
|
||||
uint8_t
|
||||
code,
|
||||
subCode,
|
||||
flags;
|
||||
bool
|
||||
handled;
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
#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
|
||||
@@ -1,46 +0,0 @@
|
||||
#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,7 +9,19 @@
|
||||
; https://docs.platformio.org/page/projectconf.html
|
||||
|
||||
[platformio]
|
||||
default_envs = mega
|
||||
default_envs =
|
||||
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]
|
||||
platform = atmelavr
|
||||
@@ -20,10 +32,8 @@ lib_deps =
|
||||
pfeerick/elapsedMillis@^1.0.6
|
||||
adafruit/Adafruit GFX Library@^1.11.9
|
||||
arduino-libraries/SD@^1.3.0
|
||||
apechinsky/MemoryFree@^0.3.0
|
||||
ivanseidel/LinkedList@0.0.0-alpha+sha.dac3874d28
|
||||
|
||||
[env:mega]
|
||||
[env:mega2560]
|
||||
platform = atmelavr
|
||||
board = megaatmega2560
|
||||
framework = arduino
|
||||
@@ -32,19 +42,12 @@ lib_deps =
|
||||
pfeerick/elapsedMillis@^1.0.6
|
||||
adafruit/Adafruit GFX Library@^1.11.9
|
||||
arduino-libraries/SD@^1.3.0
|
||||
apechinsky/MemoryFree@^0.3.0
|
||||
ivanseidel/LinkedList@0.0.0-alpha+sha.dac3874d28
|
||||
|
||||
[common]
|
||||
|
||||
[env:teensy36]
|
||||
platform = teensy
|
||||
[env:esp32]
|
||||
platform = espressif32
|
||||
board = adafruit_feather_esp32s3_nopsram
|
||||
framework = arduino
|
||||
board = teensy36
|
||||
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
|
||||
apechinsky/MemoryFree@^0.3.0
|
||||
ivanseidel/LinkedList@0.0.0-alpha+sha.dac3874d28
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
#include "ColorRandomizerMatrix.h"
|
||||
|
||||
void ColorRandomizerMatrix::execute() {
|
||||
Serial.println("In Execute");
|
||||
if(fade && isFading) {
|
||||
CRGB color;
|
||||
|
||||
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) {
|
||||
color = matrix->getColor(0, i);
|
||||
} else {
|
||||
@@ -20,7 +19,7 @@ void ColorRandomizerMatrix::execute() {
|
||||
|
||||
colorRandomizerInt++;
|
||||
} 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) {
|
||||
matrix->drawFastHLine(0, i, matrix->getWidth(), matrix->getColor(0, i) - fadingValues[i]);
|
||||
} else {
|
||||
@@ -34,17 +33,14 @@ void ColorRandomizerMatrix::execute() {
|
||||
isFading = false;
|
||||
}
|
||||
} else {
|
||||
Serial.println("Setup Colors");
|
||||
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);
|
||||
|
||||
if(type == ColorRandomizerType::HORIZONTAL_COLORRANDOMIZER) {
|
||||
Serial.println("Draw Horizontal");
|
||||
matrix->drawFastHLine(0, i, matrix->getWidth(), colors[rand]);
|
||||
} else {
|
||||
Serial.println("Draw Vertical");
|
||||
matrix->drawFastVLine(i, 0, matrix->getHeight(), colors[rand]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,9 +8,9 @@ void ColorRandomizerStrip::execute() {
|
||||
for(uint16_t i = 0; i < strip->getNumLEDs(); i++) {
|
||||
color = strip->getColor(i);
|
||||
|
||||
fadingValues[i].red = (uint8_t)(ceil((float)color.red/scale));
|
||||
fadingValues[i].green = (uint8_t)(ceil((float)color.green/scale));
|
||||
fadingValues[i].blue = (uint8_t)(ceil((float)color.blue/scale));
|
||||
fadingValues[i].red = (ceil((float)color.red/scale));
|
||||
fadingValues[i].green = (ceil((float)color.green/scale));
|
||||
fadingValues[i].blue = (ceil((float)color.blue/scale));
|
||||
}
|
||||
|
||||
colorRandomizerInt++;
|
||||
|
||||
@@ -1,5 +1,38 @@
|
||||
#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() {
|
||||
for(uint16_t x = 0; x < matrix->getWidth(); x++) {
|
||||
for(uint16_t y = 0; y < matrix->getHeight(); y++) {
|
||||
@@ -9,5 +42,7 @@ void PlasmaMatrix::execute() {
|
||||
}
|
||||
}
|
||||
|
||||
paletteShift++;
|
||||
|
||||
matrix->requestShow();
|
||||
}
|
||||
@@ -9,37 +9,18 @@ void RicochetMatrix::initialize() {
|
||||
randomSeed(random(0, 10000000));
|
||||
balls[i] = new RicochetHelper(random(0, matrix->getWidth()), random(0, matrix->getHeight()),
|
||||
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() {
|
||||
Serial.println("Pre Clear");
|
||||
matrix->clearLEDs();
|
||||
Serial.println("Post Clear");
|
||||
|
||||
Serial.println("Positional Updates");
|
||||
for(uint16_t i = 0; i < numBalls; i++) {
|
||||
balls[i]->updatePositions();
|
||||
|
||||
matrix->drawPixel(balls[i]->getCurrentXPos(), balls[i]->getCurrentYPos(),
|
||||
balls[i]->getCurrentColor());
|
||||
}
|
||||
Serial.println("Post Positional Updates");
|
||||
|
||||
Serial.println("Pre Request Show");
|
||||
matrix->requestShow();
|
||||
Serial.println("Post Request Show");
|
||||
}
|
||||
189
src/main.cpp
189
src/main.cpp
@@ -1,143 +1,110 @@
|
||||
#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 "CLEDControllerPhysicalStrip.h"
|
||||
#include "CLEDControllerPhysicalMatrix.h"
|
||||
#include "SerpentineArrangement.h"
|
||||
#include "TiledSerpentineArrangement.h"
|
||||
#include "MemoryFree.h"
|
||||
#include "elapsedMillis.h"
|
||||
#include "LogicalMatrix.h"
|
||||
#include "AlternateStrip.h"
|
||||
#include "AnimationBase.h"
|
||||
#include "MatrixAnimation.h"
|
||||
#include "AlternateMatrix.h"
|
||||
#include "CollisionStrip.h"
|
||||
#include "CollisionMatrix.h"
|
||||
#include "ColorRandomizerMatrix.h"
|
||||
#include "ColorRandomizerStrip.h"
|
||||
#include "CycleLightStrip.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"
|
||||
#include "elapsedMillis.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
|
||||
|
||||
#define NUMLEDS 24
|
||||
#define WIDTH 6
|
||||
#define HEIGHT 36
|
||||
#define TILE_WIDTH 6
|
||||
#define TILE_HEIGHT 6
|
||||
|
||||
CRGB leds[NUMLEDS];
|
||||
CRGB leds2D[WIDTH * HEIGHT];
|
||||
CRGB rainbow[] = {CRGB::Red, CRGB(255, 45, 0), CRGB::Yellow, CRGB::Green, CRGB::Blue, CRGB::Purple};
|
||||
|
||||
CRGB rainbow[] = {CRGB::Red, CRGB::Orange, CRGB::Yellow, CRGB::Green, CRGB::Blue, CRGB::Purple};
|
||||
|
||||
LEDHAL* hal;
|
||||
LEDHAL2D* hal2D;
|
||||
LogicalMatrix* lm1;
|
||||
LogicalMatrix* lm2;
|
||||
AnimationBase* animation;
|
||||
AnimationBase* animationMatrix;
|
||||
AnimationBase* animationMatrix2;
|
||||
|
||||
uint16_t shiftNumber = 0;
|
||||
MatrixAnimation* animation;
|
||||
|
||||
SerpentineArrangement arrangement(false);
|
||||
TiledSerpentineArrangement tileArrangement(false, true, TILE_WIDTH, TILE_HEIGHT);
|
||||
elapsedMillis printTimer;
|
||||
|
||||
elapsedMillis memoryPrintTimer;
|
||||
int animationCode = 0;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
Serial.println("Hello World!");
|
||||
Serial.begin(9600);
|
||||
|
||||
delay(5000);
|
||||
|
||||
Serial.println(F("STARTUP!"));
|
||||
|
||||
CLEDController* controller = &FastLED.addLeds<NEOPIXEL, 6>(leds, NUMLEDS);
|
||||
CLEDController* controller2D = &FastLED.addLeds<NEOPIXEL, 7>(leds2D, WIDTH * HEIGHT);
|
||||
controller->setCorrection(TypicalLEDStrip);
|
||||
|
||||
hal = new CLEDControllerPhysicalStrip(controller, "Test Strip");
|
||||
hal2D = new CLEDControllerPhysicalMatrix(controller2D, "Test Matrix", arrangement, WIDTH, HEIGHT);
|
||||
lm1 = new LogicalMatrix("LM1", hal2D, 0, 0, 6, HEIGHT / 2);
|
||||
lm2 = new LogicalMatrix("LM2", hal2D, 0, HEIGHT / 2, 6, HEIGHT);
|
||||
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 = new AlternateStrip(hal, "Alternate Strip", 150, rainbow, 6);
|
||||
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() {
|
||||
/*for(uint8_t i = 0; i < NUMLEDS; i++) {
|
||||
hal->setColor(i, rainbow[(i + shiftNumber) % 6]);
|
||||
}*/
|
||||
animation->update();
|
||||
|
||||
//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();
|
||||
//shiftNumber++;
|
||||
|
||||
if(memoryPrintTimer >= 1000) {
|
||||
Serial.println(freeMemory());
|
||||
memoryPrintTimer = 0;
|
||||
if(printTimer >= 5000) {
|
||||
Serial.println("PRINT!");
|
||||
printTimer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[wokwi]
|
||||
version = 1
|
||||
firmware = '.pio/build/mega/firmware.hex'
|
||||
elf = '.pio/build/mega/firmware.elf'
|
||||
firmware = '.pio/build/esp32/firmware.bin'
|
||||
elf = '.pio/build/esp32/firmware.elf'
|
||||
gdbServerPort=3333
|
||||
Reference in New Issue
Block a user