mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
multi fix commit (#112)
* multi fix commit - refactoring leddevicefactory - adalight: default for "delayAfterConnect" is 1s now - needed for most arduino's because of there special behaviour on open - fadecandy: new option for disabling configuration send - if you want to keep your fadecandy defaults - Hyperion.cpp: simplify createSmoothing discussed in #105 - smoothing: -- add option for continuous output -- when updatedelay>0 and continousOutput is disabled, buffer is flushed correctly after no input is detected * add doxygen to travis
This commit is contained in:
@@ -3,26 +3,24 @@
|
||||
|
||||
#include "LinearColorSmoothing.h"
|
||||
|
||||
LinearColorSmoothing::LinearColorSmoothing(
|
||||
LedDevice * ledDevice,
|
||||
double ledUpdateFrequency_hz,
|
||||
int settlingTime_ms,
|
||||
unsigned updateDelay) :
|
||||
QObject(),
|
||||
LedDevice(),
|
||||
_ledDevice(ledDevice),
|
||||
_updateInterval(1000 / ledUpdateFrequency_hz),
|
||||
_settlingTime(settlingTime_ms),
|
||||
_timer(),
|
||||
_outputDelay(updateDelay),
|
||||
_writeToLedsEnable(true)
|
||||
LinearColorSmoothing::LinearColorSmoothing( LedDevice * ledDevice, double ledUpdateFrequency_hz, int settlingTime_ms, unsigned updateDelay, bool continuousOutput)
|
||||
: QObject()
|
||||
, LedDevice()
|
||||
, _ledDevice(ledDevice)
|
||||
, _updateInterval(1000 / ledUpdateFrequency_hz)
|
||||
, _settlingTime(settlingTime_ms)
|
||||
, _timer()
|
||||
, _outputDelay(updateDelay)
|
||||
, _writeToLedsEnable(true)
|
||||
, _continuousOutput(continuousOutput)
|
||||
{
|
||||
_timer.setSingleShot(false);
|
||||
_timer.setInterval(_updateInterval);
|
||||
|
||||
connect(&_timer, SIGNAL(timeout()), this, SLOT(updateLeds()));
|
||||
|
||||
Info(Logger::getInstance("Smoothing"), "Created linear-smoothing with interval_ms: %d, settlingTime_ms: %d, updateDelay: %d",
|
||||
Info(Logger::getInstance("Smoothing"),
|
||||
"Created linear-smoothing with interval: %d ms, settlingTime: %d ms, updateDelay: %d frames",
|
||||
_updateInterval, settlingTime_ms, _outputDelay );
|
||||
}
|
||||
|
||||
@@ -84,7 +82,7 @@ void LinearColorSmoothing::updateLeds()
|
||||
_previousTime = now;
|
||||
|
||||
queueColors(_previousValues);
|
||||
_writeToLedsEnable = false;
|
||||
_writeToLedsEnable = _continuousOutput;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -116,14 +114,18 @@ void LinearColorSmoothing::queueColors(const std::vector<ColorRgb> & ledColors)
|
||||
}
|
||||
else
|
||||
{
|
||||
// Push the new colors in the delay-buffer
|
||||
_outputQueue.push_back(ledColors);
|
||||
// Push new colors in the delay-buffer
|
||||
if ( _writeToLedsEnable )
|
||||
_outputQueue.push_back(ledColors);
|
||||
|
||||
// If the delay-buffer is filled pop the front and write to device
|
||||
if (_outputQueue.size() > _outputDelay)
|
||||
if (_outputQueue.size() > 0 )
|
||||
{
|
||||
if ( _writeToLedsEnable )
|
||||
if ( _outputQueue.size() > _outputDelay || !_writeToLedsEnable )
|
||||
{
|
||||
_ledDevice->write(_outputQueue.front());
|
||||
_outputQueue.pop_front();
|
||||
_outputQueue.pop_front();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user