2020-07-12 20:27:56 +02:00
|
|
|
#ifndef LEDEVICEMULTILIGHTPACK_H
|
|
|
|
#define LEDEVICEMULTILIGHTPACK_H
|
2013-11-17 15:51:42 +01:00
|
|
|
|
|
|
|
// stl includes
|
|
|
|
#include <vector>
|
|
|
|
#include <cstdint>
|
2017-03-04 22:17:42 +01:00
|
|
|
#include <QStringList>
|
|
|
|
#include <QString>
|
2013-11-17 15:51:42 +01:00
|
|
|
|
|
|
|
// libusb include
|
|
|
|
#include <libusb.h>
|
|
|
|
|
|
|
|
// Hyperion includes
|
2013-12-17 19:50:15 +01:00
|
|
|
#include <leddevice/LedDevice.h>
|
2013-11-17 15:51:42 +01:00
|
|
|
#include "LedDeviceLightpack.h"
|
|
|
|
|
|
|
|
///
|
|
|
|
/// LedDevice implementation for multiple lightpack devices
|
|
|
|
///
|
|
|
|
class LedDeviceMultiLightpack : public LedDevice
|
|
|
|
{
|
|
|
|
public:
|
2020-07-12 20:27:56 +02:00
|
|
|
|
|
|
|
///
|
|
|
|
/// @brief Constructs a LedDevice of multiple Lightpack LED-devices
|
2013-11-17 15:51:42 +01:00
|
|
|
///
|
2020-07-12 20:27:56 +02:00
|
|
|
/// @param deviceConfig Device's configuration as JSON-Object
|
2013-11-17 15:51:42 +01:00
|
|
|
///
|
2020-07-12 20:27:56 +02:00
|
|
|
explicit LedDeviceMultiLightpack(const QJsonObject &deviceConfig);
|
2013-11-17 15:51:42 +01:00
|
|
|
|
|
|
|
///
|
2020-07-12 20:27:56 +02:00
|
|
|
/// @brief Destructor of the LedDevice
|
2013-11-17 15:51:42 +01:00
|
|
|
///
|
2020-08-08 23:12:43 +02:00
|
|
|
~LedDeviceMultiLightpack() override;
|
2013-11-17 15:51:42 +01:00
|
|
|
|
2020-07-12 20:27:56 +02:00
|
|
|
///
|
|
|
|
/// @brief Constructs the LED-device
|
|
|
|
///
|
|
|
|
/// @param[in] deviceConfig Device's configuration as JSON-Object
|
|
|
|
/// @return LedDevice constructed
|
|
|
|
///
|
2016-10-13 21:59:58 +02:00
|
|
|
static LedDevice* construct(const QJsonObject &deviceConfig);
|
2016-08-23 20:07:12 +02:00
|
|
|
|
2020-07-12 20:27:56 +02:00
|
|
|
protected:
|
|
|
|
|
|
|
|
///
|
|
|
|
/// @brief Initialise the device's configuration
|
2020-02-10 15:21:58 +01:00
|
|
|
///
|
2020-07-12 20:27:56 +02:00
|
|
|
/// @param[in] deviceConfig the JSON device configuration
|
|
|
|
/// @return True, if success
|
|
|
|
///
|
2020-08-08 23:12:43 +02:00
|
|
|
bool init(const QJsonObject &deviceConfig) override;
|
2020-02-10 15:21:58 +01:00
|
|
|
|
2013-11-17 15:51:42 +01:00
|
|
|
///
|
2020-07-12 20:27:56 +02:00
|
|
|
/// @brief Opens the output device.
|
2013-11-17 15:51:42 +01:00
|
|
|
///
|
2020-07-12 20:27:56 +02:00
|
|
|
/// @return Zero on success (i.e. device is ready), else negative
|
2013-11-17 15:51:42 +01:00
|
|
|
///
|
2020-08-08 23:12:43 +02:00
|
|
|
int open() override;
|
2020-07-12 20:27:56 +02:00
|
|
|
|
|
|
|
///
|
|
|
|
/// @brief Closes the output device.
|
2013-11-17 15:51:42 +01:00
|
|
|
///
|
2020-07-12 20:27:56 +02:00
|
|
|
/// @return Zero on success (i.e. device is closed), else negative
|
2013-11-17 15:51:42 +01:00
|
|
|
///
|
2020-08-08 23:12:43 +02:00
|
|
|
int close() override;
|
2013-11-17 15:51:42 +01:00
|
|
|
|
|
|
|
///
|
2020-07-12 20:27:56 +02:00
|
|
|
/// @brief Power-/turn off the Nanoleaf device.
|
2016-09-23 08:49:22 +02:00
|
|
|
///
|
2020-07-12 20:27:56 +02:00
|
|
|
/// @return True if success
|
|
|
|
///
|
2020-08-08 23:12:43 +02:00
|
|
|
bool powerOff() override;
|
2020-07-12 20:27:56 +02:00
|
|
|
|
2013-11-17 15:51:42 +01:00
|
|
|
///
|
2020-07-12 20:27:56 +02:00
|
|
|
/// @brief Writes the RGB-Color values to the LEDs.
|
2013-11-17 15:51:42 +01:00
|
|
|
///
|
2020-07-12 20:27:56 +02:00
|
|
|
/// @param[in] ledValues The RGB-color per LED
|
|
|
|
/// @return Zero on success, else negative
|
|
|
|
///
|
|
|
|
int write(const std::vector<ColorRgb> & ledValues) override;
|
|
|
|
|
|
|
|
private:
|
2013-11-17 15:51:42 +01:00
|
|
|
|
2017-03-04 22:17:42 +01:00
|
|
|
static QStringList getLightpackSerials();
|
|
|
|
static QString getString(libusb_device * device, int stringDescriptorIndex);
|
2013-11-20 20:54:04 +01:00
|
|
|
|
2013-11-17 15:51:42 +01:00
|
|
|
/// buffer for led data
|
|
|
|
std::vector<LedDeviceLightpack *> _lightpacks;
|
|
|
|
};
|
2020-07-12 20:27:56 +02:00
|
|
|
|
|
|
|
#endif // LEDEVICEMULTILIGHTPACK_H
|