2020-07-12 20:27:56 +02:00
|
|
|
#ifndef LEDEVICEPIBLASTER_H
|
|
|
|
#define LEDEVICEPIBLASTER_H
|
2014-01-04 11:35:11 +01:00
|
|
|
|
2020-07-12 20:27:56 +02:00
|
|
|
// LedDevice includes
|
2014-01-04 11:35:11 +01:00
|
|
|
#include <leddevice/LedDevice.h>
|
|
|
|
|
2016-10-08 13:52:22 +02:00
|
|
|
///
|
|
|
|
/// Implementation of the LedDevice interface for writing to pi-blaster based PWM LEDs
|
|
|
|
///
|
2014-01-04 11:35:11 +01:00
|
|
|
class LedDevicePiBlaster : public LedDevice
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
///
|
2020-07-12 20:27:56 +02:00
|
|
|
/// @brief Constructs a pi-Blaster LED-device
|
2014-01-04 11:35:11 +01:00
|
|
|
///
|
2020-07-12 20:27:56 +02:00
|
|
|
/// @param deviceConfig Device's configuration as JSON-Object
|
2016-08-23 20:07:12 +02:00
|
|
|
///
|
2020-02-10 15:21:58 +01:00
|
|
|
explicit LedDevicePiBlaster(const QJsonObject &deviceConfig);
|
2014-01-04 11:35:11 +01:00
|
|
|
|
2020-07-12 20:27:56 +02:00
|
|
|
///
|
|
|
|
/// @brief Destructor of the LedDevice
|
|
|
|
///
|
2020-02-10 15:21:58 +01:00
|
|
|
virtual ~LedDevicePiBlaster() override;
|
2014-01-04 11:35:11 +01:00
|
|
|
|
2016-08-23 20:07:12 +02:00
|
|
|
///
|
2020-07-12 20:27:56 +02:00
|
|
|
/// @brief Constructs the LED-device
|
2016-08-23 20:07:12 +02:00
|
|
|
///
|
2020-07-12 20:27:56 +02:00
|
|
|
/// @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);
|
2020-02-10 15:21:58 +01:00
|
|
|
|
2020-07-12 20:27:56 +02:00
|
|
|
protected:
|
|
|
|
|
2020-02-10 15:21:58 +01:00
|
|
|
///
|
2020-07-12 20:27:56 +02:00
|
|
|
/// @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
|
|
|
|
bool init(const QJsonObject &deviceConfig) override;
|
2020-02-10 15:21:58 +01:00
|
|
|
|
2014-01-07 14:24:56 +01:00
|
|
|
///
|
|
|
|
/// Attempts to open the piblaster-device. This will only succeed if the device is not yet open
|
|
|
|
/// and the device is available.
|
|
|
|
///
|
2020-07-12 20:27:56 +02:00
|
|
|
/// @return Zero on success (i.e. device is ready), else negative
|
2014-01-07 14:24:56 +01:00
|
|
|
///
|
2020-07-12 20:27:56 +02:00
|
|
|
virtual int open() override;
|
2014-01-04 11:35:11 +01:00
|
|
|
|
|
|
|
///
|
2020-07-12 20:27:56 +02:00
|
|
|
/// @brief Closes the output device.
|
|
|
|
///
|
|
|
|
/// @return Zero on success (i.e. device is closed), else negative
|
|
|
|
///
|
|
|
|
virtual int close() override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
2014-01-04 11:35:11 +01:00
|
|
|
///
|
2020-07-12 20:27:56 +02:00
|
|
|
/// @brief Writes the RGB-Color values to the LEDs.
|
2014-01-04 11:35:11 +01:00
|
|
|
///
|
2020-07-12 20:27:56 +02:00
|
|
|
/// @param[in] ledValues The RGB-color per LED
|
|
|
|
/// @return Zero on success, else negative
|
2014-01-04 11:35:11 +01:00
|
|
|
///
|
2020-02-10 15:21:58 +01:00
|
|
|
int write(const std::vector<ColorRgb> &ledValues) override;
|
2014-01-04 11:35:11 +01:00
|
|
|
|
|
|
|
/// The name of the output device (very likely '/dev/pi-blaster')
|
2017-03-04 22:17:42 +01:00
|
|
|
QString _deviceName;
|
2014-01-04 11:35:11 +01:00
|
|
|
|
2016-04-29 16:00:33 +02:00
|
|
|
int _gpio_to_led[64];
|
|
|
|
char _gpio_to_color[64];
|
2014-01-04 11:35:11 +01:00
|
|
|
|
|
|
|
/// File-Pointer to the PiBlaster device
|
|
|
|
FILE * _fid;
|
2016-06-25 14:44:52 +02:00
|
|
|
|
2014-01-04 11:35:11 +01:00
|
|
|
};
|
2020-07-12 20:27:56 +02:00
|
|
|
|
|
|
|
#endif // LEDEVICETEMPLATE_H
|