mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
Effects added to configuration file
Former-commit-id: 2ff4700ee5d5bc3a7dd5a29ecd35c1c9dd189873
This commit is contained in:
parent
554bc30c35
commit
ae1bd7d254
@ -11,7 +11,7 @@ class EffectEngine : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
EffectEngine(Hyperion * hyperion);
|
||||
EffectEngine(Hyperion * hyperion, const Json::Value & jsonEffectConfig);
|
||||
virtual ~EffectEngine();
|
||||
|
||||
std::list<std::string> getEffects() const;
|
||||
|
@ -1,16 +1,14 @@
|
||||
// Qt includes
|
||||
#include <QMetaType>
|
||||
|
||||
// Python includes
|
||||
#include <Python.h>
|
||||
|
||||
// Qt includes
|
||||
#include <QMetaType>
|
||||
|
||||
// effect engine includes
|
||||
#include <effectengine/EffectEngine.h>
|
||||
#include "Effect.h"
|
||||
|
||||
//static PyThreadState *_mainThreadState = 0;
|
||||
|
||||
EffectEngine::EffectEngine(Hyperion * hyperion) :
|
||||
EffectEngine::EffectEngine(Hyperion * hyperion, const Json::Value & jsonEffectConfig) :
|
||||
_hyperion(hyperion),
|
||||
_availableEffects(),
|
||||
_activeEffects(),
|
||||
@ -23,7 +21,12 @@ EffectEngine::EffectEngine(Hyperion * hyperion) :
|
||||
connect(_hyperion, SIGNAL(allChannelsCleared()), this, SLOT(allChannelsCleared()));
|
||||
|
||||
// read all effects
|
||||
_availableEffects["test"] = {"test.py", "{\"speed\":0.2}"};
|
||||
std::vector<std::string> effectNames = jsonEffectConfig.getMemberNames();
|
||||
for (const std::string & name : effectNames)
|
||||
{
|
||||
const Json::Value & info = jsonEffectConfig[name];
|
||||
_availableEffects[name] = {info["script"].asString(), Json::FastWriter().write(info["args"])};
|
||||
}
|
||||
|
||||
// initialize the python interpreter
|
||||
std::cout << "Initializing Python interpreter" << std::endl;
|
||||
|
@ -270,7 +270,7 @@ Hyperion::Hyperion(const Json::Value &jsonConfig) :
|
||||
QObject::connect(&_timer, SIGNAL(timeout()), this, SLOT(update()));
|
||||
|
||||
// create the effect engine
|
||||
_effectEngine = new EffectEngine(this);
|
||||
_effectEngine = new EffectEngine(this, jsonConfig["effects"]);
|
||||
|
||||
// initialize the leds
|
||||
update();
|
||||
|
@ -200,6 +200,27 @@
|
||||
"additionalProperties" : false
|
||||
}
|
||||
},
|
||||
"effects" :
|
||||
{
|
||||
"type" : "object",
|
||||
"required" : false,
|
||||
"additionalProperties" :
|
||||
{
|
||||
"type" : "object",
|
||||
"required" : false,
|
||||
"properties" :
|
||||
{
|
||||
"script" : {
|
||||
"type" : "string",
|
||||
"required" : true
|
||||
},
|
||||
"args" : {
|
||||
"type" : "object",
|
||||
"required" : false
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"blackborderdetector" :
|
||||
{
|
||||
"type" : "object",
|
||||
|
@ -176,7 +176,7 @@ void JsonClientConnection::handleServerInfoCommand(const Json::Value &)
|
||||
Json::Value & info = result["info"];
|
||||
|
||||
// collect priority information
|
||||
Json::Value & priorities = info["priorities"];
|
||||
Json::Value & priorities = info["priorities"] = Json::Value(Json::arrayValue);
|
||||
uint64_t now = QDateTime::currentMSecsSinceEpoch();
|
||||
QList<int> activePriorities = _hyperion->getActivePriorities();
|
||||
foreach (int priority, activePriorities) {
|
||||
@ -190,7 +190,7 @@ void JsonClientConnection::handleServerInfoCommand(const Json::Value &)
|
||||
}
|
||||
|
||||
// collect transform information
|
||||
Json::Value & transform = info["transform"];
|
||||
Json::Value & transform = info["transform"] = Json::Value(Json::objectValue);
|
||||
transform["saturationGain"] = _hyperion->getTransform(Hyperion::SATURATION_GAIN, Hyperion::INVALID);
|
||||
transform["valueGain"] = _hyperion->getTransform(Hyperion::VALUE_GAIN, Hyperion::INVALID);
|
||||
Json::Value & threshold = transform["threshold"];
|
||||
@ -211,7 +211,7 @@ void JsonClientConnection::handleServerInfoCommand(const Json::Value &)
|
||||
whitelevel.append(_hyperion->getTransform(Hyperion::WHITELEVEL, Hyperion::BLUE));
|
||||
|
||||
// collect effect info
|
||||
Json::Value & effects = info["effects"];
|
||||
Json::Value & effects = info["effects"] = Json::Value(Json::arrayValue);
|
||||
std::list<std::string> effectNames = _hyperion->getEffects();
|
||||
for (const std::string & name : effectNames)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user