mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Bugfix/Hotfix/Update
Signed-off-by: Paulchen-Panther <Paulchen-Panter@protonmail.com>
This commit is contained in:
@@ -10,6 +10,8 @@
|
||||
#include "hyperion/Hyperion.h"
|
||||
#include <utils/JsonUtils.h>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
LedDevice::LedDevice(const QJsonObject& config, QObject* parent)
|
||||
: QObject(parent)
|
||||
, _devConfig(config)
|
||||
@@ -43,21 +45,12 @@ void LedDevice::setEnable(bool enable)
|
||||
{
|
||||
// emit signal when state changed
|
||||
if (_enabled != enable)
|
||||
{
|
||||
emit enableStateChanged(enable);
|
||||
}
|
||||
|
||||
// set black to leds when they should go off
|
||||
if ( _enabled && !enable)
|
||||
{
|
||||
switchOff();
|
||||
}
|
||||
else {
|
||||
if ( !_enabled && enable)
|
||||
{
|
||||
switchOn();
|
||||
}
|
||||
}
|
||||
|
||||
_enabled = enable;
|
||||
}
|
||||
|
||||
|
@@ -41,25 +41,26 @@ LedDeviceWrapper::~LedDeviceWrapper()
|
||||
void LedDeviceWrapper::createLedDevice(const QJsonObject& config)
|
||||
{
|
||||
if(_ledDevice != nullptr)
|
||||
{
|
||||
stopDeviceThread();
|
||||
}
|
||||
{
|
||||
stopDeviceThread();
|
||||
}
|
||||
|
||||
// create thread and device
|
||||
QThread* thread = new QThread(this);
|
||||
_ledDevice = LedDeviceFactory::construct(config);
|
||||
_ledDevice->moveToThread(thread);
|
||||
// setup thread management
|
||||
connect(thread, &QThread::started, _ledDevice, &LedDevice::start);
|
||||
connect(thread, &QThread::finished, thread, &QObject::deleteLater);
|
||||
connect(thread, &QThread::finished, _ledDevice, &QObject::deleteLater);
|
||||
// create thread and device
|
||||
QThread* thread = new QThread(this);
|
||||
_ledDevice = LedDeviceFactory::construct(config);
|
||||
_ledDevice->moveToThread(thread);
|
||||
// setup thread management
|
||||
connect(thread, &QThread::started, _ledDevice, &LedDevice::start);
|
||||
connect(thread, &QThread::finished, thread, &QObject::deleteLater);
|
||||
connect(thread, &QThread::finished, _ledDevice, &QObject::deleteLater);
|
||||
|
||||
// further signals
|
||||
connect(this, &LedDeviceWrapper::write, _ledDevice, &LedDevice::write);
|
||||
connect(_ledDevice, &LedDevice::enableStateChanged, this, &LedDeviceWrapper::handleInternalEnableState);
|
||||
// further signals
|
||||
connect(this, &LedDeviceWrapper::write, _ledDevice, &LedDevice::write);
|
||||
connect(_hyperion->getMuxerInstance(), &PriorityMuxer::visiblePriorityChanged, _ledDevice, &LedDevice::visiblePriorityChanged);
|
||||
connect(_ledDevice, &LedDevice::enableStateChanged, this, &LedDeviceWrapper::handleInternalEnableState);
|
||||
|
||||
// start the thread
|
||||
thread->start();
|
||||
// start the thread
|
||||
thread->start();
|
||||
}
|
||||
|
||||
const QJsonObject LedDeviceWrapper::getLedDeviceSchemas()
|
||||
|
@@ -5,17 +5,17 @@ static const unsigned OPC_SET_PIXELS = 0; // OPC command codes
|
||||
static const unsigned OPC_SYS_EX = 255; // OPC command codes
|
||||
static const unsigned OPC_HEADER_SIZE = 4; // OPC header size
|
||||
|
||||
|
||||
LedDeviceFadeCandy::LedDeviceFadeCandy(const QJsonObject &deviceConfig)
|
||||
: LedDevice()
|
||||
: LedDevice()
|
||||
, _client(nullptr)
|
||||
{
|
||||
_deviceReady = init(deviceConfig);
|
||||
_client = new QTcpSocket(this);
|
||||
}
|
||||
|
||||
|
||||
LedDeviceFadeCandy::~LedDeviceFadeCandy()
|
||||
{
|
||||
_client.close();
|
||||
_client->close();
|
||||
}
|
||||
|
||||
LedDevice* LedDeviceFadeCandy::construct(const QJsonObject &deviceConfig)
|
||||
@@ -23,10 +23,9 @@ LedDevice* LedDeviceFadeCandy::construct(const QJsonObject &deviceConfig)
|
||||
return new LedDeviceFadeCandy(deviceConfig);
|
||||
}
|
||||
|
||||
|
||||
bool LedDeviceFadeCandy::init(const QJsonObject &deviceConfig)
|
||||
{
|
||||
_client.close();
|
||||
LedDevice::init(deviceConfig);
|
||||
|
||||
if (_ledCount > MAX_NUM_LEDS)
|
||||
{
|
||||
@@ -67,15 +66,14 @@ bool LedDeviceFadeCandy::init(const QJsonObject &deviceConfig)
|
||||
|
||||
bool LedDeviceFadeCandy::isConnected()
|
||||
{
|
||||
return _client.state() == QAbstractSocket::ConnectedState;
|
||||
return _client->state() == QAbstractSocket::ConnectedState;
|
||||
}
|
||||
|
||||
|
||||
bool LedDeviceFadeCandy::tryConnect()
|
||||
{
|
||||
if ( _client.state() == QAbstractSocket::UnconnectedState ) {
|
||||
_client.connectToHost( _host, _port);
|
||||
if ( _client.waitForConnected(1000) )
|
||||
if ( _client->state() == QAbstractSocket::UnconnectedState ) {
|
||||
_client->connectToHost( _host, _port);
|
||||
if ( _client->waitForConnected(1000) )
|
||||
{
|
||||
Info(_log,"fadecandy/opc: connected to %s:%i on channel %i", QSTRING_CSTR(_host), _port, _channel);
|
||||
if (_setFcConfig)
|
||||
@@ -88,7 +86,6 @@ bool LedDeviceFadeCandy::tryConnect()
|
||||
return isConnected();
|
||||
}
|
||||
|
||||
|
||||
int LedDeviceFadeCandy::write( const std::vector<ColorRgb> & ledValues )
|
||||
{
|
||||
uint idx = OPC_HEADER_SIZE;
|
||||
@@ -103,11 +100,11 @@ int LedDeviceFadeCandy::write( const std::vector<ColorRgb> & ledValues )
|
||||
return ( transferData()<0 ? -1 : 0 );
|
||||
}
|
||||
|
||||
|
||||
int LedDeviceFadeCandy::transferData()
|
||||
{
|
||||
if ( isConnected() || tryConnect() )
|
||||
return _client.write( _opc_data, _opc_data.size() );
|
||||
if (LedDevice::enabled())
|
||||
if ( isConnected() || tryConnect() )
|
||||
return _client->write( _opc_data, _opc_data.size() );
|
||||
|
||||
return -2;
|
||||
}
|
||||
@@ -131,7 +128,7 @@ int LedDeviceFadeCandy::sendSysEx(uint8_t systemId, uint8_t commandId, QByteArra
|
||||
|
||||
sysExData += msg;
|
||||
|
||||
return _client.write( sysExData, sysExData.size() );
|
||||
return _client->write( sysExData, sysExData.size() );
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
@@ -56,17 +56,18 @@ public:
|
||||
/// @return true if success
|
||||
bool init(const QJsonObject &deviceConfig);
|
||||
|
||||
private:
|
||||
///
|
||||
/// Writes the led color values to the led-device
|
||||
///
|
||||
/// @param ledValues The color-value per led
|
||||
/// @return Zero on succes else negative
|
||||
///
|
||||
virtual int write(const std::vector<ColorRgb> & ledValues);
|
||||
virtual int write(const std::vector<ColorRgb>& ledValues);
|
||||
|
||||
private:
|
||||
QTcpSocket _client;
|
||||
QString _host;
|
||||
protected:
|
||||
QTcpSocket* _client;
|
||||
QString _host;
|
||||
uint16_t _port;
|
||||
unsigned _channel;
|
||||
QByteArray _opc_data;
|
||||
|
@@ -41,7 +41,7 @@ public:
|
||||
|
||||
protected:
|
||||
///
|
||||
/// Writes the given bytes/bits to the SPI-device and sleeps the latch time to ensure that the
|
||||
/// Writes the given bytes/bits to the UDP-device and sleeps the latch time to ensure that the
|
||||
/// values are latched.
|
||||
///
|
||||
/// @param[in] size The length of the data
|
||||
|
@@ -77,6 +77,7 @@
|
||||
"gamma" : {
|
||||
"type" : "number",
|
||||
"title" : "edt_dev_spec_gamma_title",
|
||||
"default": 1.0,
|
||||
"minimum" : 0.1,
|
||||
"maximum": 5.0,
|
||||
"options": {
|
||||
|
Reference in New Issue
Block a user