Mirror of espurna firmware for wireless switches and more
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

44 lines
1.0 KiB

#if GARLAND_SUPPORT
#include "../anim.h"
#include "../palette.h"
//------------------------------------------------------------------------------
class AnimRandRun : public Anim {
private:
float speed;
float pos;
int dir;
public:
AnimRandRun() : Anim("RandRun") {
}
void SetupImpl() override {
pos = 0;
speed = ((float)secureRandom(20, 90)) / 100;
DEBUG_MSG_P(PSTR("[GARLAND] speed = %d\n"), (unsigned int)(speed*100));
dir = randDir();
for (auto i = 0; i < numLeds; ++i)
ledstmp[i] = palette->getRndInterpColor();
glowSetUp();
}
void Run() override {
pos += speed * dir;
if (pos >= numLeds) pos -= numLeds;
if (pos < 0) pos += numLeds;
for (auto i = 0; i < numLeds; ++i) {
int j = i + pos;
if (j >= numLeds) j -= numLeds;
leds[i] = ledstmp[j];
glowForEachLed(i);
}
glowRun();
}
};
#endif // GARLAND_SUPPORT