leddevice refactoring. code style and extension of baseclass to avoid dups (#174)

This commit is contained in:
redPanther
2016-08-14 10:46:44 +02:00
committed by GitHub
parent bc0c9c469f
commit 97181fa83c
63 changed files with 483 additions and 533 deletions

View File

@@ -11,22 +11,21 @@
// hyperion local includes
#include "LedDeviceP9813.h"
LedDeviceP9813::LedDeviceP9813(const std::string& outputDevice, const unsigned baudrate) :
LedSpiDevice(outputDevice, baudrate, 0),
_ledCount(0)
LedDeviceP9813::LedDeviceP9813(const std::string& outputDevice, const unsigned baudrate)
: LedSpiDevice(outputDevice, baudrate, 0)
{
// empty
}
int LedDeviceP9813::write(const std::vector<ColorRgb> &ledValues)
{
if (_ledCount != ledValues.size())
if (_ledCount != (signed)ledValues.size())
{
_ledBuf.resize(ledValues.size() * 4 + 8, 0x00);
_ledBuffer.resize(ledValues.size() * 4 + 8, 0x00);
_ledCount = ledValues.size();
}
uint8_t * dataPtr = _ledBuf.data();
uint8_t * dataPtr = _ledBuffer.data();
for (const ColorRgb & color : ledValues)
{
*dataPtr++ = calculateChecksum(color);
@@ -35,7 +34,7 @@ int LedDeviceP9813::write(const std::vector<ColorRgb> &ledValues)
*dataPtr++ = color.red;
}
return writeBytes(_ledBuf.size(), _ledBuf.data());
return writeBytes(_ledBuffer.size(), _ledBuffer.data());
}
int LedDeviceP9813::switchOff()