mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
a567f0feeb
Implemented KnightRider bootsequence (KittBootSequence).
68 lines
1.2 KiB
C++
68 lines
1.2 KiB
C++
|
|
// 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()),
|
|
_image(9, 1),
|
|
_ledColors(hyperion->getLedCount(), RgbColor::BLACK),
|
|
_forwardMove(false),
|
|
_currentLight(0)
|
|
{
|
|
// empty
|
|
}
|
|
|
|
KittBootSequence::~KittBootSequence()
|
|
{
|
|
delete _processor;
|
|
}
|
|
|
|
const std::vector<RgbColor>& KittBootSequence::nextColors()
|
|
{
|
|
|
|
// Switch the previous light 'off'
|
|
_image(_currentLight, 0) = RgbColor::BLACK;
|
|
|
|
// Move the current to the next light
|
|
moveNextLight();
|
|
|
|
// Switch the current light 'on'
|
|
_image(_currentLight, 0) = RgbColor::RED;
|
|
|
|
|
|
// 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;
|
|
}
|
|
}
|
|
}
|