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