mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Merge branch 'add_effect_engine'
Conflicts: config/hyperion.config.json libsrc/bootsequence/KittBootSequence.h Former-commit-id: ca9492accdf2ffdad52f6c0695cbba955f802b97
This commit is contained in:
@@ -1,24 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
///
|
||||
/// Pure virtual base class (or interface) for boot sequences. A BootSequence is started after the
|
||||
/// Hyperion deamon is started to demonstrate the proper functioninf of the attached leds (and lets
|
||||
/// face it because it is cool)
|
||||
///
|
||||
class BootSequence
|
||||
{
|
||||
public:
|
||||
|
||||
///
|
||||
/// Empty virtual destructor for abstract base class
|
||||
///
|
||||
virtual ~BootSequence()
|
||||
{
|
||||
// empty
|
||||
}
|
||||
|
||||
///
|
||||
/// Starts the boot sequence writing one or more colors to the attached leds
|
||||
///
|
||||
virtual void start() = 0;
|
||||
};
|
@@ -1,29 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
// Jsoncpp includes
|
||||
#include <json/json.h>
|
||||
|
||||
// Bootsequence includes
|
||||
#include <bootsequence/BootSequence.h>
|
||||
|
||||
// Hyperion includes
|
||||
#include <hyperion/Hyperion.h>
|
||||
|
||||
///
|
||||
/// Factory for settings based construction of a boot-sequence
|
||||
///
|
||||
class BootSequenceFactory
|
||||
{
|
||||
public:
|
||||
|
||||
///
|
||||
/// Creates a BootSequence using the given configuration (and Hyperion connection). Ownship of
|
||||
/// the returned instance is transferred
|
||||
///
|
||||
/// @param[in] hyperion The Hyperion controlling the leds
|
||||
/// @param[in] jsonConfig The boot-sequence configuration
|
||||
///
|
||||
/// @return The bootsequence (ownership is transferred to the caller
|
||||
///
|
||||
static BootSequence * createBootSequence(Hyperion * hyperion, const Json::Value & jsonConfig);
|
||||
};
|
14
include/effectengine/EffectDefinition.h
Normal file
14
include/effectengine/EffectDefinition.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
// stl include
|
||||
#include <string>
|
||||
|
||||
// json include
|
||||
#include <json/value.h>
|
||||
|
||||
struct EffectDefinition
|
||||
{
|
||||
std::string name;
|
||||
std::string script;
|
||||
Json::Value args;
|
||||
};
|
59
include/effectengine/EffectEngine.h
Normal file
59
include/effectengine/EffectEngine.h
Normal file
@@ -0,0 +1,59 @@
|
||||
#pragma once
|
||||
|
||||
// Qt includes
|
||||
#include <QObject>
|
||||
|
||||
// Json includes
|
||||
#include <json/value.h>
|
||||
|
||||
// Hyperion includes
|
||||
#include <hyperion/Hyperion.h>
|
||||
|
||||
// Effect engine includes
|
||||
#include <effectengine/EffectDefinition.h>
|
||||
|
||||
// pre-declarioation
|
||||
class Effect;
|
||||
typedef struct _ts PyThreadState;
|
||||
|
||||
class EffectEngine : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
EffectEngine(Hyperion * hyperion, const Json::Value & jsonEffectConfig);
|
||||
virtual ~EffectEngine();
|
||||
|
||||
const std::list<EffectDefinition> & getEffects() const;
|
||||
|
||||
static bool loadEffectDefinition(const std::string & path, const std::string & effectConfigFile, EffectDefinition &effectDefinition);
|
||||
|
||||
public slots:
|
||||
/// Run the specified effect on the given priority channel and optionally specify a timeout
|
||||
int runEffect(const std::string &effectName, int priority, int timeout = -1);
|
||||
|
||||
/// Run the specified effect on the given priority channel and optionally specify a timeout
|
||||
int runEffect(const std::string &effectName, const Json::Value & args, int priority, int timeout = -1);
|
||||
|
||||
/// Clear any effect running on the provided channel
|
||||
void channelCleared(int priority);
|
||||
|
||||
/// Clear all effects
|
||||
void allChannelsCleared();
|
||||
|
||||
private slots:
|
||||
void effectFinished(Effect * effect);
|
||||
|
||||
private:
|
||||
/// Run the specified effect on the given priority channel and optionally specify a timeout
|
||||
int runEffectScript(const std::string &script, const Json::Value & args, int priority, int timeout = -1);
|
||||
|
||||
private:
|
||||
Hyperion * _hyperion;
|
||||
|
||||
std::list<EffectDefinition> _availableEffects;
|
||||
|
||||
std::list<Effect *> _activeEffects;
|
||||
|
||||
PyThreadState * _mainThreadState;
|
||||
};
|
@@ -15,8 +15,12 @@
|
||||
#include <hyperion/LedDevice.h>
|
||||
#include <hyperion/PriorityMuxer.h>
|
||||
|
||||
// Effect engine includes
|
||||
#include <effectengine/EffectDefinition.h>
|
||||
|
||||
// Forward class declaration
|
||||
class ColorTransform;
|
||||
class EffectEngine;
|
||||
class HsvTransform;
|
||||
class RgbChannelTransform;
|
||||
class MultiColorTransform;
|
||||
@@ -71,6 +75,29 @@ public:
|
||||
///
|
||||
unsigned getLedCount() const;
|
||||
|
||||
///
|
||||
/// Returns a list of active priorities
|
||||
///
|
||||
/// @return The list with priorities
|
||||
///
|
||||
QList<int> getActivePriorities() const;
|
||||
|
||||
///
|
||||
/// Returns the information of a specific priorrity channel
|
||||
///
|
||||
/// @param[in] priority The priority channel
|
||||
///
|
||||
/// @return The information of the given
|
||||
///
|
||||
/// @throw std::runtime_error when the priority channel does not exist
|
||||
///
|
||||
const InputInfo& getPriorityInfo(const int priority) const;
|
||||
|
||||
/// Get the list of available effects
|
||||
/// @return The list of available effects
|
||||
const std::list<EffectDefinition> &getEffects() const;
|
||||
|
||||
public slots:
|
||||
///
|
||||
/// Writes a single color to all the leds for the given time and priority
|
||||
///
|
||||
@@ -78,7 +105,7 @@ public:
|
||||
/// @param[in] ledColor The color to write to the leds
|
||||
/// @param[in] timeout_ms The time the leds are set to the given color [ms]
|
||||
///
|
||||
void setColor(int priority, const ColorRgb &ledColor, const int timeout_ms);
|
||||
void setColor(int priority, const ColorRgb &ledColor, const int timeout_ms, bool clearEffects = true);
|
||||
|
||||
///
|
||||
/// Writes the given colors to all leds for the given time and priority
|
||||
@@ -87,7 +114,7 @@ public:
|
||||
/// @param[in] ledColors The colors to write to the leds
|
||||
/// @param[in] timeout_ms The time the leds are set to the given colors [ms]
|
||||
///
|
||||
void setColors(int priority, const std::vector<ColorRgb> &ledColors, const int timeout_ms);
|
||||
void setColors(int priority, const std::vector<ColorRgb> &ledColors, const int timeout_ms, bool clearEffects = true);
|
||||
|
||||
///
|
||||
/// Returns the list with unique transform identifiers
|
||||
@@ -117,24 +144,20 @@ public:
|
||||
///
|
||||
void clearall();
|
||||
|
||||
///
|
||||
/// Returns a list of active priorities
|
||||
///
|
||||
/// @return The list with priorities
|
||||
///
|
||||
QList<int> getActivePriorities() const;
|
||||
/// Run the specified effect on the given priority channel and optionally specify a timeout
|
||||
/// @param effectName Name of the effec to run
|
||||
/// @param priority The priority channel of the effect
|
||||
/// @param timout The timeout of the effect (after the timout, the effect will be cleared)
|
||||
int setEffect(const std::string & effectName, int priority, int timeout = -1);
|
||||
|
||||
///
|
||||
/// Returns the information of a specific priorrity channel
|
||||
///
|
||||
/// @param[in] priority The priority channel
|
||||
///
|
||||
/// @return The information of the given
|
||||
///
|
||||
/// @throw std::runtime_error when the priority channel does not exist
|
||||
///
|
||||
const InputInfo& getPriorityInfo(const int priority) const;
|
||||
/// Run the specified effect on the given priority channel and optionally specify a timeout
|
||||
/// @param effectName Name of the effec to run
|
||||
/// @param args arguments of the effect script
|
||||
/// @param priority The priority channel of the effect
|
||||
/// @param timout The timeout of the effect (after the timout, the effect will be cleared)
|
||||
int setEffect(const std::string & effectName, const Json::Value & args, int priority, int timeout = -1);
|
||||
|
||||
public:
|
||||
static LedDevice * createDevice(const Json::Value & deviceConfig);
|
||||
static ColorOrder createColorOrder(const Json::Value & deviceConfig);
|
||||
static LedString createLedString(const Json::Value & ledsConfig);
|
||||
@@ -146,6 +169,15 @@ public:
|
||||
|
||||
static LedDevice * createColorSmoothing(const Json::Value & smoothingConfig, LedDevice * ledDevice);
|
||||
|
||||
signals:
|
||||
/// Signal which is emitted when a priority channel is actively cleared
|
||||
/// This signal will not be emitted when a priority channel time out
|
||||
void channelCleared(int priority);
|
||||
|
||||
/// Signal which is emitted when all priority channels are actively cleared
|
||||
/// This signal will not be emitted when a priority channel time out
|
||||
void allChannelsCleared();
|
||||
|
||||
private slots:
|
||||
///
|
||||
/// Updates the priority muxer with the current time and (re)writes the led color with applied
|
||||
@@ -169,6 +201,9 @@ private:
|
||||
/// The actual LedDevice
|
||||
LedDevice * _device;
|
||||
|
||||
/// Effect engine
|
||||
EffectEngine * _effectEngine;
|
||||
|
||||
/// The timer for handling priority channel timeouts
|
||||
QTimer _timer;
|
||||
};
|
||||
|
@@ -20,6 +20,11 @@ class ImageProcessor
|
||||
public:
|
||||
~ImageProcessor();
|
||||
|
||||
///
|
||||
/// Returns the number of attached leds
|
||||
///
|
||||
unsigned getLedCount() const;
|
||||
|
||||
///
|
||||
/// Specifies the width and height of 'incomming' images. This will resize the buffer-image to
|
||||
/// match the given size.
|
||||
|
Reference in New Issue
Block a user