2013-07-26 22:38:34 +02:00
|
|
|
#include "LedDeviceWs2801.h"
|
|
|
|
|
2016-10-13 21:59:58 +02:00
|
|
|
LedDeviceWs2801::LedDeviceWs2801(const QJsonObject &deviceConfig)
|
2016-10-08 08:14:36 +02:00
|
|
|
: ProviderSpi()
|
2016-02-13 13:00:31 +01:00
|
|
|
{
|
2020-02-10 15:21:58 +01:00
|
|
|
_devConfig = deviceConfig;
|
2020-07-12 20:27:56 +02:00
|
|
|
_isDeviceReady = false;
|
|
|
|
|
|
|
|
_activeDeviceType = deviceConfig["type"].toString("UNSPECIFIED").toLower();
|
2016-08-23 20:07:12 +02:00
|
|
|
}
|
|
|
|
|
2016-10-13 21:59:58 +02:00
|
|
|
LedDevice* LedDeviceWs2801::construct(const QJsonObject &deviceConfig)
|
2016-08-23 20:07:12 +02:00
|
|
|
{
|
|
|
|
return new LedDeviceWs2801(deviceConfig);
|
2016-02-13 13:00:31 +01:00
|
|
|
}
|
|
|
|
|
2020-02-10 15:21:58 +01:00
|
|
|
bool LedDeviceWs2801::init(const QJsonObject &deviceConfig)
|
|
|
|
{
|
|
|
|
bool isInitOK = ProviderSpi::init(deviceConfig);
|
|
|
|
return isInitOK;
|
|
|
|
}
|
|
|
|
|
2013-11-11 10:00:37 +01:00
|
|
|
int LedDeviceWs2801::write(const std::vector<ColorRgb> &ledValues)
|
2013-07-26 22:38:34 +02:00
|
|
|
{
|
2016-09-23 08:49:22 +02:00
|
|
|
const unsigned dataLen = _ledCount * sizeof(ColorRgb);
|
2013-11-02 19:30:19 +01:00
|
|
|
const uint8_t * dataPtr = reinterpret_cast<const uint8_t *>(ledValues.data());
|
2013-07-26 22:38:34 +02:00
|
|
|
|
2013-11-02 19:30:19 +01:00
|
|
|
return writeBytes(dataLen, dataPtr);
|
2013-07-26 22:38:34 +02:00
|
|
|
}
|