Add color adjustment to all RBG channels

* Channel adjustment config

* Create RgbChannelAdjustment.h

* Delete RgbChannelAdjustment.h

* Create RgbChannelAdjustment.cpp

* Create RgbChannelAdjustment.h

* Delete RgbChannelAdjustment.cpp

* Create ColorAdjustment.cpp

* Delete RgbChannelAdjustment.h

* Create ColorAdjustment.h

* Update ColorAdjustment.h

* Update ColorAdjustment.h

* Update ColorAdjustment.h

* Update ColorAdjustment.cpp

* Update Hyperion.cpp

* Update Hyperion.cpp

* Update Hyperion.cpp

* Update Hyperion.h

* Create RgbChannelAdjustment.cpp

* Create RgbChannelAdjustment.h

* Create ColorAdjustment.h

* Create MultiColorAdjustment.h

* Update MultiColorAdjustment.h

* Create MultiColorAdjustment.cpp

* Delete ColorAdjustment.cpp

* Delete ColorAdjustment.h

* Update RgbChannelAdjustment.cpp

* Update Hyperion.cpp

* Update Hyperion.h

* Update Hyperion.cpp

* Bug fixes

* Update hyperion.config.json

* Add color adjustment to json server and client and adapt hyperion-remote

* Change the color modification order

* Minor bug fix

* Create calibration Images folder

* Create calibration Gamma folder

* Create calibration RGB folder

* Added files via upload

* Delete .gitkeep

* Delete .gitkeep

* Added files via upload

* Delete .gitkeep

* Update color effect order and don't correct twice

* Uploaded gradient images


Former-commit-id: 8ab465e59834f12a21709a6f4546bd6808a2a495
This commit is contained in:
AEtHeLsYn
2016-04-02 00:04:11 +02:00
committed by brindosch
parent 078dbfd88e
commit b37cbd26d5
41 changed files with 870 additions and 13 deletions

View File

@@ -0,0 +1,12 @@
#pragma once
/// Simple structure to contain the values of a color transformation
struct ColorAdjustmentValues
{
/// The value for the red color-channel
int valueRed;
/// The value for the green color-channel
int valueGreen;
/// The value for the blue color-channel
int valueBlue;
};

View File

@@ -13,6 +13,7 @@
// hyperion-remote includes
#include "ColorTransformValues.h"
#include "ColorCorrectionValues.h"
#include "ColorAdjustmentValues.h"
/// Data parameter for a color
typedef vlofgren::PODParameter<std::vector<QColor>> ColorParameter;
@@ -26,6 +27,9 @@ typedef vlofgren::PODParameter<ColorTransformValues> TransformParameter;
/// Data parameter for color correction values (list of three values)
typedef vlofgren::PODParameter<ColorCorrectionValues> CorrectionParameter;
/// Data parameter for color correction values (list of three values)
typedef vlofgren::PODParameter<ColorAdjustmentValues> AdjustmentParameter;
namespace vlofgren {
///
/// Translates a string (as passed on the commandline) to a vector of colors
@@ -161,4 +165,33 @@ namespace vlofgren {
return correction;
}
template<>
ColorAdjustmentValues AdjustmentParameter::validate(const std::string& s) throw (Parameter::ParameterRejected)
{
ColorAdjustmentValues adjustment;
// s should be split in 3 parts
// seperators are either a ',' or a space
QStringList components = QString(s.c_str()).split(" ", QString::SkipEmptyParts);
if (components.size() == 3)
{
bool ok1, ok2, ok3;
adjustment.valueRed = components[0].toInt(&ok1);
adjustment.valueGreen = components[1].toInt(&ok2);
adjustment.valueBlue = components[2].toInt(&ok3);
if (ok1 && ok2 && ok3)
{
return adjustment;
}
}
std::stringstream errorMessage;
errorMessage << "Argument " << s << " can not be parsed to 3 integer values";
throw Parameter::ParameterRejected(errorMessage.str());
return adjustment;
}
}

View File

@@ -322,6 +322,51 @@ void JsonConnection::setTemperature(std::string * temperatureId, ColorCorrection
parseReply(reply);
}
void JsonConnection::setAdjustment(std::string * adjustmentId, ColorAdjustmentValues * redAdjustment, ColorAdjustmentValues * greenAdjustment, ColorAdjustmentValues * blueAdjustment)
{
std::cout << "Set color adjustments" << std::endl;
// create command
Json::Value command;
command["command"] = "adjustment";
Json::Value & adjust = command["adjustment"];
if (adjustmentId != nullptr)
{
adjust["id"] = *adjustmentId;
}
if (redAdjustment != nullptr)
{
Json::Value & v = adjust["redAdjust"];
v.append(redAdjustment->valueRed);
v.append(redAdjustment->valueGreen);
v.append(redAdjustment->valueBlue);
}
if (greenAdjustment != nullptr)
{
Json::Value & v = adjust["greenAdjust"];
v.append(greenAdjustment->valueRed);
v.append(greenAdjustment->valueGreen);
v.append(greenAdjustment->valueBlue);
}
if (blueAdjustment != nullptr)
{
Json::Value & v = adjust["blueAdjust"];
v.append(blueAdjustment->valueRed);
v.append(blueAdjustment->valueGreen);
v.append(blueAdjustment->valueBlue);
}
// 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)

View File

@@ -15,6 +15,7 @@
// hyperion-remote includes
#include "ColorTransformValues.h"
#include "ColorCorrectionValues.h"
#include "ColorAdjustmentValues.h"
///
/// Connection class to setup an connection to the hyperion server and execute commands
@@ -130,6 +131,21 @@ public:
std::string * temperatureId,
ColorCorrectionValues * temperature);
///
/// Set the color adjustment of the leds
///
/// @note Note that providing a NULL will leave the settings on the server unchanged
///
/// @param adjustmentId The identifier of the correction to set
/// @param redAdjustment The red channel adjustment values
/// @param greenAdjustment The green channel adjustment values
/// @param blueAdjustment The blue channel adjustment values
void setAdjustment(
std::string * adjustmentId,
ColorAdjustmentValues * redAdjustment,
ColorAdjustmentValues * greenAdjustment,
ColorAdjustmentValues * blueAdjustment);
private:
///
/// Send a json command message and receive its reply

