mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
make blackboder component enable/disable at runtime (#228)
* make enable/disable of bborder work * fix typo * smoothing can be disabled via config again * fix smoothing
This commit is contained in:
@@ -15,7 +15,7 @@ LinearColorSmoothing::LinearColorSmoothing( LedDevice * ledDevice, double ledUpd
|
||||
, _outputDelay(updateDelay)
|
||||
, _writeToLedsEnable(true)
|
||||
, _continuousOutput(continuousOutput)
|
||||
, _bypass(false)
|
||||
, _enabled(true)
|
||||
{
|
||||
_log = Logger::getInstance("Smoothing");
|
||||
_timer.setSingleShot(false);
|
||||
@@ -35,28 +35,21 @@ LinearColorSmoothing::~LinearColorSmoothing()
|
||||
|
||||
int LinearColorSmoothing::write(const std::vector<ColorRgb> &ledValues)
|
||||
{
|
||||
if (_bypass)
|
||||
// received a new target color
|
||||
if (_previousValues.empty())
|
||||
{
|
||||
_ledDevice->write(ledValues);
|
||||
// not initialized yet
|
||||
_targetTime = QDateTime::currentMSecsSinceEpoch() + _settlingTime;
|
||||
_targetValues = ledValues;
|
||||
|
||||
_previousTime = QDateTime::currentMSecsSinceEpoch();
|
||||
_previousValues = ledValues;
|
||||
_timer.start();
|
||||
}
|
||||
else
|
||||
{
|
||||
// received a new target color
|
||||
if (_previousValues.empty())
|
||||
{
|
||||
// not initialized yet
|
||||
_targetTime = QDateTime::currentMSecsSinceEpoch() + _settlingTime;
|
||||
_targetValues = ledValues;
|
||||
|
||||
_previousTime = QDateTime::currentMSecsSinceEpoch();
|
||||
_previousValues = ledValues;
|
||||
_timer.start();
|
||||
}
|
||||
else
|
||||
{
|
||||
_targetTime = QDateTime::currentMSecsSinceEpoch() + _settlingTime;
|
||||
memcpy(_targetValues.data(), ledValues.data(), ledValues.size() * sizeof(ColorRgb));
|
||||
}
|
||||
_targetTime = QDateTime::currentMSecsSinceEpoch() + _settlingTime;
|
||||
memcpy(_targetValues.data(), ledValues.data(), ledValues.size() * sizeof(ColorRgb));
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -139,13 +132,13 @@ void LinearColorSmoothing::queueColors(const std::vector<ColorRgb> & ledColors)
|
||||
}
|
||||
}
|
||||
|
||||
void LinearColorSmoothing::componentStateChanged(const hyperion::Components component, bool enable)
|
||||
|
||||
void LinearColorSmoothing::setEnable(bool enable)
|
||||
{
|
||||
if (component == COMP_SMOOTHING)
|
||||
{
|
||||
InfoIf(_bypass == enable, _log, "change state to %s", (enable ? "enabled" : "disabled") );
|
||||
Hyperion::getInstance()->getComponentRegister().componentStateChanged(component, enable);
|
||||
_bypass = !enable;
|
||||
}
|
||||
_enabled = enable;
|
||||
}
|
||||
|
||||
bool LinearColorSmoothing::enabled()
|
||||
{
|
||||
return _enabled;
|
||||
}
|
||||
|
Reference in New Issue
Block a user