Differentiate between LED-Device Enable/Disable and Switch On/Off (#960)

* Switch Off devices, when no input source

* Realign Enable/SwitchOn, Disable/SwitchOff

* Align to updated LedDevice-Flow

* Remove debug statements slipped in

* Send last color update after enabling again

* Fix WLED getProperties API call

* Remove unused signals

* LedDevice process flow documentation

* LedDevice process flow documentation

Co-authored-by: Paulchen Panther <16664240+Paulchen-Panther@users.noreply.github.com>
This commit is contained in:
LordGrey
2020-09-14 17:19:14 +02:00
committed by GitHub
parent fbd8167458
commit 4aabe175cd
15 changed files with 247 additions and 146 deletions

View File

@@ -87,6 +87,7 @@ void Hyperion::start()
// connect Hyperion::update with Muxer visible priority changes as muxer updates independent
connect(&_muxer, &PriorityMuxer::visiblePriorityChanged, this, &Hyperion::update);
connect(&_muxer, &PriorityMuxer::visiblePriorityChanged, this, &Hyperion::handlPriorityChangedLedDevice);
connect(&_muxer, &PriorityMuxer::visibleComponentChanged, this, &Hyperion::handleVisibleComponentChanged);
// listens for ComponentRegister changes of COMP_ALL to perform core enable/disable actions
@@ -530,6 +531,26 @@ void Hyperion::handleVisibleComponentChanged(hyperion::Components comp)
_raw2ledAdjustment->setBacklightEnabled((comp != hyperion::COMP_COLOR && comp != hyperion::COMP_EFFECT));
}
void Hyperion::handlPriorityChangedLedDevice(const quint8& priority)
{
quint8 previousPriority = _muxer.getPreviousPriority();
Debug(_log,"priority[%u], previousPriority[%u]", priority, previousPriority);
if ( priority == PriorityMuxer::LOWEST_PRIORITY)
{
Debug(_log,"No source left -> switch LED-Device off");
emit _ledDeviceWrapper->switchOff();
}
else
{
if ( previousPriority == PriorityMuxer::LOWEST_PRIORITY )
{
Debug(_log,"new source available -> switch LED-Device on");
emit _ledDeviceWrapper->switchOn();
}
}
}
void Hyperion::update()
{
// Obtain the current priority channel

View File

@@ -18,6 +18,7 @@ PriorityMuxer::PriorityMuxer(int ledCount, QObject * parent)
: QObject(parent)
, _log(Logger::getInstance("HYPERION"))
, _currentPriority(PriorityMuxer::LOWEST_PRIORITY)
, _previousPriority(_currentPriority)
, _manualSelectedPriority(256)
, _activeInputs()
, _lowestPriorityInfo()
@@ -156,7 +157,6 @@ void PriorityMuxer::registerInput(int priority, hyperion::Components component,
if(newInput)
{
Debug(_log,"Register new input '%s/%s' with priority %d as inactive", QSTRING_CSTR(origin), hyperion::componentToIdString(component), priority);
emit priorityChanged(priority, true);
emit prioritiesChanged();
return;
}
@@ -255,7 +255,6 @@ bool PriorityMuxer::clearInput(uint8_t priority)
Debug(_log,"Removed source priority %d",priority);
// on clear success update _currentPriority
setCurrentTime();
emit priorityChanged(priority, false);
emit prioritiesChanged();
return true;
}
@@ -266,6 +265,7 @@ void PriorityMuxer::clearAll(bool forceClearAll)
{
if (forceClearAll)
{
_previousPriority = _currentPriority;
_activeInputs.clear();
_currentPriority = PriorityMuxer::LOWEST_PRIORITY;
_activeInputs[_currentPriority] = _lowestPriorityInfo;
@@ -296,7 +296,6 @@ void PriorityMuxer::setCurrentTime()
quint8 tPrio = infoIt->priority;
infoIt = _activeInputs.erase(infoIt);
Debug(_log,"Timeout clear for priority %d",tPrio);
emit priorityChanged(tPrio, false);
emit prioritiesChanged();
}
else
@@ -329,6 +328,7 @@ void PriorityMuxer::setCurrentTime()
// apply & emit on change (after apply!)
if (_currentPriority != newPriority)
{
_previousPriority = _currentPriority;
_currentPriority = newPriority;
Debug(_log, "Set visible priority to %d", newPriority);
emit visiblePriorityChanged(newPriority);