hyperion.ng/libsrc/leddevice/LedDevicePaintpack.cpp
redPanther 5aac2be702 Leddevice refactoring the next next part (#263)
* switch rs232 provider to completly async transfer

* start of implementing a seperate init function for leddevices

* rename setconfig to init

* more fixes

* implement missing code

* fix code style

* remove debug  code

* remove  debug stuff

* set loglevel to original state
2016-10-08 08:14:36 +02:00

35 lines
748 B
C++

#include "LedDevicePaintpack.h"
// Use out report HID device
LedDevicePaintpack::LedDevicePaintpack(const Json::Value &deviceConfig)
: ProviderHID()
{
ProviderHID::init(deviceConfig);
_useFeature = false;
_ledBuffer.resize(_ledRGBCount + 2, uint8_t(0));
_ledBuffer[0] = 3;
_ledBuffer[1] = 0;
}
LedDevice* LedDevicePaintpack::construct(const Json::Value &deviceConfig)
{
return new LedDevicePaintpack(deviceConfig);
}
int LedDevicePaintpack::write(const std::vector<ColorRgb> & ledValues)
{
auto bufIt = _ledBuffer.begin()+2;
for (const ColorRgb & color : ledValues)
{
*bufIt = color.red;
++bufIt;
*bufIt = color.green;
++bufIt;
*bufIt = color.blue;
++bufIt;
}
return writeBytes(_ledBuffer.size(), _ledBuffer.data());
}