Update hyperion-remote.cpp

Former-commit-id: bb2282e48bdd93d4dffcd763ff34e33d3f00670c
This commit is contained in:
AEtHeLsYn 2016-03-11 12:20:59 +01:00
parent d7546dc042
commit 0baebe3873
1 changed files with 72 additions and 12 deletions

View File

@ -61,12 +61,22 @@ int main(int argc, char * argv[])
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> ('cq', "qualifier" , "Identifier(qualifier) of the correction to set");
IntParameter & argCorrR = parameters.add<IntParameter> ('cr', "correctionR" , "Specify the red channel correction factor");
IntParameter & argCorrG = parameters.add<IntParameter> ('cg', "correctionG" , "Specify the green channel correction factor");
IntParameter & argCorrB = parameters.add<IntParameter> ('cb', "correctionB" , "Specify the blue channel correction factor");
StringParameter & argIdT = parameters.add<StringParameter> ('tq', "qualifier" , "Identifier(qualifier) of the temperature to set");
IntParameter & argTempR = parameters.add<IntParameter> ('tr', "tempR" , "Specify the red channel temperature factor");
IntParameter & argTempG = parameters.add<IntParameter> ('tg', "tempG" , "Specify the red channel temperature factor");
IntParameter & argTempB = parameters.add<IntParameter> ('tb', "tempB" , "Specify the red channel temperature factor");
// 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;
}
@ -141,12 +165,14 @@ 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();
@ -156,11 +182,45 @@ int main(int argc, char * argv[])
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)
{