2020-07-12 20:27:56 +02:00
|
|
|
// Local-Hyperion includes
|
|
|
|
#include "LedDeviceWled.h"
|
|
|
|
|
|
|
|
#include <utils/QStringUtils.h>
|
2021-03-19 22:52:04 +01:00
|
|
|
#include <utils/WaitTime.h>
|
|
|
|
#include <QThread>
|
|
|
|
|
|
|
|
#include <chrono>
|
2020-07-12 20:27:56 +02:00
|
|
|
|
|
|
|
// Constants
|
|
|
|
namespace {
|
|
|
|
|
2021-08-31 10:55:32 +02:00
|
|
|
const bool verbose = true;
|
2021-03-19 22:52:04 +01:00
|
|
|
|
2020-07-12 20:27:56 +02:00
|
|
|
// Configuration settings
|
|
|
|
const char CONFIG_ADDRESS[] = "host";
|
2021-03-19 22:52:04 +01:00
|
|
|
const char CONFIG_RESTORE_STATE[] = "restoreOriginalState";
|
2021-04-24 19:37:29 +02:00
|
|
|
const char CONFIG_BRIGHTNESS[] = "brightness";
|
|
|
|
const char CONFIG_BRIGHTNESS_OVERWRITE[] = "overwriteBrightness";
|
|
|
|
const char CONFIG_SYNC_OVERWRITE[] = "overwriteSync";
|
2020-07-12 20:27:56 +02:00
|
|
|
|
|
|
|
// UDP elements
|
|
|
|
const quint16 STREAM_DEFAULT_PORT = 19446;
|
|
|
|
|
|
|
|
// WLED JSON-API elements
|
|
|
|
const int API_DEFAULT_PORT = -1; //Use default port per communication scheme
|
|
|
|
|
|
|
|
const char API_BASE_PATH[] = "/json/";
|
2020-11-14 17:58:56 +01:00
|
|
|
//const char API_PATH_INFO[] = "info";
|
2020-07-12 20:27:56 +02:00
|
|
|
const char API_PATH_STATE[] = "state";
|
|
|
|
|
|
|
|
// List of State Information
|
|
|
|
const char STATE_ON[] = "on";
|
|
|
|
const char STATE_VALUE_TRUE[] = "true";
|
|
|
|
const char STATE_VALUE_FALSE[] = "false";
|
2021-03-19 22:52:04 +01:00
|
|
|
const char STATE_LIVE[] = "live";
|
2020-07-12 20:27:56 +02:00
|
|
|
|
2021-04-24 19:37:29 +02:00
|
|
|
const bool DEFAULT_IS_RESTORE_STATE = false;
|
|
|
|
const bool DEFAULT_IS_BRIGHTNESS_OVERWRITE = true;
|
2021-03-19 22:52:04 +01:00
|
|
|
const int BRI_MAX = 255;
|
2021-04-24 19:37:29 +02:00
|
|
|
const bool DEFAULT_IS_SYNC_OVERWRITE = true;
|
2021-03-19 22:52:04 +01:00
|
|
|
|
|
|
|
constexpr std::chrono::milliseconds DEFAULT_IDENTIFY_TIME{ 2000 };
|
2020-07-12 20:27:56 +02:00
|
|
|
|
|
|
|
} //End of constants
|
|
|
|
|
|
|
|
LedDeviceWled::LedDeviceWled(const QJsonObject &deviceConfig)
|
2020-08-08 00:21:19 +02:00
|
|
|
: ProviderUdp(deviceConfig)
|
2020-07-12 20:27:56 +02:00
|
|
|
,_restApi(nullptr)
|
|
|
|
,_apiPort(API_DEFAULT_PORT)
|
2021-04-24 19:37:29 +02:00
|
|
|
,_isBrightnessOverwrite(DEFAULT_IS_BRIGHTNESS_OVERWRITE)
|
|
|
|
,_brightness (BRI_MAX)
|
|
|
|
,_isSyncOverwrite(DEFAULT_IS_SYNC_OVERWRITE)
|
|
|
|
,_originalStateUdpnSend(false)
|
|
|
|
,_originalStateUdpnRecv(true)
|
2020-07-12 20:27:56 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
LedDeviceWled::~LedDeviceWled()
|
|
|
|
{
|
2020-08-08 00:21:19 +02:00
|
|
|
delete _restApi;
|
|
|
|
_restApi = nullptr;
|
2020-07-12 20:27:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
LedDevice* LedDeviceWled::construct(const QJsonObject &deviceConfig)
|
|
|
|
{
|
|
|
|
return new LedDeviceWled(deviceConfig);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool LedDeviceWled::init(const QJsonObject &deviceConfig)
|
|
|
|
{
|
|
|
|
bool isInitOK = false;
|
|
|
|
|
|
|
|
// Initialise LedDevice sub-class, ProviderUdp::init will be executed later, if connectivity is defined
|
|
|
|
if ( LedDevice::init(deviceConfig) )
|
|
|
|
{
|
|
|
|
// Initialise LedDevice configuration and execution environment
|
2020-11-14 17:58:56 +01:00
|
|
|
int configuredLedCount = this->getLedCount();
|
2020-07-12 20:27:56 +02:00
|
|
|
Debug(_log, "DeviceType : %s", QSTRING_CSTR( this->getActiveDeviceType() ));
|
2020-11-14 17:58:56 +01:00
|
|
|
Debug(_log, "LedCount : %d", configuredLedCount);
|
2020-07-12 20:27:56 +02:00
|
|
|
Debug(_log, "ColorOrder : %s", QSTRING_CSTR( this->getColorOrder() ));
|
|
|
|
Debug(_log, "LatchTime : %d", this->getLatchTime());
|
|
|
|
|
2021-04-24 19:37:29 +02:00
|
|
|
_isRestoreOrigState = _devConfig[CONFIG_RESTORE_STATE].toBool(DEFAULT_IS_RESTORE_STATE);
|
|
|
|
_isSyncOverwrite = _devConfig[CONFIG_SYNC_OVERWRITE].toBool(DEFAULT_IS_SYNC_OVERWRITE);
|
|
|
|
_isBrightnessOverwrite = _devConfig[CONFIG_BRIGHTNESS_OVERWRITE].toBool(DEFAULT_IS_BRIGHTNESS_OVERWRITE);
|
|
|
|
_brightness = _devConfig[CONFIG_BRIGHTNESS].toInt(BRI_MAX);
|
|
|
|
|
2021-03-19 22:52:04 +01:00
|
|
|
Debug(_log, "RestoreOrigState : %d", _isRestoreOrigState);
|
2021-04-24 19:37:29 +02:00
|
|
|
Debug(_log, "Overwrite Sync. : %d", _isSyncOverwrite);
|
|
|
|
Debug(_log, "Overwrite Brightn.: %d", _isBrightnessOverwrite);
|
|
|
|
Debug(_log, "Set Brightness to : %d", _brightness);
|
2021-03-19 22:52:04 +01:00
|
|
|
|
2020-07-12 20:27:56 +02:00
|
|
|
//Set hostname as per configuration
|
2021-03-19 22:52:04 +01:00
|
|
|
QString hostName = deviceConfig[ CONFIG_ADDRESS ].toString();
|
2020-07-12 20:27:56 +02:00
|
|
|
|
|
|
|
//If host not configured the init fails
|
2021-03-19 22:52:04 +01:00
|
|
|
if ( hostName.isEmpty() )
|
2020-07-12 20:27:56 +02:00
|
|
|
{
|
|
|
|
this->setInError("No target hostname nor IP defined");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-03-19 22:52:04 +01:00
|
|
|
QStringList addressparts = QStringUtils::split(hostName,":", QStringUtils::SplitBehavior::SkipEmptyParts);
|
2020-07-12 20:27:56 +02:00
|
|
|
_hostname = addressparts[0];
|
|
|
|
if ( addressparts.size() > 1 )
|
|
|
|
{
|
|
|
|
_apiPort = addressparts[1].toInt();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_apiPort = API_DEFAULT_PORT;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( initRestAPI( _hostname, _apiPort ) )
|
|
|
|
{
|
|
|
|
// Update configuration with hostname without port
|
|
|
|
_devConfig["host"] = _hostname;
|
|
|
|
_devConfig["port"] = STREAM_DEFAULT_PORT;
|
|
|
|
|
|
|
|
isInitOK = ProviderUdp::init(_devConfig);
|
|
|
|
Debug(_log, "Hostname/IP : %s", QSTRING_CSTR( _hostname ));
|
|
|
|
Debug(_log, "Port : %d", _port);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return isInitOK;
|
|
|
|
}
|
|
|
|
|
2020-08-08 23:12:43 +02:00
|
|
|
bool LedDeviceWled::initRestAPI(const QString &hostname, int port)
|
2020-07-12 20:27:56 +02:00
|
|
|
{
|
|
|
|
bool isInitOK = false;
|
|
|
|
|
|
|
|
if ( _restApi == nullptr )
|
|
|
|
{
|
|
|
|
_restApi = new ProviderRestApi(hostname, port);
|
|
|
|
_restApi->setBasePath( API_BASE_PATH );
|
|
|
|
|
|
|
|
isInitOK = true;
|
|
|
|
}
|
|
|
|
return isInitOK;
|
|
|
|
}
|
|
|
|
|
2020-08-08 23:12:43 +02:00
|
|
|
QString LedDeviceWled::getOnOffRequest(bool isOn) const
|
2020-07-12 20:27:56 +02:00
|
|
|
{
|
|
|
|
QString state = isOn ? STATE_VALUE_TRUE : STATE_VALUE_FALSE;
|
2021-03-19 22:52:04 +01:00
|
|
|
return QString( "\"%1\":%2,\"%3\":%4" ).arg( STATE_ON, state).arg( STATE_LIVE, state);
|
|
|
|
}
|
|
|
|
|
|
|
|
QString LedDeviceWled::getBrightnessRequest(int bri) const
|
|
|
|
{
|
|
|
|
return QString( "\"bri\":%1" ).arg(bri);
|
2020-07-12 20:27:56 +02:00
|
|
|
}
|
|
|
|
|
2021-03-19 22:52:04 +01:00
|
|
|
QString LedDeviceWled::getEffectRequest(int effect, int speed) const
|
|
|
|
{
|
|
|
|
return QString( "\"seg\":{\"fx\":%1,\"sx\":%2}" ).arg(effect).arg(speed);
|
|
|
|
}
|
|
|
|
|
|
|
|
QString LedDeviceWled::getLorRequest(int lor) const
|
|
|
|
{
|
|
|
|
return QString( "\"lor\":%1" ).arg(lor);
|
|
|
|
}
|
|
|
|
|
2021-04-24 19:37:29 +02:00
|
|
|
QString LedDeviceWled::getUdpnRequest(bool isSendOn, bool isRecvOn) const
|
|
|
|
{
|
|
|
|
QString send = isSendOn ? STATE_VALUE_TRUE : STATE_VALUE_FALSE;
|
|
|
|
QString recv = isRecvOn ? STATE_VALUE_TRUE : STATE_VALUE_FALSE;
|
|
|
|
return QString( "\"udpn\":{\"send\":%1,\"recv\":%2}" ).arg(send, recv);
|
|
|
|
}
|
|
|
|
|
2021-03-19 22:52:04 +01:00
|
|
|
bool LedDeviceWled::sendStateUpdateRequest(const QString &request)
|
|
|
|
{
|
|
|
|
bool rc = true;
|
|
|
|
|
|
|
|
_restApi->setPath(API_PATH_STATE);
|
|
|
|
|
|
|
|
httpResponse response1 = _restApi->put(QString("{%1}").arg(request));
|
|
|
|
if ( response1.error() )
|
|
|
|
{
|
|
|
|
rc = false;
|
|
|
|
}
|
|
|
|
return rc;
|
|
|
|
}
|
2020-07-12 20:27:56 +02:00
|
|
|
bool LedDeviceWled::powerOn()
|
|
|
|
{
|
2021-03-19 22:52:04 +01:00
|
|
|
bool on = false;
|
2020-07-12 20:27:56 +02:00
|
|
|
if ( _isDeviceReady)
|
|
|
|
{
|
|
|
|
//Power-on WLED device
|
|
|
|
_restApi->setPath(API_PATH_STATE);
|
2021-03-19 22:52:04 +01:00
|
|
|
|
2021-04-24 19:37:29 +02:00
|
|
|
QString cmd = getOnOffRequest(true);
|
|
|
|
|
|
|
|
if ( _isBrightnessOverwrite)
|
|
|
|
{
|
|
|
|
cmd += "," + getBrightnessRequest(_brightness);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_isSyncOverwrite)
|
|
|
|
{
|
|
|
|
Debug( _log, "Disable synchronisation with other WLED devices");
|
|
|
|
cmd += "," + getUdpnRequest(false, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
httpResponse response = _restApi->put(QString("{%1}").arg(cmd));
|
2020-07-12 20:27:56 +02:00
|
|
|
if ( response.error() )
|
|
|
|
{
|
2021-03-19 22:52:04 +01:00
|
|
|
QString errorReason = QString("Power-on request failed with error: '%1'").arg(response.getErrorReason());
|
|
|
|
this->setInError ( errorReason );
|
2020-07-12 20:27:56 +02:00
|
|
|
on = false;
|
|
|
|
}
|
2021-03-19 22:52:04 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
on = true;
|
|
|
|
}
|
2020-07-12 20:27:56 +02:00
|
|
|
}
|
|
|
|
return on;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool LedDeviceWled::powerOff()
|
|
|
|
{
|
|
|
|
bool off = true;
|
|
|
|
if ( _isDeviceReady)
|
|
|
|
{
|
|
|
|
// Write a final "Black" to have a defined outcome
|
|
|
|
writeBlack();
|
|
|
|
|
|
|
|
//Power-off the WLED device physically
|
|
|
|
_restApi->setPath(API_PATH_STATE);
|
2021-04-24 19:37:29 +02:00
|
|
|
|
|
|
|
QString cmd = getOnOffRequest(false);
|
|
|
|
|
|
|
|
if (_isSyncOverwrite)
|
|
|
|
{
|
|
|
|
Debug( _log, "Restore synchronisation with other WLED devices");
|
|
|
|
cmd += "," + getUdpnRequest(_originalStateUdpnSend, _originalStateUdpnRecv);
|
|
|
|
}
|
|
|
|
|
|
|
|
httpResponse response = _restApi->put(QString("{%1}").arg(cmd));
|
2020-07-12 20:27:56 +02:00
|
|
|
if ( response.error() )
|
|
|
|
{
|
2021-03-19 22:52:04 +01:00
|
|
|
QString errorReason = QString("Power-off request failed with error: '%1'").arg(response.getErrorReason());
|
|
|
|
this->setInError ( errorReason );
|
2020-07-12 20:27:56 +02:00
|
|
|
off = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return off;
|
|
|
|
}
|
|
|
|
|
2021-03-19 22:52:04 +01:00
|
|
|
bool LedDeviceWled::storeState()
|
2020-07-12 20:27:56 +02:00
|
|
|
{
|
2021-03-19 22:52:04 +01:00
|
|
|
bool rc = true;
|
2020-07-12 20:27:56 +02:00
|
|
|
|
2021-04-24 19:37:29 +02:00
|
|
|
if ( _isRestoreOrigState || _isSyncOverwrite )
|
2021-03-19 22:52:04 +01:00
|
|
|
{
|
|
|
|
_restApi->setPath(API_PATH_STATE);
|
|
|
|
|
|
|
|
httpResponse response = _restApi->get();
|
|
|
|
if ( response.error() )
|
|
|
|
{
|
|
|
|
QString errorReason = QString("Storing device state failed with error: '%1'").arg(response.getErrorReason());
|
|
|
|
setInError(errorReason);
|
|
|
|
rc = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_originalStateProperties = response.getBody().object();
|
|
|
|
DebugIf(verbose, _log, "state: [%s]", QString(QJsonDocument(_originalStateProperties).toJson(QJsonDocument::Compact)).toUtf8().constData() );
|
2021-04-24 19:37:29 +02:00
|
|
|
|
|
|
|
QJsonObject udpn = _originalStateProperties.value("udpn").toObject();
|
|
|
|
if (!udpn.isEmpty())
|
|
|
|
{
|
|
|
|
_originalStateUdpnSend = udpn["send"].toBool(false);
|
|
|
|
_originalStateUdpnRecv = udpn["recv"].toBool(true);
|
|
|
|
}
|
2021-03-19 22:52:04 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
2020-07-12 20:27:56 +02:00
|
|
|
|
2021-03-19 22:52:04 +01:00
|
|
|
bool LedDeviceWled::restoreState()
|
|
|
|
{
|
|
|
|
bool rc = true;
|
2020-07-12 20:27:56 +02:00
|
|
|
|
2021-03-19 22:52:04 +01:00
|
|
|
if ( _isRestoreOrigState )
|
2020-07-12 20:27:56 +02:00
|
|
|
{
|
2021-03-19 22:52:04 +01:00
|
|
|
_restApi->setPath(API_PATH_STATE);
|
|
|
|
|
|
|
|
_originalStateProperties[STATE_LIVE] = false;
|
|
|
|
|
|
|
|
httpResponse response = _restApi->put(QString(QJsonDocument(_originalStateProperties).toJson(QJsonDocument::Compact)).toUtf8().constData());
|
|
|
|
|
|
|
|
if ( response.error() )
|
|
|
|
{
|
|
|
|
Warning (_log, "%s restoring state failed with error: '%s'", QSTRING_CSTR(_activeDeviceType), QSTRING_CSTR(response.getErrorReason()));
|
|
|
|
}
|
2020-07-12 20:27:56 +02:00
|
|
|
}
|
|
|
|
|
2021-03-19 22:52:04 +01:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
QJsonObject LedDeviceWled::discover(const QJsonObject& /*params*/)
|
|
|
|
{
|
|
|
|
QJsonObject devicesDiscovered;
|
|
|
|
devicesDiscovered.insert("ledDeviceType", _activeDeviceType );
|
|
|
|
|
|
|
|
QJsonArray deviceList;
|
2020-07-12 20:27:56 +02:00
|
|
|
devicesDiscovered.insert("devices", deviceList);
|
2021-03-19 22:52:04 +01:00
|
|
|
DebugIf(verbose, _log, "devicesDiscovered: [%s]", QString(QJsonDocument(devicesDiscovered).toJson(QJsonDocument::Compact)).toUtf8().constData() );
|
2020-07-12 20:27:56 +02:00
|
|
|
|
|
|
|
return devicesDiscovered;
|
|
|
|
}
|
|
|
|
|
|
|
|
QJsonObject LedDeviceWled::getProperties(const QJsonObject& params)
|
|
|
|
{
|
2021-03-19 22:52:04 +01:00
|
|
|
DebugIf(verbose, _log, "params: [%s]", QString(QJsonDocument(params).toJson(QJsonDocument::Compact)).toUtf8().constData() );
|
2020-07-12 20:27:56 +02:00
|
|
|
QJsonObject properties;
|
|
|
|
|
2021-03-19 22:52:04 +01:00
|
|
|
QString hostName = params["host"].toString("");
|
|
|
|
|
|
|
|
if ( !hostName.isEmpty() )
|
2020-07-12 20:27:56 +02:00
|
|
|
{
|
|
|
|
QString filter = params["filter"].toString("");
|
|
|
|
|
|
|
|
// Resolve hostname and port (or use default API port)
|
2021-03-19 22:52:04 +01:00
|
|
|
QStringList addressparts = QStringUtils::split(hostName,":", QStringUtils::SplitBehavior::SkipEmptyParts);
|
2020-07-12 20:27:56 +02:00
|
|
|
QString apiHost = addressparts[0];
|
|
|
|
int apiPort;
|
|
|
|
|
|
|
|
if ( addressparts.size() > 1)
|
|
|
|
{
|
|
|
|
apiPort = addressparts[1].toInt();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
apiPort = API_DEFAULT_PORT;
|
|
|
|
}
|
|
|
|
|
|
|
|
initRestAPI(apiHost, apiPort);
|
2020-09-14 17:19:14 +02:00
|
|
|
_restApi->setPath(filter);
|
2020-07-12 20:27:56 +02:00
|
|
|
|
2020-09-14 17:19:14 +02:00
|
|
|
httpResponse response = _restApi->get();
|
2020-07-12 20:27:56 +02:00
|
|
|
if ( response.error() )
|
|
|
|
{
|
|
|
|
Warning (_log, "%s get properties failed with error: '%s'", QSTRING_CSTR(_activeDeviceType), QSTRING_CSTR(response.getErrorReason()));
|
|
|
|
}
|
|
|
|
|
|
|
|
properties.insert("properties", response.getBody().object());
|
|
|
|
|
2021-03-19 22:52:04 +01:00
|
|
|
DebugIf(verbose, _log, "properties: [%s]", QString(QJsonDocument(properties).toJson(QJsonDocument::Compact)).toUtf8().constData() );
|
2020-07-12 20:27:56 +02:00
|
|
|
}
|
|
|
|
return properties;
|
|
|
|
}
|
|
|
|
|
2021-03-19 22:52:04 +01:00
|
|
|
void LedDeviceWled::identify(const QJsonObject& params)
|
2020-07-12 20:27:56 +02:00
|
|
|
{
|
2021-03-19 22:52:04 +01:00
|
|
|
DebugIf(verbose, _log, "params: [%s]", QString(QJsonDocument(params).toJson(QJsonDocument::Compact)).toUtf8().constData());
|
2020-07-12 20:27:56 +02:00
|
|
|
|
2021-03-19 22:52:04 +01:00
|
|
|
QString hostName = params["host"].toString("");
|
|
|
|
|
|
|
|
if ( !hostName.isEmpty() )
|
2020-07-12 20:27:56 +02:00
|
|
|
{
|
|
|
|
// Resolve hostname and port (or use default API port)
|
2021-03-19 22:52:04 +01:00
|
|
|
QStringList addressparts = QStringUtils::split(hostName,":", QStringUtils::SplitBehavior::SkipEmptyParts);
|
2020-07-12 20:27:56 +02:00
|
|
|
QString apiHost = addressparts[0];
|
|
|
|
int apiPort;
|
|
|
|
|
|
|
|
if ( addressparts.size() > 1)
|
2021-03-19 22:52:04 +01:00
|
|
|
{
|
2020-07-12 20:27:56 +02:00
|
|
|
apiPort = addressparts[1].toInt();
|
2021-03-19 22:52:04 +01:00
|
|
|
}
|
2020-07-12 20:27:56 +02:00
|
|
|
else
|
2021-03-19 22:52:04 +01:00
|
|
|
{
|
2020-07-12 20:27:56 +02:00
|
|
|
apiPort = API_DEFAULT_PORT;
|
2021-03-19 22:52:04 +01:00
|
|
|
}
|
2020-07-12 20:27:56 +02:00
|
|
|
|
2021-03-19 22:52:04 +01:00
|
|
|
initRestAPI(apiHost, apiPort);
|
2020-07-12 20:27:56 +02:00
|
|
|
|
2021-03-19 22:52:04 +01:00
|
|
|
_isRestoreOrigState = true;
|
|
|
|
storeState();
|
2020-07-12 20:27:56 +02:00
|
|
|
|
2021-03-19 22:52:04 +01:00
|
|
|
QString request = getOnOffRequest(true) + "," + getLorRequest(1) + "," + getEffectRequest(25);
|
|
|
|
sendStateUpdateRequest(request);
|
2020-07-12 20:27:56 +02:00
|
|
|
|
2021-03-19 22:52:04 +01:00
|
|
|
wait(DEFAULT_IDENTIFY_TIME);
|
2020-07-12 20:27:56 +02:00
|
|
|
|
2021-03-19 22:52:04 +01:00
|
|
|
restoreState();
|
2020-07-12 20:27:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int LedDeviceWled::write(const std::vector<ColorRgb> &ledValues)
|
|
|
|
{
|
|
|
|
const uint8_t * dataPtr = reinterpret_cast<const uint8_t *>(ledValues.data());
|
|
|
|
|
|
|
|
return writeBytes( _ledRGBCount, dataPtr);
|
|
|
|
}
|