hyperion.ng/libsrc/leddevice/LedDeviceWs2801.cpp
penfold42 080059cbf5 Added latchtime web configuration for ws2801 device. (#302)
* Added latchtime web configuration for ws2801 device.
Fixed default to be 500000ns

* cleaner code using defaults and added "ns" to web schema

* oops... "ns" not "ms"
2016-12-01 10:00:52 +01:00

22 lines
558 B
C++

#include "LedDeviceWs2801.h"
LedDeviceWs2801::LedDeviceWs2801(const QJsonObject &deviceConfig)
: ProviderSpi()
{
_latchTime_ns = 500000;
_deviceReady = ProviderSpi::init(deviceConfig);
}
LedDevice* LedDeviceWs2801::construct(const QJsonObject &deviceConfig)
{
return new LedDeviceWs2801(deviceConfig);
}
int LedDeviceWs2801::write(const std::vector<ColorRgb> &ledValues)
{
const unsigned dataLen = _ledCount * sizeof(ColorRgb);
const uint8_t * dataPtr = reinterpret_cast<const uint8_t *>(ledValues.data());
return writeBytes(dataLen, dataPtr);
}