Modifying PlasmaMatrix to make it look more...standard practice?
This commit is contained in:
parent
8a00b69e9e
commit
1a19425592
@ -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();
|
||||
|
||||
|
@ -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++) {
|
||||
|
Loading…
Reference in New Issue
Block a user