hyperion.ng/libsrc/bootsequence/AbstractBootSequence.cpp
T. van der Zwan a567f0feeb Added abstract boot sequence to handle events and iteration count.
Implemented KnightRider bootsequence (KittBootSequence).
2013-09-09 15:24:36 +00:00

36 lines
796 B
C++

#include "AbstractBootSequence.h"
AbstractBootSequence::AbstractBootSequence(Hyperion * hyperion, const int64_t interval, const unsigned iterationCnt) :
_timer(),
_hyperion(hyperion),
_priority(0),
_iterationCounter(iterationCnt)
{
_timer.setInterval(interval);
_timer.setSingleShot(false);
QObject::connect(&_timer, SIGNAL(timeout()), this, SLOT(update()));
}
void AbstractBootSequence::start()
{
_timer.start();
}
void AbstractBootSequence::update()
{
if (_iterationCounter == 0)
{
_timer.stop();
_hyperion->clear(_priority);
return;
}
// Obtain the next led-colors from the child-class
const std::vector<RgbColor>& colors = nextColors();
// Write the colors to hyperion
_hyperion->setColors(_priority, colors, -1);
// Decrease the loop count
--_iterationCounter;
}