esp32-sk6812/include/Animation/Animation.h

54 lines
1.2 KiB
C++

#pragma once
#include <cstdint>
#include "Fader.h"
class Animation
{
public:
Animation(Fader *fader)
: m_fader(fader), m_running(true)
{}
/*!
* The animation's main function. Will be called once per frame.
*
* \param frame The current frame since the animation's start.
*/
virtual void loop(uint64_t frame) = 0;
/*!
* Stop the animation. After this function is called, the animation code
* might start some transition to black (all LEDs off).
*/
virtual void stop(void)
{
m_running = false;
}
/*!
* A function for checking wether the animation has stopped. This must
* return true after the stop transition has finished.
*
* \returns True if all activity of the animation code has stopped.
*/
virtual bool finished(void)
{
return !m_running;
}
/*!
* Reset function of the animation code. This should clear any
* internal state.
*/
virtual void reset(void)
{
m_running = true;
};
protected:
Fader *m_fader;
bool m_running;
};