mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
5aac2be702
* 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
40 lines
889 B
C++
40 lines
889 B
C++
#include "LedDeviceRawHID.h"
|
|
|
|
// Use feature report HID device
|
|
LedDeviceRawHID::LedDeviceRawHID(const Json::Value &deviceConfig)
|
|
: ProviderHID()
|
|
, _timer()
|
|
{
|
|
ProviderHID::init(deviceConfig);
|
|
_useFeature = true;
|
|
_ledBuffer.resize(_ledRGBCount);
|
|
|
|
// setup the timer
|
|
_timer.setSingleShot(false);
|
|
_timer.setInterval(5000);
|
|
connect(&_timer, SIGNAL(timeout()), this, SLOT(rewriteLeds()));
|
|
|
|
// start the timer
|
|
_timer.start();
|
|
}
|
|
|
|
LedDevice* LedDeviceRawHID::construct(const Json::Value &deviceConfig)
|
|
{
|
|
return new LedDeviceRawHID(deviceConfig);
|
|
}
|
|
|
|
int LedDeviceRawHID::write(const std::vector<ColorRgb> & ledValues)
|
|
{
|
|
// restart the timer
|
|
_timer.start();
|
|
|
|
// write data
|
|
memcpy(_ledBuffer.data(), ledValues.data(), _ledRGBCount);
|
|
return writeBytes(_ledBuffer.size(), _ledBuffer.data());
|
|
}
|
|
|
|
void LedDeviceRawHID::rewriteLeds()
|
|
{
|
|
writeBytes(_ledBuffer.size(), _ledBuffer.data());
|
|
}
|