Hyperion Light 2 (#1428)

* Hyperion Light - Have EffectEngine as component

* Hyperion light - Build switches for LED Devices (Serial, Network)

* Fix file uri generation

* Fix missing guard for Windows

* Fix file uri generation

* Update jsonschema and checkschema

* Allow to provide cmake build args to docker build
This commit is contained in:
LordGrey
2022-02-11 20:36:15 +01:00
committed by GitHub
parent 9e4b58d5c6
commit 5078688dc8
47 changed files with 1920 additions and 938 deletions

View File

@@ -107,6 +107,7 @@ protected:
///
void setVideoMode(VideoMode mode, hyperion::Components callerComp = hyperion::COMP_INVALID);
#if defined(ENABLE_EFFECTENGINE)
///
/// @brief Set an effect
/// @param dat The effect data
@@ -115,6 +116,7 @@ protected:
/// @return True on success else false
///
bool setEffect(const EffectCmdData &dat, hyperion::Components callerComp = hyperion::COMP_INVALID);
#endif
///
/// @brief Set source auto select enabled or disabled
@@ -213,6 +215,7 @@ protected:
///
QString setInstanceName(quint8 index, const QString &name);
#if defined(ENABLE_EFFECTENGINE)
///
/// @brief Delete an effect. Requires ADMIN ACCESS
/// @param name The effect name
@@ -226,6 +229,7 @@ protected:
/// @return True on success else false
///
QString saveEffect(const QJsonObject &data);
#endif
///
/// @brief Save settings object. Requires ADMIN ACCESS

View File

@@ -148,6 +148,7 @@ private:
///
void handleImageCommand(const QJsonObject &message, const QString &command, int tan);
#if defined(ENABLE_EFFECTENGINE)
///
/// Handle an incoming JSON Effect message
///
@@ -168,6 +169,7 @@ private:
/// @param message the incoming message
///
void handleDeleteEffectCommand(const QJsonObject &message, const QString &command, int tan);
#endif
///
/// Handle an incoming JSON System info message

View File

@@ -99,10 +99,12 @@ private slots:
///
void handleVideoModeChange(VideoMode mode);
#if defined(ENABLE_EFFECTENGINE)
///
/// @brief Handle effect list change
///
void handleEffectListChange();
#endif
///
/// @brief Handle a config part change. This does NOT include (global) changes from other hyperion instances

View File

@@ -22,8 +22,6 @@ class Effect : public QThread
public:
static const int ENDLESS;
friend class EffectModule;
Effect(Hyperion *hyperion

View File

@@ -70,13 +70,13 @@ signals:
public slots:
/// Run the specified effect on the given priority channel and optionally specify a timeout
int runEffect(const QString &effectName, int priority, int timeout = Effect::ENDLESS, const QString &origin="System");
int runEffect(const QString &effectName, int priority, int timeout = PriorityMuxer::ENDLESS, const QString &origin="System");
/// Run the specified effect on the given priority channel and optionally specify a timeout
int runEffect(const QString &effectName
, const QJsonObject &args
, int priority
, int timeout = Effect::ENDLESS
, int timeout = PriorityMuxer::ENDLESS
, const QString &pythonScript = ""
, const QString &origin = "System"
, unsigned smoothCfg=0
@@ -103,7 +103,7 @@ private:
,const QString &name
, const QJsonObject &args
, int priority
, int timeout = Effect::ENDLESS
, int timeout = PriorityMuxer::ENDLESS
, const QString &origin="System"
, unsigned smoothCfg=0
, const QString &imageData = ""

View File

@@ -55,8 +55,12 @@ private slots:
{
_isBgEffectConfigured = true;
#if defined(ENABLE_EFFECTENGINE)
const QString bgTypeConfig = BGEffectConfig["type"].toString("effect");
const QString bgEffectConfig = BGEffectConfig["effect"].toString("Warm mood blobs");
#else
const QString bgTypeConfig = "color";
#endif
const QJsonValue bgColorConfig = BGEffectConfig["color"];
if (bgTypeConfig.contains("color"))
{
@@ -70,11 +74,13 @@ private slots:
_hyperion->setColor(PriorityMuxer::BG_PRIORITY, bg_color);
Info(Logger::getInstance("HYPERION"),"Initial background color set (%d %d %d)",bg_color.at(0).red, bg_color.at(0).green, bg_color.at(0).blue);
}
#if defined(ENABLE_EFFECTENGINE)
else
{
int result = _hyperion->setEffect(bgEffectConfig, PriorityMuxer::BG_PRIORITY, Effect::ENDLESS);
int result = _hyperion->setEffect(bgEffectConfig, PriorityMuxer::BG_PRIORITY, PriorityMuxer::ENDLESS);
Info(Logger::getInstance("HYPERION"),"Initial background effect '%s' %s", QSTRING_CSTR(bgEffectConfig), ((result == 0) ? "started" : "failed"));
}
#endif
}
#undef BGCONFIG_ARRAY
}

View File

@@ -24,11 +24,13 @@
#include <hyperion/ColorAdjustment.h>
#include <hyperion/ComponentRegister.h>
#if defined(ENABLE_EFFECTENGINE)
// Effect engine includes
#include <effectengine/EffectDefinition.h>
#include <effectengine/Effect.h>
#include <effectengine/ActiveEffectDefinition.h>
#include <effectengine/EffectSchema.h>
#endif
#include <leddevice/LedDevice.h>
@@ -42,7 +44,9 @@ class ImageProcessor;
class MessageForwarder;
#endif
class LinearColorSmoothing;
#if defined(ENABLE_EFFECTENGINE)
class EffectEngine;
#endif
class MultiColorAdjustment;
class ColorAdjustment;
class SettingsManager;
@@ -138,7 +142,7 @@ public slots:
/// @param clearEffect Should be true when NOT called from an effect
/// @return True on success, false when priority is not found
///
bool setInput(int priority, const std::vector<ColorRgb>& ledColors, int timeout_ms = -1, bool clearEffect = true);
bool setInput(int priority, const std::vector<ColorRgb>& ledColors, int timeout_ms = PriorityMuxer::ENDLESS, bool clearEffect = true);
///
/// @brief Update the current image of a priority (prev registered with registerInput())
@@ -149,7 +153,7 @@ public slots:
/// @param clearEffect Should be true when NOT called from an effect
/// @return True on success, false when priority is not found
///
bool setInputImage(int priority, const Image<ColorRgb>& image, int64_t timeout_ms = -1, bool clearEffect = true);
bool setInputImage(int priority, const Image<ColorRgb>& image, int64_t timeout_ms = PriorityMuxer::ENDLESS, bool clearEffect = true);
///
/// Writes a single color to all the leds for the given time and priority
@@ -162,7 +166,7 @@ public slots:
/// @param[in] origin The setter
/// @param clearEffect Should be true when NOT called from an effect
///
void setColor(int priority, const std::vector<ColorRgb> &ledColors, int timeout_ms = -1, const QString& origin = "System" ,bool clearEffects = true);
void setColor(int priority, const std::vector<ColorRgb> &ledColors, int timeout_ms = PriorityMuxer::ENDLESS, const QString& origin = "System" ,bool clearEffects = true);
///
/// @brief Set the given priority to inactive
@@ -196,14 +200,15 @@ public slots:
///
bool clear(int priority, bool forceClearAll=false);
#if defined(ENABLE_EFFECTENGINE)
/// #############
/// EFFECTENGINE
///
/// @brief Get a pointer to the effect engine
/// @return EffectEngine instance pointer
///
EffectEngine* getEffectEngineInstance() const { return _effectEngine; }
///
/// @brief Save an effect
/// @param obj The effect args
@@ -222,7 +227,7 @@ public slots:
/// @param effectName Name of the effec to run
/// @param priority The priority channel of the effect
/// @param timeout The timeout of the effect (after the timout, the effect will be cleared)
int setEffect(const QString & effectName, int priority, int timeout = Effect::ENDLESS, const QString & origin="System");
int setEffect(const QString & effectName, int priority, int timeout = PriorityMuxer::ENDLESS, const QString & origin="System");
/// Run the specified effect on the given priority channel and optionally specify a timeout
/// @param effectName Name of the effec to run
@@ -232,7 +237,7 @@ public slots:
int setEffect(const QString &effectName
, const QJsonObject &args
, int priority
, int timeout = Effect::ENDLESS
, int timeout = PriorityMuxer::ENDLESS
, const QString &pythonScript = ""
, const QString &origin="System"
, const QString &imageData = ""
@@ -249,6 +254,7 @@ public slots:
/// Get the list of available effect schema files
/// @return The list of available effect schema files
std::list<EffectSchema> getEffectSchemas() const;
#endif
/// #############
/// PRIORITYMUXER
@@ -444,10 +450,12 @@ signals:
///
void adjustmentChanged();
#if defined(ENABLE_EFFECTENGINE)
///
/// @brief Signal pipe from EffectEngine to external, emits when effect list has been updated
///
void effectListUpdated();
#endif
///
/// @brief Emits whenever new data should be pushed to the LedDeviceWrapper which forwards it to the threaded LedDevice
@@ -533,8 +541,10 @@ private:
/// The smoothing LedDevice
LinearColorSmoothing * _deviceSmooth;
#if defined(ENABLE_EFFECTENGINE)
/// Effect engine
EffectEngine * _effectEngine;
#endif
#if defined(ENABLE_FORWARDER)
// Message forwarder

View File

@@ -63,6 +63,8 @@ public:
/// Timeout used to identify a non active priority
const static int TIMEOUT_NOT_ACTIVE_PRIO;
const static int ENDLESS;
///
/// Constructs the PriorityMuxer for the given number of LEDs (used to switch to black when
/// there are no priority channels
@@ -164,7 +166,7 @@ public:
/// @param timeout_ms The new timeout (defaults to -1 endless)
/// @return True on success, false when priority is not found
///
bool setInput(int priority, const std::vector<ColorRgb>& ledColors, int64_t timeout_ms = -1);
bool setInput(int priority, const std::vector<ColorRgb>& ledColors, int64_t timeout_ms = ENDLESS);
///
/// @brief Update the current image of a priority (prev registered with registerInput())
@@ -173,7 +175,7 @@ public:
/// @param timeout_ms The new timeout (defaults to -1 endless)
/// @return True on success, false when priority is not found
///
bool setInputImage(int priority, const Image<ColorRgb>& image, int64_t timeout_ms = -1);
bool setInputImage(int priority, const Image<ColorRgb>& image, int64_t timeout_ms = ENDLESS);
///
/// @brief Set the given priority to inactive
@@ -220,7 +222,7 @@ signals:
///
/// @brief Emits whenever something changes which influences the priorities listing
/// Emits also in 1s interval when a COLOR or EFFECT is running with a timeout > -1
/// Emits also in 1s interval when a COLOR or EFFECT is running with a timeout > -1 (endless)
///
void prioritiesChanged();

View File

@@ -4,6 +4,8 @@
#include <QObject>
#include <QString>
#include "HyperionConfig.h"
class SysInfo : public QObject
{
public:
@@ -24,7 +26,9 @@ public:
QString domainName;
bool isUserAdmin;
QString qtVersion;
#if defined(ENABLE_EFFECTENGINE)
QString pyVersion;
#endif
};
static HyperionSysInfo get();

View File

@@ -10,7 +10,9 @@
// fg effect
#include <hyperion/Hyperion.h>
#include <hyperion/PriorityMuxer.h>
#if defined(ENABLE_EFFECTENGINE)
#include <effectengine/Effect.h>
#endif
///
/// @brief Provide utility methods for Hyperion class
@@ -24,12 +26,16 @@ namespace hyperion {
// initial foreground effect/color
if (FGEffectConfig["enable"].toBool(true))
{
#if defined(ENABLE_EFFECTENGINE)
const QString fgTypeConfig = FGEffectConfig["type"].toString("effect");
const QString fgEffectConfig = FGEffectConfig["effect"].toString("Rainbow swirl fast");
#else
const QString fgTypeConfig = "color";
#endif
const QJsonValue fgColorConfig = FGEffectConfig["color"];
int default_fg_duration_ms = 3000;
int fg_duration_ms = FGEffectConfig["duration_ms"].toInt(default_fg_duration_ms);
if (fg_duration_ms <= Effect::ENDLESS)
if (fg_duration_ms <= PriorityMuxer::ENDLESS )
{
fg_duration_ms = default_fg_duration_ms;
Warning(Logger::getInstance("HYPERION"), "foreground effect duration 'infinity' is forbidden, set to default value %d ms",default_fg_duration_ms);
@@ -46,11 +52,13 @@ namespace hyperion {
hyperion->setColor(PriorityMuxer::FG_PRIORITY, fg_color, fg_duration_ms);
Info(Logger::getInstance("HYPERION","I"+QString::number(hyperion->getInstanceIndex())),"Initial foreground color set (%d %d %d)",fg_color.at(0).red,fg_color.at(0).green,fg_color.at(0).blue);
}
#if defined(ENABLE_EFFECTENGINE)
else
{
int result = hyperion->setEffect(fgEffectConfig, PriorityMuxer::FG_PRIORITY, fg_duration_ms);
Info(Logger::getInstance("HYPERION","I"+QString::number(hyperion->getInstanceIndex())),"Initial foreground effect '%s' %s", QSTRING_CSTR(fgEffectConfig), ((result == 0) ? "started" : "failed"));
}
#endif
}
#undef FGCONFIG_ARRAY
}