hyperion.ng/libsrc/leddevice/LedDeviceUdpRaw.cpp
penfold42 cc8185691a Renamed the lowlevel providers from LedXXXDevice to ProviderXXX (#206)
%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
2016-08-28 07:12:47 +02:00

47 lines
1007 B
C++

// STL includes
#include <cstring>
#include <cstdio>
#include <iostream>
// Linux includes
#include <fcntl.h>
#include <sys/ioctl.h>
// hyperion local includes
#include "LedDeviceUdpRaw.h"
LedDeviceUdpRaw::LedDeviceUdpRaw(const Json::Value &deviceConfig)
: ProviderUdp(deviceConfig)
{
setConfig(deviceConfig);
}
bool LedDeviceUdpRaw::setConfig(const Json::Value &deviceConfig)
{
ProviderUdp::setConfig(deviceConfig);
_LatchTime_ns = deviceConfig.get("latchtime",500000).asInt();
return true;
}
LedDevice* LedDeviceUdpRaw::construct(const Json::Value &deviceConfig)
{
return new LedDeviceUdpRaw(deviceConfig);
}
int LedDeviceUdpRaw::write(const std::vector<ColorRgb> &ledValues)
{
_ledCount = ledValues.size();
const unsigned dataLen = _ledCount * sizeof(ColorRgb);
const uint8_t * dataPtr = reinterpret_cast<const uint8_t *>(ledValues.data());
return writeBytes(dataLen, dataPtr);
}
int LedDeviceUdpRaw::switchOff()
{
return write(std::vector<ColorRgb>(_ledCount, ColorRgb{0,0,0}));
}