hyperion.ng
LinearColorSmoothing.h
1 #pragma once
2 
3 // STL includes
4 #include <vector>
5 
6 // Qt includes
7 #include <QVector>
8 
9 // hyperion incluse
10 #include <leddevice/LedDevice.h>
11 #include <utils/Components.h>
12 
13 // settings
14 #include <utils/settings.h>
15 
16 class QTimer;
17 class Logger;
18 class Hyperion;
19 
25 {
26  Q_OBJECT
27 
28 public:
33  LinearColorSmoothing(const QJsonDocument& config, Hyperion* hyperion);
34 
36  virtual ~LinearColorSmoothing();
37 
43  virtual int write(const std::vector<ColorRgb> &ledValues);
44 
46  virtual int switchOff();
47 
48  void setEnable(bool enable);
49  void setPause(bool pause);
50  bool pause() { return _pause; } ;
51  bool enabled() { return LedDevice::enabled() && !_pause; };
52 
61  unsigned addConfig(int settlingTime_ms, double ledUpdateFrequency_hz=25.0, unsigned updateDelay=0);
62 
70  bool selectConfig(unsigned cfg, const bool& force = false);
71 
72 public slots:
78  void handleSettingsUpdate(const settings::type& type, const QJsonDocument& config);
79 
80 private slots:
82  void updateLeds();
83 
89  void componentStateChange(const hyperion::Components component, const bool state);
90 
91 private:
97  void queueColors(const std::vector<ColorRgb> & ledColors);
98 
100  Logger* _log;
101 
103  Hyperion* _hyperion;
104 
106  int64_t _updateInterval;
107 
109  int64_t _settlingTime;
110 
112  QTimer * _timer;
113 
115  int64_t _targetTime;
116 
118  std::vector<ColorRgb> _targetValues;
119 
121  int64_t _previousTime;
122 
124  std::vector<ColorRgb> _previousValues;
125 
127  unsigned _outputDelay;
129  std::list<std::vector<ColorRgb> > _outputQueue;
130 
132  bool _writeToLedsEnable;
133 
135  bool _continuousOutput;
136 
138  bool _pause;
139 
140  struct SMOOTHING_CFG
141  {
142  bool pause;
143  int64_t settlingTime;
144  int64_t updateInterval;
145  unsigned outputDelay;
146  };
147 
149  QVector<SMOOTHING_CFG> _cfgList;
150 
151  unsigned _currentConfigId;
152 };
Definition: Logger.h:32
Interface (pure virtual base class) for LedDevices.
Definition: LedDevice.h:32
LinearColorSmoothing(const QJsonDocument &config, Hyperion *hyperion)
Constructor.
Definition: LinearColorSmoothing.cpp:12
The main class of Hyperion.
Definition: Hyperion.h:57
unsigned addConfig(int settlingTime_ms, double ledUpdateFrequency_hz=25.0, unsigned updateDelay=0)
Add a new smoothing cfg which can be used with selectConfig()
Definition: LinearColorSmoothing.cpp:199
Provide utility methods for Hyperion class.
Definition: BlackBorderDetector.h:7
Components
Enumeration of components in Hyperion.
Definition: Components.h:10
Linear Smooting class.
Definition: LinearColorSmoothing.h:24
bool selectConfig(unsigned cfg, const bool &force=false)
select a smoothing cfg given by cfg index from addConfig()
Definition: LinearColorSmoothing.cpp:208
virtual ~LinearColorSmoothing()
Destructor.
Definition: LinearColorSmoothing.cpp:42
void handleSettingsUpdate(const settings::type &type, const QJsonDocument &config)
Handle settings update from Hyperion Settingsmanager emit or this constructor.
Definition: LinearColorSmoothing.cpp:47
virtual int write(const std::vector< ColorRgb > &ledValues)
write updated values as input for the smoothing filter
Definition: LinearColorSmoothing.cpp:64
virtual int switchOff()
Switch the leds off.
Definition: LinearColorSmoothing.cpp:86