diff --git a/assets/webconfig/i18n/cs.json b/assets/webconfig/i18n/cs.json
index 2a6a0110..96c269e3 100644
--- a/assets/webconfig/i18n/cs.json
+++ b/assets/webconfig/i18n/cs.json
@@ -52,8 +52,8 @@
"dashboard_infobox_message_updatesuccess": "Spusťte nejnovější verzi Hyperionu.",
"dashboard_infobox_label_statush": "Stav Hyperionu:",
"dashboard_infobox_label_smartacc": "Inteligentní přístup",
- "dashboard_infobox_label_enableh": "Zapnout Hyperion",
- "dashboard_infobox_label_disableh": "Vypnout Hyperion",
+ "dashboard_infobox_label_enableh": "Povolit Instance: $1",
+ "dashboard_infobox_label_disableh": "Vypnout Instance $1",
"dashboard_componentbox_label_title": "Stav komponent",
"dashboard_componentbox_label_comp": "Komponenty",
"dashboard_componentbox_label_status": "Status",
diff --git a/assets/webconfig/i18n/de.json b/assets/webconfig/i18n/de.json
index 209dd71e..ee803ee2 100644
--- a/assets/webconfig/i18n/de.json
+++ b/assets/webconfig/i18n/de.json
@@ -68,8 +68,8 @@
"dashboard_infobox_message_updatesuccess": "Du nutzt die aktuellste Version von Hyperion.",
"dashboard_infobox_label_statush": "Hyperion Status:",
"dashboard_infobox_label_smartacc": "Schnellzugriff",
- "dashboard_infobox_label_enableh": "Aktiviere Hyperion",
- "dashboard_infobox_label_disableh": "Deaktiviere Hyperion",
+ "dashboard_infobox_label_enableh" : "Aktiviere Instanz: $1",
+ "dashboard_infobox_label_disableh" : "Deaktiviere Instanz: $1",
"dashboard_componentbox_label_title": "Komponenten Status",
"dashboard_componentbox_label_comp": "Komponente",
"dashboard_componentbox_label_status": "Status",
diff --git a/assets/webconfig/i18n/en.json b/assets/webconfig/i18n/en.json
index 71fb12d9..018279d1 100644
--- a/assets/webconfig/i18n/en.json
+++ b/assets/webconfig/i18n/en.json
@@ -68,8 +68,8 @@
"dashboard_infobox_message_updatesuccess" : "You run the latest version of Hyperion.",
"dashboard_infobox_label_statush" : "Hyperion status:",
"dashboard_infobox_label_smartacc" : "Smart Access",
- "dashboard_infobox_label_enableh" : "Enable Hyperion",
- "dashboard_infobox_label_disableh" : "Disable Hyperion",
+ "dashboard_infobox_label_enableh" : "Enable Instance: $1",
+ "dashboard_infobox_label_disableh" : "Disable Instance: $1",
"dashboard_componentbox_label_title" : "Components status",
"dashboard_componentbox_label_comp" : "Component",
"dashboard_componentbox_label_status" : "Status",
diff --git a/assets/webconfig/i18n/es.json b/assets/webconfig/i18n/es.json
index ecb50870..cf9475b5 100644
--- a/assets/webconfig/i18n/es.json
+++ b/assets/webconfig/i18n/es.json
@@ -52,8 +52,8 @@
"dashboard_infobox_message_updatesuccess": "Ejecutas la última versión de Hyperion.",
"dashboard_infobox_label_statush": "Estado de Hyperion:",
"dashboard_infobox_label_smartacc": "Acceso Inteligente",
- "dashboard_infobox_label_enableh": "Habilitar Hyperion",
- "dashboard_infobox_label_disableh": "Deshabilitar Hyperion",
+ "dashboard_infobox_label_enableh": "Habilitar Instancia: $1",
+ "dashboard_infobox_label_disableh": "Deshabilitar Instancia: $1",
"dashboard_componentbox_label_title": "Estado de los componentes",
"dashboard_componentbox_label_comp": "Estado de los componentes",
"dashboard_componentbox_label_status": "Estado",
diff --git a/assets/webconfig/i18n/it.json b/assets/webconfig/i18n/it.json
index 77cc6524..70275db2 100644
--- a/assets/webconfig/i18n/it.json
+++ b/assets/webconfig/i18n/it.json
@@ -52,8 +52,8 @@
"dashboard_infobox_message_updatesuccess": "Stai eseguendo l'ultima versione di Hyperion.",
"dashboard_infobox_label_statush": "Status Hyperion:",
"dashboard_infobox_label_smartacc": "Accesso Smart",
- "dashboard_infobox_label_enableh": "Abilita Hyperion",
- "dashboard_infobox_label_disableh": "Disabilita Hyperion",
+ "dashboard_infobox_label_enableh": "Abilita Istanza: $1",
+ "dashboard_infobox_label_disableh": "Disabilita Istanza: $1",
"dashboard_componentbox_label_title": "Status componenti",
"dashboard_componentbox_label_comp": "Componente",
"dashboard_componentbox_label_status": "Status",
diff --git a/assets/webconfig/i18n/nl.json b/assets/webconfig/i18n/nl.json
index 894bd6bf..496103f2 100644
--- a/assets/webconfig/i18n/nl.json
+++ b/assets/webconfig/i18n/nl.json
@@ -52,8 +52,8 @@
"dashboard_infobox_message_updatesuccess": "Je draait de laatste versie van Hyperion",
"dashboard_infobox_label_statush": "Hyperion status:",
"dashboard_infobox_label_smartacc": "Slimme toegang",
- "dashboard_infobox_label_enableh": "Schakel Hyperion in",
- "dashboard_infobox_label_disableh": "Schakel Hyperion uit",
+ "dashboard_infobox_label_enableh": "Schakel Instantie $1 in",
+ "dashboard_infobox_label_disableh": "Schakel Instantie $1 uit",
"dashboard_componentbox_label_title": "Componenten status",
"dashboard_componentbox_label_comp": "Component",
"dashboard_componentbox_label_status": "Status",
diff --git a/assets/webconfig/i18n/sv.json b/assets/webconfig/i18n/sv.json
index ea5786bf..5aa03e29 100644
--- a/assets/webconfig/i18n/sv.json
+++ b/assets/webconfig/i18n/sv.json
@@ -52,8 +52,8 @@
"dashboard_infobox_message_updatesuccess": "Du använder den senaste versionen av Hyperion.",
"dashboard_infobox_label_statush": "Hyperion-status:",
"dashboard_infobox_label_smartacc": "Smart Åtkomst",
- "dashboard_infobox_label_enableh": "Aktivera Hyperion",
- "dashboard_infobox_label_disableh": "Inaktivera Hyperion",
+ "dashboard_infobox_label_enableh": "Aktivera Instans: $1",
+ "dashboard_infobox_label_disableh": "Inaktivera Instans: $1",
"dashboard_componentbox_label_title": "Komponentstatus",
"dashboard_componentbox_label_comp": "Komponent",
"dashboard_componentbox_label_status": "Status",
diff --git a/assets/webconfig/js/content_dashboard.js b/assets/webconfig/js/content_dashboard.js
index 1315d704..48f46bdc 100644
--- a/assets/webconfig/js/content_dashboard.js
+++ b/assets/webconfig/js/content_dashboard.js
@@ -69,8 +69,11 @@ $(document).ready( function() {
}
});
+ var instancename = window.currentHyperionInstanceName;
+ console.log ("instancename: ",instancename);
+
$('#dash_statush').html(hyperion_enabled ? ''+$.i18n('general_btn_on')+'' : ''+$.i18n('general_btn_off')+'');
- $('#btn_hsc').html(hyperion_enabled ? '' : '');
+ $('#btn_hsc').html(hyperion_enabled ? '' : '');
}
// add more info
diff --git a/include/grabber/VideoStandard.h b/include/grabber/VideoStandard.h
index 3bbc20a9..5b22f8f6 100644
--- a/include/grabber/VideoStandard.h
+++ b/include/grabber/VideoStandard.h
@@ -3,11 +3,11 @@
/**
* Enumeration of the possible video standards the grabber can be set to
*/
-enum VideoStandard {
- VIDEOSTANDARD_PAL,
- VIDEOSTANDARD_NTSC,
- VIDEOSTANDARD_SECAM,
- VIDEOSTANDARD_NO_CHANGE
+enum class VideoStandard {
+ PAL,
+ NTSC,
+ SECAM,
+ NO_CHANGE
};
inline VideoStandard parseVideoStandard(QString videoStandard)
@@ -17,17 +17,17 @@ inline VideoStandard parseVideoStandard(QString videoStandard)
if (videoStandard == "pal")
{
- return VIDEOSTANDARD_PAL;
+ return VideoStandard::PAL;
}
else if (videoStandard == "ntsc")
{
- return VIDEOSTANDARD_NTSC;
+ return VideoStandard::NTSC;
}
else if (videoStandard == "secam")
{
- return VIDEOSTANDARD_SECAM;
+ return VideoStandard::SECAM;
}
// return the default NO_CHANGE
- return VIDEOSTANDARD_NO_CHANGE;
+ return VideoStandard::NO_CHANGE;
}
diff --git a/include/hyperion/Hyperion.h b/include/hyperion/Hyperion.h
index 6eb16712..091fe9b9 100644
--- a/include/hyperion/Hyperion.h
+++ b/include/hyperion/Hyperion.h
@@ -552,7 +552,7 @@ private:
/// buffer for leds (with adjustment)
std::vector _ledBuffer;
- VideoMode _currVideoMode = VIDEO_2D;
+ VideoMode _currVideoMode = VideoMode::VIDEO_2D;
/// Boblight instance
BoblightServer* _boblightServer;
diff --git a/include/hyperion/LedString.h b/include/hyperion/LedString.h
index 2d87c222..ed981df0 100644
--- a/include/hyperion/LedString.h
+++ b/include/hyperion/LedString.h
@@ -15,7 +15,7 @@
namespace Json { class Value; }
/// Enumeration containing the possible orders of device color byte data
-enum ColorOrder
+enum class ColorOrder
{
ORDER_RGB, ORDER_RBG, ORDER_GRB, ORDER_BRG, ORDER_GBR, ORDER_BGR
};
@@ -24,17 +24,17 @@ inline QString colorOrderToString(const ColorOrder colorOrder)
{
switch (colorOrder)
{
- case ORDER_RGB:
+ case ColorOrder::ORDER_RGB:
return "rgb";
- case ORDER_RBG:
+ case ColorOrder::ORDER_RBG:
return "rbg";
- case ORDER_GRB:
+ case ColorOrder::ORDER_GRB:
return "grb";
- case ORDER_BRG:
+ case ColorOrder::ORDER_BRG:
return "brg";
- case ORDER_GBR:
+ case ColorOrder::ORDER_GBR:
return "gbr";
- case ORDER_BGR:
+ case ColorOrder::ORDER_BGR:
return "bgr";
default:
return "not-a-colororder";
@@ -44,31 +44,31 @@ inline ColorOrder stringToColorOrder(const QString & order)
{
if (order == "rgb")
{
- return ORDER_RGB;
+ return ColorOrder::ORDER_RGB;
}
else if (order == "bgr")
{
- return ORDER_BGR;
+ return ColorOrder::ORDER_BGR;
}
else if (order == "rbg")
{
- return ORDER_RBG;
+ return ColorOrder::ORDER_RBG;
}
else if (order == "brg")
{
- return ORDER_BRG;
+ return ColorOrder::ORDER_BRG;
}
else if (order == "gbr")
{
- return ORDER_GBR;
+ return ColorOrder::ORDER_GBR;
}
else if (order == "grb")
{
- return ORDER_GRB;
+ return ColorOrder::ORDER_GRB;
}
std::cout << "Unknown color order defined (" << order.toStdString() << "). Using RGB." << std::endl;
- return ORDER_RGB;
+ return ColorOrder::ORDER_RGB;
}
///
diff --git a/include/leddevice/LedDevice.h b/include/leddevice/LedDevice.h
index 186fe96a..5f751215 100644
--- a/include/leddevice/LedDevice.h
+++ b/include/leddevice/LedDevice.h
@@ -7,6 +7,7 @@
#include
#include
#include
+#include
// STL includes
#include
@@ -179,8 +180,8 @@ protected:
QTimer* _refresh_timer;
int _refresh_timer_interval;
- /// timestamp of last write
- qint64 _last_write_time;
+ /// Timestamp of last write
+ QDateTime _lastWriteTime;
/// Time a device requires mandatorily between two writes
int _latchTime_ms;
diff --git a/include/ssdp/SSDPDiscover.h b/include/ssdp/SSDPDiscover.h
index 00975e30..e149a0e5 100644
--- a/include/ssdp/SSDPDiscover.h
+++ b/include/ssdp/SSDPDiscover.h
@@ -5,51 +5,59 @@
class QUdpSocket;
-enum searchType{
+enum class searchType{
STY_WEBSERVER,
STY_FLATBUFSERVER,
STY_JSONSERVER
};
///
-/// @brief Search for SSDP sessions, used by standalone capture binaries
+/// @brief Search for SSDP sessions, used by stand-alone capture binaries
///
class SSDPDiscover : public QObject
{
Q_OBJECT
public:
+
SSDPDiscover(QObject* parent = nullptr);
///
- /// @brief Search for specified service, results will be returned by signal newService(). Calling this method again will reset all found usns and search again
+ /// @brief Search for specified service, results will be returned by signal newService(). Calling this method again will reset all found urns and search again
/// @param st The service to search for
///
- void searchForService(const QString& st = "urn:hyperion-project.org:device:basic:1");
+ void searchForService(const QString &st = "urn:hyperion-project.org:device:basic:1");
///
- /// @brief Search for specified searchTarget, the method will block until a server has been found or a timeout happend
+ /// @brief Search for specified searchTarget, the method will block until a server has been found or a timeout happened
/// @param type The address type one of struct searchType
/// @param st The service to search for
/// @param timeout_ms The timeout in ms
- /// @return The address+port of webserver or empty if timed out
+ /// @return The address+port of web-server or empty if timed out
///
- const QString getFirstService(const searchType& type = STY_WEBSERVER,const QString& st = "urn:hyperion-project.org:device:basic:1", const int& timeout_ms = 3000);
+ const QString getFirstService(const searchType &type = searchType::STY_WEBSERVER,const QString &st = "urn:hyperion-project.org:device:basic:1", const int &timeout_ms = 3000);
signals:
///
- /// @brief Emits whenever a new service has ben found, search started with searchForService()
- /// @param webServer The address+port of webserver "192.168.0.10:8090"
+ /// @brief Emits whenever a new service has been found, search started with searchForService()
///
- void newService(const QString webServer);
+ /// @param webServer The address+port of web-server "192.168.0.10:8090"
+ ///
+ void newService(const QString &webServer);
private slots:
void readPendingDatagrams();
private:
- void sendSearch(const QString& st);
+ ///
+ /// @brief Execute ssdp discovery request
+ ///
+ /// @param[in] st Search Target
+ ///
+ void sendSearch(const QString &st);
private:
+
Logger* _log;
QUdpSocket* _udpSocket;
QString _searchTarget;
diff --git a/include/utils/ColorRgb.h b/include/utils/ColorRgb.h
index 3a05075a..8de27f2d 100644
--- a/include/utils/ColorRgb.h
+++ b/include/utils/ColorRgb.h
@@ -4,6 +4,8 @@
#include
#include
+#include
+
struct ColorRgb;
///
@@ -49,6 +51,19 @@ inline std::ostream& operator<<(std::ostream& os, const ColorRgb& color)
return os;
}
+///
+/// Stream operator to write ColorRgb to a QTextStream (format "'{'[red]','[green]','[blue]'}'")
+///
+/// @param os The output stream
+/// @param color The color to write
+/// @return The output stream (with the color written to it)
+///
+inline QTextStream& operator<<(QTextStream &os, const ColorRgb& color)
+{
+ os << "{" << unsigned(color.red) << "," << unsigned(color.green) << "," << unsigned(color.blue) << "}";
+ return os;
+}
+
/// Compare operator to check if a color is 'smaller' than another color
inline bool operator<(const ColorRgb & lhs, const ColorRgb & rhs)
{
diff --git a/include/utils/PixelFormat.h b/include/utils/PixelFormat.h
index 4af71b78..eecd4464 100644
--- a/include/utils/PixelFormat.h
+++ b/include/utils/PixelFormat.h
@@ -5,17 +5,17 @@
/**
* Enumeration of the possible pixel formats the grabber can be set to
*/
-enum PixelFormat {
- PIXELFORMAT_YUYV,
- PIXELFORMAT_UYVY,
- PIXELFORMAT_BGR16,
- PIXELFORMAT_BGR24,
- PIXELFORMAT_RGB32,
- PIXELFORMAT_BGR32,
+enum class PixelFormat {
+ YUYV,
+ UYVY,
+ BGR16,
+ BGR24,
+ RGB32,
+ BGR32,
#ifdef HAVE_JPEG_DECODER
- PIXELFORMAT_MJPEG,
+ MJPEG,
#endif
- PIXELFORMAT_NO_CHANGE
+ NO_CHANGE
};
inline PixelFormat parsePixelFormat(QString pixelFormat)
@@ -23,37 +23,37 @@ inline PixelFormat parsePixelFormat(QString pixelFormat)
// convert to lower case
pixelFormat = pixelFormat.toLower();
- if (pixelFormat == "yuyv")
+ if (pixelFormat.compare("yuyv") )
{
- return PIXELFORMAT_YUYV;
+ return PixelFormat::YUYV;
}
- else if (pixelFormat == "uyvy")
+ else if (pixelFormat.compare("uyvy") )
{
- return PIXELFORMAT_UYVY;
+ return PixelFormat::UYVY;
}
- else if (pixelFormat == "bgr16")
+ else if (pixelFormat.compare("bgr16") )
{
- return PIXELFORMAT_BGR16;
+ return PixelFormat::BGR16;
}
- else if (pixelFormat == "bgr24")
+ else if (pixelFormat.compare("bgr24") )
{
- return PIXELFORMAT_BGR24;
+ return PixelFormat::BGR24;
}
- else if (pixelFormat == "rgb32")
+ else if (pixelFormat.compare("rgb32") )
{
- return PIXELFORMAT_RGB32;
+ return PixelFormat::RGB32;
}
- else if (pixelFormat == "bgr32")
+ else if (pixelFormat.compare("bgr32") )
{
- return PIXELFORMAT_BGR32;
+ return PixelFormat::BGR32;
}
#ifdef HAVE_JPEG_DECODER
- else if (pixelFormat == "mjpeg")
+ else if (pixelFormat.compare("mjpeg") )
{
- return PIXELFORMAT_MJPEG;
+ return PixelFormat::MJPEG;
}
#endif
// return the default NO_CHANGE
- return PIXELFORMAT_NO_CHANGE;
+ return PixelFormat::NO_CHANGE;
}
diff --git a/include/utils/RgbToRgbw.h b/include/utils/RgbToRgbw.h
index bbac086b..0c6c9aee 100644
--- a/include/utils/RgbToRgbw.h
+++ b/include/utils/RgbToRgbw.h
@@ -6,7 +6,7 @@
namespace RGBW {
- enum WhiteAlgorithm {
+ enum class WhiteAlgorithm {
INVALID,
SUBTRACT_MINIMUM,
SUB_MIN_WARM_ADJUST,
diff --git a/include/utils/VideoMode.h b/include/utils/VideoMode.h
index 654a6431..b4500dfc 100644
--- a/include/utils/VideoMode.h
+++ b/include/utils/VideoMode.h
@@ -5,7 +5,7 @@
/**
* Enumeration of the possible modes in which video can be playing (2D, 3D)
*/
-enum VideoMode
+enum class VideoMode
{
VIDEO_2D,
VIDEO_3DSBS,
@@ -19,24 +19,24 @@ inline VideoMode parse3DMode(QString videoMode)
if (videoMode == "3DTAB")
{
- return VIDEO_3DTAB;
+ return VideoMode::VIDEO_3DTAB;
}
else if (videoMode == "3DSBS")
{
- return VIDEO_3DSBS;
+ return VideoMode::VIDEO_3DSBS;
}
// return the default 2D
- return VIDEO_2D;
+ return VideoMode::VIDEO_2D;
}
inline QString videoMode2String(VideoMode mode)
{
switch(mode)
{
- case VIDEO_3DTAB: return "3DTAB";
- case VIDEO_3DSBS: return "3DSBS";
- case VIDEO_2D: return "2D";
+ case VideoMode::VIDEO_3DTAB: return "3DTAB";
+ case VideoMode::VIDEO_3DSBS: return "3DSBS";
+ case VideoMode::VIDEO_2D: return "2D";
default: return "INVALID";
}
}
diff --git a/libsrc/boblightserver/BoblightClientConnection.cpp b/libsrc/boblightserver/BoblightClientConnection.cpp
index 60f53f87..0336f34f 100644
--- a/libsrc/boblightserver/BoblightClientConnection.cpp
+++ b/libsrc/boblightserver/BoblightClientConnection.cpp
@@ -90,8 +90,11 @@ void BoblightClientConnection::socketClosed()
void BoblightClientConnection::handleMessage(const QString & message)
{
//std::cout << "boblight message: " << message.toStdString() << std::endl;
-
- QStringList messageParts = message.split(" ", QString::SkipEmptyParts);
+ #if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
+ QStringList messageParts = message.split(" ", Qt::SkipEmptyParts);
+ #else
+ QStringList messageParts = message.split(" ", QString::SkipEmptyParts);
+ #endif
if (messageParts.size() > 0)
{
diff --git a/libsrc/grabber/amlogic/AmlogicGrabber.cpp b/libsrc/grabber/amlogic/AmlogicGrabber.cpp
index f8581177..f3fe7a54 100644
--- a/libsrc/grabber/amlogic/AmlogicGrabber.cpp
+++ b/libsrc/grabber/amlogic/AmlogicGrabber.cpp
@@ -159,7 +159,7 @@ int AmlogicGrabber::grabFrame_amvideocap(Image & image)
}
_useImageResampler = true;
- _imageResampler.processImage((const uint8_t*)_image_ptr, _width, _height, (_width << 1) + _width, PIXELFORMAT_BGR24, image);
+ _imageResampler.processImage((const uint8_t*)_image_ptr, _width, _height, (_width << 1) + _width, PixelFormat::BGR24, image);
_lastError = 0;
return 0;
diff --git a/libsrc/grabber/dispmanx/DispmanxFrameGrabber.cpp b/libsrc/grabber/dispmanx/DispmanxFrameGrabber.cpp
index 54bcbf52..7e7ec9b5 100644
--- a/libsrc/grabber/dispmanx/DispmanxFrameGrabber.cpp
+++ b/libsrc/grabber/dispmanx/DispmanxFrameGrabber.cpp
@@ -114,15 +114,15 @@ int DispmanxFrameGrabber::grabFrame(Image & image)
// calculate final image dimensions and adjust top/left cropping in 3D modes
switch (_videoMode)
{
- case VIDEO_3DSBS:
+ case VideoMode::VIDEO_3DSBS:
imageWidth /= 2;
cropLeft /= 2;
break;
- case VIDEO_3DTAB:
+ case VideoMode::VIDEO_3DTAB:
imageHeight /= 2;
cropTop /= 2;
break;
- case VIDEO_2D:
+ case VideoMode::VIDEO_2D:
default:
break;
}
diff --git a/libsrc/grabber/framebuffer/FramebufferFrameGrabber.cpp b/libsrc/grabber/framebuffer/FramebufferFrameGrabber.cpp
index a14cf805..e5c1ab46 100644
--- a/libsrc/grabber/framebuffer/FramebufferFrameGrabber.cpp
+++ b/libsrc/grabber/framebuffer/FramebufferFrameGrabber.cpp
@@ -44,12 +44,12 @@ int FramebufferFrameGrabber::grabFrame(Image & image)
switch (vinfo.bits_per_pixel)
{
- case 16: pixelFormat = PIXELFORMAT_BGR16; break;
- case 24: pixelFormat = PIXELFORMAT_BGR24; break;
+ case 16: pixelFormat = PixelFormat::BGR16; break;
+ case 24: pixelFormat = PixelFormat::BGR24; break;
#ifdef ENABLE_AMLOGIC
- case 32: pixelFormat = PIXELFORMAT_RGB32; break;
+ case 32: pixelFormat = PixelFormat::PIXELFORMAT_RGB32; break;
#else
- case 32: pixelFormat = PIXELFORMAT_BGR32; break;
+ case 32: pixelFormat = PixelFormat::BGR32; break;
#endif
default:
Error(_log, "Unknown pixel format: %d bits per pixel", vinfo.bits_per_pixel);
diff --git a/libsrc/grabber/osx/OsxFrameGrabber.cpp b/libsrc/grabber/osx/OsxFrameGrabber.cpp
index 7306b40a..7929899f 100644
--- a/libsrc/grabber/osx/OsxFrameGrabber.cpp
+++ b/libsrc/grabber/osx/OsxFrameGrabber.cpp
@@ -50,7 +50,7 @@ int OsxFrameGrabber::grabFrame(Image & image)
dspWidth,
dspHeight,
CGImageGetBytesPerRow(dispImage),
- PIXELFORMAT_BGR32,
+ PixelFormat::BGR32,
image);
CFRelease(imgData);
diff --git a/libsrc/grabber/qt/QtGrabber.cpp b/libsrc/grabber/qt/QtGrabber.cpp
index 1ab5abf0..1f24aa13 100644
--- a/libsrc/grabber/qt/QtGrabber.cpp
+++ b/libsrc/grabber/qt/QtGrabber.cpp
@@ -146,7 +146,7 @@ int QtGrabber::updateScreenDimensions(const bool& force)
// calculate final image dimensions and adjust top/left cropping in 3D modes
switch (_videoMode)
{
- case VIDEO_3DSBS:
+ case VideoMode::VIDEO_3DSBS:
_width = width /2;
_height = height;
_src_x = _cropLeft / 2;
@@ -154,7 +154,7 @@ int QtGrabber::updateScreenDimensions(const bool& force)
_src_x_max = (_screenWidth / 2) - _cropRight;
_src_y_max = _screenHeight - _cropBottom;
break;
- case VIDEO_3DTAB:
+ case VideoMode::VIDEO_3DTAB:
_width = width;
_height = height / 2;
_src_x = _cropLeft;
@@ -162,7 +162,7 @@ int QtGrabber::updateScreenDimensions(const bool& force)
_src_x_max = _screenWidth - _cropRight;
_src_y_max = (_screenHeight / 2) - _cropBottom;
break;
- case VIDEO_2D:
+ case VideoMode::VIDEO_2D:
default:
_width = width;
_height = height;
diff --git a/libsrc/grabber/v4l2/V4L2Grabber.cpp b/libsrc/grabber/v4l2/V4L2Grabber.cpp
index 0cfd9dfb..164e7173 100644
--- a/libsrc/grabber/v4l2/V4L2Grabber.cpp
+++ b/libsrc/grabber/v4l2/V4L2Grabber.cpp
@@ -591,7 +591,7 @@ void V4L2Grabber::init_device(VideoStandard videoStandard)
{
switch (videoStandard)
{
- case VIDEOSTANDARD_PAL:
+ case VideoStandard::PAL:
{
standard.id = V4L2_STD_PAL;
if (-1 == xioctl(VIDIOC_S_STD, &standard.id))
@@ -603,7 +603,7 @@ void V4L2Grabber::init_device(VideoStandard videoStandard)
}
break;
- case VIDEOSTANDARD_NTSC:
+ case VideoStandard::NTSC:
{
standard.id = V4L2_STD_NTSC;
if (-1 == xioctl(VIDIOC_S_STD, &standard.id))
@@ -615,7 +615,7 @@ void V4L2Grabber::init_device(VideoStandard videoStandard)
}
break;
- case VIDEOSTANDARD_SECAM:
+ case VideoStandard::SECAM:
{
standard.id = V4L2_STD_SECAM;
if (-1 == xioctl(VIDIOC_S_STD, &standard.id))
@@ -627,7 +627,7 @@ void V4L2Grabber::init_device(VideoStandard videoStandard)
}
break;
- case VIDEOSTANDARD_NO_CHANGE:
+ case VideoStandard::NO_CHANGE:
default:
// No change to device settings
break;
@@ -648,20 +648,20 @@ void V4L2Grabber::init_device(VideoStandard videoStandard)
// set the requested pixel format
switch (_pixelFormat)
{
- case PIXELFORMAT_UYVY:
+ case PixelFormat::UYVY:
fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_UYVY;
break;
- case PIXELFORMAT_YUYV:
+ case PixelFormat::YUYV:
fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_YUYV;
break;
- case PIXELFORMAT_RGB32:
+ case PixelFormat::RGB32:
fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_RGB32;
break;
#ifdef HAVE_JPEG_DECODER
- case PIXELFORMAT_MJPEG:
+ case PixelFormat::MJPEG:
{
fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_MJPEG;
fmt.fmt.pix.field = V4L2_FIELD_ANY;
@@ -669,7 +669,7 @@ void V4L2Grabber::init_device(VideoStandard videoStandard)
break;
#endif
- case PIXELFORMAT_NO_CHANGE:
+ case PixelFormat::NO_CHANGE:
default:
// No change to device settings
break;
@@ -723,7 +723,7 @@ void V4L2Grabber::init_device(VideoStandard videoStandard)
{
case V4L2_PIX_FMT_UYVY:
{
- _pixelFormat = PIXELFORMAT_UYVY;
+ _pixelFormat = PixelFormat::UYVY;
_frameByteSize = _width * _height * 2;
Debug(_log, "Pixel format=UYVY");
}
@@ -731,7 +731,7 @@ void V4L2Grabber::init_device(VideoStandard videoStandard)
case V4L2_PIX_FMT_YUYV:
{
- _pixelFormat = PIXELFORMAT_YUYV;
+ _pixelFormat = PixelFormat::YUYV;
_frameByteSize = _width * _height * 2;
Debug(_log, "Pixel format=YUYV");
}
@@ -739,7 +739,7 @@ void V4L2Grabber::init_device(VideoStandard videoStandard)
case V4L2_PIX_FMT_RGB32:
{
- _pixelFormat = PIXELFORMAT_RGB32;
+ _pixelFormat = PixelFormat::RGB32;
_frameByteSize = _width * _height * 4;
Debug(_log, "Pixel format=RGB32");
}
@@ -748,7 +748,7 @@ void V4L2Grabber::init_device(VideoStandard videoStandard)
#ifdef HAVE_JPEG_DECODER
case V4L2_PIX_FMT_MJPEG:
{
- _pixelFormat = PIXELFORMAT_MJPEG;
+ _pixelFormat = PixelFormat::MJPEG;
Debug(_log, "Pixel format=MJPEG");
}
break;
@@ -1016,7 +1016,7 @@ bool V4L2Grabber::process_image(const void *p, int size)
{
// We do want a new frame...
#ifdef HAVE_JPEG_DECODER
- if (size < _frameByteSize && _pixelFormat != PIXELFORMAT_MJPEG)
+ if (size < _frameByteSize && _pixelFormat != PixelFormat::MJPEG)
#else
if (size < _frameByteSize)
#endif
@@ -1041,7 +1041,7 @@ void V4L2Grabber::process_image(const uint8_t * data, int size)
* --------------------------------------------------------*/
#ifdef HAVE_JPEG_DECODER
- if (_pixelFormat == PIXELFORMAT_MJPEG)
+ if (_pixelFormat == PixelFormat::MJPEG)
{
#endif
#ifdef HAVE_JPEG
diff --git a/libsrc/grabber/x11/X11Grabber.cpp b/libsrc/grabber/x11/X11Grabber.cpp
index 4054e9fa..855ea4c0 100644
--- a/libsrc/grabber/x11/X11Grabber.cpp
+++ b/libsrc/grabber/x11/X11Grabber.cpp
@@ -184,7 +184,7 @@ int X11Grabber::grabFrame(Image & image, bool forceUpdate)
return -1;
}
- _imageResampler.processImage(reinterpret_cast(_xImage->data), _xImage->width, _xImage->height, _xImage->bytes_per_line, PIXELFORMAT_BGR32, image);
+ _imageResampler.processImage(reinterpret_cast(_xImage->data), _xImage->width, _xImage->height, _xImage->bytes_per_line, PixelFormat::BGR32, image);
return 0;
}
@@ -244,19 +244,19 @@ int X11Grabber::updateScreenDimensions(bool force)
// calculate final image dimensions and adjust top/left cropping in 3D modes
switch (_videoMode)
{
- case VIDEO_3DSBS:
+ case VideoMode::VIDEO_3DSBS:
_width = width /2;
_height = height;
_src_x = _cropLeft / 2;
_src_y = _cropTop;
break;
- case VIDEO_3DTAB:
+ case VideoMode::VIDEO_3DTAB:
_width = width;
_height = height / 2;
_src_x = _cropLeft;
_src_y = _cropTop / 2;
break;
- case VIDEO_2D:
+ case VideoMode::VIDEO_2D:
default:
_width = width;
_height = height;
diff --git a/libsrc/hyperion/Grabber.cpp b/libsrc/hyperion/Grabber.cpp
index 6a1d814b..8a57722f 100644
--- a/libsrc/hyperion/Grabber.cpp
+++ b/libsrc/hyperion/Grabber.cpp
@@ -4,7 +4,7 @@
Grabber::Grabber(QString grabberName, int width, int height, int cropLeft, int cropRight, int cropTop, int cropBottom)
: _imageResampler()
, _useImageResampler(true)
- , _videoMode(VIDEO_2D)
+ , _videoMode(VideoMode::VIDEO_2D)
, _width(width)
, _height(height)
, _fps(15)
@@ -16,7 +16,7 @@ Grabber::Grabber(QString grabberName, int width, int height, int cropLeft, int c
, _enabled(true)
, _log(Logger::getInstance(grabberName))
{
- Grabber::setVideoMode(VIDEO_2D);
+ Grabber::setVideoMode(VideoMode::VIDEO_2D);
Grabber::setCropping(cropLeft, cropRight, cropTop, cropBottom);
}
diff --git a/libsrc/hyperion/Hyperion.cpp b/libsrc/hyperion/Hyperion.cpp
index 1055fb8f..6940d470 100644
--- a/libsrc/hyperion/Hyperion.cpp
+++ b/libsrc/hyperion/Hyperion.cpp
@@ -568,24 +568,24 @@ void Hyperion::update()
// correct the color byte order
switch (_ledStringColorOrder.at(i))
{
- case ORDER_RGB:
+ case ColorOrder::ORDER_RGB:
// leave as it is
break;
- case ORDER_BGR:
+ case ColorOrder::ORDER_BGR:
std::swap(color.red, color.blue);
break;
- case ORDER_RBG:
+ case ColorOrder::ORDER_RBG:
std::swap(color.green, color.blue);
break;
- case ORDER_GRB:
+ case ColorOrder::ORDER_GRB:
std::swap(color.red, color.green);
break;
- case ORDER_GBR:
+ case ColorOrder::ORDER_GBR:
std::swap(color.red, color.green);
std::swap(color.green, color.blue);
break;
- case ORDER_BRG:
+ case ColorOrder::ORDER_BRG:
std::swap(color.red, color.blue);
std::swap(color.green, color.blue);
break;
diff --git a/libsrc/hyperion/MultiColorAdjustment.cpp b/libsrc/hyperion/MultiColorAdjustment.cpp
index 0c88667e..1a9ed9ca 100644
--- a/libsrc/hyperion/MultiColorAdjustment.cpp
+++ b/libsrc/hyperion/MultiColorAdjustment.cpp
@@ -14,6 +14,7 @@ MultiColorAdjustment::~MultiColorAdjustment()
for (ColorAdjustment * adjustment : _adjustment)
{
delete adjustment;
+ // BUG: Calling pop_back while iterating is invalid
_adjustment.pop_back();
}
}
diff --git a/libsrc/leddevice/LedDevice.cpp b/libsrc/leddevice/LedDevice.cpp
index 38456cb4..5c831ba5 100644
--- a/libsrc/leddevice/LedDevice.cpp
+++ b/libsrc/leddevice/LedDevice.cpp
@@ -8,6 +8,7 @@
#include
#include
#include
+#include
#include "hyperion/Hyperion.h"
#include
@@ -21,7 +22,7 @@ LedDevice::LedDevice(const QJsonObject& config, QObject* parent)
, _deviceInError(false)
, _refresh_timer(new QTimer(this))
, _refresh_timer_interval(0)
- , _last_write_time(QDateTime::currentMSecsSinceEpoch())
+ , _lastWriteTime(QDateTime::currentDateTime())
, _latchTime_ms(0)
, _componentRegistered(false)
, _enabled(false)
@@ -140,7 +141,7 @@ bool LedDevice::init(const QJsonObject &deviceConfig)
//Debug(_log, "Refresh interval = %dms",_refresh_timer_interval );
_refresh_timer->setInterval( _refresh_timer_interval );
- _last_write_time = QDateTime::currentMSecsSinceEpoch();
+ _lastWriteTime = QDateTime::currentDateTime();
this->startRefreshTimer();
}
@@ -170,12 +171,12 @@ int LedDevice::updateLeds(const std::vector& ledValues)
}
else
{
- qint64 elapsedTime = QDateTime::currentMSecsSinceEpoch() - _last_write_time;
- if (_latchTime_ms == 0 || elapsedTime >= _latchTime_ms)
+ qint64 elapsedTimeMs = _lastWriteTime.msecsTo(QDateTime::currentDateTime());
+ if (_latchTime_ms == 0 || elapsedTimeMs >= _latchTime_ms)
{
- //std::cout << "LedDevice::updateLeds(), Elapsed time since last write (" << elapsedTime << ") ms > _latchTime_ms (" << _latchTime_ms << ") ms" << std::endl;
+ //std::cout << "LedDevice::updateLeds(), Elapsed time since last write (" << elapsedTimeMs << ") ms > _latchTime_ms (" << _latchTime_ms << ") ms" << std::endl;
retval = write(ledValues);
- _last_write_time = QDateTime::currentMSecsSinceEpoch();
+ _lastWriteTime = QDateTime::currentDateTime();
// if device requires refreshing, save Led-Values and restart the timer
if ( _refresh_enabled )
@@ -186,7 +187,7 @@ int LedDevice::updateLeds(const std::vector& ledValues)
}
else
{
- //std::cout << "LedDevice::updateLeds(), Skip write. _latchTime_ms (" << _latchTime_ms << ") ms > elapsedTime (" << elapsedTime << ") ms" << std::endl;
+ //std::cout << "LedDevice::updateLeds(), Skip write. elapsedTime (" << elapsedTimeMs << ") ms < _latchTime_ms (" << _latchTime_ms << ") ms" << std::endl;
if ( _refresh_enabled )
{
//Stop timer to allow for next non-refresh update
@@ -242,16 +243,16 @@ int LedDevice::rewriteLeds()
if ( _deviceReady )
{
-// qint64 elapsedTime = QDateTime::currentMSecsSinceEpoch() - _last_write_time;
-// std::cout << "LedDevice::rewriteLeds(): Rewrite Leds now, elapsedTime [" << elapsedTime << "] ms" << std::endl;
+// qint64 elapsedTimeMs = _lastWriteTime.msecsTo(QDateTime::currentDateTime());
+// std::cout << "LedDevice::rewriteLEDs(): Rewrite LEDs now, elapsedTime [" << elapsedTimeMs << "] ms" << std::endl;
// //:TESTING: Inject "white" output records to differentiate from normal writes
// _last_ledValues.clear();
// _last_ledValues.resize(static_cast(_ledCount), ColorRgb::WHITE);
// printLedValues(_last_ledValues);
-// //:TESTING:
+ //:TESTING:
retval = write(_last_ledValues);
- _last_write_time = QDateTime::currentMSecsSinceEpoch();
+ _lastWriteTime = QDateTime::currentDateTime();
}
else
{
diff --git a/libsrc/leddevice/dev_net/LedDeviceAtmoOrb.cpp b/libsrc/leddevice/dev_net/LedDeviceAtmoOrb.cpp
index b3f3e991..d3c7b4ad 100644
--- a/libsrc/leddevice/dev_net/LedDeviceAtmoOrb.cpp
+++ b/libsrc/leddevice/dev_net/LedDeviceAtmoOrb.cpp
@@ -2,18 +2,20 @@
#include "LedDeviceAtmoOrb.h"
// qt includes
-#include
+#include
+
+const quint16 MULTICAST_GROUPL_DEFAULT_PORT = 49692;
+const int LEDS_DEFAULT_NUMBER = 24;
LedDeviceAtmoOrb::LedDeviceAtmoOrb(const QJsonObject &deviceConfig)
: LedDevice()
- , _networkmanager (nullptr)
, _udpSocket (nullptr)
- , _multiCastGroupPort (49692)
- , joinedMulticastgroup (false)
+ , _multiCastGroupPort (MULTICAST_GROUPL_DEFAULT_PORT)
+ , _joinedMulticastgroup (false)
, _useOrbSmoothing (false)
, _transitiontime (0)
, _skipSmoothingDiff (0)
- , _numLeds (24)
+ , _numLeds (LEDS_DEFAULT_NUMBER)
{
_devConfig = deviceConfig;
@@ -27,25 +29,32 @@ LedDevice* LedDeviceAtmoOrb::construct(const QJsonObject &deviceConfig)
LedDeviceAtmoOrb::~LedDeviceAtmoOrb()
{
- _networkmanager->deleteLater();
- _udpSocket->deleteLater();
+ if ( _udpSocket != nullptr )
+ {
+ _udpSocket->deleteLater();
+ }
}
bool LedDeviceAtmoOrb::init(const QJsonObject &deviceConfig)
{
- bool isInitOK = LedDevice::init(deviceConfig);
+ bool isInitOK = false;
- if ( isInitOK )
+ if ( LedDevice::init(deviceConfig) )
{
_multicastGroup = deviceConfig["output"].toString().toStdString().c_str();
_useOrbSmoothing = deviceConfig["useOrbSmoothing"].toBool(false);
_transitiontime = deviceConfig["transitiontime"].toInt(0);
_skipSmoothingDiff = deviceConfig["skipSmoothingDiff"].toInt(0);
- _multiCastGroupPort = static_cast(deviceConfig["port"].toInt(49692));
- _numLeds = deviceConfig["numLeds"].toInt(24);
+ _multiCastGroupPort = static_cast(deviceConfig["port"].toInt(MULTICAST_GROUPL_DEFAULT_PORT));
+ _numLeds = deviceConfig["numLeds"].toInt(LEDS_DEFAULT_NUMBER);
+
+ #if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
+ const QStringList orbIds = deviceConfig["orbIds"].toString().simplified().remove(" ").split(",", Qt::SkipEmptyParts);
+ #else
+ const QStringList orbIds = deviceConfig["orbIds"].toString().simplified().remove(" ").split(",", QString::SkipEmptyParts);
+ #endif
- const QStringList orbIds = deviceConfig["orbIds"].toString().simplified().remove(" ").split(",", QString::SkipEmptyParts);
_orbIds.clear();
foreach(auto & id_str, orbIds)
@@ -53,7 +62,12 @@ bool LedDeviceAtmoOrb::init(const QJsonObject &deviceConfig)
bool ok;
int id = id_str.toInt(&ok);
if (ok)
- _orbIds.append(id);
+ {
+ if ( id < 1 || id > 255 )
+ Warning(_log, "Skip orb id '%d'. IDs must be in range 1-255", id);
+ else
+ _orbIds.append(id);
+ }
else
Error(_log, "orb id '%s' is not a number", QSTRING_CSTR(id_str));
}
@@ -63,25 +77,15 @@ bool LedDeviceAtmoOrb::init(const QJsonObject &deviceConfig)
this->setInError("No valid OrbIds found!");
isInitOK = false;
}
+ else
+ {
+ _udpSocket = new QUdpSocket(this);
+ isInitOK = true;
+ }
}
return isInitOK;
}
-bool LedDeviceAtmoOrb::initNetwork()
-{
- bool isInitOK = true;
-
- // TODO: Add Network-Error handling
- _networkmanager = new QNetworkAccessManager();
- _groupAddress = QHostAddress(_multicastGroup);
-
- _udpSocket = new QUdpSocket(this);
- _udpSocket->bind(QHostAddress::AnyIPv4, _multiCastGroupPort, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint);
-
- joinedMulticastgroup = _udpSocket->joinMulticastGroup(_groupAddress);
- return isInitOK;
-}
-
int LedDeviceAtmoOrb::open()
{
int retval = -1;
@@ -89,24 +93,56 @@ int LedDeviceAtmoOrb::open()
if ( init(_devConfig) )
{
- if ( !initNetwork() )
+ // Try to bind the UDP-Socket
+ if ( _udpSocket != nullptr )
{
- this->setInError( "Network error!" );
- }
- else
- {
- _deviceReady = true;
- setEnable(true);
- retval = 0;
+ _groupAddress = QHostAddress(_multicastGroup);
+ if ( !_udpSocket->bind(QHostAddress::AnyIPv4, _multiCastGroupPort, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint) )
+ {
+ QString errortext = QString ("(%1) %2, MulticastGroup: (%3)").arg(_udpSocket->error()).arg(_udpSocket->errorString()).arg(_multicastGroup);
+ this->setInError( errortext );
+ }
+ else
+ {
+ _joinedMulticastgroup = _udpSocket->joinMulticastGroup(_groupAddress);
+ if ( !_joinedMulticastgroup )
+ {
+ QString errortext = QString ("(%1) %2, MulticastGroup: (%3)").arg(_udpSocket->error()).arg(_udpSocket->errorString()).arg(_multicastGroup);
+ this->setInError( errortext );
+ }
+ else
+ {
+ // Everything is OK, device is ready
+ _deviceReady = true;
+ setEnable(true);
+ retval = 0;
+ }
+ }
}
}
return retval;
}
+void LedDeviceAtmoOrb::close()
+{
+ LedDevice::close();
+
+ if ( _udpSocket != nullptr )
+ {
+ // Test, if device requires closing
+ if ( _udpSocket->isOpen() )
+ {
+ Debug(_log,"Close UDP-device: %s", QSTRING_CSTR( this->getActiveDeviceType() ) );
+ _udpSocket->close();
+ // Everything is OK -> device is closed
+ }
+ }
+}
+
int LedDeviceAtmoOrb::write(const std::vector &ledValues)
{
// If not in multicast group return
- if (!joinedMulticastgroup)
+ if (!_joinedMulticastgroup)
{
return 0;
}
@@ -179,20 +215,23 @@ void LedDeviceAtmoOrb::setColor(int orbId, const ColorRgb &color, int commandTyp
bytes.fill('\0');
// Command identifier: C0FFEE
- bytes[0] = 0xC0;
- bytes[1] = 0xFF;
- bytes[2] = 0xEE;
+ bytes[0] = static_cast(0xC0);
+ bytes[1] = static_cast(0xFF);
+ bytes[2] = static_cast(0xEE);
// Command type
- bytes[3] = commandType;
+ bytes[3] = static_cast(commandType);
// Orb ID
- bytes[4] = orbId;
+ bytes[4] = static_cast(orbId);
// RED / GREEN / BLUE
- bytes[5] = color.red;
- bytes[6] = color.green;
- bytes[7] = color.blue;
+ bytes[5] = static_cast(color.red);
+ bytes[6] = static_cast(color.green);
+ bytes[7] = static_cast(color.blue);
+
+ // TODO: Why is the datagram _numLeds * 3 in size, if only bypes 5,6,7 are updated with the color?
+ //std::cout << "Orb [" << orbId << "] Cmd [" << bytes.toHex(':').toStdString() <<"]"<< std::endl;
sendCommand(bytes);
}
diff --git a/libsrc/leddevice/dev_net/LedDeviceAtmoOrb.h b/libsrc/leddevice/dev_net/LedDeviceAtmoOrb.h
index d6b74210..fc01ba33 100644
--- a/libsrc/leddevice/dev_net/LedDeviceAtmoOrb.h
+++ b/libsrc/leddevice/dev_net/LedDeviceAtmoOrb.h
@@ -60,6 +60,13 @@ protected:
///
virtual int open() override;
+ ///
+ /// @brief Closes the output device.
+ ///
+ /// @return Zero on success (i.e. device is closed), else negative
+ ///
+ virtual void close() override;
+
private:
///
@@ -102,7 +109,7 @@ private:
quint16 _multiCastGroupPort;
// Multicast status
- bool joinedMulticastgroup;
+ bool _joinedMulticastgroup;
/// use Orbs own (external) smoothing algorithm
bool _useOrbSmoothing;
@@ -116,9 +123,6 @@ private:
/// Number of leds in Orb, used to determine buffer size
int _numLeds;
-
-
-
/// Array of the orb ids.
QVector _orbIds;
@@ -127,7 +131,4 @@ private:
QMap lastColorGreenMap;
QMap lastColorBlueMap;
-
-
-
};
diff --git a/libsrc/leddevice/dev_net/LedDeviceFadeCandy.cpp b/libsrc/leddevice/dev_net/LedDeviceFadeCandy.cpp
index 0e43448b..49a433de 100644
--- a/libsrc/leddevice/dev_net/LedDeviceFadeCandy.cpp
+++ b/libsrc/leddevice/dev_net/LedDeviceFadeCandy.cpp
@@ -165,7 +165,7 @@ int LedDeviceFadeCandy::sendSysEx(uint8_t systemId, uint8_t commandId, QByteArra
if ( isConnected() )
{
QByteArray sysExData;
- ssize_t data_size = msg.size() + 4;
+ uint data_size = msg.size() + 4;
sysExData.resize( 4 + OPC_HEADER_SIZE );
sysExData[0] = 0;
diff --git a/libsrc/leddevice/dev_net/LedDeviceNanoleaf.cpp b/libsrc/leddevice/dev_net/LedDeviceNanoleaf.cpp
index e734592a..350413fa 100644
--- a/libsrc/leddevice/dev_net/LedDeviceNanoleaf.cpp
+++ b/libsrc/leddevice/dev_net/LedDeviceNanoleaf.cpp
@@ -337,12 +337,12 @@ bool LedDeviceNanoleaf::discoverDevice()
SSDPDiscover discover;
// Discover Canvas device
- address = discover.getFirstService(STY_WEBSERVER, SSDP_CANVAS, SSDP_TIMEOUT);
+ address = discover.getFirstService(searchType::STY_WEBSERVER, SSDP_CANVAS, SSDP_TIMEOUT);
//No Canvas device not found
if ( address.isEmpty() ) {
// Discover Light Panels (Aurora) device
- address = discover.getFirstService(STY_WEBSERVER, SSDP_LIGHTPANELS, SSDP_TIMEOUT);
+ address = discover.getFirstService(searchType::STY_WEBSERVER, SSDP_LIGHTPANELS, SSDP_TIMEOUT);
if ( address.isEmpty() ) {
Warning(_log, "No Nanoleaf device discovered");
@@ -353,7 +353,12 @@ bool LedDeviceNanoleaf::discoverDevice()
if ( ! address.isEmpty() ) {
Info(_log, "Nanoleaf device discovered at [%s]", QSTRING_CSTR( address ));
isDeviceFound = true;
- QStringList addressparts = address.split(":", QString::SkipEmptyParts);
+ // Resolve hostname and port (or use default API port)
+ #if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
+ QStringList addressparts = address.split(":", Qt::SkipEmptyParts);
+ #else
+ QStringList addressparts = address.split(":", QString::SkipEmptyParts);
+ #endif
_hostname = addressparts[0];
_api_port = addressparts[1];
}
diff --git a/libsrc/leddevice/dev_net/LedDevicePhilipsHue.cpp b/libsrc/leddevice/dev_net/LedDevicePhilipsHue.cpp
index 1748d826..d4268799 100644
--- a/libsrc/leddevice/dev_net/LedDevicePhilipsHue.cpp
+++ b/libsrc/leddevice/dev_net/LedDevicePhilipsHue.cpp
@@ -282,7 +282,11 @@ bool LedDevicePhilipsHueBridge::init(const QJsonObject &deviceConfig)
if ( !address.isEmpty() )
{
- QStringList addressparts = address.split(":", QString::SkipEmptyParts);
+ #if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
+ QStringList addressparts = address.split(":", Qt::SkipEmptyParts);
+ #else
+ QStringList addressparts = address.split(":", QString::SkipEmptyParts);
+ #endif
_hostname = addressparts[0];
if ( addressparts.size() > 1 )
@@ -402,7 +406,12 @@ void LedDevicePhilipsHueBridge::setBridgeConfig(QJsonDocument doc)
_deviceFirmwareVersion = jsonConfigInfo[DEV_DATA_FIRMWAREVERSION].toString();
_deviceAPIVersion = jsonConfigInfo[DEV_DATA_APIVERSION].toString();
- QStringList apiVersionParts = _deviceAPIVersion.split(".", QString::SkipEmptyParts);
+ #if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
+ QStringList apiVersionParts = _deviceAPIVersion.split(".", Qt::SkipEmptyParts);
+ #else
+ QStringList apiVersionParts = _deviceAPIVersion.split(".", QString::SkipEmptyParts);
+ #endif
+
if ( !apiVersionParts.isEmpty() )
{
_api_major = apiVersionParts[0].toUInt();
@@ -483,7 +492,7 @@ bool LedDevicePhilipsHueBridge::discoverDevice()
SSDPDiscover discover;
// Discover Philips Hue Bridge
- address = discover.getFirstService( STY_WEBSERVER, SSDP_ID, SSDP_TIMEOUT );
+ address = discover.getFirstService( searchType::STY_WEBSERVER, SSDP_ID, SSDP_TIMEOUT );
if ( address.isEmpty() )
{
Warning(_log, "No Philips Hue Bridge discovered" );
@@ -493,7 +502,13 @@ bool LedDevicePhilipsHueBridge::discoverDevice()
// Philips Hue Bridge found
Info(_log, "Philips Hue Bridge discovered at [%s]", QSTRING_CSTR( address ) );
isDeviceFound = true;
- QStringList addressparts = address.split(":", QString::SkipEmptyParts);
+
+ #if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
+ QStringList addressparts = address.split(":", Qt::SkipEmptyParts);
+ #else
+ QStringList addressparts = address.split(":", QString::SkipEmptyParts);
+ #endif
+
_hostname = addressparts[0];
_api_port = addressparts[1];
}
diff --git a/libsrc/leddevice/dev_net/LedDeviceUdpH801.cpp b/libsrc/leddevice/dev_net/LedDeviceUdpH801.cpp
index 18d08a44..7577408a 100644
--- a/libsrc/leddevice/dev_net/LedDeviceUdpH801.cpp
+++ b/libsrc/leddevice/dev_net/LedDeviceUdpH801.cpp
@@ -1,5 +1,8 @@
#include "LedDeviceUdpH801.h"
+const ushort H801_DEFAULT_PORT = 30977;
+static const char H801_DEFAULT_HOST[] = "255.255.255.255";
+
LedDeviceUdpH801::LedDeviceUdpH801(const QJsonObject &deviceConfig)
: ProviderUdp()
{
@@ -31,8 +34,8 @@ bool LedDeviceUdpH801::init(const QJsonObject &deviceConfig)
}
_message = QByteArray(_prefix_size + _colors + _id_size * _ids.size() + _suffix_size, 0x00);
- _message[0] = 0xFB;
- _message[1] = 0xEB;
+ _message[0] = static_cast(0xFB);
+ _message[1] = static_cast(0xEB);
for (int i = 0; i < _ids.length(); i++) {
_message[_prefix_size + _colors + i * _id_size + 0] = (_ids[i] >> 0x00) & 0xFF;
diff --git a/libsrc/leddevice/dev_net/LedDeviceUdpH801.h b/libsrc/leddevice/dev_net/LedDeviceUdpH801.h
index 223d281d..70dde8c5 100644
--- a/libsrc/leddevice/dev_net/LedDeviceUdpH801.h
+++ b/libsrc/leddevice/dev_net/LedDeviceUdpH801.h
@@ -8,9 +8,6 @@
///
///
-const ushort H801_DEFAULT_PORT = 30977;
-static const char H801_DEFAULT_HOST[] = "255.255.255.255";
-
class LedDeviceUdpH801: public ProviderUdp
{
protected:
diff --git a/libsrc/leddevice/dev_net/ProviderUdp.cpp b/libsrc/leddevice/dev_net/ProviderUdp.cpp
index ef4d51b1..3df9b8e4 100644
--- a/libsrc/leddevice/dev_net/ProviderUdp.cpp
+++ b/libsrc/leddevice/dev_net/ProviderUdp.cpp
@@ -14,6 +14,8 @@
// Local Hyperion includes
#include "ProviderUdp.h"
+const ushort MAX_PORT = 65535;
+
ProviderUdp::ProviderUdp()
: LedDevice()
, _udpSocket (nullptr)
@@ -26,7 +28,10 @@ ProviderUdp::ProviderUdp()
ProviderUdp::~ProviderUdp()
{
- _udpSocket->deleteLater();
+ if ( _udpSocket != nullptr )
+ {
+ _udpSocket->deleteLater();
+ }
}
bool ProviderUdp::init(const QJsonObject &deviceConfig)
@@ -79,17 +84,18 @@ bool ProviderUdp::initNetwork()
_udpSocket = new QUdpSocket(this);
- if ( _udpSocket != nullptr)
+ // Try to bind the UDP-Socket
+ if ( _udpSocket != nullptr )
{
QHostAddress localAddress = QHostAddress::Any;
quint16 localPort = 0;
if ( !_udpSocket->bind(localAddress, localPort) )
{
- Warning ( _log, "Could not bind local address: %s", strerror(errno));
+ QString warntext = QString ("Could not bind local address: %1, (%2) %3").arg(localAddress.toString()).arg(_udpSocket->error()).arg(_udpSocket->errorString());
+ Warning ( _log, "%s", QSTRING_CSTR(warntext));
}
isInitOK = true;
}
-
return isInitOK;
}
@@ -120,18 +126,24 @@ void ProviderUdp::close()
{
LedDevice::close();
- // LedDevice specific closing activites
- if ( _udpSocket != nullptr)
+ if ( _udpSocket != nullptr )
{
- _udpSocket->close();
+ // Test, if device requires closing
+ if ( _udpSocket->isOpen() )
+ {
+ Debug(_log,"Close UDP-device: %s", QSTRING_CSTR( this->getActiveDeviceType() ) );
+ _udpSocket->close();
+ // Everything is OK -> device is closed
+ }
}
}
int ProviderUdp::writeBytes(const unsigned size, const uint8_t * data)
{
-
qint64 retVal = _udpSocket->writeDatagram((const char *)data,size,_address,_port);
- WarningIf((retVal<0), _log, "Error sending: %s", strerror(errno));
+
+ WarningIf((retVal<0), _log, "&s", QSTRING_CSTR(QString
+ ("(%1:%2) Write Error: (%3) %4").arg(_address.toString()).arg(_port).arg(_udpSocket->error()).arg(_udpSocket->errorString())));
return retVal;
}
diff --git a/libsrc/leddevice/dev_net/ProviderUdp.h b/libsrc/leddevice/dev_net/ProviderUdp.h
index 697ed3bf..d4582c71 100644
--- a/libsrc/leddevice/dev_net/ProviderUdp.h
+++ b/libsrc/leddevice/dev_net/ProviderUdp.h
@@ -9,8 +9,6 @@
class QUdpSocket;
-const ushort MAX_PORT = 65535;
-
///
/// The ProviderUdp implements an abstract base-class for LedDevices using UDP packets.
///
diff --git a/libsrc/leddevice/dev_other/LedDeviceFile.cpp b/libsrc/leddevice/dev_other/LedDeviceFile.cpp
index 8d95fe88..ab47a879 100644
--- a/libsrc/leddevice/dev_other/LedDeviceFile.cpp
+++ b/libsrc/leddevice/dev_other/LedDeviceFile.cpp
@@ -1,11 +1,12 @@
#include "LedDeviceFile.h"
-#include
-#include
-#include
+// Qt includes
+#include
+#include
LedDeviceFile::LedDeviceFile(const QJsonObject &deviceConfig)
: LedDevice()
+ , _file (nullptr)
{
_devConfig = deviceConfig;
_deviceReady = false;
@@ -14,6 +15,10 @@ LedDeviceFile::LedDeviceFile(const QJsonObject &deviceConfig)
LedDeviceFile::~LedDeviceFile()
{
+ if ( _file != nullptr )
+ {
+ _file->deleteLater();
+ }
}
LedDevice* LedDeviceFile::construct(const QJsonObject &deviceConfig)
@@ -28,9 +33,19 @@ bool LedDeviceFile::init(const QJsonObject &deviceConfig)
_fileName = deviceConfig["output"].toString("/dev/null");
_printTimeStamp = deviceConfig["printTimeStamp"].toBool(false);
+ initFile(_fileName);
+
return initOK;
}
+void LedDeviceFile::initFile(const QString &fileName)
+{
+ if ( _file == nullptr )
+ {
+ _file = new QFile(fileName);
+ }
+}
+
int LedDeviceFile::open()
{
int retval = -1;
@@ -39,26 +54,24 @@ int LedDeviceFile::open()
if ( init(_devConfig) )
{
- if ( _ofs.is_open() )
+ if ( ! _file->isOpen() )
{
- _ofs.close();
- }
+ Debug(_log, "QIODevice::WriteOnly, %s", QSTRING_CSTR(_fileName));
+ if ( !_file->open(QIODevice::WriteOnly | QIODevice::Text) )
+ {
+ errortext = QString ("(%1) %2, file: (%3)").arg(_file->error()).arg(_file->errorString()).arg(_fileName);
+ }
+ else
+ {
+ _deviceReady = true;
+ setEnable(true);
+ retval = 0;
+ }
- _ofs.open( QSTRING_CSTR(_fileName));
- if ( _ofs.fail() )
- {
- errortext = QString ("Failed to open file (%1). Error message: %2").arg(_fileName, strerror(errno));
- }
- else
- {
- _deviceReady = true;
- setEnable(true);
- retval = 0;
- }
-
- if ( retval < 0 )
- {
- this->setInError( errortext );
+ if ( retval < 0 )
+ {
+ this->setInError( errortext );
+ }
}
}
return retval;
@@ -68,43 +81,47 @@ void LedDeviceFile::close()
{
LedDevice::close();
- // LedDevice specific closing activites
- if ( _ofs )
+ if ( _file != nullptr)
{
- _ofs.close();
- if ( _ofs.fail() )
+ // Test, if device requires closing
+ if ( _file->isOpen() )
{
- Error( _log, "Failed to close device (%s). Error message: %s", QSTRING_CSTR(_fileName), strerror(errno) );
+ // close device physically
+ Debug(_log,"File: %s", QSTRING_CSTR(_fileName) );
+ _file->close();
}
}
}
int LedDeviceFile::write(const std::vector & ledValues)
{
+ QTextStream out(_file);
+
//printLedValues (ledValues);
+
if ( _printTimeStamp )
{
- // get a precise timestamp as a string
- const auto now = std::chrono::system_clock::now();
- const auto nowAsTimeT = std::chrono::system_clock::to_time_t(now);
- const auto nowMs = std::chrono::duration_cast(now.time_since_epoch()) % 1000;
+ QDateTime now = QDateTime::currentDateTime();
+ qint64 elapsedTimeMs = _lastWriteTime.msecsTo(now);
- const auto elapsedTimeMs = std::chrono::duration_cast(now - lastWriteTime);
-
- _ofs
- << std::put_time(std::localtime(&nowAsTimeT), "%Y-%m-%d %T")
- << '.' << std::setfill('0') << std::setw(3) << nowMs.count()
- << " | +" << std::setfill('0') << std::setw(4) << elapsedTimeMs.count();
-
- lastWriteTime = now;
+ #if (QT_VERSION >= QT_VERSION_CHECK(5, 8, 0))
+ out << now.toString(Qt::ISODateWithMs) << " | +" << QString("%1").arg( elapsedTimeMs,4);
+ #else
+ out << now.toString(Qt::ISODate) << now.toString(".zzz") << " | +" << QString("%1").arg( elapsedTimeMs,4);
+ #endif
}
- _ofs << " [";
+ out << " [";
for (const ColorRgb& color : ledValues)
{
- _ofs << color;
+ out << color;
}
- _ofs << "]" << std::endl;
+
+ #if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
+ out << "]" << Qt::endl;
+ #else
+ out << "]" << endl;
+ #endif
return 0;
}
diff --git a/libsrc/leddevice/dev_other/LedDeviceFile.h b/libsrc/leddevice/dev_other/LedDeviceFile.h
index c27dee42..b9f5b852 100644
--- a/libsrc/leddevice/dev_other/LedDeviceFile.h
+++ b/libsrc/leddevice/dev_other/LedDeviceFile.h
@@ -1,74 +1,84 @@
-#pragma once
+#ifndef LEDEVICEFILE_H
+#define LEDEVICEFILE_H
-// STL includes
-#include
-#include
-
-// Leddevice includes
+// LedDevice includes
#include
+// Qt includes
+#include
+#include
+
///
-/// Implementation of the LedDevice that write the led-colors to an
-/// ASCII-textfile('/home/pi/LedDevice.out')
+/// Implementation of the LedDevice that write the LED-colors to an
+/// ASCII-textfile primarily for testing purposes
///
class LedDeviceFile : public LedDevice
{
public:
+
///
- /// Constructs specific LedDevice
+ /// @brief Constructs a file output LED-device
///
- /// @param deviceConfig json device config
+ /// @param deviceConfig Device's configuration as JSON-Object
///
explicit LedDeviceFile(const QJsonObject &deviceConfig);
///
- /// Destructor of this test-device
+ /// @brief Destructor of the LedDevice
///
virtual ~LedDeviceFile() override;
- /// constructs leddevice
+ ///
+ /// @brief Constructs the LED-device
+ ///
+ /// @param[in] deviceConfig Device's configuration as JSON-Object
+ /// @return LedDevice constructed
static LedDevice* construct(const QJsonObject &deviceConfig);
+ public slots:
///
- /// Sets configuration
+ /// @brief Closes the output device.
///
- /// @param deviceConfig the json device config
- /// @return true if success
- virtual bool init(const QJsonObject &deviceConfig) override;
-
-public slots:
- ///
- /// Closes the output device.
- /// Includes switching-off the device and stopping refreshes
+ /// @return Zero on success (i.e. device is closed), else negative
///
virtual void close() override;
-
+
protected:
+
///
- /// Opens and initiatialises the output device
+ /// @brief Initialise the device's configuration
///
- /// @return Zero on succes (i.e. device is ready and enabled) else negative
+ /// @param[in] deviceConfig the JSON device configuration
+ /// @return True, if success
+ ///
+ virtual bool init(const QJsonObject &deviceConfig) override;
+
+ ///
+ /// @brief Opens the output device.
+ ///
+ /// @return Zero on success (i.e. device is ready), else negative
///
virtual int open() override;
///
- /// Writes the given led-color values to the output stream
+ /// @brief Writes the RGB-Color values to the LEDs.
///
- /// @param ledValues The color-value per led
- ///
- /// @return Zero on success else negative
+ /// @param[in] ledValues The RGB-color per LED
+ /// @return Zero on success, else negative
///
virtual int write(const std::vector & ledValues) override;
/// The outputstream
- std::ofstream _ofs;
+ QFile* _file;
private:
+ void initFile(const QString &filename);
+
QString _fileName;
/// Timestamp for the output record
bool _printTimeStamp;
- /// Last write/output timestamp
- std::chrono::system_clock::time_point lastWriteTime = std::chrono::system_clock::now();
};
+
+#endif // LEDEVICEFILE_H
diff --git a/libsrc/leddevice/dev_rpi_pwm/LedDeviceWS281x.cpp b/libsrc/leddevice/dev_rpi_pwm/LedDeviceWS281x.cpp
index add73c98..8d6df23e 100644
--- a/libsrc/leddevice/dev_rpi_pwm/LedDeviceWS281x.cpp
+++ b/libsrc/leddevice/dev_rpi_pwm/LedDeviceWS281x.cpp
@@ -27,7 +27,7 @@ bool LedDeviceWS281x::init(const QJsonObject &deviceConfig)
QString whiteAlgorithm = deviceConfig["whiteAlgorithm"].toString("white_off");
_whiteAlgorithm = RGBW::stringToWhiteAlgorithm(whiteAlgorithm);
- if (_whiteAlgorithm == RGBW::INVALID)
+ if (_whiteAlgorithm == RGBW::WhiteAlgorithm::INVALID)
{
errortext = QString ("unknown whiteAlgorithm: %1").arg(whiteAlgorithm);
isInitOK = false;
diff --git a/libsrc/leddevice/dev_spi/LedDeviceSk6812SPI.cpp b/libsrc/leddevice/dev_spi/LedDeviceSk6812SPI.cpp
index d8aeb114..aa3c1a5a 100644
--- a/libsrc/leddevice/dev_spi/LedDeviceSk6812SPI.cpp
+++ b/libsrc/leddevice/dev_spi/LedDeviceSk6812SPI.cpp
@@ -2,7 +2,7 @@
LedDeviceSk6812SPI::LedDeviceSk6812SPI(const QJsonObject &deviceConfig)
: ProviderSpi()
- , _whiteAlgorithm(RGBW::INVALID)
+ , _whiteAlgorithm(RGBW::WhiteAlgorithm::INVALID)
, SPI_BYTES_PER_COLOUR(4)
, bitpair_to_byte {
0b10001000,
@@ -30,7 +30,7 @@ bool LedDeviceSk6812SPI::init(const QJsonObject &deviceConfig)
QString whiteAlgorithm = deviceConfig["whiteAlgorithm"].toString("white_off");
_whiteAlgorithm = RGBW::stringToWhiteAlgorithm(whiteAlgorithm);
- if (_whiteAlgorithm == RGBW::INVALID)
+ if (_whiteAlgorithm == RGBW::WhiteAlgorithm::INVALID)
{
QString errortext = QString ("unknown whiteAlgorithm: %1").arg(whiteAlgorithm);
this->setInError(errortext);
diff --git a/libsrc/ssdp/SSDPDiscover.cpp b/libsrc/ssdp/SSDPDiscover.cpp
index 48aaab5f..9cd203f5 100644
--- a/libsrc/ssdp/SSDPDiscover.cpp
+++ b/libsrc/ssdp/SSDPDiscover.cpp
@@ -1,6 +1,6 @@
#include
-// qt inc
+// Qt includes
#include
#include
@@ -40,7 +40,7 @@ const QString SSDPDiscover::getFirstService(const searchType& type, const QStrin
_searchTarget = st;
// search
- sendSearch(st);
+ sendSearch(_searchTarget);
if ( _udpSocket->waitForReadyRead(timeout_ms) )
{
@@ -58,12 +58,18 @@ const QString SSDPDiscover::getFirstService(const searchType& type, const QStrin
QString data(datagram);
- Debug(_log, "_data: [%s]", QSTRING_CSTR(data));
+ //Debug(_log, "_data: [%s]", QSTRING_CSTR(data));
QMap headers;
QString address;
// parse request
- QStringList entries = data.split("\n", QString::SkipEmptyParts);
+
+ #if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
+ QStringList entries = data.split("\n", Qt::SkipEmptyParts);
+ #else
+ QStringList entries = data.split("\n", QString::SkipEmptyParts);
+ #endif
+
for(auto entry : entries)
{
// http header parse skip
@@ -92,13 +98,13 @@ const QString SSDPDiscover::getFirstService(const searchType& type, const QStrin
_usnList << headers.value("usn");
QUrl url(headers.value("location"));
//Debug(_log, "Received msearch response from '%s:%d'. Search target: %s",QSTRING_CSTR(sender.toString()), senderPort, QSTRING_CSTR(headers.value("st")));
- if(type == STY_WEBSERVER)
+ if(type == searchType::STY_WEBSERVER)
{
Debug(_log, "Found service [%s] at: %s:%d", QSTRING_CSTR(st), QSTRING_CSTR(url.host()), url.port());
return url.host()+":"+QString::number(url.port());
}
- else if(type == STY_FLATBUFSERVER)
+ else if(type == searchType::STY_FLATBUFSERVER)
{
const QString fbsport = headers.value("hyperion-fbs-port");
if(fbsport.isEmpty())
@@ -111,7 +117,7 @@ const QString SSDPDiscover::getFirstService(const searchType& type, const QStrin
return url.host()+":"+fbsport;
}
}
- else if(type == STY_JSONSERVER)
+ else if(type == searchType::STY_JSONSERVER)
{
const QString jssport = headers.value("hyperion-jss-port");
if(jssport.isEmpty())
@@ -146,7 +152,11 @@ void SSDPDiscover::readPendingDatagrams()
QString data(datagram);
QMap headers;
// parse request
- QStringList entries = data.split("\n", QString::SkipEmptyParts);
+ #if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
+ QStringList entries = data.split("\n", Qt::SkipEmptyParts);
+ #else
+ QStringList entries = data.split("\n", QString::SkipEmptyParts);
+ #endif
for(auto entry : entries)
{
// http header parse skip
diff --git a/libsrc/ssdp/SSDPServer.cpp b/libsrc/ssdp/SSDPServer.cpp
index 4556f956..4ff6f3aa 100644
--- a/libsrc/ssdp/SSDPServer.cpp
+++ b/libsrc/ssdp/SSDPServer.cpp
@@ -137,7 +137,11 @@ void SSDPServer::readPendingDatagrams()
QString data(datagram);
QMap headers;
// parse request
- QStringList entries = data.split("\n", QString::SkipEmptyParts);
+ #if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
+ QStringList entries = data.split("\n", Qt::SkipEmptyParts);
+ #else
+ QStringList entries = data.split("\n", QString::SkipEmptyParts);
+ #endif
for(auto entry : entries)
{
// http header parse skip
diff --git a/libsrc/utils/ImageResampler.cpp b/libsrc/utils/ImageResampler.cpp
index 8f02ac92..38c3f7cb 100644
--- a/libsrc/utils/ImageResampler.cpp
+++ b/libsrc/utils/ImageResampler.cpp
@@ -8,7 +8,7 @@ ImageResampler::ImageResampler()
, _cropRight(0)
, _cropTop(0)
, _cropBottom(0)
- , _videoMode(VIDEO_2D)
+ , _videoMode(VideoMode::VIDEO_2D)
{
}
@@ -47,10 +47,10 @@ void ImageResampler::processImage(const uint8_t * data, int width, int height, i
// handle 3D mode
switch (_videoMode)
{
- case VIDEO_3DSBS:
+ case VideoMode::VIDEO_3DSBS:
cropRight = width >> 1;
break;
- case VIDEO_3DTAB:
+ case VideoMode::VIDEO_3DTAB:
cropBottom = width >> 1;
break;
default:
@@ -71,7 +71,7 @@ void ImageResampler::processImage(const uint8_t * data, int width, int height, i
switch (pixelFormat)
{
- case PIXELFORMAT_UYVY:
+ case PixelFormat::UYVY:
{
int index = lineLength * ySource + (xSource << 1);
uint8_t y = data[index+1];
@@ -80,7 +80,7 @@ void ImageResampler::processImage(const uint8_t * data, int width, int height, i
yuv2rgb(y, u, v, rgb.red, rgb.green, rgb.blue);
}
break;
- case PIXELFORMAT_YUYV:
+ case PixelFormat::YUYV:
{
int index = lineLength * ySource + (xSource << 1);
uint8_t y = data[index];
@@ -89,7 +89,7 @@ void ImageResampler::processImage(const uint8_t * data, int width, int height, i
yuv2rgb(y, u, v, rgb.red, rgb.green, rgb.blue);
}
break;
- case PIXELFORMAT_BGR16:
+ case PixelFormat::BGR16:
{
int index = lineLength * ySource + (xSource << 1);
rgb.blue = (data[index] & 0x1f) << 3;
@@ -97,7 +97,7 @@ void ImageResampler::processImage(const uint8_t * data, int width, int height, i
rgb.red = (data[index+1] & 0xF8);
}
break;
- case PIXELFORMAT_BGR24:
+ case PixelFormat::BGR24:
{
int index = lineLength * ySource + (xSource << 1) + xSource;
rgb.blue = data[index ];
@@ -105,7 +105,7 @@ void ImageResampler::processImage(const uint8_t * data, int width, int height, i
rgb.red = data[index+2];
}
break;
- case PIXELFORMAT_RGB32:
+ case PixelFormat::RGB32:
{
int index = lineLength * ySource + (xSource << 2);
rgb.red = data[index ];
@@ -113,7 +113,7 @@ void ImageResampler::processImage(const uint8_t * data, int width, int height, i
rgb.blue = data[index+2];
}
break;
- case PIXELFORMAT_BGR32:
+ case PixelFormat::BGR32:
{
int index = lineLength * ySource + (xSource << 2);
rgb.blue = data[index ];
@@ -122,10 +122,10 @@ void ImageResampler::processImage(const uint8_t * data, int width, int height, i
}
break;
#ifdef HAVE_JPEG_DECODER
- case PIXELFORMAT_MJPEG:
+ case PixelFormat::MJPEG:
break;
#endif
- case PIXELFORMAT_NO_CHANGE:
+ case PixelFormat::NO_CHANGE:
Error(Logger::getInstance("ImageResampler"), "Invalid pixel format given");
break;
}
diff --git a/libsrc/utils/RgbToRgbw.cpp b/libsrc/utils/RgbToRgbw.cpp
index bb6aaa40..8f2fa8b7 100644
--- a/libsrc/utils/RgbToRgbw.cpp
+++ b/libsrc/utils/RgbToRgbw.cpp
@@ -7,18 +7,18 @@ namespace RGBW {
WhiteAlgorithm stringToWhiteAlgorithm(QString str)
{
- if (str == "subtract_minimum") return SUBTRACT_MINIMUM;
- if (str == "sub_min_warm_adjust") return SUB_MIN_WARM_ADJUST;
- if (str == "sub_min_cool_adjust") return SUB_MIN_COOL_ADJUST;
- if (str.isEmpty() || str == "white_off") return WHITE_OFF;
- return INVALID;
+ if (str == "subtract_minimum") return WhiteAlgorithm::SUBTRACT_MINIMUM;
+ if (str == "sub_min_warm_adjust") return WhiteAlgorithm::SUB_MIN_WARM_ADJUST;
+ if (str == "sub_min_cool_adjust") return WhiteAlgorithm::SUB_MIN_COOL_ADJUST;
+ if (str.isEmpty() || str == "white_off") return WhiteAlgorithm::WHITE_OFF;
+ return WhiteAlgorithm::INVALID;
}
void Rgb_to_Rgbw(ColorRgb input, ColorRgbw * output, const WhiteAlgorithm algorithm)
{
switch (algorithm)
{
- case SUBTRACT_MINIMUM:
+ case WhiteAlgorithm::SUBTRACT_MINIMUM:
{
output->white = qMin(qMin(input.red, input.green), input.blue);
output->red = input.red - output->white;
@@ -27,13 +27,13 @@ void Rgb_to_Rgbw(ColorRgb input, ColorRgbw * output, const WhiteAlgorithm algori
break;
}
- case SUB_MIN_WARM_ADJUST:
+ case WhiteAlgorithm::SUB_MIN_WARM_ADJUST:
{
// http://forum.garagecube.com/viewtopic.php?t=10178
- // warm white
- float F1 = 0.274;
- float F2 = 0.454;
- float F3 = 2.333;
+ // warm white
+ float F1 = static_cast(0.274);
+ float F2 = static_cast(0.454);
+ float F3 = static_cast(2.333);
output->white = qMin(input.red*F1,qMin(input.green*F2,input.blue*F3));
output->red = input.red - output->white/F1;
@@ -42,13 +42,13 @@ void Rgb_to_Rgbw(ColorRgb input, ColorRgbw * output, const WhiteAlgorithm algori
break;
}
- case SUB_MIN_COOL_ADJUST:
+ case WhiteAlgorithm::SUB_MIN_COOL_ADJUST:
{
// http://forum.garagecube.com/viewtopic.php?t=10178
- // cold white
- float F1 = 0.299;
- float F2 = 0.587;
- float F3 = 0.114;
+ // cold white
+ float F1 = static_cast(0.299);
+ float F2 = static_cast(0.587);
+ float F3 = static_cast(0.114);
output->white = qMin(input.red*F1,qMin(input.green*F2,input.blue*F3));
output->red = input.red - output->white/F1;
@@ -57,7 +57,7 @@ void Rgb_to_Rgbw(ColorRgb input, ColorRgbw * output, const WhiteAlgorithm algori
break;
}
- case WHITE_OFF:
+ case WhiteAlgorithm::WHITE_OFF:
{
output->red = input.red;
output->green = input.green;
diff --git a/libsrc/webserver/QtHttpClientWrapper.cpp b/libsrc/webserver/QtHttpClientWrapper.cpp
index de337078..2495098f 100644
--- a/libsrc/webserver/QtHttpClientWrapper.cpp
+++ b/libsrc/webserver/QtHttpClientWrapper.cpp
@@ -58,7 +58,11 @@ void QtHttpClientWrapper::onClientDataReceived (void)
case AwaitingRequest: // "command url version" × 1
{
QString str = QString::fromUtf8 (line).trimmed ();
- QStringList parts = str.split (SPACE, QString::SkipEmptyParts);
+ #if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
+ QStringList parts = str.split (SPACE, Qt::SkipEmptyParts);
+ #else
+ QStringList parts = str.split (SPACE, QString::SkipEmptyParts);
+ #endif
if (parts.size () == 3)
{
@@ -192,7 +196,12 @@ void QtHttpClientWrapper::onClientDataReceived (void)
// catch /jsonrpc in url, we need async callback, StaticFileServing is sync
QString path = m_currentRequest->getUrl ().path ();
- QStringList uri_parts = path.split('/', QString::SkipEmptyParts);
+
+ #if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
+ QStringList uri_parts = path.split('/', Qt::SkipEmptyParts);
+ #else
+ QStringList uri_parts = path.split('/', QString::SkipEmptyParts);
+ #endif
if ( ! uri_parts.empty() && uri_parts.at(0) == "json-rpc" )
{
diff --git a/libsrc/webserver/StaticFileServing.cpp b/libsrc/webserver/StaticFileServing.cpp
index 7b0141f9..5986eb91 100644
--- a/libsrc/webserver/StaticFileServing.cpp
+++ b/libsrc/webserver/StaticFileServing.cpp
@@ -81,7 +81,11 @@ void StaticFileServing::onRequestNeedsReply (QtHttpRequest * request, QtHttpRepl
if (command == QStringLiteral ("GET"))
{
QString path = request->getUrl ().path ();
- QStringList uri_parts = path.split('/', QString::SkipEmptyParts);
+ #if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
+ QStringList uri_parts = path.split('/', Qt::SkipEmptyParts);
+ #else
+ QStringList uri_parts = path.split('/', QString::SkipEmptyParts);
+ #endif
// special uri handling for server commands
if ( ! uri_parts.empty() )
diff --git a/libsrc/webserver/WebSocketClient.cpp b/libsrc/webserver/WebSocketClient.cpp
index 0942a299..d5577949 100644
--- a/libsrc/webserver/WebSocketClient.cpp
+++ b/libsrc/webserver/WebSocketClient.cpp
@@ -239,7 +239,7 @@ void WebSocketClient::handleBinaryMessage(QByteArray &data)
unsigned width = ((data.at(2) << 8) & 0xFF00) | (data.at(3) & 0xFF);
unsigned height = imgSize / width;
- if ( ! (imgSize) % width)
+ if ( imgSize % width > 0 )
{
Error(_log, "data size is not multiple of width");
return;
diff --git a/src/hyperion-aml/hyperion-aml.cpp b/src/hyperion-aml/hyperion-aml.cpp
index 83b7733b..eb897d8e 100644
--- a/src/hyperion-aml/hyperion-aml.cpp
+++ b/src/hyperion-aml/hyperion-aml.cpp
@@ -69,7 +69,7 @@ int main(int argc, char ** argv)
if(argAddress.value(parser) == "127.0.0.1:19400")
{
SSDPDiscover discover;
- address = discover.getFirstService(STY_FLATBUFSERVER);
+ address = discover.getFirstService(searchType::STY_FLATBUFSERVER);
if(address.isEmpty())
{
address = argAddress.value(parser);
diff --git a/src/hyperion-dispmanx/hyperion-dispmanx.cpp b/src/hyperion-dispmanx/hyperion-dispmanx.cpp
index 550a2425..77b8dbc5 100644
--- a/src/hyperion-dispmanx/hyperion-dispmanx.cpp
+++ b/src/hyperion-dispmanx/hyperion-dispmanx.cpp
@@ -57,15 +57,15 @@ int main(int argc, char ** argv)
// parse all options
parser.process(app);
- VideoMode videoMode = VIDEO_2D;
+ VideoMode videoMode = VideoMode::VIDEO_2D;
if (parser.isSet(arg3DSBS))
{
- videoMode = VIDEO_3DSBS;
+ videoMode = VideoMode::VIDEO_3DSBS;
}
else if (parser.isSet(arg3DTAB))
{
- videoMode = VIDEO_3DTAB;
+ videoMode = VideoMode::VIDEO_3DTAB;
}
// check if we need to display the usage. exit if we do.
@@ -98,7 +98,7 @@ int main(int argc, char ** argv)
if(argAddress.value(parser) == "127.0.0.1:19400")
{
SSDPDiscover discover;
- address = discover.getFirstService(STY_FLATBUFSERVER);
+ address = discover.getFirstService(searchType::STY_FLATBUFSERVER);
if(address.isEmpty())
{
address = argAddress.value(parser);
diff --git a/src/hyperion-framebuffer/hyperion-framebuffer.cpp b/src/hyperion-framebuffer/hyperion-framebuffer.cpp
index 8ca41556..02833bb2 100644
--- a/src/hyperion-framebuffer/hyperion-framebuffer.cpp
+++ b/src/hyperion-framebuffer/hyperion-framebuffer.cpp
@@ -62,7 +62,7 @@ int main(int argc, char ** argv)
if(argAddress.value(parser) == "127.0.0.1:19400")
{
SSDPDiscover discover;
- address = discover.getFirstService(STY_FLATBUFSERVER);
+ address = discover.getFirstService(searchType::STY_FLATBUFSERVER);
if(address.isEmpty())
{
address = argAddress.value(parser);
diff --git a/src/hyperion-osx/hyperion-osx.cpp b/src/hyperion-osx/hyperion-osx.cpp
index c3edf07b..09c2cc0d 100644
--- a/src/hyperion-osx/hyperion-osx.cpp
+++ b/src/hyperion-osx/hyperion-osx.cpp
@@ -65,7 +65,7 @@ int main(int argc, char ** argv)
if(argAddress.value(parser) == "127.0.0.1:19400")
{
SSDPDiscover discover;
- address = discover.getFirstService(STY_FLATBUFSERVER);
+ address = discover.getFirstService(searchType::STY_FLATBUFSERVER);
if(address.isEmpty())
{
address = argAddress.value(parser);
diff --git a/src/hyperion-qt/hyperion-qt.cpp b/src/hyperion-qt/hyperion-qt.cpp
index 0445db05..8d1b0b82 100644
--- a/src/hyperion-qt/hyperion-qt.cpp
+++ b/src/hyperion-qt/hyperion-qt.cpp
@@ -78,7 +78,7 @@ int main(int argc, char ** argv)
if(argAddress.value(parser) == "127.0.0.1:19400")
{
SSDPDiscover discover;
- address = discover.getFirstService(STY_FLATBUFSERVER);
+ address = discover.getFirstService(searchType::STY_FLATBUFSERVER);
if(address.isEmpty())
{
address = argAddress.value(parser);
diff --git a/src/hyperion-remote/hyperion-remote.cpp b/src/hyperion-remote/hyperion-remote.cpp
index 804823d6..32714bd2 100644
--- a/src/hyperion-remote/hyperion-remote.cpp
+++ b/src/hyperion-remote/hyperion-remote.cpp
@@ -182,7 +182,7 @@ int main(int argc, char * argv[])
if(argAddress.value(parser) == "127.0.0.1:19444")
{
SSDPDiscover discover;
- address = discover.getFirstService(STY_JSONSERVER);
+ address = discover.getFirstService(searchType::STY_JSONSERVER);
if(address.isEmpty())
{
address = argAddress.value(parser);
diff --git a/src/hyperion-v4l2/hyperion-v4l2.cpp b/src/hyperion-v4l2/hyperion-v4l2.cpp
index dff94b9b..2c8ba3c3 100644
--- a/src/hyperion-v4l2/hyperion-v4l2.cpp
+++ b/src/hyperion-v4l2/hyperion-v4l2.cpp
@@ -84,18 +84,18 @@ int main(int argc, char** argv)
BooleanOption & argSkipReply = parser.add(0x0, "skip-reply", "Do not receive and check reply messages from Hyperion");
BooleanOption & argHelp = parser.add('h', "help", "Show this help message and exit");
- argVideoStandard.addSwitch("pal", VIDEOSTANDARD_PAL);
- argVideoStandard.addSwitch("ntsc", VIDEOSTANDARD_NTSC);
- argVideoStandard.addSwitch("secam", VIDEOSTANDARD_SECAM);
- argVideoStandard.addSwitch("no-change", VIDEOSTANDARD_NO_CHANGE);
+ argVideoStandard.addSwitch("pal", VideoStandard::PAL);
+ argVideoStandard.addSwitch("ntsc", VideoStandard::NTSC);
+ argVideoStandard.addSwitch("secam", VideoStandard::SECAM);
+ argVideoStandard.addSwitch("no-change", VideoStandard::NO_CHANGE);
- argPixelFormat.addSwitch("yuyv", PIXELFORMAT_YUYV);
- argPixelFormat.addSwitch("uyvy", PIXELFORMAT_UYVY);
- argPixelFormat.addSwitch("rgb32", PIXELFORMAT_RGB32);
+ argPixelFormat.addSwitch("yuyv", PixelFormat::YUYV);
+ argPixelFormat.addSwitch("uyvy", PixelFormat::UYVY);
+ argPixelFormat.addSwitch("rgb32", PixelFormat::RGB32);
#ifdef HAVE_JPEG
- argPixelFormat.addSwitch("mjpeg", PIXELFORMAT_MJPEG);
+ argPixelFormat.addSwitch("mjpeg", PixelFormat::MJPEG);
#endif
- argPixelFormat.addSwitch("no-change", PIXELFORMAT_NO_CHANGE);
+ argPixelFormat.addSwitch("no-change", PixelFormat::NO_CHANGE);
// parse all options
parser.process(app);
@@ -173,11 +173,11 @@ int main(int argc, char** argv)
// set 3D mode if applicable
if (parser.isSet(arg3DSBS))
{
- grabber.setVideoMode(VIDEO_3DSBS);
+ grabber.setVideoMode(VideoMode::VIDEO_3DSBS);
}
else if (parser.isSet(arg3DTAB))
{
- grabber.setVideoMode(VIDEO_3DTAB);
+ grabber.setVideoMode(VideoMode::VIDEO_3DTAB);
}
// run the grabber
@@ -198,7 +198,7 @@ int main(int argc, char** argv)
if(argAddress.value(parser) == "127.0.0.1:19400")
{
SSDPDiscover discover;
- address = discover.getFirstService(STY_FLATBUFSERVER);
+ address = discover.getFirstService(searchType::STY_FLATBUFSERVER);
if(address.isEmpty())
{
address = argAddress.value(parser);
diff --git a/src/hyperion-x11/hyperion-x11.cpp b/src/hyperion-x11/hyperion-x11.cpp
index bbce7eb8..322c7b53 100644
--- a/src/hyperion-x11/hyperion-x11.cpp
+++ b/src/hyperion-x11/hyperion-x11.cpp
@@ -83,7 +83,7 @@ int main(int argc, char ** argv)
if(argAddress.value(parser) == "127.0.0.1:19400")
{
SSDPDiscover discover;
- address = discover.getFirstService(STY_FLATBUFSERVER);
+ address = discover.getFirstService(searchType::STY_FLATBUFSERVER);
if(address.isEmpty())
{
address = argAddress.value(parser);
diff --git a/src/hyperiond/detectProcess.h b/src/hyperiond/detectProcess.h
index 2937ae2e..557c10b9 100644
--- a/src/hyperiond/detectProcess.h
+++ b/src/hyperiond/detectProcess.h
@@ -77,7 +77,12 @@ unsigned int getProcessIdsByProcessName(const char *processName, QStringList &li
if (bytes.isEmpty())
return 0;
- listOfPids = QString(bytes).split("\n", QString::SkipEmptyParts);
+ #if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
+ listOfPids = QString(bytes).split("\n", Qt::SkipEmptyParts);
+ #else
+ listOfPids = QString(bytes).split("\n", QString::SkipEmptyParts);
+ #endif
+
return listOfPids.count();
#endif
diff --git a/src/hyperiond/hyperiond.cpp b/src/hyperiond/hyperiond.cpp
index 2db8eb6a..626c1076 100644
--- a/src/hyperiond/hyperiond.cpp
+++ b/src/hyperiond/hyperiond.cpp
@@ -76,7 +76,7 @@ HyperionDaemon::HyperionDaemon(const QString rootPath, QObject *parent, const bo
, _osxGrabber(nullptr)
, _qtGrabber(nullptr)
, _ssdp(nullptr)
- , _currVideoMode(VIDEO_2D)
+ , _currVideoMode(VideoMode::VIDEO_2D)
{
HyperionDaemon::daemon = this;
@@ -278,7 +278,7 @@ void HyperionDaemon::handleSettingsUpdate(const settings::type &settingsType, co
if (level == "silent")
Logger::setLogLevel(Logger::OFF);
else if (level == "warn")
- Logger::setLogLevel(Logger::WARNING);
+ Logger::setLogLevel(Logger::LogLevel::WARNING);
else if (level == "verbose")
Logger::setLogLevel(Logger::INFO);
else if (level == "debug")
@@ -325,15 +325,19 @@ void HyperionDaemon::handleSettingsUpdate(const settings::type &settingsType, co
Error(_log, "grabber device '%s' for type amlogic not found!", QSTRING_CSTR(_grabber_device));
}
}
- // x11 -> if DISPLAY is set
- else if (getenv("DISPLAY") != NULL)
- {
- type = "x11";
- }
- // qt -> if nothing other applies
else
{
- type = "qt";
+ // x11 -> if DISPLAY is set
+ QByteArray envDisplay = qgetenv("DISPLAY");
+ if ( !envDisplay.isEmpty() )
+ {
+ type = "x11";
+ }
+ // qt -> if nothing other applies
+ else
+ {
+ type = "qt";
+ }
}
}
diff --git a/src/hyperiond/main.cpp b/src/hyperiond/main.cpp
index e09cca0c..d90f0c5f 100644
--- a/src/hyperiond/main.cpp
+++ b/src/hyperiond/main.cpp
@@ -230,7 +230,7 @@ int main(int argc, char** argv)
if (parser.isSet(versionOption))
{
std::cout
- << "Hyperion Ambilight Deamon (" << getpid() << ")" << std::endl
+ << "Hyperion Ambilight Deamon" << std::endl
<< "\tVersion : " << HYPERION_VERSION << " (" << HYPERION_BUILD_ID << ")" << std::endl
<< "\tBuild Time: " << __DATE__ << " " << __TIME__ << std::endl;
diff --git a/test/TestX11Performance.cpp b/test/TestX11Performance.cpp
index b29e0587..de146070 100644
--- a/test/TestX11Performance.cpp
+++ b/test/TestX11Performance.cpp
@@ -1,13 +1,13 @@
-// X11 includes
-#include
-#include
-
#include
#include
#include
+// X11 includes
+#include
+#include
+
void foo_1(int pixelDecimation)
{
int cropWidth = 0;