2019-12-02 22:42:31 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <cstdint>
|
|
|
|
|
|
|
|
#include "Fader.h"
|
|
|
|
|
|
|
|
class Animation
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Animation(Fader *fader)
|
2019-12-03 22:09:55 +01:00
|
|
|
: m_fader(fader), m_running(true)
|
2019-12-02 22:42:31 +01:00
|
|
|
{}
|
|
|
|
|
2019-12-03 22:09:55 +01:00
|
|
|
/*!
|
|
|
|
* The animation's main function. Will be called once per frame.
|
|
|
|
*
|
|
|
|
* \param frame The current frame since the animation's start.
|
|
|
|
*/
|
2019-12-02 22:42:31 +01:00
|
|
|
virtual void loop(uint64_t frame) = 0;
|
|
|
|
|
2019-12-03 22:09:55 +01:00
|
|
|
/*!
|
|
|
|
* 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.
|
|
|
|
*/
|
2019-12-03 23:11:34 +01:00
|
|
|
virtual void reset(void)
|
|
|
|
{
|
|
|
|
m_running = true;
|
|
|
|
};
|
2019-12-03 22:09:55 +01:00
|
|
|
|
2019-12-02 22:42:31 +01:00
|
|
|
protected:
|
|
|
|
Fader *m_fader;
|
2019-12-03 22:09:55 +01:00
|
|
|
bool m_running;
|
2019-12-02 22:42:31 +01:00
|
|
|
};
|