esp32-sk6812/include/Animation/MatrixCodeAnimation.h

38 lines
770 B
C
Raw Normal View History

2019-12-30 12:18:04 +01:00
#pragma once
#include <random>
#include <list>
#include "Animation.h"
class MatrixCodeAnimation : public Animation
{
public:
MatrixCodeAnimation(Fader *fader, int vspeed = 80, int spawn_rate = 8);
void loop(uint64_t frame) override;
void stop(void) override
{
m_stopping = true;
}
void reset(void) override;
private:
struct Pixel
{
int x; // position in 1/1 led
int y; // position in 1/256 led
int vspeed; // vertical speed in 1/256 leds per frame
};
std::default_random_engine m_gen;
std::list<Pixel> m_pixels;
int m_vspeed;
int m_spawnRate; // average pixels per second
bool m_stopping;
};