mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
* - disable device when error indecates that the problem is not solvable on reconnect
- introduce a preOpenDelay of 2 seconds (currently value is hardcoded)
* rs232:
- make preOpenDelay available via webui
- fix preOpenDelay
- add basic usb serial detection
* - revert 3819ae7
- fix schema files
* make json checks compat with utf8+bom
* make shutdown effect a bit more flexible
53 lines
1.1 KiB
C++
53 lines
1.1 KiB
C++
#include "LedDeviceSedu.h"
|
|
|
|
struct FrameSpec
|
|
{
|
|
uint8_t id;
|
|
size_t size;
|
|
};
|
|
|
|
LedDeviceSedu::LedDeviceSedu(const QJsonObject &deviceConfig)
|
|
: ProviderRs232()
|
|
{
|
|
_deviceReady = init(deviceConfig);
|
|
}
|
|
|
|
LedDevice* LedDeviceSedu::construct(const QJsonObject &deviceConfig)
|
|
{
|
|
return new LedDeviceSedu(deviceConfig);
|
|
}
|
|
|
|
bool LedDeviceSedu::init(const QJsonObject &deviceConfig)
|
|
{
|
|
ProviderRs232::init(deviceConfig);
|
|
|
|
std::vector<FrameSpec> frameSpecs{{0xA1, 256}, {0xA2, 512}, {0xB0, 768}, {0xB1, 1536}, {0xB2, 3072} };
|
|
|
|
for (const FrameSpec& frameSpec : frameSpecs)
|
|
{
|
|
if ((unsigned)_ledRGBCount <= frameSpec.size)
|
|
{
|
|
_ledBuffer.clear();
|
|
_ledBuffer.resize(frameSpec.size + 3, 0);
|
|
_ledBuffer[0] = 0x5A;
|
|
_ledBuffer[1] = frameSpec.id;
|
|
_ledBuffer.back() = 0xA5;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (_ledBuffer.size() == 0)
|
|
{
|
|
Warning(_log, "More rgb-channels required then available");
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
int LedDeviceSedu::write(const std::vector<ColorRgb> &ledValues)
|
|
{
|
|
memcpy(_ledBuffer.data()+2, ledValues.data(), ledValues.size() * sizeof(ColorRgb));
|
|
return writeBytes(_ledBuffer.size(), _ledBuffer.data());
|
|
}
|