mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
leddevice refactoring. code style and extension of baseclass to avoid dups (#174)
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user