Modifying PlasmaMatrix to make it look more...standard practice?

This commit is contained in:
Bradley Bickford 2025-09-16 18:00:51 -04:00
parent 8a00b69e9e
commit 1a19425592
2 changed files with 36 additions and 30 deletions

View File

@ -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();

View File

@ -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++) {