mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Merge branch 'HEAD' of https://github.com/tvdzwan/hyperion.git
This commit is contained in:
@@ -30,5 +30,5 @@ qt4_use_modules(hyperion-remote
|
||||
Network)
|
||||
|
||||
target_link_libraries(hyperion-remote
|
||||
hyperion-utils
|
||||
jsoncpp
|
||||
getoptPlusPlus)
|
||||
|
@@ -160,7 +160,7 @@ void JsonConnection::clearAll()
|
||||
parseReply(reply);
|
||||
}
|
||||
|
||||
void JsonConnection::setTransform(ColorTransformValues *threshold, ColorTransformValues *gamma, ColorTransformValues *blacklevel, ColorTransformValues *whitelevel)
|
||||
void JsonConnection::setTransform(double * saturation, double * value, ColorTransformValues *threshold, ColorTransformValues *gamma, ColorTransformValues *blacklevel, ColorTransformValues *whitelevel)
|
||||
{
|
||||
std::cout << "Set color transforms" << std::endl;
|
||||
|
||||
@@ -169,6 +169,16 @@ void JsonConnection::setTransform(ColorTransformValues *threshold, ColorTransfor
|
||||
command["command"] = "transform";
|
||||
Json::Value & transform = command["transform"];
|
||||
|
||||
if (saturation != nullptr)
|
||||
{
|
||||
transform["saturationGain"] = *saturation;
|
||||
}
|
||||
|
||||
if (value != nullptr)
|
||||
{
|
||||
transform["valueGain"] = *value;
|
||||
}
|
||||
|
||||
if (threshold != nullptr)
|
||||
{
|
||||
Json::Value & v = transform["threshold"];
|
||||
@@ -180,25 +190,25 @@ void JsonConnection::setTransform(ColorTransformValues *threshold, ColorTransfor
|
||||
if (gamma != nullptr)
|
||||
{
|
||||
Json::Value & v = transform["gamma"];
|
||||
v.append(threshold->valueRed);
|
||||
v.append(threshold->valueGreen);
|
||||
v.append(threshold->valueBlue);
|
||||
v.append(gamma->valueRed);
|
||||
v.append(gamma->valueGreen);
|
||||
v.append(gamma->valueBlue);
|
||||
}
|
||||
|
||||
if (blacklevel != nullptr)
|
||||
{
|
||||
Json::Value & v = transform["blacklevel"];
|
||||
v.append(threshold->valueRed);
|
||||
v.append(threshold->valueGreen);
|
||||
v.append(threshold->valueBlue);
|
||||
v.append(blacklevel->valueRed);
|
||||
v.append(blacklevel->valueGreen);
|
||||
v.append(blacklevel->valueBlue);
|
||||
}
|
||||
|
||||
if (whitelevel != nullptr)
|
||||
{
|
||||
Json::Value & v = transform["whitelevel"];
|
||||
v.append(threshold->valueRed);
|
||||
v.append(threshold->valueGreen);
|
||||
v.append(threshold->valueBlue);
|
||||
v.append(whitelevel->valueRed);
|
||||
v.append(whitelevel->valueGreen);
|
||||
v.append(whitelevel->valueBlue);
|
||||
}
|
||||
|
||||
// send command message
|
||||
@@ -275,7 +285,7 @@ bool JsonConnection::parseReply(const Json::Value &reply)
|
||||
|
||||
if (!success)
|
||||
{
|
||||
throw std::runtime_error("Error while executing command: " + reason);
|
||||
throw std::runtime_error("Error: " + reason);
|
||||
}
|
||||
|
||||
return success;
|
||||
|
@@ -39,7 +39,13 @@ public:
|
||||
|
||||
/// Set the color transform of the leds
|
||||
/// Note that providing a NULL will leave the settings on the server unchanged
|
||||
void setTransform(ColorTransformValues * threshold, ColorTransformValues * gamma, ColorTransformValues * blacklevel, ColorTransformValues * whitelevel);
|
||||
void setTransform(
|
||||
double * saturation,
|
||||
double * value,
|
||||
ColorTransformValues * threshold,
|
||||
ColorTransformValues * gamma,
|
||||
ColorTransformValues * blacklevel,
|
||||
ColorTransformValues * whitelevel);
|
||||
|
||||
private:
|
||||
/// Send a json command message and receive its reply
|
||||
|
@@ -42,9 +42,11 @@ 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)");
|
||||
ImageParameter & argImage = parameters.add<ImageParameter> ('i', "image" , "Set the leds to the colors according to the given image file");
|
||||
SwitchParameter<> & argServerInfo = parameters.add<SwitchParameter<> >('s', "info" , "List server info");
|
||||
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, "clear-all" , "Clear data for all priority channels");
|
||||
SwitchParameter<> & argClearAll = parameters.add<SwitchParameter<> >(0x0, "clearall" , "Clear data for all active priority channels");
|
||||
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");
|
||||
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)");
|
||||
@@ -68,7 +70,7 @@ int main(int argc, char * argv[])
|
||||
}
|
||||
|
||||
// check if at least one of the available color transforms is set
|
||||
bool colorTransform = argThreshold.isSet() || argGamma.isSet() || argBlacklevel.isSet() || argWhitelevel.isSet();
|
||||
bool colorTransform = argSaturation.isSet() || argValue.isSet() || argThreshold.isSet() || argGamma.isSet() || argBlacklevel.isSet() || argWhitelevel.isSet();
|
||||
|
||||
// check that exactly one command was given
|
||||
int commandCount = count({argColor.isSet(), argImage.isSet(), argServerInfo.isSet(), argClear.isSet(), argClearAll.isSet(), colorTransform});
|
||||
@@ -81,6 +83,8 @@ int main(int argc, char * argv[])
|
||||
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 << " " << argSaturation.usageLine() << std::endl;
|
||||
std::cerr << " " << argValue.usageLine() << std::endl;
|
||||
std::cerr << " " << argThreshold.usageLine() << std::endl;
|
||||
std::cerr << " " << argGamma.usageLine() << std::endl;
|
||||
std::cerr << " " << argBlacklevel.usageLine() << std::endl;
|
||||
@@ -115,14 +119,19 @@ int main(int argc, char * argv[])
|
||||
}
|
||||
else if (colorTransform)
|
||||
{
|
||||
double saturation, value;
|
||||
ColorTransformValues threshold, gamma, blacklevel, whitelevel;
|
||||
|
||||
if (argSaturation.isSet()) saturation = argSaturation.getValue();
|
||||
if (argValue.isSet()) value = argValue.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(
|
||||
argSaturation.isSet() ? &saturation : nullptr,
|
||||
argValue.isSet() ? &value : nullptr,
|
||||
argThreshold.isSet() ? &threshold : nullptr,
|
||||
argGamma.isSet() ? &gamma : nullptr,
|
||||
argBlacklevel.isSet() ? &blacklevel : nullptr,
|
||||
|
Reference in New Issue
Block a user