mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
make opc channel available in via config.
Former-commit-id: 6a065cd049e29d7184a3aa1454de0fe1855e9941
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user