mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
enable components at runtime + grabber refactoring (#160)
* implement enable/disable on runtime for: - smoothing - kodi - udplistener - boblight * implement enable/disable for forwarder refactor component * - implement grabber enable/disable at runtime - big grabber refactoring. now with common base class for all grabbers * implement enable/disable at runtime for bb detector * osx fix * try to fix cutted travis output for osx build
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
|
||||
#include "LinearColorSmoothing.h"
|
||||
|
||||
using namespace hyperion;
|
||||
|
||||
LinearColorSmoothing::LinearColorSmoothing( LedDevice * ledDevice, double ledUpdateFrequency_hz, int settlingTime_ms, unsigned updateDelay, bool continuousOutput)
|
||||
: QObject()
|
||||
, LedDevice()
|
||||
@@ -13,15 +15,16 @@ LinearColorSmoothing::LinearColorSmoothing( LedDevice * ledDevice, double ledUpd
|
||||
, _outputDelay(updateDelay)
|
||||
, _writeToLedsEnable(true)
|
||||
, _continuousOutput(continuousOutput)
|
||||
, _bypass(false)
|
||||
{
|
||||
_log = Logger::getInstance("Smoothing");
|
||||
_timer.setSingleShot(false);
|
||||
_timer.setInterval(_updateInterval);
|
||||
|
||||
connect(&_timer, SIGNAL(timeout()), this, SLOT(updateLeds()));
|
||||
|
||||
Info(Logger::getInstance("Smoothing"),
|
||||
"Created linear-smoothing with interval: %d ms, settlingTime: %d ms, updateDelay: %d frames",
|
||||
_updateInterval, settlingTime_ms, _outputDelay );
|
||||
Info( _log, "Created linear-smoothing with interval: %d ms, settlingTime: %d ms, updateDelay: %d frames",
|
||||
_updateInterval, settlingTime_ms, _outputDelay );
|
||||
}
|
||||
|
||||
LinearColorSmoothing::~LinearColorSmoothing()
|
||||
@@ -33,21 +36,28 @@ LinearColorSmoothing::~LinearColorSmoothing()
|
||||
|
||||
int LinearColorSmoothing::write(const std::vector<ColorRgb> &ledValues)
|
||||
{
|
||||
// received a new target color
|
||||
if (_previousValues.empty())
|
||||
if (_bypass)
|
||||
{
|
||||
// not initialized yet
|
||||
_targetTime = QDateTime::currentMSecsSinceEpoch() + _settlingTime;
|
||||
_targetValues = ledValues;
|
||||
|
||||
_previousTime = QDateTime::currentMSecsSinceEpoch();
|
||||
_previousValues = ledValues;
|
||||
_timer.start();
|
||||
_ledDevice->write(ledValues);
|
||||
}
|
||||
else
|
||||
{
|
||||
_targetTime = QDateTime::currentMSecsSinceEpoch() + _settlingTime;
|
||||
memcpy(_targetValues.data(), ledValues.data(), ledValues.size() * sizeof(ColorRgb));
|
||||
// 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));
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -129,3 +139,13 @@ void LinearColorSmoothing::queueColors(const std::vector<ColorRgb> & ledColors)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LinearColorSmoothing::componentStateChanged(const hyperion::Components component, bool enable)
|
||||
{
|
||||
if (component == COMP_SMOOTHING && _bypass == enable)
|
||||
{
|
||||
_bypass = !enable;
|
||||
Info(_log, "change state to %s", (enable ? "enabled" : "disabled") );
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user