hyperion.ng
LedDeviceWrapper.h
1 #pragma once
2 
3 // util
4 #include <utils/Logger.h>
5 #include <utils/ColorRgb.h>
6 #include <utils/Components.h>
7 
8 class LedDevice;
9 class Hyperion;
10 
11 typedef LedDevice* ( *LedDeviceCreateFuncType ) ( const QJsonObject& );
12 typedef std::map<QString,LedDeviceCreateFuncType> LedDeviceRegistry;
13 
17 class LedDeviceWrapper : public QObject
18 {
19  Q_OBJECT
20 public:
27  void createLedDevice(const QJsonObject& config);
28 
33  static const QJsonObject getLedDeviceSchemas();
34 
38  static int addToDeviceMap(QString name, LedDeviceCreateFuncType funcPtr);
39 
44  static const LedDeviceRegistry& getDeviceMap();
45 
50  int getLatchTime();
51 
55  const QString & getActiveDevice();
56 
60  const bool & enabled() { return _enabled; };
61 
65  const QString & getColorOrder();
66 
67 public slots:
73  void handleComponentState(const hyperion::Components component, const bool state);
74 
75 signals:
83  int write(const std::vector<ColorRgb>& ledValues);
84 
85 private slots:
91  void handleInternalEnableState(bool newState);
92 
93 
94 protected:
96  static LedDeviceRegistry _ledDeviceMap;
97 
98 private:
102  void stopDeviceThread();
103 
104 private:
105  // parent Hyperion
106  Hyperion* _hyperion;
107  // Pointer of current led device
108  LedDevice* _ledDevice;
109  // the enable state
110  bool _enabled;
111 };
static LedDeviceRegistry _ledDeviceMap
contains all available led device constrcutors
Definition: LedDeviceWrapper.h:96
const QString & getActiveDevice()
Get the current active ledDevice.
Definition: LedDeviceWrapper.cpp:118
void handleComponentState(const hyperion::Components component, const bool state)
Handle new component state request component The comp from enum.
Definition: LedDeviceWrapper.cpp:128
const bool & enabled()
Return the last enable state.
Definition: LedDeviceWrapper.h:60
Interface (pure virtual base class) for LedDevices.
Definition: LedDevice.h:32
static int addToDeviceMap(QString name, LedDeviceCreateFuncType funcPtr)
add all device constrcutors to the map
Definition: LedDeviceWrapper.cpp:102
The main class of Hyperion.
Definition: Hyperion.h:57
Provide utility methods for Hyperion class.
Definition: BlackBorderDetector.h:7
int write(const std::vector< ColorRgb > &ledValues)
PIPER signal for Hyperion -> LedDevice.
void createLedDevice(const QJsonObject &config)
Contructs a new LedDevice, moves to thread and starts.
Definition: LedDeviceWrapper.cpp:41
static const LedDeviceRegistry & getDeviceMap()
Return all available device contructors.
Definition: LedDeviceWrapper.cpp:108
Creates and destroys LedDevice instances with LedDeviceFactory and moves the device to a thread...
Definition: LedDeviceWrapper.h:17
int getLatchTime()
Get the current latchtime of the ledDevice @ return latchtime in ms.
Definition: LedDeviceWrapper.cpp:113
const QString & getColorOrder()
Get the current colorOrder from device.
Definition: LedDeviceWrapper.cpp:123
Components
Enumeration of components in Hyperion.
Definition: Components.h:10
static const QJsonObject getLedDeviceSchemas()
Get all available device schemas.
Definition: LedDeviceWrapper.cpp:66