mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
Merge remote-tracking branch 'refs/remotes/origin/test'
Former-commit-id: 009da18a860ea64f2921d4c34229749539d1e990
This commit is contained in:
commit
901876246e
@ -42,6 +42,32 @@
|
||||
/// - 'updateDelay' The delay of the output to leds (in periods of smoothing)
|
||||
"color" :
|
||||
{
|
||||
"correction" :
|
||||
[
|
||||
{
|
||||
"id" : "default",
|
||||
"leds" : "*",
|
||||
"correctionValues" :
|
||||
{
|
||||
"red" : 255,
|
||||
"green" : 255,
|
||||
"blue" : 255
|
||||
}
|
||||
}
|
||||
],
|
||||
"temperature" :
|
||||
[
|
||||
{
|
||||
"id" : "default",
|
||||
"leds" : "*",
|
||||
"correctionValues" :
|
||||
{
|
||||
"red" : 255,
|
||||
"green" : 255,
|
||||
"blue" : 255
|
||||
}
|
||||
}
|
||||
],
|
||||
"transform" :
|
||||
[
|
||||
{
|
||||
@ -52,6 +78,11 @@
|
||||
"saturationGain" : 1.0000,
|
||||
"valueGain" : 1.0000
|
||||
},
|
||||
"hsl" :
|
||||
{
|
||||
"saturationGain" : 1.0000,
|
||||
"luminanceGain" : 1.0000
|
||||
},`
|
||||
"red" :
|
||||
{
|
||||
"threshold" : 0.0000,
|
||||
|
@ -38,7 +38,7 @@
|
||||
"type":"object",
|
||||
"required":false,
|
||||
"properties": {
|
||||
"hsv" : {
|
||||
"hsv" : {
|
||||
"type" : "object",
|
||||
"required" : false,
|
||||
"properties" : {
|
||||
@ -54,6 +54,23 @@
|
||||
}
|
||||
},
|
||||
"additionalProperties" : false
|
||||
},
|
||||
"hsl" : {
|
||||
"type" : "object",
|
||||
"required" : false,
|
||||
"properties" : {
|
||||
"saturationGain" : {
|
||||
"type" : "number",
|
||||
"required" : false,
|
||||
"minimum" : 0.0
|
||||
},
|
||||
"luminanceGain" : {
|
||||
"type" : "number",
|
||||
"required" : false,
|
||||
"minimum" : 0.0
|
||||
}
|
||||
},
|
||||
"additionalProperties" : false
|
||||
},
|
||||
"red": {
|
||||
"type":"object",
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include <hyperion/ImageProcessor.h>
|
||||
#include <hyperion/MessageForwarder.h>
|
||||
#include <hyperion/ColorTransform.h>
|
||||
#include <hyperion/ColorCorrection.h>
|
||||
#include <utils/ColorRgb.h>
|
||||
|
||||
// project includes
|
||||
@ -231,7 +232,7 @@ void JsonClientConnection::handleMessage(const std::string &messageString)
|
||||
sendErrorReply("Error while validating json: " + errors);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// switch over all possible commands and handle them
|
||||
if (command == "color")
|
||||
handleColorCommand(message);
|
||||
@ -247,6 +248,10 @@ void JsonClientConnection::handleMessage(const std::string &messageString)
|
||||
handleClearallCommand(message);
|
||||
else if (command == "transform")
|
||||
handleTransformCommand(message);
|
||||
else if (command == "correction")
|
||||
handleCorrectionCommand(message);
|
||||
else if (command == "temperature")
|
||||
handleTemperatureCommand(message);
|
||||
else
|
||||
handleNotImplemented();
|
||||
}
|
||||
@ -404,6 +409,8 @@ void JsonClientConnection::handleServerInfoCommand(const Json::Value &)
|
||||
|
||||
transform["saturationGain"] = colorTransform->_hsvTransform.getSaturationGain();
|
||||
transform["valueGain"] = colorTransform->_hsvTransform.getValueGain();
|
||||
transform["saturationLGain"] = colorTransform->_hslTransform.getSaturationGain();
|
||||
transform["luminanceGain"] = colorTransform->_hslTransform.getLuminanceGain();
|
||||
|
||||
Json::Value & threshold = transform["threshold"];
|
||||
threshold.append(colorTransform->_rgbRedTransform.getThreshold());
|
||||
@ -476,7 +483,7 @@ void JsonClientConnection::handleTransformCommand(const Json::Value &message)
|
||||
//sendErrorReply(std::string("Incorrect transform identifier: ") + transformId);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (transform.isMember("saturationGain"))
|
||||
{
|
||||
colorTransform->_hsvTransform.setSaturationGain(transform["saturationGain"].asDouble());
|
||||
@ -486,6 +493,16 @@ void JsonClientConnection::handleTransformCommand(const Json::Value &message)
|
||||
{
|
||||
colorTransform->_hsvTransform.setValueGain(transform["valueGain"].asDouble());
|
||||
}
|
||||
|
||||
if (transform.isMember("saturationLGain"))
|
||||
{
|
||||
colorTransform->_hslTransform.setSaturationGain(transform["saturationLGain"].asDouble());
|
||||
}
|
||||
|
||||
if (transform.isMember("luminanceGain"))
|
||||
{
|
||||
colorTransform->_hslTransform.setLuminanceGain(transform["luminanceGain"].asDouble());
|
||||
}
|
||||
|
||||
if (transform.isMember("threshold"))
|
||||
{
|
||||
@ -518,13 +535,79 @@ void JsonClientConnection::handleTransformCommand(const Json::Value &message)
|
||||
colorTransform->_rgbGreenTransform.setWhitelevel(values[1u].asDouble());
|
||||
colorTransform->_rgbBlueTransform .setWhitelevel(values[2u].asDouble());
|
||||
}
|
||||
|
||||
|
||||
// commit the changes
|
||||
_hyperion->transformsUpdated();
|
||||
|
||||
sendSuccessReply();
|
||||
}
|
||||
|
||||
void JsonClientConnection::handleCorrectionCommand(const Json::Value &message)
|
||||
{
|
||||
const Json::Value & correction = message["correction"];
|
||||
|
||||
const std::string correctionId = correction.get("id", _hyperion->getCorrectionIds().front()).asString();
|
||||
ColorCorrection * colorCorrection = _hyperion->getCorrection(correctionId);
|
||||
if (colorCorrection == nullptr)
|
||||
{
|
||||
//sendErrorReply(std::string("Incorrect correction identifier: ") + correctionId);
|
||||
return;
|
||||
}
|
||||
|
||||
if (correction.isMember("red"))
|
||||
{
|
||||
colorCorrection->_rgbCorrection.setcorrectionR(correction["red"].asInt());
|
||||
}
|
||||
|
||||
if (correction.isMember("green"))
|
||||
{
|
||||
colorCorrection->_rgbCorrection.setcorrectionG(correction["green"].asInt());
|
||||
}
|
||||
|
||||
if (correction.isMember("blue"))
|
||||
{
|
||||
colorCorrection->_rgbCorrection.setcorrectionB(correction["blue"].asInt());
|
||||
}
|
||||
|
||||
// commit the changes
|
||||
_hyperion->correctionsUpdated();
|
||||
|
||||
sendSuccessReply();
|
||||
}
|
||||
|
||||
void JsonClientConnection::handleTemperatureCommand(const Json::Value &message)
|
||||
{
|
||||
const Json::Value & temperature = message["temperature"];
|
||||
|
||||
const std::string tempId = temperature.get("id", _hyperion->getTemperatureIds().front()).asString();
|
||||
ColorCorrection * colorTemperature = _hyperion->getTemperature(tempId);
|
||||
if (colorTemperature == nullptr)
|
||||
{
|
||||
//sendErrorReply(std::string("Incorrect temperature identifier: ") + tempId);
|
||||
return;
|
||||
}
|
||||
|
||||
if (temperature.isMember("red"))
|
||||
{
|
||||
colorTemperature->_rgbCorrection.setcorrectionR(temperature["red"].asInt());
|
||||
}
|
||||
|
||||
if (temperature.isMember("green"))
|
||||
{
|
||||
colorTemperature->_rgbCorrection.setcorrectionG(temperature["green"].asInt());
|
||||
}
|
||||
|
||||
if (temperature.isMember("blue"))
|
||||
{
|
||||
colorTemperature->_rgbCorrection.setcorrectionB(temperature["blue"].asInt());
|
||||
}
|
||||
|
||||
// commit the changes
|
||||
_hyperion->temperaturesUpdated();
|
||||
|
||||
sendSuccessReply();
|
||||
}
|
||||
|
||||
void JsonClientConnection::handleNotImplemented()
|
||||
{
|
||||
sendErrorReply("Command not implemented");
|
||||
|
@ -112,6 +112,20 @@ private:
|
||||
/// @param message the incoming message
|
||||
///
|
||||
void handleTransformCommand(const Json::Value & message);
|
||||
|
||||
///
|
||||
/// Handle an incoming JSON Correction message
|
||||
///
|
||||
/// @param message the incoming message
|
||||
///
|
||||
void handleCorrectionCommand(const Json::Value & message);
|
||||
|
||||
///
|
||||
/// Handle an incoming JSON Temperature message
|
||||
///
|
||||
/// @param message the incoming message
|
||||
///
|
||||
void handleTemperatureCommand(const Json::Value & message);
|
||||
|
||||
///
|
||||
/// Handle an incoming JSON message of unknown type
|
||||
|
@ -7,6 +7,8 @@
|
||||
<file alias="schema-clear">schema/schema-clear.json</file>
|
||||
<file alias="schema-clearall">schema/schema-clearall.json</file>
|
||||
<file alias="schema-transform">schema/schema-transform.json</file>
|
||||
<file alias="schema-correction">schema/schema-correction.json</file>
|
||||
<file alias="schema-temperature">schema/schema-temperature.json</file>
|
||||
<file alias="schema-effect">schema/schema-effect.json</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
41
libsrc/jsonserver/schema/schema-correction.json
Normal file
41
libsrc/jsonserver/schema/schema-correction.json
Normal file
@ -0,0 +1,41 @@
|
||||
{
|
||||
"type":"object",
|
||||
"required":true,
|
||||
"properties":{
|
||||
"command": {
|
||||
"type" : "string",
|
||||
"required" : true,
|
||||
"enum" : ["correction"]
|
||||
},
|
||||
"correction": {
|
||||
"type": "object",
|
||||
"required": true,
|
||||
"properties": {
|
||||
"id" : {
|
||||
"type" : "string",
|
||||
"required" : false
|
||||
},
|
||||
"red" : {
|
||||
"type" : "integer",
|
||||
"required" : false,
|
||||
"minimum": 0,
|
||||
"maximum": 255
|
||||
},
|
||||
"green" : {
|
||||
"type" : "integer",
|
||||
"required" : false,
|
||||
"minimum": 0,
|
||||
"maximum": 255
|
||||
},
|
||||
"blue" : {
|
||||
"type" : "integer",
|
||||
"required" : false,
|
||||
"minimum": 0,
|
||||
"maximum": 255
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
41
libsrc/jsonserver/schema/schema-temperature.json
Normal file
41
libsrc/jsonserver/schema/schema-temperature.json
Normal file
@ -0,0 +1,41 @@
|
||||
{
|
||||
"type":"object",
|
||||
"required":true,
|
||||
"properties":{
|
||||
"command": {
|
||||
"type" : "string",
|
||||
"required" : true,
|
||||
"enum" : ["temperature"]
|
||||
},
|
||||
"temperature": {
|
||||
"type": "object",
|
||||
"required": true,
|
||||
"properties": {
|
||||
"id" : {
|
||||
"type" : "string",
|
||||
"required" : false
|
||||
},
|
||||
"red" : {
|
||||
"type" : "integer",
|
||||
"required" : false,
|
||||
"minimum": 0,
|
||||
"maximum": 255
|
||||
},
|
||||
"green" : {
|
||||
"type" : "integer",
|
||||
"required" : false,
|
||||
"minimum": 0,
|
||||
"maximum": 255
|
||||
},
|
||||
"blue" : {
|
||||
"type" : "integer",
|
||||
"required" : false,
|
||||
"minimum": 0,
|
||||
"maximum": 255
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
@ -25,6 +25,16 @@
|
||||
"required" : false,
|
||||
"minimum" : 0.0
|
||||
},
|
||||
"saturationLGain" : {
|
||||
"type" : "number",
|
||||
"required" : false,
|
||||
"minimum" : 0.0
|
||||
},
|
||||
"luminanceGain" : {
|
||||
"type" : "number",
|
||||
"required" : false,
|
||||
"minimum" : 0.0
|
||||
},
|
||||
"threshold": {
|
||||
"type": "array",
|
||||
"required": false,
|
||||
|
@ -5,7 +5,7 @@
|
||||
"command": {
|
||||
"type" : "string",
|
||||
"required" : true,
|
||||
"enum" : ["color", "image", "effect", "serverinfo", "clear", "clearall", "transform"]
|
||||
"enum" : ["color", "image", "effect", "serverinfo", "clear", "clearall", "transform", "correction", "temperature"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -192,7 +192,7 @@ void JsonConnection::clearAll()
|
||||
parseReply(reply);
|
||||
}
|
||||
|
||||
void JsonConnection::setTransform(std::string * transformId, double * saturation, double * value, ColorTransformValues *threshold, ColorTransformValues *gamma, ColorTransformValues *blacklevel, ColorTransformValues *whitelevel)
|
||||
void JsonConnection::setTransform(std::string * transformId, double * saturation, double * value, double * saturationL, double * luminance, ColorTransformValues *threshold, ColorTransformValues *gamma, ColorTransformValues *blacklevel, ColorTransformValues *whitelevel)
|
||||
{
|
||||
std::cout << "Set color transforms" << std::endl;
|
||||
|
||||
@ -215,7 +215,16 @@ void JsonConnection::setTransform(std::string * transformId, double * saturation
|
||||
{
|
||||
transform["valueGain"] = *value;
|
||||
}
|
||||
|
||||
if (saturationL != nullptr)
|
||||
{
|
||||
transform["saturationLGain"] = *saturationL;
|
||||
}
|
||||
|
||||
if (luminance != nullptr)
|
||||
{
|
||||
transform["luminanceGain"] = *luminance;
|
||||
}
|
||||
if (threshold != nullptr)
|
||||
{
|
||||
Json::Value & v = transform["threshold"];
|
||||
@ -255,6 +264,78 @@ void JsonConnection::setTransform(std::string * transformId, double * saturation
|
||||
parseReply(reply);
|
||||
}
|
||||
|
||||
void JsonConnection::setCorrection(std::string * correctionId, int * red, int * green, int * blue)
|
||||
{
|
||||
std::cout << "Set color corrections" << std::endl;
|
||||
|
||||
// create command
|
||||
Json::Value command;
|
||||
command["command"] = "correction";
|
||||
Json::Value & correction = command["correction"];
|
||||
|
||||
if (correctionId != nullptr)
|
||||
{
|
||||
correction["id"] = *correctionId;
|
||||
}
|
||||
|
||||
if (red != nullptr)
|
||||
{
|
||||
correction["red"] = *red;
|
||||
}
|
||||
|
||||
if (green != nullptr)
|
||||
{
|
||||
correction["green"] = *green;
|
||||
}
|
||||
|
||||
if (blue != nullptr)
|
||||
{
|
||||
correction["blue"] = *blue;
|
||||
}
|
||||
|
||||
// send command message
|
||||
Json::Value reply = sendMessage(command);
|
||||
|
||||
// parse reply message
|
||||
parseReply(reply);
|
||||
}
|
||||
|
||||
void JsonConnection::setTemperature(std::string * temperatureId, int * red, int * green, int * blue)
|
||||
{
|
||||
std::cout << "Set color temperature corrections" << std::endl;
|
||||
|
||||
// create command
|
||||
Json::Value command;
|
||||
command["command"] = "temperature";
|
||||
Json::Value & temperature = command["temperature"];
|
||||
|
||||
if (temperatureId != nullptr)
|
||||
{
|
||||
temperature["id"] = *temperatureId;
|
||||
}
|
||||
|
||||
if (red != nullptr)
|
||||
{
|
||||
temperature["red"] = *red;
|
||||
}
|
||||
|
||||
if (green != nullptr)
|
||||
{
|
||||
temperature["green"] = *green;
|
||||
}
|
||||
|
||||
if (blue != nullptr)
|
||||
{
|
||||
temperature["blue"] = *blue;
|
||||
}
|
||||
|
||||
// send command message
|
||||
Json::Value reply = sendMessage(command);
|
||||
|
||||
// parse reply message
|
||||
parseReply(reply);
|
||||
}
|
||||
|
||||
Json::Value JsonConnection::sendMessage(const Json::Value & message)
|
||||
{
|
||||
// serialize message (FastWriter already appends a newline)
|
||||
|
@ -89,6 +89,8 @@ public:
|
||||
/// @param transformId The identifier of the transform to set
|
||||
/// @param saturation The HSV saturation gain
|
||||
/// @param value The HSV value gain
|
||||
/// @param saturationL The HSL saturation gain
|
||||
/// @param luminance The HSL luminance gain
|
||||
/// @param threshold The threshold
|
||||
/// @param gamma The gamma value
|
||||
/// @param blacklevel The blacklevel
|
||||
@ -98,10 +100,42 @@ public:
|
||||
std::string * transformId,
|
||||
double * saturation,
|
||||
double * value,
|
||||
double * saturationL,
|
||||
double * luminance,
|
||||
ColorTransformValues * threshold,
|
||||
ColorTransformValues * gamma,
|
||||
ColorTransformValues * blacklevel,
|
||||
ColorTransformValues * whitelevel);
|
||||
|
||||
///
|
||||
/// Set the color correction of the leds
|
||||
///
|
||||
/// @note Note that providing a NULL will leave the settings on the server unchanged
|
||||
///
|
||||
/// @param correctionId The identifier of the correction to set
|
||||
/// @param red The red correction value
|
||||
/// @param green The green correction value
|
||||
/// @param blue The blue correction value
|
||||
void setCorrection(
|
||||
std::string * correctionId,
|
||||
int * red,
|
||||
int * green,
|
||||
int * blue);
|
||||
|
||||
///
|
||||
/// Set the color temperature of the leds
|
||||
///
|
||||
/// @note Note that providing a NULL will leave the settings on the server unchanged
|
||||
///
|
||||
/// @param temperatureId The identifier of the correction to set
|
||||
/// @param red The red temperature value
|
||||
/// @param green The green temperature value
|
||||
/// @param blue The blue temperature value
|
||||
void setTemperature(
|
||||
std::string * temperatureId,
|
||||
int * red,
|
||||
int * green,
|
||||
int * blue);
|
||||
|
||||
private:
|
||||
///
|
||||
|
@ -53,20 +53,30 @@ int main(int argc, char * argv[])
|
||||
IntParameter & argDuration = parameters.add<IntParameter> ('d', "duration" , "Specify how long the leds should be switched on in millseconds [default: infinity]");
|
||||
ColorParameter & argColor = parameters.add<ColorParameter> ('c', "color" , "Set all leds to a constant color (either RRGGBB hex value or a color name. The color may be repeated multiple time like: RRGGBBRRGGBB)");
|
||||
ImageParameter & argImage = parameters.add<ImageParameter> ('i', "image" , "Set the leds to the colors according to the given image file");
|
||||
StringParameter & argEffect = parameters.add<StringParameter> ('e', "effect" , "Enable the effect with the given name");
|
||||
StringParameter & argEffectArgs = parameters.add<StringParameter> (0x0, "effectArgs", "Arguments to use in combination with the specified effect. Should be a Json object string.");
|
||||
StringParameter & argEffect = parameters.add<StringParameter> ('e', "effect" , "Enable the effect with the given name");
|
||||
StringParameter & argEffectArgs = parameters.add<StringParameter> (0x0, "effectArgs", "Arguments to use in combination with the specified effect. Should be a Json object string.");
|
||||
SwitchParameter<> & argServerInfo = parameters.add<SwitchParameter<> >('l', "list" , "List server info");
|
||||
SwitchParameter<> & argClear = parameters.add<SwitchParameter<> >('x', "clear" , "Clear data for the priority channel provided by the -p option");
|
||||
SwitchParameter<> & argClearAll = parameters.add<SwitchParameter<> >(0x0, "clearall" , "Clear data for all active priority channels");
|
||||
StringParameter & argId = parameters.add<StringParameter> ('q', "qualifier" , "Identifier(qualifier) of the transform to set");
|
||||
DoubleParameter & argSaturation = parameters.add<DoubleParameter> ('s', "saturation", "Set the HSV saturation gain of the leds");
|
||||
DoubleParameter & argValue = parameters.add<DoubleParameter> ('v', "value" , "Set the HSV value gain of the leds");
|
||||
DoubleParameter & argSaturationL = parameters.add<DoubleParameter> ('u', "saturationL", "Set the HSL saturation gain of the leds");
|
||||
DoubleParameter & argLuminance = parameters.add<DoubleParameter> ('m', "luminance" , "Set the HSL luminance gain of the leds");
|
||||
TransformParameter & argGamma = parameters.add<TransformParameter>('g', "gamma" , "Set the gamma of the leds (requires 3 space seperated values)");
|
||||
TransformParameter & argThreshold = parameters.add<TransformParameter>('t', "threshold" , "Set the threshold of the leds (requires 3 space seperated values between 0.0 and 1.0)");
|
||||
TransformParameter & argBlacklevel = parameters.add<TransformParameter>('b', "blacklevel", "Set the blacklevel of the leds (requires 3 space seperated values which are normally between 0.0 and 1.0)");
|
||||
TransformParameter & argWhitelevel = parameters.add<TransformParameter>('w', "whitelevel", "Set the whitelevel of the leds (requires 3 space seperated values which are normally between 0.0 and 1.0)");
|
||||
SwitchParameter<> & argPrint = parameters.add<SwitchParameter<> >(0x0, "print" , "Print the json input and output messages on stdout");
|
||||
SwitchParameter<> & argHelp = parameters.add<SwitchParameter<> >('h', "help" , "Show this help message and exit");
|
||||
StringParameter & argIdC = parameters.add<StringParameter> ('y', "qualifier" , "Identifier(qualifier) of the correction to set");
|
||||
IntParameter & argCorrR = parameters.add<IntParameter> ('1', "correctionR" , "Specify the red channel correction");
|
||||
IntParameter & argCorrG = parameters.add<IntParameter> ('2', "correctionG" , "Specify the green channel correction");
|
||||
IntParameter & argCorrB = parameters.add<IntParameter> ('3', "correctionB" , "Specify the blue channel correction");
|
||||
StringParameter & argIdT = parameters.add<StringParameter> ('z', "qualifier" , "Identifier(qualifier) of the temperature to set");
|
||||
IntParameter & argTempR = parameters.add<IntParameter> ('4', "tempR" , "Specify the red channel temperature correction");
|
||||
IntParameter & argTempG = parameters.add<IntParameter> ('5', "tempG" , "Specify the red channel temperature correction");
|
||||
IntParameter & argTempB = parameters.add<IntParameter> ('6', "tempB" , "Specify the red channel temperature correction");
|
||||
|
||||
// set the default values
|
||||
argAddress.setDefault(defaultServerAddress.toStdString());
|
||||
@ -85,10 +95,12 @@ int main(int argc, char * argv[])
|
||||
}
|
||||
|
||||
// check if at least one of the available color transforms is set
|
||||
bool colorTransform = argSaturation.isSet() || argValue.isSet() || argThreshold.isSet() || argGamma.isSet() || argBlacklevel.isSet() || argWhitelevel.isSet();
|
||||
bool colorTransform = argSaturation.isSet() || argValue.isSet() || argSaturationL.isSet() || argLuminance.isSet() || argThreshold.isSet() || argGamma.isSet() || argBlacklevel.isSet() || argWhitelevel.isSet();
|
||||
bool colorCorrection = argCorrR.isSet() || argCorrG.isSet() || argCorrB.isSet();
|
||||
bool colorTemp = argTempR.isSet() || argTempG.isSet() || argTempB.isSet();
|
||||
|
||||
// check that exactly one command was given
|
||||
int commandCount = count({argColor.isSet(), argImage.isSet(), argEffect.isSet(), argServerInfo.isSet(), argClear.isSet(), argClearAll.isSet(), colorTransform});
|
||||
int commandCount = count({argColor.isSet(), argImage.isSet(), argEffect.isSet(), argServerInfo.isSet(), argClear.isSet(), argClearAll.isSet(), colorTransform, colorCorrection, colorTemp});
|
||||
if (commandCount != 1)
|
||||
{
|
||||
std::cerr << (commandCount == 0 ? "No command found." : "Multiple commands found.") << " Provide exactly one of the following options:" << std::endl;
|
||||
@ -98,14 +110,26 @@ int main(int argc, char * argv[])
|
||||
std::cerr << " " << argServerInfo.usageLine() << std::endl;
|
||||
std::cerr << " " << argClear.usageLine() << std::endl;
|
||||
std::cerr << " " << argClearAll.usageLine() << std::endl;
|
||||
std::cerr << "or one or more of the available color transformations:" << std::endl;
|
||||
std::cerr << "one or more of the available color transformations:" << std::endl;
|
||||
std::cerr << " " << argId.usageLine() << std::endl;
|
||||
std::cerr << " " << argSaturation.usageLine() << std::endl;
|
||||
std::cerr << " " << argValue.usageLine() << std::endl;
|
||||
std::cerr << " " << argSaturationL.usageLine() << std::endl;
|
||||
std::cerr << " " << argLuminance.usageLine() << std::endl;
|
||||
std::cerr << " " << argThreshold.usageLine() << std::endl;
|
||||
std::cerr << " " << argGamma.usageLine() << std::endl;
|
||||
std::cerr << " " << argBlacklevel.usageLine() << std::endl;
|
||||
std::cerr << " " << argWhitelevel.usageLine() << std::endl;
|
||||
std::cerr << "one or more of the available color corrections:" << std::endl;
|
||||
std::cerr << " " << argIdC.usageLine() << std::endl;
|
||||
std::cerr << " " << argCorrR.usageLine() << std::endl;
|
||||
std::cerr << " " << argCorrG.usageLine() << std::endl;
|
||||
std::cerr << " " << argCorrB.usageLine() << std::endl;
|
||||
std::cerr << "or one or more of the available color temperature adjustment:" << std::endl;
|
||||
std::cerr << " " << argIdT.usageLine() << std::endl;
|
||||
std::cerr << " " << argTempR.usageLine() << std::endl;
|
||||
std::cerr << " " << argTempG.usageLine() << std::endl;
|
||||
std::cerr << " " << argTempB.usageLine() << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -121,11 +145,11 @@ int main(int argc, char * argv[])
|
||||
{
|
||||
connection.setImage(argImage.getValue(), argPriority.getValue(), argDuration.getValue());
|
||||
}
|
||||
else if (argEffect.isSet())
|
||||
{
|
||||
connection.setEffect(argEffect.getValue(), argEffectArgs.getValue(), argPriority.getValue(), argDuration.getValue());
|
||||
}
|
||||
else if (argServerInfo.isSet())
|
||||
else if (argEffect.isSet())
|
||||
{
|
||||
connection.setEffect(argEffect.getValue(), argEffectArgs.getValue(), argPriority.getValue(), argDuration.getValue());
|
||||
}
|
||||
else if (argServerInfo.isSet())
|
||||
{
|
||||
QString info = connection.getServerInfo();
|
||||
std::cout << "Server info:\n" << info.toStdString() << std::endl;
|
||||
@ -141,26 +165,62 @@ int main(int argc, char * argv[])
|
||||
else if (colorTransform)
|
||||
{
|
||||
std::string transId;
|
||||
double saturation, value;
|
||||
double saturation, value, saturationL, luminance;
|
||||
ColorTransformValues threshold, gamma, blacklevel, whitelevel;
|
||||
|
||||
if (argId.isSet()) transId = argId.getValue();
|
||||
if (argSaturation.isSet()) saturation = argSaturation.getValue();
|
||||
if (argValue.isSet()) value = argValue.getValue();
|
||||
if (argSaturationL.isSet()) saturationL = argSaturationL.getValue();
|
||||
if (argLuminance.isSet()) luminance = argLuminance.getValue();
|
||||
if (argThreshold.isSet()) threshold = argThreshold.getValue();
|
||||
if (argGamma.isSet()) gamma = argGamma.getValue();
|
||||
if (argBlacklevel.isSet()) blacklevel = argBlacklevel.getValue();
|
||||
if (argWhitelevel.isSet()) whitelevel = argWhitelevel.getValue();
|
||||
|
||||
|
||||
connection.setTransform(
|
||||
argId.isSet() ? &transId : nullptr,
|
||||
argSaturation.isSet() ? &saturation : nullptr,
|
||||
argValue.isSet() ? &value : nullptr,
|
||||
argSaturationL.isSet() ? &saturationL : nullptr,
|
||||
argLuminance.isSet() ? &luminance : nullptr,
|
||||
argThreshold.isSet() ? &threshold : nullptr,
|
||||
argGamma.isSet() ? &gamma : nullptr,
|
||||
argBlacklevel.isSet() ? &blacklevel : nullptr,
|
||||
argWhitelevel.isSet() ? &whitelevel : nullptr);
|
||||
}
|
||||
else if (colorCorrection)
|
||||
{
|
||||
std::string transId;
|
||||
int red, green, blue;
|
||||
|
||||
if (argIdC.isSet()) transId = argId.getValue();
|
||||
if (argCorrR.isSet()) red = argCorrR.getValue();
|
||||
if (argCorrG.isSet()) green = argCorrG.getValue();
|
||||
if (argCorrB.isSet()) blue = argCorrB.getValue();
|
||||
|
||||
connection.setCorrection(
|
||||
argIdC.isSet() ? &transId : nullptr,
|
||||
argCorrR.isSet() ? &red : nullptr,
|
||||
argCorrG.isSet() ? &green : nullptr,
|
||||
argCorrB.isSet() ? &blue : nullptr);
|
||||
}
|
||||
else if (colorTemp)
|
||||
{
|
||||
std::string transId;
|
||||
int red, green, blue;
|
||||
|
||||
if (argIdT.isSet()) transId = argId.getValue();
|
||||
if (argTempR.isSet()) red = argTempR.getValue();
|
||||
if (argTempG.isSet()) green = argTempG.getValue();
|
||||
if (argTempB.isSet()) blue = argTempB.getValue();
|
||||
|
||||
connection.setCorrection(
|
||||
argIdC.isSet() ? &transId : nullptr,
|
||||
argTempR.isSet() ? &red : nullptr,
|
||||
argTempG.isSet() ? &green : nullptr,
|
||||
argTempB.isSet() ? &blue : nullptr);
|
||||
}
|
||||
}
|
||||
catch (const std::runtime_error & e)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user