hyperion.ng
LedDeviceLightpack.h
1 #pragma once
2 
3 // stl includes
4 #include <cstdint>
5 
6 // libusb include
7 #include <libusb.h>
8 
9 // Hyperion includes
10 #include <leddevice/LedDevice.h>
11 
16 {
17 public:
23  LedDeviceLightpack(const QString & serialNumber = "");
29  LedDeviceLightpack(const QJsonObject &deviceConfig);
30 
36  bool init(const QJsonObject &deviceConfig);
37 
39  static LedDevice* construct(const QJsonObject &deviceConfig);
40 
44  virtual ~LedDeviceLightpack();
45 
51  int open();
52 
61  int write(const ColorRgb * ledValues, int size);
62 
68  virtual int switchOff();
69 
71  const QString & getSerialNumber() const;
72 
74  int getLedCount() const;
75 
76 private:
84  virtual int write(const std::vector<ColorRgb>& ledValues);
85 
91  int testAndOpen(libusb_device * device, const QString & requestedSerialNumber);
92 
94  int writeBytes(uint8_t *data, int size);
95 
97  int disableSmoothing();
98 
99  struct Version
100  {
101  int majorVersion;
102  int minorVersion;
103  };
104 
105  static libusb_device_handle * openDevice(libusb_device * device);
106  static QString getString(libusb_device * device, int stringDescriptorIndex);
107 
109  libusb_context * _libusbContext;
110 
112  libusb_device_handle * _deviceHandle;
113 
115  int _busNumber;
116 
118  int _addressNumber;
119 
121  QString _serialNumber;
122 
124  Version _firmwareVersion;
125 
127  int _bitsPerChannel;
128 
130  int _hwLedCount;
131 };
LedDeviceLightpack(const QString &serialNumber="")
Constructs the LedDeviceLightpack.
Definition: LedDeviceLightpack.cpp:35
virtual ~LedDeviceLightpack()
Destructor of the LedDevice; closes the output device if it is open.
Definition: LedDeviceLightpack.cpp:54
LedDevice implementation for a lightpack device (http://code.google.com/p/light-pack/) ...
Definition: LedDeviceLightpack.h:15
Interface (pure virtual base class) for LedDevices.
Definition: LedDevice.h:32
bool init(const QJsonObject &deviceConfig)
Sets configuration.
Definition: LedDeviceLightpack.cpp:72
int write(const ColorRgb *ledValues, int size)
Writes the RGB-Color values to the leds.
Definition: LedDeviceLightpack.cpp:253
const QString & getSerialNumber() const
Get the serial of the Lightpack.
Definition: LedDeviceLightpack.cpp:282
static LedDevice * construct(const QJsonObject &deviceConfig)
constructs leddevice
Definition: LedDeviceLightpack.cpp:80
virtual int switchOff()
Switch the leds off.
Definition: LedDeviceLightpack.cpp:276
int open()
Opens and configures the output device.
Definition: LedDeviceLightpack.cpp:85
int getLedCount() const
Get the number of leds.
Definition: LedDeviceLightpack.cpp:287
Plain-Old-Data structure containing the red-green-blue color specification.
Definition: ColorRgb.h:13