Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix/refactor backlight stuff #394

Merged
merged 5 commits into from
Feb 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions assets/webconfig/i18n/de.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"@metadata": {
"authors": [
"brindosch"
],
"project" : "Hyperion WebUI",
"locale": "de",
"@metadata": {
"authors": [
"brindosch"
],
"project" : "Hyperion WebUI",
"locale": "de",
"last-updated": "2016-11-30",
"message-documentation": "qqq"
},
"message-documentation": "qqq"
},
"general_webui_title" : "Hyperion - Web Konfiguration",
"general_country_de" : "Deutschland",
"general_country_us" : "Amerika",
Expand Down Expand Up @@ -422,7 +422,8 @@
"edt_conf_color_gammaGreen_expl" : "Gamma von grün.",
"edt_conf_color_gammaBlue_title" : "Gamma blau",
"edt_conf_color_gammaBlue_expl" : "Gamma von blau",
"edt_conf_color_brightnessMin_title" : "Minimale Helligkeit",
"edt_conf_color_backlightThreshold_title" : "Minimale Helligkeit",
"edt_conf_color_backlightColored_title" : "Farbige Hintergrundbeleuchtung",
"edt_conf_color_brightnessMin_expl" : "Auch als Hintergrundhelligkeit genutzt.",
"edt_conf_color_brightness_title" : "Maximale Helligkeit",
"edt_conf_color_brightness_expl" : "Zwischen 0.0 und 0.5 ist die Helligkeit linearisiert. Von 0.5 bis 1.0 wird cyan, magenta und gelb bis zu 2x heller und weiß bis zu 3x.",
Expand Down
19 changes: 10 additions & 9 deletions assets/webconfig/i18n/en.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"@metadata": {
"authors": [
"brindosch"
],
"project" : "Hyperion WebUI",
"locale": "en",
"@metadata": {
"authors": [
"brindosch"
],
"project" : "Hyperion WebUI",
"locale": "en",
"last-updated": "2016-11-30",
"message-documentation": "qqq.json"
},
"message-documentation": "qqq.json"
},
"general_webui_title" : "Hyperion - Web Configuration",
"general_country_de" : "Germany",
"general_country_us" : "United States",
Expand Down Expand Up @@ -422,7 +422,8 @@
"edt_conf_color_gammaGreen_expl" : "The gamma of green.",
"edt_conf_color_gammaBlue_title" : "gamma blue",
"edt_conf_color_gammaBlue_expl" : "The gamma of blue.",
"edt_conf_color_brightnessMin_title" : "minimal brightness",
"edt_conf_color_backlightThreshold_title" : "backlight threshold",
"edt_conf_color_backlightColored_title" : "Colored backlight",
"edt_conf_color_brightnessMin_expl" : "The minimum amount of brightness (backlight).",
"edt_conf_color_brightness_title" : "maximal brightness",
"edt_conf_color_brightness_expl" : "From 0.0 to 0.5 the brightness is linearised, from 0.5 to 1.0 cyan, magenta, yellow is up to 2x brighter and white 3x.",
Expand Down
2 changes: 1 addition & 1 deletion assets/webconfig/js/wizard.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ $(document).ready( function() {
}
if(step == 10)
{
updateWEditor(["brightnessMin"]);
updateWEditor(["backlightThreshold"]);
h = $.i18n('wiz_cc_minBright');
if(withKodi)
{
Expand Down
6 changes: 4 additions & 2 deletions config/hyperion.config.json.commented
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
/// * 'gammaRed'/'gammaGreen'/'gammaBlue' : Gamma value for each channel
/// * 'id' : The unique identifier of the channel adjustments (eg 'device_1')
/// * 'id' : The unique identifier of the channel adjustments (eg 'device_1')
/// * 'brightnessMin' : Minimum brightness (backlight)
/// * 'backlightThreshold' : Minimum brightness (backlight)
/// * 'backlightColored' : backlight with color, instead of white
/// * 'brightness' : Between 0.0-0.5 the brightness is linearized (white is as bright as red, is as bright as yellow).
/// Between 0.5-1.0 the linearization reduces slowly until it's gone with 1.0 (white is 3x brighter than red, yellow is 2x brighter than red)
"color" :
Expand All @@ -71,7 +72,8 @@
"gammaRed" : 1.0,
"gammaGreen" : 1.0,
"gammaBlue" : 1.0,
"brightnessMin" : 0.0,
"backlightThreshold" : 0.0,
"backlightColored" : false,
"brightness" : 0.5
}
]
Expand Down
3 changes: 2 additions & 1 deletion config/hyperion.config.json.default
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
"gammaRed" : 1.0,
"gammaGreen" : 1.0,
"gammaBlue" : 1.0,
"brightnessMin" : 0.0,
"backlightThreshold" : 0.0,
"backlightColored" : false,
"brightness" : 0.75
}
]
Expand Down
59 changes: 32 additions & 27 deletions include/commandline/DoubleOption.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef HYPERION_DOUBLECOMMANDLINEOPTION_H
#define HYPERION_DOUBLECOMMANDLINEOPTION_H
#pragma once

