General tidy up

This commit is contained in:
Murat 2020-08-08 00:21:19 +02:00
parent 13205a9d11
commit dd2d5e4b40
62 changed files with 117 additions and 296 deletions

View File

@ -60,12 +60,12 @@ namespace hyperion
/// @return The detected (or not detected) black border info
///
uint8_t calculateThreshold(double blackborderThreshold);
uint8_t calculateThreshold(double blackborderThreshold) const;
///
/// default detection mode (3lines 4side detection)
template <typename Pixel_T>
BlackBorder process(const Image<Pixel_T> & image)
BlackBorder process(const Image<Pixel_T> & image) const
{
// test center and 33%, 66% of width/heigth
// 33 and 66 will check left and top
@ -122,7 +122,7 @@ namespace hyperion
///
/// classic detection mode (topleft single line mode)
template <typename Pixel_T>
BlackBorder process_classic(const Image<Pixel_T> & image)
BlackBorder process_classic(const Image<Pixel_T> & image) const
{
// only test the topleft third of the image
int width = image.width() /3;
@ -179,7 +179,7 @@ namespace hyperion
///
/// osd detection mode (find x then y at detected x to avoid changes by osd overlays)
template <typename Pixel_T>
BlackBorder process_osd(const Image<Pixel_T> & image)
BlackBorder process_osd(const Image<Pixel_T> & image) const
{
// find X position at height33 and height66 we check from the left side, Ycenter will check from right side
// then we try to find a pixel at this X position from top and bottom and right side from top
@ -245,7 +245,7 @@ namespace hyperion
/// @return True if the color is considered black else false
///
template <typename Pixel_T>
inline bool isBlack(const Pixel_T & color)
inline bool isBlack(const Pixel_T & color) const
{
// Return the simple compare of the color against black
return color.red < _blackborderThreshold && color.green < _blackborderThreshold && color.blue < _blackborderThreshold;

View File

@ -1,4 +1,3 @@
#pragma once
// QT includes

View File

@ -10,7 +10,6 @@
class ColorAdjustment
{
public:
/// Unique identifier for this color transform
QString _id;

View File

@ -57,8 +57,8 @@ namespace hyperion
///
unsigned height() const;
unsigned horizontalBorder() { return _horizontalBorder; };
unsigned verticalBorder() { return _verticalBorder; };
unsigned horizontalBorder() const { return _horizontalBorder; };
unsigned verticalBorder() const { return _verticalBorder; };
///
/// Determines the mean color for each led using the mapping the image given
@ -176,9 +176,9 @@ namespace hyperion
}
// Accumulate the sum of each seperate color channel
uint_fast16_t cummRed = 0;
uint_fast16_t cummGreen = 0;
uint_fast16_t cummBlue = 0;
uint_fast32_t cummRed = 0;
uint_fast32_t cummGreen = 0;
uint_fast32_t cummBlue = 0;
const auto& imgData = image.memptr();
for (const unsigned colorOffset : colors)
@ -210,9 +210,9 @@ namespace hyperion
ColorRgb calcMeanColor(const Image<Pixel_T> & image) const
{
// Accumulate the sum of each seperate color channel
uint_fast16_t cummRed = 0;
uint_fast16_t cummGreen = 0;
uint_fast16_t cummBlue = 0;
uint_fast32_t cummRed = 0;
uint_fast32_t cummGreen = 0;
uint_fast32_t cummBlue = 0;
const unsigned imageSize = image.width() * image.height();
const auto& imgData = image.memptr();

View File

@ -25,13 +25,13 @@ public:
/// @param local The local address of the socket (Differs based on NetworkAdapter IP or localhost)
/// @return True when allowed, else false
///
bool accessAllowed(const QHostAddress& address, const QHostAddress& local);
bool accessAllowed(const QHostAddress& address, const QHostAddress& local) const;
///
/// @brief Check if address is in subnet of local
/// @return True or false
///
bool isLocalAddress(const QHostAddress& address, const QHostAddress& local);
bool isLocalAddress(const QHostAddress& address, const QHostAddress& local) const;
static NetOrigin* getInstance(){ return instance; };
static NetOrigin* instance;

View File

@ -1,11 +1,11 @@
#pragma once
#include <QByteArray>
#include <QString>
#include <QByteArray>
namespace Process {
void restartHyperion(bool asNewProcess=false);
QByteArray command_exec(QString cmd, QByteArray data="");
QByteArray command_exec(const QString& cmd, const QByteArray& data = {});
}

View File

@ -13,7 +13,7 @@ BlackBorderDetector::BlackBorderDetector(double threshold)
// empty
}
uint8_t BlackBorderDetector::calculateThreshold(double threshold)
uint8_t BlackBorderDetector::calculateThreshold(double threshold) const
{
int rgbThreshold = int(std::ceil(threshold * 255));
if (rgbThreshold < 0)

View File

@ -56,7 +56,6 @@ void BlackBorderProcessor::handleSettingsUpdate(const settings::type& type, cons
{
_oldThreshold = newThreshold;
if(_detector != nullptr)
delete _detector;
_detector = new BlackBorderDetector(newThreshold);

View File

@ -210,12 +210,14 @@ bool XcbGrabber::Setup()
setupRender();
setupShm();
Info(_log, "XcbRandR : %s", _XcbRandRAvailable ? "available" : "unavailable");
Info(_log, "XcbRender : %s", _XcbRenderAvailable ? "available" : "unavailable");
Info(_log, "XcbShm : %s", _XcbShmAvailable ? "available" : "unavailable");
Info(_log, "XcbPixmap : %s", _XcbShmPixmapAvailable ? "available" : "unavailable");
Info(_log, QString("XcbRandR=[%1] XcbRender=[%2] XcbShm=[%3] XcbPixmap=[%4]")
.arg(_XcbRandRAvailable ? "available" : "unavailable")
.arg(_XcbRenderAvailable ? "available" : "unavailable")
.arg(_XcbShmAvailable ? "available" : "unavailable")
.arg(_XcbShmPixmapAvailable ? "available" : "unavailable")
.toStdString().c_str());
bool result = (updateScreenDimensions(true) >=0);
bool result = (updateScreenDimensions(true) >= 0);
ErrorIf(!result, _log, "XCB Grabber start failed");
setEnabled(result);
return result;

View File

@ -33,7 +33,7 @@ LedDevice::LedDevice(const QJsonObject& deviceConfig, QObject* parent)
, _lastWriteTime(QDateTime::currentDateTime())
, _isRefreshEnabled (false)
{
_activeDeviceType = deviceConfig["type"].toString("UNSPECIFIED").toLower();
}
LedDevice::~LedDevice()

View File

@ -13,14 +13,10 @@ QString _usbProductDescription = "Hyperion led controller";
}
LedDeviceHyperionUsbasp::LedDeviceHyperionUsbasp(const QJsonObject &deviceConfig)
: LedDevice()
: LedDevice(deviceConfig)
, _libusbContext(nullptr)
, _deviceHandle(nullptr)
{
_devConfig = deviceConfig;
_isDeviceReady = false;
_activeDeviceType = deviceConfig["type"].toString("UNSPECIFIED").toLower();
}
LedDeviceHyperionUsbasp::~LedDeviceHyperionUsbasp()

View File

@ -33,7 +33,7 @@ enum DATA_VERSION_INDEXES{
};
LedDeviceLightpack::LedDeviceLightpack(const QJsonObject &deviceConfig)
: LedDevice()
: LedDevice(deviceConfig)
, _libusbContext(nullptr)
, _deviceHandle(nullptr)
, _busNumber(-1)
@ -41,12 +41,8 @@ LedDeviceLightpack::LedDeviceLightpack(const QJsonObject &deviceConfig)
, _firmwareVersion({-1,-1})
, _bitsPerChannel(-1)
, _hwLedCount(-1)
,_isOpen(false)
, _isOpen(false)
{
_devConfig = deviceConfig;
_isDeviceReady = false;
_activeDeviceType = deviceConfig["type"].toString("UNSPECIFIED").toLower();
}
LedDeviceLightpack::~LedDeviceLightpack()

View File

@ -18,24 +18,17 @@ bool compareLightpacks(LedDeviceLightpack * lhs, LedDeviceLightpack * rhs)
}
LedDeviceMultiLightpack::LedDeviceMultiLightpack(const QJsonObject &deviceConfig)
: LedDevice()
: LedDevice(deviceConfig)
, _lightpacks()
{
_devConfig = deviceConfig;
_isDeviceReady = false;
_activeDeviceType = deviceConfig["type"].toString("UNSPECIFIED").toLower();
}
LedDeviceMultiLightpack::~LedDeviceMultiLightpack()
{
for (LedDeviceLightpack * device : _lightpacks)
{
if ( device != nullptr)
{
delete device;
}
}
}
LedDevice* LedDeviceMultiLightpack::construct(const QJsonObject &deviceConfig)

View File

@ -2,14 +2,9 @@
// Use out report HID device
LedDevicePaintpack::LedDevicePaintpack(const QJsonObject &deviceConfig)
: ProviderHID()
: ProviderHID(deviceConfig)
{
_devConfig = deviceConfig;
_isDeviceReady = false;
_useFeature = false;
_activeDeviceType = deviceConfig["type"].toString("UNSPECIFIED").toLower();
}
LedDevice* LedDevicePaintpack::construct(const QJsonObject &deviceConfig)

View File

@ -2,13 +2,8 @@
// Use feature report HID device
LedDeviceRawHID::LedDeviceRawHID(const QJsonObject &deviceConfig)
: ProviderHID()
: ProviderHID(deviceConfig)
{
_devConfig = deviceConfig;
_isDeviceReady = false;
_activeDeviceType = deviceConfig["type"].toString("UNSPECIFIED").toLower();
_useFeature = true;
}

View File

@ -9,8 +9,9 @@
// Local Hyperion includes
#include "ProviderHID.h"
ProviderHID::ProviderHID()
: _VendorId(0)
ProviderHID::ProviderHID(const QJsonObject &deviceConfig)
: LedDevice(deviceConfig)
, _VendorId(0)
, _ProductId(0)
, _useFeature(false)
, _deviceHandle(nullptr)

View File

@ -21,7 +21,7 @@ public:
///
/// @param deviceConfig Device's configuration as JSON-Object
///
ProviderHID();
ProviderHID(const QJsonObject &deviceConfig);
///
/// @brief Destructor of the LedDevice

View File

@ -9,7 +9,7 @@ const quint16 MULTICAST_GROUPL_DEFAULT_PORT = 49692;
const int LEDS_DEFAULT_NUMBER = 24;
LedDeviceAtmoOrb::LedDeviceAtmoOrb(const QJsonObject &deviceConfig)
: LedDevice()
: LedDevice(deviceConfig)
, _udpSocket (nullptr)
, _multiCastGroupPort (MULTICAST_GROUPL_DEFAULT_PORT)
, _joinedMulticastgroup (false)
@ -19,10 +19,6 @@ LedDeviceAtmoOrb::LedDeviceAtmoOrb(const QJsonObject &deviceConfig)
, _numLeds (LEDS_DEFAULT_NUMBER)
{
_devConfig = deviceConfig;
_isDeviceReady = false;
_activeDeviceType = deviceConfig["type"].toString("UNSPECIFIED").toLower();
}
LedDevice* LedDeviceAtmoOrb::construct(const QJsonObject &deviceConfig)
@ -32,10 +28,7 @@ LedDevice* LedDeviceAtmoOrb::construct(const QJsonObject &deviceConfig)
LedDeviceAtmoOrb::~LedDeviceAtmoOrb()
{
if ( _udpSocket != nullptr )
{
delete _udpSocket;
}
}
bool LedDeviceAtmoOrb::init(const QJsonObject &deviceConfig)
@ -241,6 +234,5 @@ void LedDeviceAtmoOrb::setColor(int orbId, const ColorRgb &color, int commandTyp
void LedDeviceAtmoOrb::sendCommand(const QByteArray &bytes)
{
QByteArray datagram = bytes;
_udpSocket->writeDatagram(datagram.data(), datagram.size(), _groupAddress, _multiCastGroupPort);
_udpSocket->writeDatagram(bytes.data(), bytes.size(), _groupAddress, _multiCastGroupPort);
}

View File

@ -127,7 +127,6 @@ private:
QMap<int, int> lastColorRedMap;
QMap<int, int> lastColorGreenMap;
QMap<int, int> lastColorBlueMap;
};
#endif // LEDEVICEATMOORB_H

View File

@ -20,23 +20,16 @@ const unsigned OPC_HEADER_SIZE = 4; // OPC header size
const quint16 STREAM_DEFAULT_PORT = 7890;
LedDeviceFadeCandy::LedDeviceFadeCandy(const QJsonObject &deviceConfig)
: LedDevice()
: LedDevice(deviceConfig)
, _client(nullptr)
,_host()
,_port(STREAM_DEFAULT_PORT)
{
_devConfig = deviceConfig;
_isDeviceReady = false;
_activeDeviceType = deviceConfig["type"].toString("UNSPECIFIED").toLower();
}
LedDeviceFadeCandy::~LedDeviceFadeCandy()
{
if ( _client != nullptr )
{
delete _client;
}
}
LedDevice* LedDeviceFadeCandy::construct(const QJsonObject &deviceConfig)

View File

@ -90,7 +90,7 @@ enum EXTCONTROLVERSIONS {
};
LedDeviceNanoleaf::LedDeviceNanoleaf(const QJsonObject &deviceConfig)
: ProviderUdp()
: ProviderUdp(deviceConfig)
,_restApi(nullptr)
,_apiPort(API_DEFAULT_PORT)
,_topDown(true)
@ -100,10 +100,6 @@ LedDeviceNanoleaf::LedDeviceNanoleaf(const QJsonObject &deviceConfig)
,_extControlVersion (EXTCTRLVER_V2),
_panelLedCount(0)
{
_devConfig = deviceConfig;
_isDeviceReady = false;
_activeDeviceType = deviceConfig["type"].toString("UNSPECIFIED").toLower();
}
LedDevice* LedDeviceNanoleaf::construct(const QJsonObject &deviceConfig)
@ -113,11 +109,8 @@ LedDevice* LedDeviceNanoleaf::construct(const QJsonObject &deviceConfig)
LedDeviceNanoleaf::~LedDeviceNanoleaf()
{
if ( _restApi != nullptr )
{
delete _restApi;
_restApi = nullptr;
}
}
bool LedDeviceNanoleaf::init(const QJsonObject &deviceConfig)

View File

@ -264,7 +264,7 @@ double CiColor::getDistanceBetweenTwoPoints(CiColor p1, XYColor p2)
}
LedDevicePhilipsHueBridge::LedDevicePhilipsHueBridge(const QJsonObject &deviceConfig)
: ProviderUdpSSL()
: ProviderUdpSSL(deviceConfig)
, _restApi(nullptr)
, _apiPort(API_DEFAULT_PORT)
, _useHueEntertainmentAPI(false)
@ -273,17 +273,12 @@ LedDevicePhilipsHueBridge::LedDevicePhilipsHueBridge(const QJsonObject &deviceCo
, _api_patch(0)
, _isHueEntertainmentReady(false)
{
_devConfig = deviceConfig;
_isDeviceReady = false;
}
LedDevicePhilipsHueBridge::~LedDevicePhilipsHueBridge()
{
if ( _restApi != nullptr )
{
delete _restApi;
_restApi = nullptr;
}
}
bool LedDevicePhilipsHueBridge::init(const QJsonObject &deviceConfig)
@ -828,10 +823,6 @@ LedDevicePhilipsHue::LedDevicePhilipsHue(const QJsonObject& deviceConfig)
, start_retry_left(3)
, stop_retry_left(3)
{
_devConfig = deviceConfig;
_isDeviceReady = false;
_activeDeviceType = deviceConfig["type"].toString("UNSPECIFIED").toLower();
}
LedDevice* LedDevicePhilipsHue::construct(const QJsonObject &deviceConfig)

View File

@ -3,12 +3,8 @@
const ushort TPM2_DEFAULT_PORT = 65506;
LedDeviceTpm2net::LedDeviceTpm2net(const QJsonObject &deviceConfig)
: ProviderUdp()
: ProviderUdp(deviceConfig)
{
_devConfig = deviceConfig;
_isDeviceReady = false;
_activeDeviceType = deviceConfig["type"].toString("UNSPECIFIED").toLower();
}
LedDevice* LedDeviceTpm2net::construct(const QJsonObject &deviceConfig)

View File

@ -12,15 +12,10 @@
const ushort ARTNET_DEFAULT_PORT = 6454;
LedDeviceUdpArtNet::LedDeviceUdpArtNet(const QJsonObject &deviceConfig)
: ProviderUdp()
: ProviderUdp(deviceConfig)
{
_devConfig = deviceConfig;
_isDeviceReady = false;
_activeDeviceType = deviceConfig["type"].toString("UNSPECIFIED").toLower();
}
LedDevice* LedDeviceUdpArtNet::construct(const QJsonObject &deviceConfig)
{
return new LedDeviceUdpArtNet(deviceConfig);

View File

@ -25,12 +25,8 @@ const uint32_t VECTOR_E131_DATA_PACKET = 0x00000002;
const int DMX_MAX = 512; // 512 usable slots
LedDeviceUdpE131::LedDeviceUdpE131(const QJsonObject &deviceConfig)
: ProviderUdp()
: ProviderUdp(deviceConfig)
{
_devConfig = deviceConfig;
_isDeviceReady = false;
_activeDeviceType = deviceConfig["type"].toString("UNSPECIFIED").toLower();
}
LedDevice* LedDeviceUdpE131::construct(const QJsonObject &deviceConfig)

View File

@ -9,12 +9,8 @@ const char H801_DEFAULT_HOST[] = "255.255.255.255";
} //End of constants
LedDeviceUdpH801::LedDeviceUdpH801(const QJsonObject &deviceConfig)
: ProviderUdp()
: ProviderUdp(deviceConfig)
{
_devConfig = deviceConfig;
_isDeviceReady = false;
_activeDeviceType = deviceConfig["type"].toString("UNSPECIFIED").toLower();
}
LedDevice* LedDeviceUdpH801::construct(const QJsonObject &deviceConfig)

View File

@ -3,12 +3,8 @@
const ushort RAW_DEFAULT_PORT=5568;
LedDeviceUdpRaw::LedDeviceUdpRaw(const QJsonObject &deviceConfig)
: ProviderUdp()
: ProviderUdp(deviceConfig)
{
_devConfig = deviceConfig;
_isDeviceReady = false;
_activeDeviceType = deviceConfig["type"].toString("UNSPECIFIED").toLower();
}
LedDevice* LedDeviceUdpRaw::construct(const QJsonObject &deviceConfig)

View File

@ -34,23 +34,16 @@ const char SSDP_FILTER_HEADER[] = "ST";
} //End of constants
LedDeviceWled::LedDeviceWled(const QJsonObject &deviceConfig)
: ProviderUdp()
: ProviderUdp(deviceConfig)
,_restApi(nullptr)
,_apiPort(API_DEFAULT_PORT)
{
_devConfig = deviceConfig;
_isDeviceReady = false;
_activeDeviceType = deviceConfig["type"].toString("UNSPECIFIED").toLower();
}
LedDeviceWled::~LedDeviceWled()
{
if ( _restApi != nullptr )
{
delete _restApi;
_restApi = nullptr;
}
}
LedDevice* LedDeviceWled::construct(const QJsonObject &deviceConfig)

View File

@ -117,10 +117,7 @@ YeelightLight::YeelightLight( Logger *log, const QString &hostname, quint16 port
YeelightLight::~YeelightLight()
{
log (3,"~YeelightLight()","" );
if ( _tcpSocket != nullptr)
{
delete _tcpSocket;
}
log (2,"~YeelightLight()","void" );
}
@ -968,7 +965,7 @@ void YeelightLight::log(const int logLevel, const char* msg, const char* type, .
//---------------------------------------------------------------------------------
LedDeviceYeelight::LedDeviceYeelight(const QJsonObject &deviceConfig)
: LedDevice()
: LedDevice(deviceConfig)
,_lightsCount (0)
,_outputColorModel(0)
,_transitionEffect(YeelightLight::API_EFFECT_SMOOTH)
@ -982,10 +979,6 @@ LedDeviceYeelight::LedDeviceYeelight(const QJsonObject &deviceConfig)
,_debuglevel(0)
,_musicModeServerPort(-1)
{
_devConfig = deviceConfig;
_isDeviceReady = false;
_activeDeviceType = deviceConfig["type"].toString("UNSPECIFIED").toLower();
}
LedDeviceYeelight::~LedDeviceYeelight()

View File

@ -16,10 +16,9 @@
class httpResponse
{
public:
httpResponse() = default;
explicit httpResponse() {}
bool error() { return _hasError;}
bool error() const { return _hasError;}
void setError(const bool hasError) { _hasError = hasError; }
QJsonDocument getBody() const { return _responseBody; }
@ -70,7 +69,7 @@ public:
///
/// @brief Constructor of the REST-API wrapper
///
explicit ProviderRestApi();
ProviderRestApi();
///
/// @brief Constructor of the REST-API wrapper

View File

@ -16,22 +16,18 @@
const ushort MAX_PORT = 65535;
ProviderUdp::ProviderUdp()
: LedDevice()
ProviderUdp::ProviderUdp(const QJsonObject &deviceConfig)
: LedDevice(deviceConfig)
, _udpSocket (nullptr)
, _port(1)
, _defaultHost("127.0.0.1")
{
_isDeviceReady = false;
_latchTime_ms = 1;
}
ProviderUdp::~ProviderUdp()
{
if ( _udpSocket != nullptr )
{
delete _udpSocket;
}
}
bool ProviderUdp::init(const QJsonObject &deviceConfig)

View File

@ -21,7 +21,7 @@ public:
///
/// @brief Constructs an UDP LED-device
///
ProviderUdp();
ProviderUdp(const QJsonObject &deviceConfig);
///
/// @brief Destructor of the UDP LED-device

View File

@ -15,8 +15,8 @@
const int MAX_RETRY = 5;
const ushort MAX_PORT_SSL = 65535;
ProviderUdpSSL::ProviderUdpSSL()
: LedDevice()
ProviderUdpSSL::ProviderUdpSSL(const QJsonObject &deviceConfig)
: LedDevice(deviceConfig)
, client_fd()
, entropy()
, ssl()
@ -41,7 +41,6 @@ ProviderUdpSSL::ProviderUdpSSL()
, _debugStreamer(false)
, _debugLevel(0)
{
_isDeviceReady = false;
_latchTime_ms = 1;
}

View File

@ -61,7 +61,7 @@ public:
///
/// @brief Constructs an UDP SSL LED-device
///
ProviderUdpSSL();
ProviderUdpSSL(const QJsonObject &deviceConfig);
///
/// @brief Destructor of the LED-device

View File

@ -5,14 +5,10 @@
#include <QTextStream>
LedDeviceFile::LedDeviceFile(const QJsonObject &deviceConfig)
: LedDevice()
: LedDevice(deviceConfig)
, _file (nullptr)
{
_devConfig = deviceConfig;
_isDeviceReady = false;
_printTimeStamp = false;
_activeDeviceType = deviceConfig["type"].toString("UNSPECIFIED").toLower();
}
LedDeviceFile::~LedDeviceFile()

View File

@ -10,13 +10,9 @@
#include "LedDevicePiBlaster.h"
LedDevicePiBlaster::LedDevicePiBlaster(const QJsonObject &deviceConfig)
: _fid(nullptr)
: LedDevice(deviceConfig)
, _fid(nullptr)
{
_devConfig = deviceConfig;
_isDeviceReady = false;
_activeDeviceType = deviceConfig["type"].toString("UNSPECIFIED").toLower();
// initialise the mapping tables
// -1 is invalid
// z is also meaningless

View File

@ -1,12 +1,8 @@
#include "LedDeviceWS281x.h"
LedDeviceWS281x::LedDeviceWS281x(const QJsonObject &deviceConfig)
: LedDevice()
: LedDevice(deviceConfig)
{
_devConfig = deviceConfig;
_isDeviceReady = false;
_activeDeviceType = deviceConfig["type"].toString("UNSPECIFIED").toLower();
}
LedDeviceWS281x::~LedDeviceWS281x()

View File

@ -3,14 +3,10 @@
#include <cassert>
LedDeviceAdalight::LedDeviceAdalight(const QJsonObject &deviceConfig)
: ProviderRs232()
: ProviderRs232(deviceConfig)
, _headerSize(6)
, _ligthBerryAPA102Mode(false)
{
_devConfig = deviceConfig;
_isDeviceReady = false;
_activeDeviceType = deviceConfig["type"].toString("UNSPECIFIED").toLower();
}
LedDevice* LedDeviceAdalight::construct(const QJsonObject &deviceConfig)

View File

@ -2,15 +2,10 @@
#include "LedDeviceAtmo.h"
LedDeviceAtmo::LedDeviceAtmo(const QJsonObject &deviceConfig)
: ProviderRs232()
: ProviderRs232(deviceConfig)
{
_devConfig = deviceConfig;
_isDeviceReady = false;
_activeDeviceType = deviceConfig["type"].toString("UNSPECIFIED").toLower();
}
LedDevice* LedDeviceAtmo::construct(const QJsonObject &deviceConfig)
{
return new LedDeviceAtmo(deviceConfig);

View File

@ -6,20 +6,15 @@
#endif
LedDeviceDMX::LedDeviceDMX(const QJsonObject &deviceConfig)
: ProviderRs232()
: ProviderRs232(deviceConfig)
, _dmxDeviceType(0)
, _dmxStart(1)
, _dmxSlotsPerLed(3)
, _dmxLedCount(0)
, _dmxChannelCount(0)
{
_devConfig = deviceConfig;
_isDeviceReady = false;
_activeDeviceType = deviceConfig["type"].toString("UNSPECIFIED").toLower();
}
LedDevice* LedDeviceDMX::construct(const QJsonObject &deviceConfig)
{
return new LedDeviceDMX(deviceConfig);

View File

@ -2,12 +2,8 @@
#include "LedDeviceKarate.h"
LedDeviceKarate::LedDeviceKarate(const QJsonObject &deviceConfig)
: ProviderRs232()
: ProviderRs232(deviceConfig)
{
_devConfig = deviceConfig;
_isDeviceReady = false;
_activeDeviceType = deviceConfig["type"].toString("UNSPECIFIED").toLower();
}
LedDevice* LedDeviceKarate::construct(const QJsonObject &deviceConfig)

View File

@ -7,12 +7,8 @@ struct FrameSpec
};
LedDeviceSedu::LedDeviceSedu(const QJsonObject &deviceConfig)
: ProviderRs232()
: ProviderRs232(deviceConfig)
{
_devConfig = deviceConfig;
_isDeviceReady = false;
_activeDeviceType = deviceConfig["type"].toString("UNSPECIFIED").toLower();
}
LedDevice* LedDeviceSedu::construct(const QJsonObject &deviceConfig)

View File

@ -2,15 +2,10 @@
LedDeviceTpm2::LedDeviceTpm2(const QJsonObject &deviceConfig)
: ProviderRs232()
: ProviderRs232(deviceConfig)
{
_devConfig = deviceConfig;
_isDeviceReady = false;
_activeDeviceType = deviceConfig["type"].toString("UNSPECIFIED").toLower();
}
LedDevice* LedDeviceTpm2::construct(const QJsonObject &deviceConfig)
{
return new LedDeviceTpm2(deviceConfig);

View File

@ -15,8 +15,9 @@ constexpr std::chrono::milliseconds OPEN_TIMEOUT{5000}; // device open timeout
const int MAX_WRITE_TIMEOUTS = 5; // Maximum number of allowed timeouts
const int NUM_POWEROFF_WRITE_BLACK = 2; // Number of write "BLACK" during powering off
ProviderRs232::ProviderRs232()
: _rs232Port(this)
ProviderRs232::ProviderRs232(const QJsonObject &deviceConfig)
: LedDevice(deviceConfig)
, _rs232Port(this)
,_baudRate_Hz(1000000)
,_isAutoDeviceName(false)
,_delayAfterConnect_ms(0)

View File

@ -19,7 +19,7 @@ public:
///
/// @brief Constructs a RS232 LED-device
///
ProviderRs232();
ProviderRs232(const QJsonObject &deviceConfig);
///
/// @brief Destructor of the UDP LED-device

View File

@ -1,12 +1,8 @@
#include "LedDeviceAPA102.h"
LedDeviceAPA102::LedDeviceAPA102(const QJsonObject &deviceConfig)
: ProviderSpi()
: ProviderSpi(deviceConfig)
{
_devConfig = deviceConfig;
_isDeviceReady = false;
_activeDeviceType = deviceConfig["type"].toString("UNSPECIFIED").toLower();
}
LedDevice* LedDeviceAPA102::construct(const QJsonObject &deviceConfig)

View File

@ -35,7 +35,7 @@ Reset time is 24uS = 59 bits = 8 bytes
*/
LedDeviceAPA104::LedDeviceAPA104(const QJsonObject &deviceConfig)
: ProviderSpi()
: ProviderSpi(deviceConfig)
, SPI_BYTES_PER_COLOUR(4)
, SPI_FRAME_END_LATCH_BYTES(8)
, bitpair_to_byte {
@ -45,10 +45,6 @@ LedDeviceAPA104::LedDeviceAPA104(const QJsonObject &deviceConfig)
0b11101110,
}
{
_devConfig = deviceConfig;
_isDeviceReady = false;
_activeDeviceType = deviceConfig["type"].toString("UNSPECIFIED").toLower();
}

View File

@ -1,12 +1,8 @@
#include "LedDeviceLpd6803.h"
LedDeviceLpd6803::LedDeviceLpd6803(const QJsonObject &deviceConfig)
: ProviderSpi()
: ProviderSpi(deviceConfig)
{
_devConfig = deviceConfig;
_isDeviceReady = false;
_activeDeviceType = deviceConfig["type"].toString("UNSPECIFIED").toLower();
}
LedDevice* LedDeviceLpd6803::construct(const QJsonObject &deviceConfig)

View File

@ -1,12 +1,8 @@
#include "LedDeviceLpd8806.h"
LedDeviceLpd8806::LedDeviceLpd8806(const QJsonObject &deviceConfig)
: ProviderSpi()
: ProviderSpi(deviceConfig)
{
_devConfig = deviceConfig;
_isDeviceReady = false;
_activeDeviceType = deviceConfig["type"].toString("UNSPECIFIED").toLower();
}
LedDevice* LedDeviceLpd8806::construct(const QJsonObject &deviceConfig)

View File

@ -1,12 +1,8 @@
#include "LedDeviceP9813.h"
LedDeviceP9813::LedDeviceP9813(const QJsonObject &deviceConfig)
: ProviderSpi()
: ProviderSpi(deviceConfig)
{
_devConfig = deviceConfig;
_isDeviceReady = false;
_activeDeviceType = deviceConfig["type"].toString("UNSPECIFIED").toLower();
}
LedDevice* LedDeviceP9813::construct(const QJsonObject &deviceConfig)

View File

@ -1,7 +1,7 @@
#include "LedDeviceSk6812SPI.h"
LedDeviceSk6812SPI::LedDeviceSk6812SPI(const QJsonObject &deviceConfig)
: ProviderSpi()
LedDeviceSk6812SPI::LedDeviceSk6812SPI(const QJsonObject &deviceConfig)
: ProviderSpi(deviceConfig)
, _whiteAlgorithm(RGBW::WhiteAlgorithm::INVALID)
, SPI_BYTES_PER_COLOUR(4)
, bitpair_to_byte {
@ -11,10 +11,6 @@
0b11001100,
}
{
_devConfig = deviceConfig;
_isDeviceReady = false;
_activeDeviceType = deviceConfig["type"].toString("UNSPECIFIED").toLower();
}
LedDevice* LedDeviceSk6812SPI::construct(const QJsonObject &deviceConfig)

View File

@ -37,7 +37,7 @@ Reset time is 50uS = 100 bits = 13 bytes
*/
LedDeviceSk6822SPI::LedDeviceSk6822SPI(const QJsonObject &deviceConfig)
: ProviderSpi()
: ProviderSpi(deviceConfig)
, SPI_BYTES_PER_COLOUR(4)
, SPI_BYTES_WAIT_TIME(3)
, SPI_FRAME_END_LATCH_BYTES(13)
@ -48,13 +48,8 @@ LedDeviceSk6822SPI::LedDeviceSk6822SPI(const QJsonObject &deviceConfig)
0b11101110,
}
{
_devConfig = deviceConfig;
_isDeviceReady = false;
_activeDeviceType = deviceConfig["type"].toString("UNSPECIFIED").toLower();
}
LedDevice* LedDeviceSk6822SPI::construct(const QJsonObject &deviceConfig)
{
return new LedDeviceSk6822SPI(deviceConfig);

View File

@ -1,12 +1,8 @@
#include "LedDeviceWs2801.h"
LedDeviceWs2801::LedDeviceWs2801(const QJsonObject &deviceConfig)
: ProviderSpi()
: ProviderSpi(deviceConfig)
{
_devConfig = deviceConfig;
_isDeviceReady = false;
_activeDeviceType = deviceConfig["type"].toString("UNSPECIFIED").toLower();
}
LedDevice* LedDeviceWs2801::construct(const QJsonObject &deviceConfig)

View File

@ -34,8 +34,8 @@ Reset time is 300uS = 923 bits = 116 bytes
*/
LedDeviceWs2812SPI::LedDeviceWs2812SPI(const QJsonObject &deviceConfig)
: ProviderSpi()
LedDeviceWs2812SPI::LedDeviceWs2812SPI(const QJsonObject &deviceConfig)
: ProviderSpi(deviceConfig)
, SPI_BYTES_PER_COLOUR(4)
, SPI_FRAME_END_LATCH_BYTES(116)
, bitpair_to_byte {
@ -45,10 +45,6 @@ Reset time is 300uS = 923 bits = 116 bytes
0b11001100,
}
{
_devConfig = deviceConfig;
_isDeviceReady = false;
_activeDeviceType = deviceConfig["type"].toString("UNSPECIFIED").toLower();
}
LedDevice* LedDeviceWs2812SPI::construct(const QJsonObject &deviceConfig)

View File

@ -14,9 +14,8 @@
#include "ProviderSpi.h"
#include <utils/Logger.h>
ProviderSpi::ProviderSpi()
: LedDevice()
ProviderSpi::ProviderSpi(const QJsonObject &deviceConfig)
: LedDevice(deviceConfig)
, _deviceName("/dev/spidev0.0")
, _baudRate_Hz(1000000)
, _fid(-1)

View File

@ -15,7 +15,7 @@ public:
///
/// Constructs specific LedDevice
///
ProviderSpi();
ProviderSpi(const QJsonObject &deviceConfig);
///
/// Sets configuration

View File

@ -16,16 +16,12 @@ const uint16_t DEFAULT_PORT = 4223;
} //End of constants
LedDeviceTinkerforge::LedDeviceTinkerforge(const QJsonObject &deviceConfig)
: LedDevice()
: LedDevice(deviceConfig)
,_port(DEFAULT_PORT)
,_ipConnection(nullptr)
,_ledStrip(nullptr)
,_colorChannelSize(0)
{
_devConfig = deviceConfig;
_isDeviceReady = false;
_activeDeviceType = deviceConfig["type"].toString("UNSPECIFIED").toLower();
}
LedDeviceTinkerforge::~LedDeviceTinkerforge()

View File

@ -22,7 +22,6 @@
#define STRINGIFY2(x) #x
#define STRINGIFY(x) STRINGIFY2(x)
PythonInit::PythonInit()
{
// register modules

View File

@ -13,7 +13,7 @@ NetOrigin::NetOrigin(QObject* parent, Logger* log)
NetOrigin::instance = this;
}
bool NetOrigin::accessAllowed(const QHostAddress& address, const QHostAddress& local)
bool NetOrigin::accessAllowed(const QHostAddress& address, const QHostAddress& local) const
{
if(_internetAccessAllowed)
return true;
@ -29,7 +29,7 @@ bool NetOrigin::accessAllowed(const QHostAddress& address, const QHostAddress& l
return true;
}
bool NetOrigin::isLocalAddress(const QHostAddress& address, const QHostAddress& local)
bool NetOrigin::isLocalAddress(const QHostAddress& address, const QHostAddress& local) const
{
if(address.protocol() == QAbstractSocket::IPv4Protocol)
{

View File

@ -4,9 +4,9 @@
#include <QByteArray>
namespace Process {
void restartHyperion(bool asNewProcess){}
void restartHyperion(bool asNewProcess) {}
QByteArray command_exec(QString /*cmd*/, QByteArray /*data*/)
QByteArray command_exec(const QString& /*cmd*/, const QByteArray& /*data*/)
{
return QSTRING_CSTR(QString());
}
@ -48,7 +48,7 @@ void restartHyperion(bool asNewProcess)
QCoreApplication::quit();
}
QByteArray command_exec(QString cmd, QByteArray data)
QByteArray command_exec(const QString& cmd, const QByteArray& data)
{
char buffer[128];
QString result;

View File

@ -31,9 +31,9 @@ void Rgb_to_Rgbw(ColorRgb input, ColorRgbw * output, const WhiteAlgorithm algori
{
// http://forum.garagecube.com/viewtopic.php?t=10178
// warm white
float F1 = static_cast<float>(0.274);
float F2 = static_cast<float>(0.454);
float F3 = static_cast<float>(2.333);
const float F1(0.274);
const float F2(0.454);
const float F3(2.333);
output->white = qMin(input.red*F1,qMin(input.green*F2,input.blue*F3));
output->red = input.red - output->white/F1;
@ -46,9 +46,9 @@ void Rgb_to_Rgbw(ColorRgb input, ColorRgbw * output, const WhiteAlgorithm algori
{
// http://forum.garagecube.com/viewtopic.php?t=10178
// cold white
float F1 = static_cast<float>(0.299);
float F2 = static_cast<float>(0.587);
float F3 = static_cast<float>(0.114);
const float F1(0.299);
const float F2(0.587);
const float F3(0.114);
output->white = qMin(input.red*F1,qMin(input.green*F2,input.blue*F3));
output->red = input.red - output->white/F1;