2015-11-08 16:31:18 +01:00
|
|
|
#include "LedDeviceRawHID.h"
|
|
|
|
|
|
|
|
// Use feature report HID device
|
2016-10-13 21:59:58 +02:00
|
|
|
LedDeviceRawHID::LedDeviceRawHID(const QJsonObject &deviceConfig)
|
2016-10-08 08:14:36 +02:00
|
|
|
: ProviderHID()
|
2015-11-08 16:31:18 +01:00
|
|
|
{
|
2016-10-08 08:14:36 +02:00
|
|
|
ProviderHID::init(deviceConfig);
|
2016-08-23 20:07:12 +02:00
|
|
|
_useFeature = true;
|
2016-10-08 08:14:36 +02:00
|
|
|
_ledBuffer.resize(_ledRGBCount);
|
2015-11-08 16:31:18 +01:00
|
|
|
}
|
|
|
|
|
2016-10-13 21:59:58 +02:00
|
|
|
LedDevice* LedDeviceRawHID::construct(const QJsonObject &deviceConfig)
|
2016-08-23 20:07:12 +02:00
|
|
|
{
|
|
|
|
return new LedDeviceRawHID(deviceConfig);
|
|
|
|
}
|
|
|
|
|
2015-11-08 16:31:18 +01:00
|
|
|
int LedDeviceRawHID::write(const std::vector<ColorRgb> & ledValues)
|
|
|
|
{
|
|
|
|
// write data
|
2016-10-08 08:14:36 +02:00
|
|
|
memcpy(_ledBuffer.data(), ledValues.data(), _ledRGBCount);
|
2015-11-08 16:31:18 +01:00
|
|
|
return writeBytes(_ledBuffer.size(), _ledBuffer.data());
|
|
|
|
}
|
|
|
|
|
|
|
|
void LedDeviceRawHID::rewriteLeds()
|
|
|
|
{
|
|
|
|
writeBytes(_ledBuffer.size(), _ledBuffer.data());
|
|
|
|
}
|