#include <QtCore>
#include "ValidatorOption.h"
Expand All @@ -9,32 +8,38 @@ namespace commandline

class DoubleOption: public ValidatorOption
{
protected:
double _double;
public:
DoubleOption(const QString &name,
const QString &description = QString(),
const QString &valueName = QString(),
const QString &defaultValue = QString(),
double minimum = -INFINITY, double maximum = INFINITY, int decimals = 1000)
: ValidatorOption(name, description, valueName, defaultValue)
{ setValidator(new QDoubleValidator(minimum, maximum, decimals)); }
DoubleOption(const QStringList &names,
const QString &description = QString(),
const QString &valueName = QString(),
const QString &defaultValue = QString(),
double minimum = -INFINITY, double maximum = INFINITY, int decimals = 1000)
: ValidatorOption(names, description, valueName, defaultValue)
{ setValidator(new QDoubleValidator(minimum, maximum, decimals)); }
DoubleOption(const QCommandLineOption &other,
double minimum = -INFINITY, double maximum = INFINITY, int decimals = 1000)
: ValidatorOption(other)
{ setValidator(new QDoubleValidator(minimum, maximum, decimals)); }

double getDouble(Parser &parser, bool *ok = 0);
double *getDoublePtr(Parser &parser, bool *ok = 0);
DoubleOption(const QString &name,
const QString &description = QString(),
const QString &valueName = QString(),
const QString &defaultValue = QString(),
double minimum = -INFINITY, double maximum = INFINITY, int decimals = 1000)
: ValidatorOption(name, description, valueName, defaultValue)
{
setValidator(new QDoubleValidator(minimum, maximum, decimals));
}

DoubleOption(const QStringList &names,
const QString &description = QString(),
const QString &valueName = QString(),
const QString &defaultValue = QString(),
double minimum = -INFINITY, double maximum = INFINITY, int decimals = 1000)
: ValidatorOption(names, description, valueName, defaultValue)
{
setValidator(new QDoubleValidator(minimum, maximum, decimals));
}

DoubleOption(const QCommandLineOption &other, double minimum = -INFINITY, double maximum = INFINITY, int decimals = 1000)
: ValidatorOption(other)
{
setValidator(new QDoubleValidator(minimum, maximum, decimals));
}

double getDouble(Parser &parser, bool *ok = 0);
double *getDoublePtr(Parser &parser, bool *ok = 0);

protected:
double _double;
};

}

#endif //HYPERION_DOUBLECOMMANDLINEOPTION_H
12 changes: 5 additions & 7 deletions include/commandline/SwitchOption.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef HYPERION_SWITCHCOMMANDLINEOPTION_H
#define HYPERION_SWITCHCOMMANDLINEOPTION_H
#pragma once

#include <QtCore>
#include "Option.h"
Expand All @@ -10,10 +9,8 @@ namespace commandline
template <class T>
class SwitchOption: public Option
{
protected:
QMap<QString, T> _switches;
public:
SwitchOption(const QString &name,
SwitchOption(const QString &name,
const QString &description = QString(),
const QString &valueName = QString(),
const QString &defaultValue = QString(),
Expand All @@ -38,8 +35,9 @@ class SwitchOption: public Option
void addSwitch(const QString &switch_, T value=T()){_switches[switch_.toLower()] = value;}
void removeSwitch(const QString &switch_){_switches.remove(switch_.toLower());}
T & switchValue(Parser & parser){return _switches[value(parser).toLower()];}

protected:
QMap<QString, T> _switches;
};

}

#endif //HYPERION_SWITCHCOMMANDLINEOPTION_H
2 changes: 2 additions & 0 deletions include/hyperion/Hyperion.h
Original file line number Diff line number Diff line change
Expand Up @@ -368,4 +368,6 @@ private slots:
int _ledMAppingType;

int _configVersionId;

hyperion::Components _prevCompId;
};
42 changes: 31 additions & 11 deletions include/utils/RgbTransform.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ class RgbTransform
/// @param gammaR The used red gamma
/// @param gammaG The used green gamma
/// @param gammab The used blue gamma
/// @param brightnessLow The used lower brightness
/// @param backlightThreshold The used lower brightness
/// @param backlightColored use color in backlight
/// @param brightnessHigh The used higher brightness
///
RgbTransform(double gammaR, double gammaG, double gammaB, double brightnessLow, double brightnessHigh);
RgbTransform(double gammaR, double gammaG, double gammaB, double backlightThreshold, bool backlightColored, double brightnessHigh);

///
/// Destructor
Expand All @@ -39,19 +40,34 @@ class RgbTransform
/// @return The current blue gamma value
double getGammaB() const;

/// @param gamma New gamma value
/// @param gammaR New red gamma value
/// @param gammaG New green gamma value
/// @param gammaB New blue gamma value
void setGamma(double gammaR,double gammaG=-1, double gammaB=-1);

