Allow to switch on LED device, if currently disabled

This commit is contained in:
LordGrey 2019-07-13 11:23:56 +02:00
parent bea8345e4b
commit 61bffa6dd8

View File

@ -45,12 +45,22 @@ void LedDevice::setEnable(bool enable)
{ {
// emit signal when state changed // emit signal when state changed
if (_enabled != enable) if (_enabled != enable)
{
emit enableStateChanged(enable); emit enableStateChanged(enable);
}
// set black to leds when they should go off // switch off device when disabled, default: set black to leds when they should go off
if ( _enabled && !enable) if ( _enabled && !enable)
{
switchOff(); switchOff();
}
else
{
// switch on device when enabled
if ( !_enabled && enable)
{
switchOn();
}
}
_enabled = enable; _enabled = enable;
} }