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
1007 B
C++
40 lines
1007 B
C++
// hyperion local includes
|
|
#include "LedDeviceAtmo.h"
|
|
|
|
LedDeviceAtmo::LedDeviceAtmo(const Json::Value &deviceConfig)
|
|
: ProviderRs232()
|
|
{
|
|
_deviceReady = init(deviceConfig);
|
|
}
|
|
|
|
LedDevice* LedDeviceAtmo::construct(const Json::Value &deviceConfig)
|
|
{
|
|
return new LedDeviceAtmo(deviceConfig);
|
|
}
|
|
|
|
bool LedDeviceAtmo::init(const Json::Value &deviceConfig)
|
|
{
|
|
ProviderRs232::init(deviceConfig);
|
|
|
|
if (_ledCount != 5)
|
|
{
|
|
Error( _log, "%d channels configured. This should always be 5!", _ledCount);
|
|
return 0;
|
|
}
|
|
|
|
_ledBuffer.resize(4 + 5*3); // 4-byte header, 5 RGB values
|
|
_ledBuffer[0] = 0xFF; // Startbyte
|
|
_ledBuffer[1] = 0x00; // StartChannel(Low)
|
|
_ledBuffer[2] = 0x00; // StartChannel(High)
|
|
_ledBuffer[3] = 0x0F; // Number of Databytes send (always! 15)
|
|
|
|
return true;
|
|
}
|
|
|
|
int LedDeviceAtmo::write(const std::vector<ColorRgb> &ledValues)
|
|
{
|
|
memcpy(4 + _ledBuffer.data(), ledValues.data(), _ledCount * sizeof(ColorRgb));
|
|
return writeBytes(_ledBuffer.size(), _ledBuffer.data());
|
|
}
|
|
|