/// @return The current lower brightness
double getBrightnessMin() const;
double getBacklightThreshold() const;

/// @param gamma New lower brightness
void setBrightnessMin(double brightness);
/// @param backlightThreshold New lower brightness
void setBacklightThreshold(double backlightThreshold);

/// @return The current lower brightness
/// @return The current state
bool getBacklightColored() const;

/// @param backlightColored en/disable colored backlight
void setBacklightColored(bool backlightColored);

/// @return return state of backlight
bool getBackLightEnabled() const;

/// @param enable en/disable backlight
void setBackLightEnabled(bool enable);


/// @return The current brightness
double getBrightness() const;

/// @param gamma New lower brightness
/// @param brightness New brightness
void setBrightness(double brightness);

///
Expand All @@ -72,15 +88,17 @@ class RgbTransform
/// @param gammaR The used red gamma
/// @param gammaG The used green gamma
/// @param gammab The used blue gamma
/// @param brightnessLow The used lower brightness
/// @param backlightThreshold The used lower brightness
/// @param backlightColored en/disable color in backlight
/// @param brightnessHigh The used higher brightness
///
void init(double gammaR, double gammaG, double gammaB, double brightnessLow, double brightnessHigh);
void init(double gammaR, double gammaG, double gammaB, double backlightThreshold, bool backlightColored, double brightnessHigh);

/// (re)-initilize the color mapping
void initializeMapping(); /// The saturation gain

double _brightnessLow;
double _backlightThreshold;
bool _backlightColored;
double _brightnessHigh;
double _sumBrightnessLow;
double _sumBrightnessHigh;
Expand All @@ -93,4 +111,6 @@ class RgbTransform
uint8_t _mappingR[256];
uint8_t _mappingG[256];
uint8_t _mappingB[256];

bool _backLightEnabled;
};
36 changes: 19 additions & 17 deletions libsrc/commandline/ColorOption.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,27 @@ using namespace commandline;

bool ColorOption::validate(Parser & parser, QString & value)
{
// Check if we can create the color by name
_color = QColor(value);
if (_color.isValid()) {
return true;
}
// Check if we can create the color by name
_color = QColor(value);
if (_color.isValid())
{
return true;
}

// check if we can create the color by hex RRGGBB getColors
_color = QColor(QString("#%1").arg(value));
if (_color.isValid()) {
return true;
}
// check if we can create the color by hex RRGGBB getColors
_color = QColor(QString("#%1").arg(value));
if (_color.isValid())
{
return true;
}

if(!parser.isSet(*this)){
// Return true if no value is available
return true;
}
if(!parser.isSet(*this))
{
// Return true if no value is available
return true;
}

QStringList error;
_error = QString("Invalid color. A color is specified by a six lettered RRGGBB hex getColors or one of the following names:\n\t- %1").arg(QColor::colorNames().join("\n\t- "));
_error = QString("Invalid color. A color is specified by a six lettered RRGGBB hex getColors or one of the following names:\n\t- %1").arg(QColor::colorNames().join("\n\t- "));

return false;
return false;
}
44 changes: 24 additions & 20 deletions libsrc/commandline/ColorsOption.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,36 @@ using namespace commandline;

bool ColorsOption::validate(Parser & parser, QString & value)
{
// Clear any old results
_colors.clear();
// Clear any old results
_colors.clear();

// Check if we can create the color by name
QColor color(value);
if (color.isValid()) {
_colors.push_back(color);
return true;
}
// Check if we can create the color by name
QColor color(value);
if (color.isValid())
{
_colors.push_back(color);
return true;
}

// check if we can create the color by hex RRGGBB getColors
QRegularExpression hexRe("^([0-9A-F]{6})+$", QRegularExpression::CaseInsensitiveOption);
QRegularExpressionMatch match = hexRe.match(value);
if(match.hasMatch()) {
Q_FOREACH(const QString m, match.capturedTexts()){
_colors.push_back(QColor(QString("#%1").arg(m)));
}
return true;
}
// check if we can create the color by hex RRGGBB getColors
QRegularExpression hexRe("^([0-9A-F]{6})+$", QRegularExpression::CaseInsensitiveOption);
QRegularExpressionMatch match = hexRe.match(value);
if(match.hasMatch())
{
Q_FOREACH(const QString m, match.capturedTexts())
{
_colors.push_back(QColor(QString("#%1").arg(m)));
}
return true;
}

if(!parser.isSet(*this)){
if(!parser.isSet(*this))
{
// Return true if no value is available
return true;
}

_error = QString("Invalid color. A color is specified by a six lettered RRGGBB hex getColors or one of the following names:\n\t- %1").arg(QColor::colorNames().join("\n\t- "));
_error = QString("Invalid color. A color is specified by a six lettered RRGGBB hex getColors or one of the following names:\n\t- %1").arg(QColor::colorNames().join("\n\t- "));

return false;
return false;
}
Loading