mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
cc8185691a
%s/LedUdpDevice/ProviderUdp/g git mv LedUdpDevice.cpp ProviderUdp.cpp git mv LedUdpDevice.h ProviderUdp.h vi `grep -l LedHID *` %s/LedHIDDevice/ProviderHID/g git mv LedHIDDevice.cpp ProviderHID.cpp git mv LedHIDDevice.h ProviderHID.h vi `grep -l LedRs *` %s/LedRs232Device/ProviderRs232/g git mv LedRs232Device.cpp ProviderRs232.cpp git mv LedRs232Device.h ProviderRs232.h vi `grep -l LedSpi *` %s/LedSpiDevice/ProviderSpi/g git mv LedSpiDevice.cpp ProviderSpi.cpp git mv LedSpiDevice.h ProviderSpi.h
40 lines
1.1 KiB
C++
40 lines
1.1 KiB
C++
// hyperion local includes
|
|
#include "LedDeviceAtmo.h"
|
|
|
|
LedDeviceAtmo::LedDeviceAtmo(const Json::Value &deviceConfig)
|
|
: ProviderRs232(deviceConfig)
|
|
{
|
|
_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)
|
|
}
|
|
|
|
LedDevice* LedDeviceAtmo::construct(const Json::Value &deviceConfig)
|
|
{
|
|
return new LedDeviceAtmo(deviceConfig);
|
|
}
|
|
|
|
|
|
int LedDeviceAtmo::write(const std::vector<ColorRgb> &ledValues)
|
|
{
|
|
// The protocol is shomehow limited. we always need to send exactly 5 channels + header
|
|
// (19 bytes) for the hardware to recognize the data
|
|
if (ledValues.size() != 5)
|
|
{
|
|
Error( _log, "%d channels configured. This should always be 5!", ledValues.size());
|
|
return 0;
|
|
}
|
|
|
|
// write data
|
|
memcpy(4 + _ledBuffer.data(), ledValues.data(), ledValues.size() * sizeof(ColorRgb));
|
|
return writeBytes(_ledBuffer.size(), _ledBuffer.data());
|
|
}
|
|
|
|
int LedDeviceAtmo::switchOff()
|
|
{
|
|
memset(4 + _ledBuffer.data(), 0, _ledBuffer.size() - 4);
|
|
return writeBytes(_ledBuffer.size(), _ledBuffer.data());
|
|
}
|