7 #include <QJsonDocument> 17 #include <utils/ColorRgb.h> 18 #include <utils/ColorRgbw.h> 19 #include <utils/RgbToRgbw.h> 20 #include <utils/Logger.h> 22 #include <utils/Components.h> 26 typedef LedDevice* ( *LedDeviceCreateFuncType ) (
const QJsonObject& );
27 typedef std::map<QString,LedDeviceCreateFuncType> LedDeviceRegistry;
37 LedDevice(
const QJsonObject& config = QJsonObject(), QObject* parent =
nullptr);
46 virtual int setLedValues(
const std::vector<ColorRgb>& ledValues);
54 void setActiveDevice(QString dev);
55 const QString & getActiveDevice() {
return _activeDevice; };
56 void setLedCount(
int ledCount);
57 int getLedCount() {
return _ledCount; }
59 void setEnable(
bool enable);
60 bool enabled() {
return _enabled; };
61 int getLatchTime() {
return _latchTime_ms; };
63 inline bool componentState() {
return enabled(); };
78 virtual int write(
const std::vector<ColorRgb>& ledValues) = 0;
96 virtual bool init(
const QJsonObject &deviceConfig);
106 QJsonObject _devConfig;
116 QString _activeDevice;
125 unsigned int _refresh_timer_interval;
126 qint64 _last_write_time;
127 unsigned int _latchTime_ms;
133 std::vector<ColorRgb> _ledValues;
134 bool _componentRegistered;
Interface (pure virtual base class) for LedDevices.
Definition: LedDevice.h:32
virtual int write(const std::vector< ColorRgb > &ledValues)=0
Writes the RGB-Color values to the leds.
QTimer _refresh_timer
Timer object which makes sure that led data is written at a minimum rate e.g.
Definition: LedDevice.h:124
const QString & getColorOrder()
Get color order of device.
Definition: LedDevice.h:52
std::vector< uint8_t > _ledBuffer
The buffer containing the packed RGB values.
Definition: LedDevice.h:112
virtual void start()
Is called on thread start, all construction tasks and init should run here.
Definition: LedDevice.h:69
Logger * _log
The common Logger instance for all LedDevices.
Definition: LedDevice.h:109
virtual int open()
Opens and configures the output device.
Definition: LedDevice.cpp:39
virtual int switchOn()
Switch the leds on (led hardware enable), used if reinitialization is required for the device impleme...
Definition: LedDevice.cpp:108
void enableStateChanged(bool newState)
Emits whenever the led device switches between on/off.
int rewriteLeds()
Write the last data to the leds again.
Definition: LedDevice.cpp:120
virtual int switchOff()
Switch the leds off (led hardware disable)
Definition: LedDevice.cpp:103
void visiblePriorityChanged(const quint8 &priority)
PIPER signal for Priority Muxer -> LedDevice.