View File

@@ -81,6 +81,10 @@ int main(int argc, char * argv[])
CorrectionParameter & argCorrection = parameters.add<CorrectionParameter>('Y', "correction" , "Set the correction of the leds (requires 3 space seperated values between 0 and 255)");
StringParameter & argIdT = parameters.add<StringParameter> ('z', "qualifier" , "Identifier(qualifier) of the temperature correction to set");
CorrectionParameter & argTemperature = parameters.add<CorrectionParameter>('Z', "temperature" , "Set the temperature correction of the leds (requires 3 space seperated values between 0 and 255)");
StringParameter & argIdA = parameters.add<StringParameter> ('j', "qualifier" , "Identifier(qualifier) of the adjustment to set");
AdjustmentParameter & argRAdjust = parameters.add<AdjustmentParameter>('R', "redAdjustment" , "Set the adjustment of the red color (requires 3 space seperated values between 0 and 255)");
AdjustmentParameter & argGAdjust = parameters.add<AdjustmentParameter>('G', "greenAdjustment", "Set the adjustment of the green color (requires 3 space seperated values between 0 and 255)");
AdjustmentParameter & argBAdjust = parameters.add<AdjustmentParameter>('B', "blueAdjustment", "Set the adjustment of the blue color (requires 3 space seperated values between 0 and 255)");
// set the default values
argAddress.setDefault(defaultServerAddress.toStdString());
@@ -100,10 +104,11 @@ int main(int argc, char * argv[])
// check if at least one of the available color transforms is set
bool colorTransform = argSaturation.isSet() || argValue.isSet() || argSaturationL.isSet() || argLuminance.isSet() || argThreshold.isSet() || argGamma.isSet() || argBlacklevel.isSet() || argWhitelevel.isSet();
bool colorModding = colorTransform || argCorrection.isSet() || argTemperature.isSet();
bool colorAdjust = argRAdjust.isSet() || argGAdjust.isSet() || argBAdjust.isSet();
bool colorModding = colorTransform || colorAdjust || argCorrection.isSet() || argTemperature.isSet();
// check that exactly one command was given
int commandCount = count({argColor.isSet(), argImage.isSet(), argEffect.isSet(), argServerInfo.isSet(), argClear.isSet(), argClearAll.isSet(), colorModding});
int commandCount = count({argColor.isSet(), argImage.isSet(), argEffect.isSet(), argServerInfo.isSet(), argClear.isSet(), argClearAll.isSet(), colorModding});
if (commandCount != 1)
{
std::cerr << (commandCount == 0 ? "No command found." : "Multiple commands found.") << " Provide exactly one of the following options:" << std::endl;
@@ -127,6 +132,10 @@ int main(int argc, char * argv[])
std::cerr << " " << argCorrection.usageLine() << std::endl;
std::cerr << " " << argIdT.usageLine() << std::endl;
std::cerr << " " << argTemperature.usageLine() << std::endl;
std::cerr << " " << argIdA.usageLine() << std::endl;
std::cerr << " " << argRAdjust.usageLine() << std::endl;
std::cerr << " " << argGAdjust.usageLine() << std::endl;
std::cerr << " " << argBAdjust.usageLine() << std::endl;
return 1;
}
@@ -186,6 +195,24 @@ int main(int argc, char * argv[])
argIdT.isSet() ? &tempId : nullptr,
argTemperature.isSet() ? &temperature : nullptr);
}
if (colorAdjust)
{
std::string adjustId;
ColorAdjustmentValues redChannel, greenChannel, blueChannel;
if (argIdA.isSet()) adjustId = argIdA.getValue();
if (argRAdjust.isSet()) redChannel = argRAdjust.getValue();
if (argGAdjust.isSet()) greenChannel = argGAdjust.getValue();
if (argBAdjust.isSet()) blueChannel = argBAdjust.getValue();
connection.setAdjustment(
argIdA.isSet() ? &adjustId : nullptr,
argRAdjust.isSet() ? &redChannel : nullptr,
argGAdjust.isSet() ? &greenChannel : nullptr,
argBAdjust.isSet() ? &blueChannel : nullptr);
}
if (colorTransform)
{
std::string transId;