G.U.L.L.S. rebuilt to use PlatformIO
This commit is contained in:
63
include/CycloneMatrix.h
Normal file
63
include/CycloneMatrix.h
Normal file
@@ -0,0 +1,63 @@
|
||||
#ifndef CYCLONEMATRIX_H
|
||||
#define CYCLONEMATRIX_H
|
||||
|
||||
#include "LEDHAL2D.h"
|
||||
#include "CycloneHelper.h"
|
||||
#include "MatrixAnimation.h"
|
||||
|
||||
class CycloneMatrix : public MatrixAnimation {
|
||||
public:
|
||||
CycloneMatrix(LEDHAL2D* _matrix, char* _refName, long _updateTime, uint16_t originX,
|
||||
uint16_t originY, uint8_t _startRadius, uint8_t _endRadius, uint8_t numColors,
|
||||
CRGB* _colors) : MatrixAnimation(_matrix, _refName, _updateTime),
|
||||
startRadius(_startRadius), endRadius(_endRadius) {
|
||||
|
||||
colors = new CRGB[numColors];
|
||||
|
||||
for(uint8_t i = 0; i < numColors; i++) {
|
||||
colors[i] = _colors[i];
|
||||
}
|
||||
|
||||
helpers = new CycloneHelper*[_endRadius - _startRadius];
|
||||
|
||||
// The colors are currently being passed in such a way that I believe
|
||||
// there being taken into the CycloneHelper through value, rather than ByRef
|
||||
// i.e. wasting memory
|
||||
for(uint8_t i = 0; i < _endRadius - _startRadius; i++) {
|
||||
helpers[i] = new CycloneHelper(
|
||||
colors[random(0, numColors)],
|
||||
originX, originY,
|
||||
_startRadius + i,
|
||||
random(0, 100000) % 2 == 0 ? 1 : -1
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
virtual ~CycloneMatrix() { delete helpers; delete colors; }
|
||||
|
||||
// I don't know that there is a nice, memory friendly way to
|
||||
// reset this yet...
|
||||
void initialize() {
|
||||
resetTimer();
|
||||
}
|
||||
|
||||
void execute() {
|
||||
matrix->clearLEDs();
|
||||
|
||||
for(uint8_t i = 0; i < endRadius - startRadius; i++) {
|
||||
helpers[i]->updateAndRedraw(matrix);
|
||||
}
|
||||
|
||||
matrix->requestShow();
|
||||
}
|
||||
private:
|
||||
uint8_t
|
||||
startRadius,
|
||||
endRadius;
|
||||
CRGB*
|
||||
colors;
|
||||
CycloneHelper**
|
||||
helpers;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user