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:
@@ -17,7 +17,7 @@ LedDeviceLdp6803::LedDeviceLdp6803(const std::string& outputDevice, const unsign
|
||||
// empty
|
||||
}
|
||||
|
||||
int LedDeviceLdp6803::write(const std::vector<RgbColor> &ledValues)
|
||||
int LedDeviceLdp6803::write(const std::vector<ColorRgb> &ledValues)
|
||||
{
|
||||
// Reconfigure if the current connfiguration does not match the required configuration
|
||||
if (4 + 2*ledValues.size() != _ledBuffer.size())
|
||||
@@ -26,10 +26,10 @@ int LedDeviceLdp6803::write(const std::vector<RgbColor> &ledValues)
|
||||
_ledBuffer.resize(4 + 2*ledValues.size(), 0x00);
|
||||
}
|
||||
|
||||
// Copy the colors from the RgbColor vector to the Ldp6803 data vector
|
||||
// Copy the colors from the ColorRgb vector to the Ldp6803 data vector
|
||||
for (unsigned iLed=0; iLed<ledValues.size(); ++iLed)
|
||||
{
|
||||
const RgbColor& rgb = ledValues[iLed];
|
||||
const ColorRgb& rgb = ledValues[iLed];
|
||||
|
||||
_ledBuffer[4 + 2 * iLed] = 0x80 | ((rgb.red & 0xf8) >> 1) | (rgb.green >> 6);
|
||||
_ledBuffer[5 + 2 * iLed] = ((rgb.green & 0x38) << 2) | (rgb.blue >> 3);
|
||||
@@ -45,5 +45,5 @@ int LedDeviceLdp6803::write(const std::vector<RgbColor> &ledValues)
|
||||
|
||||
int LedDeviceLdp6803::switchOff()
|
||||
{
|
||||
return write(std::vector<RgbColor>(_ledBuffer.size(), RgbColor::BLACK));
|
||||
return write(std::vector<ColorRgb>(_ledBuffer.size(), ColorRgb{0,0,0}));
|
||||
}
|
||||
|
@@ -31,7 +31,7 @@ public:
|
||||
/// @param ledValues The color-value per led
|
||||
/// @return Zero on succes else negative
|
||||
///
|
||||
virtual int write(const std::vector<RgbColor> &ledValues);
|
||||
virtual int write(const std::vector<ColorRgb> &ledValues);
|
||||
|
||||
/// Switch the leds off
|
||||
virtual int switchOff();
|
||||
|
@@ -24,13 +24,13 @@ LedDeviceSedu::LedDeviceSedu(const std::string& outputDevice, const unsigned bau
|
||||
// empty
|
||||
}
|
||||
|
||||
int LedDeviceSedu::write(const std::vector<RgbColor> &ledValues)
|
||||
int LedDeviceSedu::write(const std::vector<ColorRgb> &ledValues)
|
||||
{
|
||||
if (_ledBuffer.size() == 0)
|
||||
{
|
||||
std::vector<FrameSpec> frameSpecs{{0xA0, 96}, {0xA1, 256}, {0xA2, 512}, {0xB0, 768}, {0xB1, 1536}, {0xB2, 3072} };
|
||||
|
||||
const unsigned reqColorChannels = ledValues.size() * sizeof(RgbColor);
|
||||
const unsigned reqColorChannels = ledValues.size() * sizeof(ColorRgb);
|
||||
|
||||
for (const FrameSpec& frameSpec : frameSpecs)
|
||||
{
|
||||
@@ -52,7 +52,7 @@ int LedDeviceSedu::write(const std::vector<RgbColor> &ledValues)
|
||||
}
|
||||
}
|
||||
|
||||
memcpy(_ledBuffer.data()+2, ledValues.data(), ledValues.size() * sizeof(RgbColor));
|
||||
memcpy(_ledBuffer.data()+2, ledValues.data(), ledValues.size() * sizeof(ColorRgb));
|
||||
return writeBytes(_ledBuffer.size(), _ledBuffer.data());
|
||||
}
|
||||
|
||||
|
@@ -26,7 +26,7 @@ public:
|
||||
/// @param ledValues The color-value per led
|
||||
/// @return Zero on succes else negative
|
||||
///
|
||||
virtual int write(const std::vector<RgbColor> &ledValues);
|
||||
virtual int write(const std::vector<ColorRgb> &ledValues);
|
||||
|
||||
/// Switch the leds off
|
||||
virtual int switchOff();
|
||||
|
@@ -13,10 +13,10 @@ LedDeviceTest::~LedDeviceTest()
|
||||
// empty
|
||||
}
|
||||
|
||||
int LedDeviceTest::write(const std::vector<RgbColor> & ledValues)
|
||||
int LedDeviceTest::write(const std::vector<ColorRgb> & ledValues)
|
||||
{
|
||||
_ofs << "[";
|
||||
for (const RgbColor& color : ledValues)
|
||||
for (const ColorRgb& color : ledValues)
|
||||
{
|
||||
_ofs << color;
|
||||
}
|
||||
|
@@ -30,7 +30,7 @@ public:
|
||||
///
|
||||
/// @return Zero on success else negative
|
||||
///
|
||||
virtual int write(const std::vector<RgbColor> & ledValues);
|
||||
virtual int write(const std::vector<ColorRgb> & ledValues);
|
||||
|
||||
/// Switch the leds off
|
||||
virtual int switchOff();
|
||||
|
@@ -18,11 +18,11 @@ LedDeviceWs2801::LedDeviceWs2801(const std::string& outputDevice, const unsigned
|
||||
// empty
|
||||
}
|
||||
|
||||
int LedDeviceWs2801::write(const std::vector<RgbColor> &ledValues)
|
||||
int LedDeviceWs2801::write(const std::vector<ColorRgb> &ledValues)
|
||||
{
|
||||
mLedCount = ledValues.size();
|
||||
|
||||
const unsigned dataLen = ledValues.size() * sizeof(RgbColor);
|
||||
const unsigned dataLen = ledValues.size() * sizeof(ColorRgb);
|
||||
const uint8_t * dataPtr = reinterpret_cast<const uint8_t *>(ledValues.data());
|
||||
|
||||
return writeBytes(dataLen, dataPtr);
|
||||
@@ -30,5 +30,5 @@ int LedDeviceWs2801::write(const std::vector<RgbColor> &ledValues)
|
||||
|
||||
int LedDeviceWs2801::switchOff()
|
||||
{
|
||||
return write(std::vector<RgbColor>(mLedCount, RgbColor::BLACK));
|
||||
return write(std::vector<ColorRgb>(mLedCount, ColorRgb{0,0,0}));
|
||||
}
|
||||
|
@@ -27,7 +27,7 @@ public:
|
||||
/// @param ledValues The color-value per led
|
||||
/// @return Zero on succes else negative
|
||||
///
|
||||
virtual int write(const std::vector<RgbColor> &ledValues);
|
||||
virtual int write(const std::vector<ColorRgb> &ledValues);
|
||||
|
||||
/// Switch the leds off
|
||||
virtual int switchOff();
|
||||
|
Reference in New Issue
Block a user