2020-07-12 20:27:56 +02:00
|
|
|
#ifndef LEDEVICEUDPH801_H
|
|
|
|
#define LEDEVICEUDPH801_H
|
2016-09-21 23:03:01 +02:00
|
|
|
|
|
|
|
// hyperion includes
|
|
|
|
#include "ProviderUdp.h"
|
|
|
|
|
|
|
|
///
|
2020-07-12 20:27:56 +02:00
|
|
|
/// Implementation of the LedDevice interface for sending LED colors to a H801 LED-device via UDP
|
2016-09-21 23:03:01 +02:00
|
|
|
///
|
2020-02-10 15:21:58 +01:00
|
|
|
///
|
2016-09-21 23:32:17 +02:00
|
|
|
class LedDeviceUdpH801: public ProviderUdp
|
2016-09-21 23:03:01 +02:00
|
|
|
{
|
|
|
|
public:
|
2020-07-12 20:27:56 +02:00
|
|
|
|
2016-09-21 23:03:01 +02:00
|
|
|
///
|
2020-07-12 20:27:56 +02:00
|
|
|
/// @brief Constructs a H801 LED-device fed via UDP
|
2016-09-21 23:03:01 +02:00
|
|
|
///
|
2020-07-12 20:27:56 +02:00
|
|
|
/// @param deviceConfig Device's configuration as JSON-Object
|
2016-09-21 23:03:01 +02:00
|
|
|
///
|
2020-02-10 15:21:58 +01:00
|
|
|
explicit LedDeviceUdpH801(const QJsonObject &deviceConfig);
|
2016-09-21 23:03:01 +02:00
|
|
|
|
|
|
|
///
|
2020-07-12 20:27:56 +02:00
|
|
|
/// @brief Constructs the LED-device
|
2016-09-21 23:03:01 +02:00
|
|
|
///
|
2020-07-12 20:27:56 +02:00
|
|
|
/// @param[in] deviceConfig Device's configuration as JSON-Object
|
|
|
|
/// @return LedDevice constructed
|
|
|
|
///
|
|
|
|
static LedDevice* construct(const QJsonObject &deviceConfig);
|
2016-09-21 23:03:01 +02:00
|
|
|
|
2016-09-23 08:49:22 +02:00
|
|
|
private:
|
2020-07-12 20:27:56 +02:00
|
|
|
|
2016-09-21 23:03:01 +02:00
|
|
|
///
|
2020-07-12 20:27:56 +02:00
|
|
|
/// @brief Initialise the device's configuration
|
2016-09-21 23:03:01 +02:00
|
|
|
///
|
2020-07-12 20:27:56 +02:00
|
|
|
/// @param[in] deviceConfig the JSON device configuration
|
|
|
|
/// @return True, if success
|
2016-09-21 23:03:01 +02:00
|
|
|
///
|
2020-08-08 23:12:43 +02:00
|
|
|
bool init(const QJsonObject &deviceConfig) override;
|
2020-07-12 20:27:56 +02:00
|
|
|
|
|
|
|
///
|
|
|
|
/// @brief Writes the RGB-Color values to the LEDs.
|
|
|
|
///
|
|
|
|
/// @param[in] ledValues The RGB-color per LED
|
|
|
|
/// @return Zero on success, else negative
|
|
|
|
///
|
2020-08-08 23:12:43 +02:00
|
|
|
int write(const std::vector<ColorRgb> & ledValues) override;
|
2020-07-12 20:27:56 +02:00
|
|
|
|
|
|
|
QList<int> _ids;
|
|
|
|
QByteArray _message;
|
|
|
|
const int _prefix_size = 2;
|
|
|
|
const int _colors = 5;
|
|
|
|
const int _id_size = 3;
|
|
|
|
const int _suffix_size = 1;
|
|
|
|
|
2016-09-21 23:03:01 +02:00
|
|
|
};
|
2020-07-12 20:27:56 +02:00
|
|
|
|
|
|
|
#endif // LEDEVICEUDPH801_H
|