2013-08-23 18:24:10 +02:00
|
|
|
|
2013-08-25 18:20:19 +02:00
|
|
|
// Utils includes
|
2013-08-23 18:24:10 +02:00
|
|
|
#include <utils/HsvTransform.h>
|
|
|
|
|
2013-08-25 18:20:19 +02:00
|
|
|
// Local-Bootsequence include
|
|
|
|
#include "RainbowBootSequence.h"
|
2013-08-23 18:24:10 +02:00
|
|
|
|
2013-08-25 18:20:19 +02:00
|
|
|
RainbowBootSequence::RainbowBootSequence(Hyperion * hyperion, const unsigned duration_ms) :
|
2013-09-09 17:24:36 +02:00
|
|
|
AbstractBootSequence(hyperion, duration_ms/hyperion->getLedCount(), hyperion->getLedCount()),
|
|
|
|
_ledColors(hyperion->getLedCount())
|
2013-08-23 18:24:10 +02:00
|
|
|
{
|
2013-09-09 17:24:36 +02:00
|
|
|
for (unsigned iLed=0; iLed<hyperion->getLedCount(); ++iLed)
|
2013-08-23 18:24:10 +02:00
|
|
|
{
|
|
|
|
RgbColor& color = _ledColors[iLed];
|
2013-09-09 17:24:36 +02:00
|
|
|
HsvTransform::hsv2rgb(iLed*360/hyperion->getLedCount(), 255, 255, color.red, color.green, color.blue);
|
2013-08-23 18:24:10 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-09 17:24:36 +02:00
|
|
|
const std::vector<RgbColor>& RainbowBootSequence::nextColors()
|
2013-08-23 18:24:10 +02:00
|
|
|
{
|
2013-09-09 17:24:36 +02:00
|
|
|
// Rotate the colors left
|
|
|
|
const RgbColor headColor = _ledColors.front();
|
|
|
|
for (unsigned i=1; i<_ledColors.size(); ++i)
|
2013-08-23 18:24:10 +02:00
|
|
|
{
|
2013-09-09 17:24:36 +02:00
|
|
|
_ledColors[i-1] = _ledColors[i];
|
2013-08-23 18:24:10 +02:00
|
|
|
}
|
2013-09-09 17:24:36 +02:00
|
|
|
_ledColors.back() = headColor;
|
2013-08-23 18:24:10 +02:00
|
|
|
|
2013-09-09 17:24:36 +02:00
|
|
|
return _ledColors;
|
2013-08-23 18:24:10 +02:00
|
|
|
}
|