mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
* Cast fix * Fix #676
This commit is contained in:
parent
ed5455458b
commit
0fa5a24cec
@ -40,8 +40,19 @@ LedDevice::~LedDevice()
|
||||
|
||||
int LedDevice::open()
|
||||
{
|
||||
setEnable (true);
|
||||
return 0;
|
||||
int retval = -1;
|
||||
QString errortext;
|
||||
_deviceReady = false;
|
||||
|
||||
// General initialisation and configuration of LedDevice
|
||||
if ( init(_devConfig) )
|
||||
{
|
||||
// Everything is OK -> enable device
|
||||
_deviceReady = true;
|
||||
setEnable(true);
|
||||
retval = 0;
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
void LedDevice::setInError(const QString& errorMsg)
|
||||
@ -71,6 +82,11 @@ void LedDevice::setEnable(bool enable)
|
||||
Error(_log, "Device '%s' cannot be enabled, as it is not ready!", QSTRING_CSTR(_activeDeviceType));
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Open worked
|
||||
_deviceInError = false;
|
||||
}
|
||||
}
|
||||
|
||||
// emit signal when state changed
|
||||
@ -101,6 +117,8 @@ void LedDevice::setActiveDeviceType(const QString& deviceType)
|
||||
|
||||
bool LedDevice::init(const QJsonObject &deviceConfig)
|
||||
{
|
||||
//Debug(_log, "deviceConfig: [%s]", QString(QJsonDocument(_devConfig).toJson(QJsonDocument::Compact)).toUtf8().constData() );
|
||||
|
||||
_colorOrder = deviceConfig["colorOrder"].toString("RGB");
|
||||
_activeDeviceType = deviceConfig["type"].toString("file").toLower();
|
||||
setLedCount(static_cast<unsigned int>( deviceConfig["currentLedCount"].toInt(1) )); // property injected to reflect real led count
|
||||
@ -146,7 +164,7 @@ void LedDevice::stopRefreshTimer()
|
||||
int LedDevice::updateLeds(const std::vector<ColorRgb>& ledValues)
|
||||
{
|
||||
int retval = 0;
|
||||
if ( !_deviceReady )
|
||||
if ( !_deviceReady || _deviceInError)
|
||||
{
|
||||
std::cout << "LedDevice::updateLeds(), LedDevice NOT ready!" << std::endl;
|
||||
return -1;
|
||||
|
@ -11,6 +11,11 @@ LedDeviceWS281x::~LedDeviceWS281x()
|
||||
{
|
||||
}
|
||||
|
||||
LedDevice* LedDeviceWS281x::construct(const QJsonObject &deviceConfig)
|
||||
{
|
||||
return new LedDeviceWS281x(deviceConfig);
|
||||
}
|
||||
|
||||
bool LedDeviceWS281x::init(const QJsonObject &deviceConfig)
|
||||
{
|
||||
QString errortext;
|
||||
@ -84,11 +89,6 @@ void LedDeviceWS281x::close()
|
||||
}
|
||||
}
|
||||
|
||||
LedDevice* LedDeviceWS281x::construct(const QJsonObject &deviceConfig)
|
||||
{
|
||||
return new LedDeviceWS281x(deviceConfig);
|
||||
}
|
||||
|
||||
// Send new values down the LED chain
|
||||
int LedDeviceWS281x::write(const std::vector<ColorRgb> &ledValues)
|
||||
{
|
||||
|
@ -15,12 +15,12 @@ public:
|
||||
///
|
||||
/// @param deviceConfig json device config
|
||||
///
|
||||
LedDeviceWS281x(const QJsonObject &deviceConfig);
|
||||
explicit LedDeviceWS281x(const QJsonObject &deviceConfig);
|
||||
|
||||
///
|
||||
/// Destructor of the LedDevice, waits for DMA to complete and then cleans up
|
||||
///
|
||||
~LedDeviceWS281x() override;
|
||||
virtual ~LedDeviceWS281x() override;
|
||||
|
||||
/// constructs leddevice
|
||||
static LedDevice* construct(const QJsonObject &deviceConfig);
|
||||
@ -30,7 +30,7 @@ public:
|
||||
///
|
||||
/// @param deviceConfig the json device config
|
||||
/// @return true if success
|
||||
bool init(const QJsonObject &deviceConfig) override;
|
||||
virtual bool init(const QJsonObject &deviceConfig) override;
|
||||
|
||||
public slots:
|
||||
///
|
||||
@ -39,7 +39,7 @@ public slots:
|
||||
///
|
||||
virtual void close() override;
|
||||
|
||||
private:
|
||||
protected:
|
||||
///
|
||||
/// Writes the led color values to the led-device
|
||||
///
|
||||
@ -48,6 +48,8 @@ private:
|
||||
///
|
||||
virtual int write(const std::vector<ColorRgb> &ledValues) override;
|
||||
|
||||
private:
|
||||
|
||||
ws2811_t _led_string;
|
||||
int _channel;
|
||||
RGBW::WhiteAlgorithm _whiteAlgorithm;
|
||||
|
@ -46,7 +46,7 @@ bool LedDeviceKarate::init(const QJsonObject &deviceConfig)
|
||||
|
||||
int LedDeviceKarate::write(const std::vector<ColorRgb> &ledValues)
|
||||
{
|
||||
for (signed iLed=0; iLed<_ledCount; iLed++)
|
||||
for (signed iLed=0; iLed< static_cast<int>(_ledCount); iLed++)
|
||||
{
|
||||
|
||||
const ColorRgb& rgb = ledValues[iLed];
|
||||
|
Loading…
Reference in New Issue
Block a user