2013-12-10 20:28:27 +01:00
|
|
|
#include "LedDevicePaintpack.h"
|
|
|
|
|
2015-11-08 16:32:53 +01:00
|
|
|
// Use out report HID device
|
2016-08-23 20:07:12 +02:00
|
|
|
LedDevicePaintpack::LedDevicePaintpack(const Json::Value &deviceConfig)
|
2016-10-08 08:14:36 +02:00
|
|
|
: ProviderHID()
|
2013-12-10 20:28:27 +01:00
|
|
|
{
|
2016-10-08 08:14:36 +02:00
|
|
|
ProviderHID::init(deviceConfig);
|
2016-08-23 20:07:12 +02:00
|
|
|
_useFeature = false;
|
2016-10-08 08:14:36 +02:00
|
|
|
|
|
|
|
_ledBuffer.resize(_ledRGBCount + 2, uint8_t(0));
|
|
|
|
_ledBuffer[0] = 3;
|
|
|
|
_ledBuffer[1] = 0;
|
2013-12-10 20:28:27 +01:00
|
|
|
}
|
|
|
|
|
2016-08-23 20:07:12 +02:00
|
|
|
LedDevice* LedDevicePaintpack::construct(const Json::Value &deviceConfig)
|
|
|
|
{
|
|
|
|
return new LedDevicePaintpack(deviceConfig);
|
|
|
|
}
|
2013-12-10 20:28:27 +01:00
|
|
|
|
2015-11-08 16:32:53 +01:00
|
|
|
int LedDevicePaintpack::write(const std::vector<ColorRgb> & ledValues)
|
2013-12-10 20:28:27 +01:00
|
|
|
{
|
2015-11-08 16:32:53 +01:00
|
|
|
auto bufIt = _ledBuffer.begin()+2;
|
2016-09-23 08:49:22 +02:00
|
|
|
for (const ColorRgb & color : ledValues)
|
2013-12-10 20:28:27 +01:00
|
|
|
{
|
2016-09-23 08:49:22 +02:00
|
|
|
*bufIt = color.red;
|
2013-12-10 20:28:27 +01:00
|
|
|
++bufIt;
|
2016-09-23 08:49:22 +02:00
|
|
|
*bufIt = color.green;
|
2013-12-10 20:28:27 +01:00
|
|
|
++bufIt;
|
2016-09-23 08:49:22 +02:00
|
|
|
*bufIt = color.blue;
|
2013-12-10 20:28:27 +01:00
|
|
|
++bufIt;
|
|
|
|
}
|
|
|
|
|
2015-11-08 16:32:53 +01:00
|
|
|
return writeBytes(_ledBuffer.size(), _ledBuffer.data());
|
2013-12-10 20:28:27 +01:00
|
|
|
}
|