fix/refactor backlight stuff (#394)

* fix/refactor backlight stuff:
- fix colors dont turn of when backlight 0 and black is set
- add option to use not colored backlight
- fix colored backlight not colored on very low color values
- various code style tunings

* apply needed change to wizard

* backlight disabled on static color and efects

* fix warnings

* try fix udp compiler warnings
This commit is contained in:
redPanther
2017-02-11 22:52:47 +01:00
committed by GitHub
parent 199d266bc0
commit e1165e112f
33 changed files with 364 additions and 240 deletions

View File

@@ -158,13 +158,14 @@ MultiColorAdjustment * Hyperion::createLedColorsAdjustment(const unsigned ledCnt
RgbTransform* Hyperion::createRgbTransform(const QJsonObject& colorConfig)
{
const double brightnessMin = colorConfig["brightnessMin"].toDouble(0.0);
const double backlightThreshold = colorConfig["backlightThreshold"].toDouble(0.0);
const bool backlightColored = colorConfig["backlightColored"].toBool(false);
const double brightness = colorConfig["brightness"].toDouble(0.5);
const double gammaR = colorConfig["gammaRed"].toDouble(1.0);
const double gammaG = colorConfig["gammaGreen"].toDouble(1.0);
const double gammaB = colorConfig["gammaBlue"].toDouble(1.0);
RgbTransform* transform = new RgbTransform(gammaR, gammaG, gammaB, brightnessMin, brightness);
RgbTransform* transform = new RgbTransform(gammaR, gammaG, gammaB, backlightThreshold, backlightColored, brightness);
return transform;
}
@@ -392,10 +393,10 @@ Hyperion::Hyperion(const QJsonObject &qjsonConfig, const QString configFile)
, _timer()
, _log(CORE_LOGGER)
, _hwLedCount(_ledString.leds().size())
, _sourceAutoSelectEnabled(true)
, _configHash()
, _ledGridSize(getLedLayoutGridSize(qjsonConfig["leds"]))
, _prevCompId(hyperion::COMP_INVALID)
{
registerPriority("Off", PriorityMuxer::LOWEST_PRIORITY);
@@ -718,6 +719,12 @@ void Hyperion::update()
if ( priority < PriorityMuxer::LOWEST_PRIORITY)
{
if (priorityInfo.componentId != _prevCompId)
{
bool backlightEnabled = (priorityInfo.componentId != hyperion::COMP_COLOR && priorityInfo.componentId != hyperion::COMP_EFFECT);
_raw2ledAdjustment->setBacklightEnabled(backlightEnabled);
_prevCompId = priorityInfo.componentId;
}
_raw2ledAdjustment->applyAdjustment(_ledBuffer);
}

View File

@@ -51,11 +51,11 @@ bool MultiColorAdjustment::verifyAdjustments() const
Error(_log, "No adjustment set for %d", iLed);
return false;
}
if (adjustment->_rgbTransform.getBrightness() <= adjustment->_rgbTransform.getBrightnessMin() )
if (adjustment->_rgbTransform.getBrightness() <= adjustment->_rgbTransform.getBacklightThreshold() )
{
adjustment->_rgbTransform.setBrightnessMin(0);
adjustment->_rgbTransform.setBacklightThreshold(0.0);
adjustment->_rgbTransform.setBrightness(0.5);
Warning(_log, "Adjustment for %d has invalid Brightness values, values set to default. (brightnessMin is bigger then brightness)", iLed);
Warning(_log, "Adjustment for %d has invalid Brightness values, values set to default. (setBacklightThreshold is bigger then brightness)", iLed);
}
}
return true;
@@ -81,6 +81,15 @@ ColorAdjustment* MultiColorAdjustment::getAdjustment(const std::string& id)
return nullptr;
}
void MultiColorAdjustment::setBacklightEnabled(bool enable)
{
for (ColorAdjustment* adjustment : _adjustment)
{
adjustment->_rgbTransform.setBackLightEnabled(enable);
}
}
void MultiColorAdjustment::applyAdjustment(std::vector<ColorRgb>& ledColors)
{
const size_t itCnt = std::min(_ledAdjustments.size(), ledColors.size());

View File

@@ -30,6 +30,8 @@ public:
bool verifyAdjustments() const;
void setBacklightEnabled(bool enable);
///
/// Returns the identifier of all the unique ColorAdjustment
///

View File

@@ -271,10 +271,10 @@
"maxItems" : 3,
"propertyOrder" : 10
},
"brightnessMin" :
"backlightThreshold" :
{
"type" : "number",
"title" : "edt_conf_color_brightnessMin_title",
"title" : "edt_conf_color_backlightThreshold_title",
"required" : true,
"minimum" : 0.0,
"maximum": 1.0,
@@ -282,6 +282,14 @@
"step" : 0.05,
"propertyOrder" : 11
},
"backlightColored" :
{
"type" : "boolean",
"title" : "edt_conf_color_backlightColored_title",
"required" : true,
"default" : false,
"propertyOrder" : 12
},
"brightness" :
{
"type" : "number",
@@ -291,7 +299,7 @@
"maximum": 1.0,
"default" : 1.0,
"step" : 0.05,
"propertyOrder" : 12
"propertyOrder" : 13
},
"gammaRed" :
{
@@ -302,7 +310,7 @@
"maximum": 100.0,
"default" : 1.0,
"step" : 0.1,
"propertyOrder" : 13
"propertyOrder" : 14
},
"gammaGreen" :
{
@@ -313,7 +321,7 @@
"maximum": 100.0,
"default" : 1.0,
"step" : 0.1,
"propertyOrder" : 14
"propertyOrder" : 15
},
"gammaBlue" :
{
@@ -324,7 +332,7 @@
"maximum": 100.0,
"default" : 1.0,
"step" : 0.1,
"propertyOrder" : 15
"propertyOrder" : 16
}
},
"additionalProperties" : false