Changed RgbImage to template based Image (with template for pixel type)

Former-commit-id: ef02f164eaf3c2f9dd552c1c17b525cf6eed499c
This commit is contained in:
T. van der Zwan
2013-11-11 09:00:37 +00:00
parent 90f1f282e2
commit dd16af0df5
58 changed files with 593 additions and 464 deletions

View File

@@ -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);

View File

@@ -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

View File

@@ -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

View File

@@ -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;

View File

@@ -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];

View File

@@ -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;
};