2020-07-12 20:27:56 +02:00
|
|
|
#ifndef LEDEVICESK6822SPI_H
|
|
|
|
#define LEDEVICESK6822SPI_H
|
2017-02-14 09:33:28 +01:00
|
|
|
|
2020-02-10 15:21:58 +01:00
|
|
|
// hyperion includes
|
2017-02-14 09:33:28 +01:00
|
|
|
#include "ProviderSpi.h"
|
|
|
|
|
|
|
|
///
|
2020-07-12 20:27:56 +02:00
|
|
|
/// Implementation of the LedDevice interface for writing to Sk6822 LED-device via SPI.
|
2017-02-14 09:33:28 +01:00
|
|
|
///
|
|
|
|
class LedDeviceSk6822SPI : public ProviderSpi
|
|
|
|
{
|
|
|
|
public:
|
2020-07-12 20:27:56 +02:00
|
|
|
|
2017-02-14 09:33:28 +01:00
|
|
|
///
|
2020-07-12 20:27:56 +02:00
|
|
|
/// @brief Constructs a Sk6822 LED-device
|
2017-02-14 09:33:28 +01:00
|
|
|
///
|
2020-07-12 20:27:56 +02:00
|
|
|
/// @param deviceConfig Device's configuration as JSON-Object
|
2017-02-14 09:33:28 +01:00
|
|
|
///
|
2020-02-10 15:21:58 +01:00
|
|
|
explicit LedDeviceSk6822SPI(const QJsonObject &deviceConfig);
|
2017-02-14 09:33:28 +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
|
2017-02-14 09:33:28 +01:00
|
|
|
static LedDevice* construct(const QJsonObject &deviceConfig);
|
|
|
|
|
2020-07-12 20:27:56 +02:00
|
|
|
private:
|
|
|
|
|
|
|
|
///
|
|
|
|
/// @brief Initialise the device's configuration
|
2017-02-14 09:33:28 +01:00
|
|
|
///
|
2020-07-12 20:27:56 +02:00
|
|
|
/// @param[in] deviceConfig the JSON device configuration
|
|
|
|
/// @return True, if success
|
2017-02-14 09:33:28 +01:00
|
|
|
///
|
2020-02-10 15:21:58 +01:00
|
|
|
virtual bool init(const QJsonObject &deviceConfig) override;
|
2017-02-14 09:33:28 +01:00
|
|
|
|
|
|
|
///
|
2020-07-12 20:27:56 +02:00
|
|
|
/// @brief Writes the RGB-Color values to the LEDs.
|
2017-02-14 09:33:28 +01:00
|
|
|
///
|
2020-07-12 20:27:56 +02:00
|
|
|
/// @param[in] ledValues The RGB-color per LED
|
|
|
|
/// @return Zero on success, else negative
|
2017-02-14 09:33:28 +01:00
|
|
|
///
|
2020-07-12 20:27:56 +02:00
|
|
|
virtual int write(const std::vector<ColorRgb> & ledValues) override;
|
2017-02-14 09:33:28 +01:00
|
|
|
|
|
|
|
const int SPI_BYTES_PER_COLOUR;
|
|
|
|
const int SPI_BYTES_WAIT_TIME;
|
|
|
|
const int SPI_FRAME_END_LATCH_BYTES;
|
|
|
|
|
|
|
|
uint8_t bitpair_to_byte[4];
|
|
|
|
};
|
2020-07-12 20:27:56 +02:00
|
|
|
|
|
|
|
#endif // LEDEVICESK6822SPI_H
|