From a5e042225e640c117d32bad34287e292f0e0c854 Mon Sep 17 00:00:00 2001 From: AEtHeLsYn Date: Fri, 11 Mar 2016 12:30:32 +0100 Subject: [PATCH] Update JsonConnection.cpp Former-commit-id: 7b748e605939b65f02cb768a924faa48787618c3 --- src/hyperion-remote/JsonConnection.cpp | 83 +++++++++++++++++++++++++- 1 file changed, 82 insertions(+), 1 deletion(-) diff --git a/src/hyperion-remote/JsonConnection.cpp b/src/hyperion-remote/JsonConnection.cpp index 652a3dfa..7e296af7 100644 --- a/src/hyperion-remote/JsonConnection.cpp +++ b/src/hyperion-remote/JsonConnection.cpp @@ -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 (saturation != nullptr) + { + transform["saturationLGain"] = *saturationL; + } + if (value != 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 (correctionId != 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)