2013-10-27 18:04:37 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
// STL includes
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
// Qt includes
|
|
|
|
#include <QTimer>
|
|
|
|
|
|
|
|
// hyperion incluse
|
2013-12-17 19:50:15 +01:00
|
|
|
#include <leddevice/LedDevice.h>
|
2016-08-11 07:13:55 +02:00
|
|
|
#include <utils/Components.h>
|
2013-10-27 18:04:37 +01:00
|
|
|
|
|
|
|
/// Linear Smooting class
|
|
|
|
///
|
|
|
|
/// This class processes the requested led values and forwards them to the device after applying
|
|
|
|
/// a linear smoothing effect. This class can be handled as a generic LedDevice.
|
|
|
|
class LinearColorSmoothing : public QObject, public LedDevice
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
/// Constructor
|
|
|
|
/// @param LedDevice the led device
|
|
|
|
/// @param LedUpdatFrequency The frequency at which the leds will be updated (Hz)
|
|
|
|
/// @param settingTime The time after which the updated led values have been fully applied (sec)
|
2014-09-22 21:28:38 +02:00
|
|
|
/// @param updateDelay The number of frames to delay outgoing led updates
|
2016-07-13 11:18:12 +02:00
|
|
|
LinearColorSmoothing(LedDevice *ledDevice, double ledUpdateFrequency, int settlingTime, unsigned updateDelay, bool continuousOutput);
|
2013-10-27 18:04:37 +01:00
|
|
|
|
|
|
|
/// Destructor
|
|
|
|
virtual ~LinearColorSmoothing();
|
|
|
|
|
|
|
|
/// write updated values as input for the smoothing filter
|
|
|
|
///
|
|
|
|
/// @param ledValues The color-value per led
|
|
|
|
/// @return Zero on succes else negative
|
|
|
|
///
|
2013-11-11 10:00:37 +01:00
|
|
|
virtual int write(const std::vector<ColorRgb> &ledValues);
|
2013-10-27 18:04:37 +01:00
|
|
|
|
|
|
|
/// Switch the leds off
|
|
|
|
virtual int switchOff();
|
|
|
|
|
2016-08-11 07:13:55 +02:00
|
|
|
bool componentState() { return _bypass; }
|
|
|
|
|
2013-10-27 18:04:37 +01:00
|
|
|
private slots:
|
|
|
|
/// Timer callback which writes updated led values to the led device
|
|
|
|
void updateLeds();
|
|
|
|
|
2016-08-11 07:13:55 +02:00
|
|
|
void componentStateChanged(const hyperion::Components component, bool enable);
|
|
|
|
|
2013-10-27 18:04:37 +01:00
|
|
|
private:
|
2014-09-22 21:28:38 +02:00
|
|
|
/**
|
|
|
|
* Pushes the colors into the output queue and popping the head to the led-device
|
|
|
|
*
|
|
|
|
* @param ledColors The colors to queue
|
|
|
|
*/
|
|
|
|
void queueColors(const std::vector<ColorRgb> & ledColors);
|
|
|
|
|
2013-10-27 18:04:37 +01:00
|
|
|
/// The led device
|
|
|
|
LedDevice * _ledDevice;
|
|
|
|
|
|
|
|
/// The interval at which to update the leds (msec)
|
|
|
|
const int64_t _updateInterval;
|
|
|
|
|
|
|
|
/// The time after which the updated led values have been fully applied (msec)
|
|
|
|
const int64_t _settlingTime;
|
|
|
|
|
|
|
|
/// The Qt timer object
|
|
|
|
QTimer _timer;
|
|
|
|
|
|
|
|
/// The timestamp at which the target data should be fully applied
|
|
|
|
int64_t _targetTime;
|
|
|
|
|
|
|
|
/// The target led data
|
2013-11-11 10:00:37 +01:00
|
|
|
std::vector<ColorRgb> _targetValues;
|
2013-10-27 18:04:37 +01:00
|
|
|
|
|
|
|
/// The timestamp of the previously written led data
|
|
|
|
int64_t _previousTime;
|
|
|
|
|
|
|
|
/// The previously written led data
|
2013-11-11 10:00:37 +01:00
|
|
|
std::vector<ColorRgb> _previousValues;
|
2014-09-22 21:28:38 +02:00
|
|
|
|
2016-07-13 11:18:12 +02:00
|
|
|
/// The number of updates to keep in the output queue (delayed) before being output
|
2014-09-22 21:28:38 +02:00
|
|
|
const unsigned _outputDelay;
|
2016-07-13 11:18:12 +02:00
|
|
|
/// The output queue
|
2014-09-22 21:28:38 +02:00
|
|
|
std::list<std::vector<ColorRgb> > _outputQueue;
|
|
|
|
|
2016-07-13 11:18:12 +02:00
|
|
|
/// Prevent sending data to device when no intput data is sent
|
2016-05-26 07:01:10 +02:00
|
|
|
bool _writeToLedsEnable;
|
2016-07-13 11:18:12 +02:00
|
|
|
|
|
|
|
/// Flag for dis/enable continuous output to led device regardless there is new data or not
|
|
|
|
bool _continuousOutput;
|
2016-08-11 07:13:55 +02:00
|
|
|
|
|
|
|
bool _bypass;
|
2013-10-27 18:04:37 +01:00
|
|
|
};
|