2016-05-30 23:58:31 +02:00
|
|
|
|
|
|
|
// STL includes
|
|
|
|
#include <cstring>
|
|
|
|
#include <cstdio>
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
// Linux includes
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
|
|
|
|
// hyperion local includes
|
|
|
|
#include "LedDeviceUdpRaw.h"
|
|
|
|
|
2016-08-23 20:07:12 +02:00
|
|
|
LedDeviceUdpRaw::LedDeviceUdpRaw(const Json::Value &deviceConfig)
|
|
|
|
: LedUdpDevice(deviceConfig)
|
2016-05-30 23:58:31 +02:00
|
|
|
{
|
2016-08-23 20:07:12 +02:00
|
|
|
setConfig(deviceConfig);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool LedDeviceUdpRaw::setConfig(const Json::Value &deviceConfig)
|
|
|
|
{
|
|
|
|
LedUdpDevice::setConfig(deviceConfig);
|
|
|
|
_LatchTime_ns = deviceConfig.get("latchtime",500000).asInt();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
LedDevice* LedDeviceUdpRaw::construct(const Json::Value &deviceConfig)
|
|
|
|
{
|
|
|
|
return new LedDeviceUdpRaw(deviceConfig);
|
2016-05-30 23:58:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int LedDeviceUdpRaw::write(const std::vector<ColorRgb> &ledValues)
|
|
|
|
{
|
2016-08-14 10:46:44 +02:00
|
|
|
_ledCount = ledValues.size();
|
2016-05-30 23:58:31 +02:00
|
|
|
|
2016-08-14 10:46:44 +02:00
|
|
|
const unsigned dataLen = _ledCount * sizeof(ColorRgb);
|
2016-05-30 23:58:31 +02:00
|
|
|
const uint8_t * dataPtr = reinterpret_cast<const uint8_t *>(ledValues.data());
|
|
|
|
|
|
|
|
return writeBytes(dataLen, dataPtr);
|
|
|
|
}
|
|
|
|
|
|
|
|
int LedDeviceUdpRaw::switchOff()
|
|
|
|
{
|
2016-08-14 10:46:44 +02:00
|
|
|
return write(std::vector<ColorRgb>(_ledCount, ColorRgb{0,0,0}));
|
2016-05-30 23:58:31 +02:00
|
|
|
}
|