mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
Fix for Philips Hue flickering when switchOffOnBlack is set true (#668)
* Improved switch off on black feature. * Changed "isnan" to "std::isnan" Former-commit-id: 5db2b97674661e4e19f796a91dd443a501268e27
This commit is contained in:
parent
6f43fe1196
commit
03cee33784
@ -174,26 +174,26 @@ int LedDevicePhilipsHue::write(const std::vector<ColorRgb> & ledValues) {
|
|||||||
CiColor xy = lamp.rgbToCiColor(color.red / 255.0f, color.green / 255.0f, color.blue / 255.0f);
|
CiColor xy = lamp.rgbToCiColor(color.red / 255.0f, color.green / 255.0f, color.blue / 255.0f);
|
||||||
// Write color if color has been changed.
|
// Write color if color has been changed.
|
||||||
if (xy != lamp.color) {
|
if (xy != lamp.color) {
|
||||||
// Switch on if the lamp has been previously switched off.
|
// From a color to black.
|
||||||
if (switchOffOnBlack && lamp.color == lamp.black) {
|
if (switchOffOnBlack && lamp.color != lamp.black && xy == lamp.black) {
|
||||||
put(getStateRoute(lamp.id), QString("{\"on\": true}"));
|
put(getStateRoute(lamp.id), QString("{\"on\": false}"));
|
||||||
}
|
}
|
||||||
|
// From black to a color
|
||||||
|
else if (switchOffOnBlack && lamp.color == lamp.black && xy != lamp.black) {
|
||||||
|
// Send adjust color and brightness command in JSON format.
|
||||||
|
// We have to set the transition time each time.
|
||||||
|
// Send also command to switch the lamp on.
|
||||||
|
put(getStateRoute(lamp.id),
|
||||||
|
QString("{\"on\": true, \"xy\": [%1, %2], \"bri\": %3, \"transitiontime\": %4}").arg(xy.x).arg(
|
||||||
|
xy.y).arg(qRound(xy.bri * 255.0f)).arg(transitiontime));
|
||||||
|
}
|
||||||
|
// Normal color change.
|
||||||
|
else {
|
||||||
// Send adjust color and brightness command in JSON format.
|
// Send adjust color and brightness command in JSON format.
|
||||||
// We have to set the transition time each time.
|
// We have to set the transition time each time.
|
||||||
put(getStateRoute(lamp.id),
|
put(getStateRoute(lamp.id),
|
||||||
QString("{\"xy\": [%1, %2], \"bri\": %3, \"transitiontime\": %4}").arg(xy.x).arg(xy.y).arg(
|
QString("{\"xy\": [%1, %2], \"bri\": %3, \"transitiontime\": %4}").arg(xy.x).arg(xy.y).arg(
|
||||||
qRound(xy.bri * 255.0f)).arg(transitiontime));
|
qRound(xy.bri * 255.0f)).arg(transitiontime));
|
||||||
|
|
||||||
}
|
|
||||||
// Switch lamp off if switchOffOnBlack is enabled and the lamp is currently on.
|
|
||||||
if (switchOffOnBlack) {
|
|
||||||
// From black to a color.
|
|
||||||
if (lamp.color == lamp.black && xy != lamp.black) {
|
|
||||||
put(getStateRoute(lamp.id), QString("{\"on\": true}"));
|
|
||||||
}
|
|
||||||
// From a color to black.
|
|
||||||
else if (lamp.color != lamp.black && xy == lamp.black) {
|
|
||||||
put(getStateRoute(lamp.id), QString("{\"on\": false}"));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Remember last color.
|
// Remember last color.
|
||||||
|
Loading…
Reference in New Issue
Block a user