hyperion.ng/libsrc/leddevice/dev_serial/LedDeviceAdalight.h
LordGrey a2db590d2a
Fixes - Smoothing, Color-Calibration (#1532)
* Smoothing Remove ouputrate as duplicate to update frequency

* Serial LDEDDevices -Increase writeBlack to overcome issues on high baud rates

* Serial LED-Devices - Support device feedback, show statistics provided by HyperSerial

* Fix - Update Color Calibration on Remote Control when settings saved

* Serial LED-Devices - Support device feedback, show statistics provided by HyperSerial
2022-11-27 15:47:54 +01:00

85 lines
1.7 KiB
C++

#ifndef LEDEVICETADALIGHT_H
#define LEDEVICETADALIGHT_H
// hyperion includes
#include "ProviderRs232.h"
namespace Adalight
{
typedef enum ProtocolType
{
ADA = 0,
LBAPA,
AWA
} PROTOCOLTYPE;
}
///
/// Implementation of the LedDevice interface for writing to an Adalight LED-device.
///
class LedDeviceAdalight : public ProviderRs232
{
Q_OBJECT
public:
///
/// @brief Constructs an Adalight LED-device
///
/// @param deviceConfig Device's configuration as JSON-Object
///
explicit LedDeviceAdalight(const QJsonObject &deviceConfig);
///
/// @brief Constructs the LED-device
///
/// @param[in] deviceConfig Device's configuration as JSON-Object
/// @return LedDevice constructed
static LedDevice* construct(const QJsonObject &deviceConfig);
private slots:
///
/// @brief Handle feedback provided by the device
/// Allows to show statistics and error for the "Awa" protocol, if configured in the ESP-sketch
///
void readFeedback() override;
private:
///
/// @brief Initialise the device's configuration
///
/// @param[in] deviceConfig the JSON device configuration
/// @return True, if success
///
bool init(const QJsonObject &deviceConfig) override;
///
/// @brief Prepare the protocol's header
///
void prepareHeader();
///
/// @brief Writes the RGB-Color values to the LEDs.
///
/// @param[in] ledValues The RGB-color per LED
/// @return Zero on success, else negative
///
int write(const std::vector<ColorRgb> & ledValues) override;
void whiteChannelExtension(uint8_t*& writer);
qint64 _bufferLength;
Adalight::PROTOCOLTYPE _streamProtocol;
bool _white_channel_calibration;
uint8_t _white_channel_limit;
uint8_t _white_channel_red;
uint8_t _white_channel_green;
uint8_t _white_channel_blue;
};
#endif // LEDEVICETADALIGHT_H