mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
make opc channel available in via config.
Former-commit-id: 6a065cd049e29d7184a3aa1454de0fe1855e9941
This commit is contained in:
parent
a257f185c9
commit
b6060d392e
@ -246,9 +246,10 @@ LedDevice * LedDeviceFactory::construct(const Json::Value & deviceConfig)
|
||||
}
|
||||
else if (type == "fadecandy")
|
||||
{
|
||||
const std::string host = deviceConfig.get("output", "127.0.0.1").asString();
|
||||
const uint16_t port = deviceConfig.get("port", 7890).asInt();
|
||||
device = new LedDeviceFadeCandy(host,port);
|
||||
const std::string host = deviceConfig.get("output", "127.0.0.1").asString();
|
||||
const uint16_t port = deviceConfig.get("port", 7890).asInt();
|
||||
const uint16_t channel = deviceConfig.get("channel", 0).asInt();
|
||||
device = new LedDeviceFadeCandy(host, port, channel);
|
||||
}
|
||||
else if (type == "tpm2")
|
||||
{
|
||||
|
@ -1,16 +1,15 @@
|
||||
#include "LedDeviceFadeCandy.h"
|
||||
|
||||
static const unsigned MAX_NUM_LEDS = 10000;
|
||||
static const unsigned OPC_BROADCAST = 0; // OPC broadcast channel
|
||||
static const unsigned OPC_SET_PIXELS = 0; // OPC command codes
|
||||
static const unsigned OPC_HEADER_SIZE = 4; // OPC header size
|
||||
static const unsigned MAX_NUM_LEDS = 10000; // OPC can handle 21845 leds - in theory, fadecandy device should handle 10000 leds
|
||||
static const unsigned OPC_SET_PIXELS = 0; // OPC command codes
|
||||
static const unsigned OPC_HEADER_SIZE = 4; // OPC header size
|
||||
|
||||
|
||||
LedDeviceFadeCandy::LedDeviceFadeCandy(const std::string& host, const uint16_t port) :
|
||||
_host(host), _port(port)
|
||||
LedDeviceFadeCandy::LedDeviceFadeCandy(const std::string& host, const uint16_t port, const unsigned channel) :
|
||||
_host(host), _port(port), _channel(channel)
|
||||
{
|
||||
_opc_data.resize( OPC_HEADER_SIZE );
|
||||
_opc_data[0] = OPC_BROADCAST;
|
||||
_opc_data[0] = channel;
|
||||
_opc_data[1] = OPC_SET_PIXELS;
|
||||
_opc_data[2] = 0;
|
||||
_opc_data[3] = 0;
|
||||
@ -33,7 +32,8 @@ bool LedDeviceFadeCandy::tryConnect()
|
||||
{
|
||||
if ( _client.state() == QAbstractSocket::UnconnectedState ) {
|
||||
_client.connectToHost( _host.c_str(), _port);
|
||||
_client.waitForConnected(1000);
|
||||
if ( _client.waitForConnected(1000) )
|
||||
qDebug("fadecandy/opc: connected to %s:%i on channel %i", _host.c_str(), _port, _channel);
|
||||
}
|
||||
|
||||
return isConnected();
|
||||
@ -48,7 +48,7 @@ int LedDeviceFadeCandy::write( const std::vector<ColorRgb> & ledValues )
|
||||
|
||||
if (nrLedValues > MAX_NUM_LEDS)
|
||||
{
|
||||
std::cerr << "Invalid attempt to write led values. Not more than " << MAX_NUM_LEDS << " leds are allowed." << std::endl;
|
||||
std::cerr << "fadecandy/opc: Invalid attempt to write led values. Not more than " << MAX_NUM_LEDS << " leds are allowed." << std::endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ public:
|
||||
/// @param host The ip address/host name of fadecandy/opc server
|
||||
/// @param port The port to use (fadecandy default is 7890)
|
||||
///
|
||||
LedDeviceFadeCandy(const std::string& host, const uint16_t port);
|
||||
LedDeviceFadeCandy(const std::string& host, const uint16_t port, const unsigned channel);
|
||||
|
||||
///
|
||||
/// Destructor of the LedDevice; closes the tcp client
|
||||
@ -46,6 +46,7 @@ private:
|
||||
QTcpSocket _client;
|
||||
const std::string _host;
|
||||
const uint16_t _port;
|
||||
const unsigned _channel;
|
||||
QByteArray _opc_data;
|
||||
|
||||
/// try to establish connection to opc server, if not connected yet
|
||||
|
Loading…
Reference in New Issue
Block a user