mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Adjustment merge + new brightness settings (#359)
* add new rgbtransform * activate rgbtransform * integrate new transform and gamma in adjustment, disable transform * fix brighness limit * advance upper and lower thresholds * start removing color transform * adjust configs/schema * implement json for new color adjustment * finish hyperion-remote extension for new adjustment settings * fix typos * rename luminance to brightness fix jsonapi for new adjustment * fix some bugs in adjustments * fix i18n * fix gamma via json * now brighness values goes from 0-1 with 0.5 is the default for all brighness is equal between the channels. less 0.5 all channels scaled down to new brighness, above 0.5 if possible channel gets brighter - but brighness is not equal between the channels anymore brighness value curve is now exponential instead of linear - this feels more natural * hslv cleanup
This commit is contained in:
@@ -401,102 +401,21 @@ void JsonConnection::setConfig(const QString &jsonString)
|
||||
parseReply(reply);
|
||||
}
|
||||
|
||||
void JsonConnection::setTransform(const QString &transformId,
|
||||
double *saturation,
|
||||
double *value,
|
||||
double *saturationL,
|
||||
double *luminance,
|
||||
double *luminanceMin,
|
||||
QColor threshold,
|
||||
QColor gamma,
|
||||
QColor blacklevel,
|
||||
QColor whitelevel)
|
||||
{
|
||||
qDebug() << "Set color transforms";
|
||||
|
||||
// create command
|
||||
QJsonObject command, transform;
|
||||
command["command"] = QString("transform");
|
||||
|
||||
if (!transformId.isNull())
|
||||
{
|
||||
transform["id"] = transformId;
|
||||
}
|
||||
|
||||
if (saturation != nullptr)
|
||||
{
|
||||
transform["saturationGain"] = *saturation;
|
||||
}
|
||||
|
||||
if (value != nullptr)
|
||||
{
|
||||
transform["valueGain"] = *value;
|
||||
}
|
||||
|
||||
if (saturationL != nullptr)
|
||||
{
|
||||
transform["saturationLGain"] = *saturationL;
|
||||
}
|
||||
|
||||
if (luminance != nullptr)
|
||||
{
|
||||
transform["luminanceGain"] = *luminance;
|
||||
}
|
||||
|
||||
if (luminanceMin != nullptr)
|
||||
{
|
||||
transform["luminanceMinimum"] = *luminanceMin;
|
||||
}
|
||||
|
||||
if (threshold.isValid())
|
||||
{
|
||||
QJsonArray t;
|
||||
t.append(threshold.red());
|
||||
t.append(threshold.green());
|
||||
t.append(threshold.blue());
|
||||
transform["threshold"] = t;
|
||||
}
|
||||
|
||||
if (gamma.isValid())
|
||||
{
|
||||
QJsonArray g;
|
||||
g.append(gamma.red());
|
||||
g.append(gamma.green());
|
||||
g.append(gamma.blue());
|
||||
transform["gamma"] = g;
|
||||
}
|
||||
|
||||
if (blacklevel.isValid())
|
||||
{
|
||||
QJsonArray b;
|
||||
b.append(blacklevel.red());
|
||||
b.append(blacklevel.green());
|
||||
b.append(blacklevel.blue());
|
||||
transform["blacklevel"] = b;
|
||||
}
|
||||
|
||||
if (whitelevel.isValid())
|
||||
{
|
||||
QJsonArray w;
|
||||
w.append(whitelevel.red());
|
||||
w.append(whitelevel.green());
|
||||
w.append(whitelevel.blue());
|
||||
transform["whitelevel"] = w;
|
||||
}
|
||||
|
||||
command["transform"] = transform;
|
||||
|
||||
// send command message
|
||||
QJsonObject reply = sendMessage(command);
|
||||
|
||||
// parse reply message
|
||||
parseReply(reply);
|
||||
}
|
||||
|
||||
void JsonConnection::setAdjustment(const QString &adjustmentId,
|
||||
const QColor & redAdjustment,
|
||||
const QColor & greenAdjustment,
|
||||
const QColor & blueAdjustment)
|
||||
void JsonConnection::setAdjustment(
|
||||
const QString & adjustmentId,
|
||||
const QColor & redAdjustment,
|
||||
const QColor & greenAdjustment,
|
||||
const QColor & blueAdjustment,
|
||||
const QColor & cyanAdjustment,
|
||||
const QColor & magentaAdjustment,
|
||||
const QColor & yellowAdjustment,
|
||||
const QColor & whiteAdjustment,
|
||||
const QColor & blackAdjustment,
|
||||
double *gammaR,
|
||||
double *gammaG,
|
||||
double *gammaB,
|
||||
double *brightnessMin,
|
||||
double *brightness)
|
||||
{
|
||||
qDebug() << "Set color adjustments";
|
||||
|
||||
@@ -535,7 +454,51 @@ void JsonConnection::setAdjustment(const QString &adjustmentId,
|
||||
blue.append(blueAdjustment.blue());
|
||||
adjust["blueAdjust"] = blue;
|
||||
}
|
||||
|
||||
if (cyanAdjustment.isValid())
|
||||
{
|
||||
QJsonArray cyan;
|
||||
cyan.append(cyanAdjustment.red());
|
||||
cyan.append(cyanAdjustment.green());
|
||||
cyan.append(cyanAdjustment.blue());
|
||||
adjust["cyanAdjust"] = cyan;
|
||||
}
|
||||
if (magentaAdjustment.isValid())
|
||||
{
|
||||
QJsonArray magenta;
|
||||
magenta.append(magentaAdjustment.red());
|
||||
magenta.append(magentaAdjustment.green());
|
||||
magenta.append(magentaAdjustment.blue());
|
||||
adjust["magentaAdjust"] = magenta;
|
||||
}
|
||||
if (yellowAdjustment.isValid())
|
||||
{
|
||||
QJsonArray yellow;
|
||||
yellow.append(yellowAdjustment.red());
|
||||
yellow.append(yellowAdjustment.green());
|
||||
yellow.append(yellowAdjustment.blue());
|
||||
adjust["yellowAdjust"] = yellow;
|
||||
}
|
||||
if (brightnessMin != nullptr)
|
||||
{
|
||||
adjust["brightnessMin"] = *brightnessMin;
|
||||
}
|
||||
if (brightness != nullptr)
|
||||
{
|
||||
adjust["brightness"] = *brightness;
|
||||
}
|
||||
if (gammaR != nullptr)
|
||||
{
|
||||
adjust["gammaR"] = *gammaR;
|
||||
}
|
||||
if (gammaG != nullptr)
|
||||
{
|
||||
adjust["gammaG"] = *gammaG;
|
||||
}
|
||||
if (gammaB != nullptr)
|
||||
{
|
||||
adjust["gammaB"] = *gammaB;
|
||||
}
|
||||
|
||||
command["adjustment"] = adjust;
|
||||
|
||||
// send command message
|
||||
|
@@ -124,34 +124,6 @@ public:
|
||||
///
|
||||
void setConfig(const QString &jsonString);
|
||||
|
||||
///
|
||||
/// Set the color transform of the leds
|
||||
///
|
||||
/// @note Note that providing a NULL will leave the settings on the server unchanged
|
||||
///
|
||||
/// @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 luminanceMin The HSL luminance minimum
|
||||
/// @param threshold The threshold
|
||||
/// @param gamma The gamma value
|
||||
/// @param blacklevel The blacklevel
|
||||
/// @param whitelevel The whitelevel
|
||||
///
|
||||
void setTransform(
|
||||
const QString &transformId,
|
||||
double *saturation,
|
||||
double *value,
|
||||
double *saturationL,
|
||||
double *luminance,
|
||||
double *luminanceMin,
|
||||
QColor threshold,
|
||||
QColor gamma,
|
||||
QColor blacklevel,
|
||||
QColor whitelevel);
|
||||
|
||||
///
|
||||
/// Set the color adjustment of the leds
|
||||
///
|
||||
@@ -161,11 +133,25 @@ public:
|
||||
/// @param redAdjustment The red channel adjustment values
|
||||
/// @param greenAdjustment The green channel adjustment values
|
||||
/// @param blueAdjustment The blue channel adjustment values
|
||||
/// @param gamma The gamma value
|
||||
/// @param brightnessMin The threshold aka backlight
|
||||
/// @param brightness The threshold aka upper brightness limit
|
||||
|
||||
void setAdjustment(
|
||||
const QString & adjustmentId,
|
||||
const QColor & redAdjustment,
|
||||
const QColor & greenAdjustment,
|
||||
const QColor & blueAdjustment);
|
||||
const QColor & blueAdjustment,
|
||||
const QColor & cyanAdjustment,
|
||||
const QColor & magentaAdjustment,
|
||||
const QColor & yellowAdjustment,
|
||||
const QColor & blackAdjustment,
|
||||
const QColor & whiteAdjustment,
|
||||
double *gammaR,
|
||||
double *gammaG,
|
||||
double *gammaB,
|
||||
double *brightnessMin,
|
||||
double *brightness);
|
||||
|
||||
///
|
||||
/// sets the image to leds mapping type
|
||||
|
@@ -54,7 +54,7 @@ int main(int argc, char * argv[])
|
||||
try
|
||||
{
|
||||
// create the option parser and initialize all parameters
|
||||
Parser parser("Simple application to send a command to hyperion using the Json interface");
|
||||
Parser parser("Application to send a command to hyperion using the Json interface");
|
||||
|
||||
Option & argAddress = parser.add<Option> ('a', "address" , "Set the address of the hyperion server [default: %1]", "localhost:19444");
|
||||
IntOption & argPriority = parser.add<IntOption> ('p', "priority" , "Use to the provided priority channel (the lower the number, the higher the priority) [default: %1]", "100");
|
||||
@@ -71,29 +71,27 @@ int main(int argc, char * argv[])
|
||||
BooleanOption & argClearAll = parser.add<BooleanOption>(0x0, "clearall" , "Clear data for all active priority channels");
|
||||
Option & argEnableComponent = parser.add<Option> ('E', "enable" , "Enable the Component with the given name. Available Components are [SMOOTHING, BLACKBORDER, KODICHECKER, FORWARDER, UDPLISTENER, BOBLIGHT_SERVER, GRABBER, V4L]");
|
||||
Option & argDisableComponent = parser.add<Option> ('D', "disable" , "Disable the Component with the given name. Available Components are [SMOOTHING, BLACKBORDER, KODICHECKER, FORWARDER, UDPLISTENER, BOBLIGHT_SERVER, GRABBER, V4L]");
|
||||
Option & argId = parser.add<Option> ('q', "qualifier" , "Identifier(qualifier) of the transform to set");
|
||||
DoubleOption & argSaturation = parser.add<DoubleOption> ('s', "saturation", "!DEPRECATED! Will be removed soon! Set the HSV saturation gain of the leds");
|
||||
DoubleOption & argValue = parser.add<DoubleOption> ('v', "getColors" , "!DEPRECATED! Will be removed soon! Set the HSV getColors gain of the leds");
|
||||
DoubleOption & argSaturationL = parser.add<DoubleOption> ('u', "saturationL", "Set the HSL saturation gain of the leds");
|
||||
DoubleOption & argLuminance = parser.add<DoubleOption> ('m', "luminance" , "Set the HSL luminance gain of the leds");
|
||||
DoubleOption & argLuminanceMin= parser.add<DoubleOption> ('n', "luminanceMin" , "Set the HSL luminance minimum of the leds (backlight)");
|
||||
ColorOption & argGamma = parser.add<ColorOption> ('g', "gamma" , "Set the gamma of the leds (requires colors in hex format as RRGGBB)");
|
||||
ColorOption & argThreshold = parser.add<ColorOption> ('t', "threshold" , "Set the threshold of the leds (requires colors in hex format as RRGGBB)");
|
||||
ColorOption & argBlacklevel = parser.add<ColorOption> ('b', "blacklevel", "!DEPRECATED! Will be removed soon! Set the blacklevel of the leds (requires colors in hex format as RRGGBB which are normally between 0.0 and 1.0)");
|
||||
ColorOption & argWhitelevel = parser.add<ColorOption> ('w', "whitelevel", "!DEPRECATED! Will be removed soon! Set the whitelevel of the leds (requires colors in hex format as RRGGBB which are normally between 0.0 and 1.0)");
|
||||
Option & argId = parser.add<Option> ('q', "qualifier" , "Identifier(qualifier) of the adjustment to set");
|
||||
DoubleOption & argBrightness = parser.add<DoubleOption> ('L', "brightness" , "Set the brightness gain of the leds");
|
||||
DoubleOption & argBrightnessMin= parser.add<DoubleOption> ('n', "brightnessMin" , "Set the brightness minimum of the leds (backlight)");
|
||||
DoubleOption & argGamma = parser.add<DoubleOption> ('g', "gamma" , "Set the overall gamma of the leds");
|
||||
BooleanOption & argPrint = parser.add<BooleanOption>(0x0, "print" , "Print the json input and output messages on stdout");
|
||||
BooleanOption & argHelp = parser.add<BooleanOption>('h', "help" , "Show this help message and exit");
|
||||
Option & argIdA = parser.add<Option> ('j', "qualifier-a" , "Identifier(qualifier) of the adjustment to set");
|
||||
ColorOption & argRAdjust = parser.add<ColorOption> ('R', "redAdjustment" , "Set the adjustment of the red color (requires colors in hex format as RRGGBB)");
|
||||
ColorOption & argGAdjust = parser.add<ColorOption> ('G', "greenAdjustment", "Set the adjustment of the green color (requires colors in hex format as RRGGBB)");
|
||||
ColorOption & argBAdjust = parser.add<ColorOption> ('B', "blueAdjustment", "Set the adjustment of the blue color (requires colors in hex format as RRGGBB)");
|
||||
Option & argMapping = parser.add<Option> ('M', "ledMapping" , "Set the methode for image to led mapping valif values: multicolor:mean, unicolor_mean");
|
||||
ColorOption & argCAdjust = parser.add<ColorOption> ('C', "cyanAdjustment" , "Set the adjustment of the cyan color (requires colors in hex format as RRGGBB)");
|
||||
ColorOption & argMAdjust = parser.add<ColorOption> ('M', "magentaAdjustment", "Set the adjustment of the magenta color (requires colors in hex format as RRGGBB)");
|
||||
ColorOption & argYAdjust = parser.add<ColorOption> ('Y', "yellowAdjustment", "Set the adjustment of the yellow color (requires colors in hex format as RRGGBB)");
|
||||
ColorOption & argWAdjust = parser.add<ColorOption> ('W', "whiteAdjustment", "Set the adjustment of the white color (requires colors in hex format as RRGGBB)");
|
||||
ColorOption & argbAdjust = parser.add<ColorOption> ('b', "blackAdjustment", "Set the adjustment of the black color (requires colors in hex format as RRGGBB)");
|
||||
Option & argMapping = parser.add<Option> ('m', "ledMapping" , "Set the methode for image to led mapping valif values: multicolor:mean, unicolor_mean");
|
||||
IntOption & argSource = parser.add<IntOption> (0x0, "sourceSelect" , "Set current active priority channel and deactivate auto source switching");
|
||||
BooleanOption & argSourceAuto = parser.add<BooleanOption>(0x0, "sourceAutoSelect", "Enables auto source, if disabled prio by manual selecting input source");
|
||||
BooleanOption & argSourceOff = parser.add<BooleanOption>(0x0, "sourceOff", "select no source, this results in leds activly set to black (=off)");
|
||||
BooleanOption & argConfigGet = parser.add<BooleanOption>(0x0, "configGet" , "Print the current loaded Hyperion configuration file");
|
||||
BooleanOption & argSchemaGet = parser.add<BooleanOption>(0x0, "schemaGet" , "Print the json schema for Hyperion configuration");
|
||||
Option & argConfigSet = parser.add<Option> ('W', "configSet", "Write to the actual loaded configuration file. Should be a Json object string.");
|
||||
Option & argConfigSet = parser.add<Option> (0x0, "configSet", "Write to the actual loaded configuration file. Should be a Json object string.");
|
||||
|
||||
// parse all _options
|
||||
parser.process(app);
|
||||
@@ -105,14 +103,12 @@ int main(int argc, char * argv[])
|
||||
}
|
||||
|
||||
// check if at least one of the available color transforms is set
|
||||
bool colorTransform = parser.isSet(argSaturation) || parser.isSet(argValue) || parser.isSet(argSaturationL) || parser.isSet(argLuminance)
|
||||
|| parser.isSet(argLuminanceMin) || parser.isSet(argThreshold) || parser.isSet(argGamma) || parser.isSet(argBlacklevel) || parser.isSet(argWhitelevel);
|
||||
bool colorAdjust = parser.isSet(argRAdjust) || parser.isSet(argGAdjust) || parser.isSet(argBAdjust);
|
||||
bool colorModding = colorTransform || colorAdjust;
|
||||
bool colorAdjust = parser.isSet(argRAdjust) || parser.isSet(argGAdjust) || parser.isSet(argBAdjust) || parser.isSet(argCAdjust) || parser.isSet(argMAdjust)
|
||||
|| parser.isSet(argYAdjust) || parser.isSet(argWAdjust) || parser.isSet(argbAdjust) || parser.isSet(argGamma)|| parser.isSet(argBrightness)|| parser.isSet(argBrightnessMin);
|
||||
|
||||
// check that exactly one command was given
|
||||
int commandCount = count({ parser.isSet(argColor), parser.isSet(argImage), parser.isSet(argEffect), parser.isSet(argCreateEffect), parser.isSet(argDeleteEffect),
|
||||
parser.isSet(argServerInfo), parser.isSet(argClear), parser.isSet(argClearAll), parser.isSet(argEnableComponent), parser.isSet(argDisableComponent), colorModding,
|
||||
parser.isSet(argServerInfo), parser.isSet(argClear), parser.isSet(argClearAll), parser.isSet(argEnableComponent), parser.isSet(argDisableComponent), colorAdjust,
|
||||
parser.isSet(argSource), parser.isSet(argSourceAuto), parser.isSet(argSourceOff), parser.isSet(argConfigGet), parser.isSet(argSchemaGet), parser.isSet(argConfigSet),
|
||||
parser.isSet(argMapping) });
|
||||
if (commandCount != 1)
|
||||
@@ -133,19 +129,15 @@ int main(int argc, char * argv[])
|
||||
showHelp(argConfigGet);
|
||||
qWarning() << "or one or more of the available color modding operations:";
|
||||
showHelp(argId);
|
||||
showHelp(argSaturation);
|
||||
showHelp(argValue);
|
||||
showHelp(argSaturationL);
|
||||
showHelp(argLuminance);
|
||||
showHelp(argLuminanceMin);
|
||||
showHelp(argThreshold);
|
||||
showHelp(argBrightness);
|
||||
showHelp(argBrightnessMin);
|
||||
showHelp(argGamma);
|
||||
showHelp(argBlacklevel);
|
||||
showHelp(argWhitelevel);
|
||||
showHelp(argIdA);
|
||||
showHelp(argRAdjust);
|
||||
showHelp(argGAdjust);
|
||||
showHelp(argBAdjust);
|
||||
showHelp(argCAdjust);
|
||||
showHelp(argMAdjust);
|
||||
showHelp(argYAdjust);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -155,7 +147,7 @@ int main(int argc, char * argv[])
|
||||
// now execute the given command
|
||||
if (parser.isSet(argColor))
|
||||
{
|
||||
// TODO: make sure setColor accepts a QList<QColor>
|
||||
// TODO: make sure setColor accepts a QList<QColor>
|
||||
connection.setColor(argColor.getColors(parser).toVector().toStdVector(), argPriority.getInt(parser), argDuration.getInt(parser));
|
||||
}
|
||||
else if (parser.isSet(argImage))
|
||||
@@ -225,32 +217,24 @@ int main(int argc, char * argv[])
|
||||
{
|
||||
connection.setLedMapping(argMapping.value(parser));
|
||||
}
|
||||
else if (colorModding)
|
||||
{
|
||||
if (colorAdjust)
|
||||
{
|
||||
connection.setAdjustment(
|
||||
argIdA.value(parser),
|
||||
argRAdjust.getColor(parser),
|
||||
argGAdjust.getColor(parser),
|
||||
argBAdjust.getColor(parser)
|
||||
);
|
||||
|
||||
}
|
||||
if (colorTransform)
|
||||
{
|
||||
connection.setTransform(
|
||||
argId.value(parser),
|
||||
argSaturation.getDoublePtr(parser),
|
||||
argValue.getDoublePtr(parser),
|
||||
argSaturationL.getDoublePtr(parser),
|
||||
argLuminance.getDoublePtr(parser),
|
||||
argLuminanceMin.getDoublePtr(parser),
|
||||
argThreshold.getColor(parser),
|
||||
argGamma.getColor(parser),
|
||||
argBlacklevel.getColor(parser),
|
||||
argWhitelevel.getColor(parser));
|
||||
}
|
||||
else if (colorAdjust)
|
||||
{
|
||||
connection.setAdjustment(
|
||||
argId.value(parser),
|
||||
argRAdjust.getColor(parser),
|
||||
argGAdjust.getColor(parser),
|
||||
argBAdjust.getColor(parser),
|
||||
argCAdjust.getColor(parser),
|
||||
argMAdjust.getColor(parser),
|
||||
argYAdjust.getColor(parser),
|
||||
argWAdjust.getColor(parser),
|
||||
argbAdjust.getColor(parser),
|
||||
argGamma.getDoublePtr(parser),
|
||||
argGamma.getDoublePtr(parser),
|
||||
argGamma.getDoublePtr(parser),
|
||||
argBrightnessMin.getDoublePtr(parser),
|
||||
argBrightness.getDoublePtr(parser)
|
||||
);
|
||||
}
|
||||
}
|
||||
catch (const std::runtime_error & e)
|
||||
|
Reference in New Issue
Block a user