2013-09-09 17:24:36 +02:00
|
|
|
|
|
|
|
// Hyperion includes
|
|
|
|
#include <hyperion/ImageProcessorFactory.h>
|
|
|
|
|
|
|
|
// Local-Bootsequence includes
|
|
|
|
#include "KittBootSequence.h"
|
|
|
|
|
|
|
|
KittBootSequence::KittBootSequence(Hyperion * hyperion, const unsigned duration_ms) :
|
|
|
|
AbstractBootSequence(hyperion, 100, duration_ms/100),
|
|
|
|
_processor(ImageProcessorFactory::getInstance().newImageProcessor()),
|
2013-11-11 10:00:37 +01:00
|
|
|
_image(9, 1, ColorRgb{0,0,0}),
|
|
|
|
_ledColors(hyperion->getLedCount(), ColorRgb{0,0,0}),
|
2013-09-09 17:24:36 +02:00
|
|
|
_forwardMove(false),
|
|
|
|
_currentLight(0)
|
|
|
|
{
|
|
|
|
// empty
|
|
|
|
}
|
|
|
|
|
|
|
|
KittBootSequence::~KittBootSequence()
|
|
|
|
{
|
|
|
|
delete _processor;
|
|
|
|
}
|
|
|
|
|
2013-11-11 10:00:37 +01:00
|
|
|
const std::vector<ColorRgb>& KittBootSequence::nextColors()
|
2013-09-09 17:24:36 +02:00
|
|
|
{
|
|
|
|
|
|
|
|
// Switch the previous light 'off'
|
2013-11-11 10:00:37 +01:00
|
|
|
_image(_currentLight, 0) = ColorRgb{0,0,0};
|
2013-09-09 17:24:36 +02:00
|
|
|
|
|
|
|
// Move the current to the next light
|
|
|
|
moveNextLight();
|
|
|
|
|
|
|
|
// Switch the current light 'on'
|
2013-11-11 10:00:37 +01:00
|
|
|
_image(_currentLight, 0) = ColorRgb{255,0,0};
|
2013-09-09 17:24:36 +02:00
|
|
|
|
|
|
|
|
|
|
|
// Translate the 'image' to led colors
|
|
|
|
_processor->process(_image, _ledColors);
|
|
|
|
|
|
|
|
// Return the colors
|
|
|
|
return _ledColors;
|
|
|
|
}
|
|
|
|
|
|
|
|
void KittBootSequence::moveNextLight()
|
|
|
|
{
|
|
|
|
// Increase/Decrease the current light
|
|
|
|
if (_forwardMove)
|
|
|
|
{
|
|
|
|
++_currentLight;
|
|
|
|
if (_currentLight == _image.width())
|
|
|
|
{
|
|
|
|
_forwardMove = false;
|
|
|
|
--_currentLight;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (_currentLight == 0)
|
|
|
|
{
|
|
|
|
_forwardMove = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
--_currentLight;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|