50 lines
1.2 KiB
C++
50 lines
1.2 KiB
C++
#ifndef COLORRANDOMIZERSTRIP_H
|
|
#define COLORRANDOMIZERSTRIP_H
|
|
|
|
#include "StripAnimation.h"
|
|
#include "LEDHAL.h"
|
|
|
|
#define DEFAULT_STRIP_FADER 64
|
|
|
|
class ColorRandomizerStrip : public StripAnimation {
|
|
public:
|
|
ColorRandomizerStrip(LEDHAL* _strip, char* _refName, long _updateTime, bool _fade,
|
|
uint8_t _numColors, CRGB* _colors) : StripAnimation(_strip, _refName, _updateTime),
|
|
numColors(_numColors), colors(new CRGB[_numColors]),
|
|
fadingValues(new CRGB[_numColors]), fade(_fade), colorRandomizerInt(0),
|
|
scale(DEFAULT_STRIP_FADER) {
|
|
for(uint8_t i = 0; i < _numColors; i++) {
|
|
colors[i] = _colors[i];
|
|
}
|
|
}
|
|
|
|
virtual ~ColorRandomizerStrip() { delete colors; delete fadingValues; }
|
|
|
|
void initialize() {
|
|
colorRandomizerInt = 0;
|
|
isFading = false;
|
|
resetTimer();
|
|
}
|
|
|
|
void execute();
|
|
|
|
void setFade(bool _fade) { fade = _fade; initialize(); }
|
|
bool getFade() { return fade; }
|
|
void setFadeScale(uint8_t _scale) { scale = _scale; initialize(); }
|
|
uint8_t getFadeScale() { return scale; }
|
|
|
|
private:
|
|
CRGB
|
|
*colors,
|
|
*fadingValues;
|
|
uint16_t
|
|
colorRandomizerInt;
|
|
uint8_t
|
|
scale,
|
|
numColors;
|
|
bool
|
|
isFading,
|
|
fade;
|
|
};
|
|
|
|
#endif |