mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Changed RgbImage to template based Image (with template for pixel type)
Former-commit-id: ef02f164eaf3c2f9dd552c1c17b525cf6eed499c
This commit is contained in:
@@ -26,7 +26,7 @@ void AbstractBootSequence::update()
|
||||
}
|
||||
|
||||
// Obtain the next led-colors from the child-class
|
||||
const std::vector<RgbColor>& colors = nextColors();
|
||||
const std::vector<ColorRgb>& colors = nextColors();
|
||||
// Write the colors to hyperion
|
||||
_hyperion->setColors(_priority, colors, -1);
|
||||
|
||||
|
@@ -45,7 +45,7 @@ protected:
|
||||
///
|
||||
/// @return The next led colors in the boot sequence
|
||||
///
|
||||
virtual const std::vector<RgbColor>& nextColors() = 0;
|
||||
virtual const std::vector<ColorRgb>& nextColors() = 0;
|
||||
|
||||
private:
|
||||
/// The timer used to generate an 'update' signal every interval
|
||||
|
@@ -8,8 +8,8 @@
|
||||
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),
|
||||
_image(9, 1, ColorRgb{0,0,0}),
|
||||
_ledColors(hyperion->getLedCount(), ColorRgb{0,0,0}),
|
||||
_forwardMove(false),
|
||||
_currentLight(0)
|
||||
{
|
||||
@@ -21,17 +21,17 @@ KittBootSequence::~KittBootSequence()
|
||||
delete _processor;
|
||||
}
|
||||
|
||||
const std::vector<RgbColor>& KittBootSequence::nextColors()
|
||||
const std::vector<ColorRgb>& KittBootSequence::nextColors()
|
||||
{
|
||||
|
||||
// Switch the previous light 'off'
|
||||
_image(_currentLight, 0) = RgbColor::BLACK;
|
||||
_image(_currentLight, 0) = ColorRgb{0,0,0};
|
||||
|
||||
// Move the current to the next light
|
||||
moveNextLight();
|
||||
|
||||
// Switch the current light 'on'
|
||||
_image(_currentLight, 0) = RgbColor::RED;
|
||||
_image(_currentLight, 0) = ColorRgb{255,0,0};
|
||||
|
||||
|
||||
// Translate the 'image' to led colors
|
||||
|
@@ -33,17 +33,17 @@ public:
|
||||
///
|
||||
/// @return The next colors for the leds
|
||||
///
|
||||
virtual const std::vector<RgbColor>& nextColors();
|
||||
virtual const std::vector<ColorRgb>& nextColors();
|
||||
|
||||
private:
|
||||
/// Image processor to compute led-colors from the image
|
||||
ImageProcessor * _processor;
|
||||
|
||||
/// 1D-Image of the KITT-grill contains a single red pixel and the rest black
|
||||
RgbImage _image;
|
||||
Image<ColorRgb> _image;
|
||||
|
||||
/// The vector with led-colors
|
||||
std::vector<RgbColor> _ledColors;
|
||||
std::vector<ColorRgb> _ledColors;
|
||||
|
||||
/// Direction the red-light is currently moving
|
||||
bool _forwardMove = true;
|
||||
|
@@ -11,15 +11,15 @@ RainbowBootSequence::RainbowBootSequence(Hyperion * hyperion, const unsigned dur
|
||||
{
|
||||
for (unsigned iLed=0; iLed<hyperion->getLedCount(); ++iLed)
|
||||
{
|
||||
RgbColor& color = _ledColors[iLed];
|
||||
ColorRgb& color = _ledColors[iLed];
|
||||
HsvTransform::hsv2rgb(iLed*360/hyperion->getLedCount(), 255, 255, color.red, color.green, color.blue);
|
||||
}
|
||||
}
|
||||
|
||||
const std::vector<RgbColor>& RainbowBootSequence::nextColors()
|
||||
const std::vector<ColorRgb>& RainbowBootSequence::nextColors()
|
||||
{
|
||||
// Rotate the colors left
|
||||
const RgbColor headColor = _ledColors.front();
|
||||
const ColorRgb headColor = _ledColors.front();
|
||||
for (unsigned i=1; i<_ledColors.size(); ++i)
|
||||
{
|
||||
_ledColors[i-1] = _ledColors[i];
|
||||
|
@@ -27,11 +27,11 @@ protected:
|
||||
///
|
||||
/// Moves the rainbow one led further
|
||||
///
|
||||
const std::vector<RgbColor>& nextColors();
|
||||
const std::vector<ColorRgb>& nextColors();
|
||||
|
||||
private:
|
||||
/// The current color of the boot sequence (the rainbow)
|
||||
std::vector<RgbColor> _ledColors;
|
||||
std::vector<ColorRgb> _ledColors;
|
||||
/// The counter of the number of iterations left
|
||||
int _iterationCounter;
|
||||
};
|
||||
|
Reference in New Issue
Block a user