mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
Implemented set transform for the json server
This commit is contained in:
parent
0a9bbe86a4
commit
cb38baa985
@ -21,6 +21,16 @@ class Hyperion : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum Color
|
||||
{
|
||||
RED, GREEN, BLUE
|
||||
};
|
||||
|
||||
enum Transform
|
||||
{
|
||||
THRESHOLD, GAMMA, BLACKLEVEL, WHITELEVEL
|
||||
};
|
||||
|
||||
static LedString createLedString(const Json::Value& ledsConfig);
|
||||
|
||||
Hyperion(const Json::Value& jsonConfig);
|
||||
@ -33,6 +43,8 @@ public:
|
||||
|
||||
void setColors(int priority, std::vector<RgbColor> &ledColors, const int timeout_ms);
|
||||
|
||||
void setTransform(Transform transform, Color color, double value);
|
||||
|
||||
void clear(int priority);
|
||||
|
||||
void clearall();
|
||||
|
@ -145,6 +145,45 @@ void Hyperion::setColors(int priority, std::vector<RgbColor>& ledColors, const i
|
||||
}
|
||||
}
|
||||
|
||||
void Hyperion::setTransform(Hyperion::Transform transform, Hyperion::Color color, double value)
|
||||
{
|
||||
// select the transform of the requested color
|
||||
ColorTransform * t = nullptr;
|
||||
switch (color)
|
||||
{
|
||||
case RED:
|
||||
t = _redTransform;
|
||||
break;
|
||||
case GREEN:
|
||||
t = _greenTransform;
|
||||
break;
|
||||
case BLUE:
|
||||
t = _blueTransform;
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
}
|
||||
|
||||
// set transform value
|
||||
switch (transform)
|
||||
{
|
||||
case THRESHOLD:
|
||||
t->setThreshold(value);
|
||||
break;
|
||||
case GAMMA:
|
||||
t->setGamma(value);
|
||||
break;
|
||||
case BLACKLEVEL:
|
||||
t->setBlacklevel(value);
|
||||
break;
|
||||
case WHITELEVEL:
|
||||
t->setWhitelevel(value);
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
|
||||
void Hyperion::clear(int priority)
|
||||
{
|
||||
if (_muxer.hasPriority(priority))
|
||||
|
@ -175,7 +175,41 @@ void JsonClientConnection::handleClearallCommand(const Json::Value &)
|
||||
|
||||
void JsonClientConnection::handleTransformCommand(const Json::Value &message)
|
||||
{
|
||||
handleNotImplemented();
|
||||
const Json::Value & transform = message["transform"];
|
||||
|
||||
if (transform.isMember("threshold"))
|
||||
{
|
||||
const Json::Value & threshold = transform["threshold"];
|
||||
_hyperion->setTransform(Hyperion::THRESHOLD, Hyperion::RED, threshold[0u].asDouble());
|
||||
_hyperion->setTransform(Hyperion::THRESHOLD, Hyperion::GREEN, threshold[1u].asDouble());
|
||||
_hyperion->setTransform(Hyperion::THRESHOLD, Hyperion::BLUE, threshold[2u].asDouble());
|
||||
}
|
||||
|
||||
if (transform.isMember("gamma"))
|
||||
{
|
||||
const Json::Value & threshold = transform["gamma"];
|
||||
_hyperion->setTransform(Hyperion::GAMMA, Hyperion::RED, threshold[0u].asDouble());
|
||||
_hyperion->setTransform(Hyperion::GAMMA, Hyperion::GREEN, threshold[1u].asDouble());
|
||||
_hyperion->setTransform(Hyperion::GAMMA, Hyperion::BLUE, threshold[2u].asDouble());
|
||||
}
|
||||
|
||||
if (transform.isMember("blacklevel"))
|
||||
{
|
||||
const Json::Value & threshold = transform["blacklevel"];
|
||||
_hyperion->setTransform(Hyperion::BLACKLEVEL, Hyperion::RED, threshold[0u].asDouble());
|
||||
_hyperion->setTransform(Hyperion::BLACKLEVEL, Hyperion::GREEN, threshold[1u].asDouble());
|
||||
_hyperion->setTransform(Hyperion::BLACKLEVEL, Hyperion::BLUE, threshold[2u].asDouble());
|
||||
}
|
||||
|
||||
if (transform.isMember("whitelevel"))
|
||||
{
|
||||
const Json::Value & threshold = transform["whitelevel"];
|
||||
_hyperion->setTransform(Hyperion::WHITELEVEL, Hyperion::RED, threshold[0u].asDouble());
|
||||
_hyperion->setTransform(Hyperion::WHITELEVEL, Hyperion::GREEN, threshold[1u].asDouble());
|
||||
_hyperion->setTransform(Hyperion::WHITELEVEL, Hyperion::BLUE, threshold[2u].asDouble());
|
||||
}
|
||||
|
||||
sendSuccessReply();
|
||||
}
|
||||
|
||||
void JsonClientConnection::handleNotImplemented()
|
||||
|
Loading…
Reference in New Issue
Block a user