2014-01-04 11:35:11 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
// Hyperion-Leddevice includes
|
|
|
|
#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:
|
|
|
|
///
|
2016-08-23 20:07:12 +02:00
|
|
|
/// Constructs specific LedDevice
|
2014-01-04 11:35:11 +01:00
|
|
|
///
|
2016-08-23 20:07:12 +02:00
|
|
|
/// @param deviceConfig json device config
|
|
|
|
///
|
2016-10-13 21:59:58 +02:00
|
|
|
LedDevicePiBlaster(const QJsonObject &deviceConfig);
|
2014-01-04 11:35:11 +01:00
|
|
|
|
|
|
|
virtual ~LedDevicePiBlaster();
|
|
|
|
|
2016-08-23 20:07:12 +02:00
|
|
|
///
|
|
|
|
/// Sets configuration
|
|
|
|
///
|
|
|
|
/// @param deviceConfig the json device config
|
|
|
|
/// @return true if success
|
2016-10-13 21:59:58 +02:00
|
|
|
bool init(const QJsonObject &deviceConfig);
|
2016-08-23 20:07:12 +02:00
|
|
|
|
|
|
|
/// constructs leddevice
|
2016-10-13 21:59:58 +02:00
|
|
|
static LedDevice* construct(const QJsonObject &deviceConfig);
|
2016-08-23 20:07:12 +02: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.
|
|
|
|
///
|
|
|
|
/// @return Zero on succes else negative
|
|
|
|
///
|
2016-08-08 00:17:00 +02:00
|
|
|
int open();
|
2014-01-04 11:35:11 +01:00
|
|
|
|
2016-09-23 08:49:22 +02:00
|
|
|
private:
|
2014-01-04 11:35:11 +01:00
|
|
|
///
|
|
|
|
/// Writes the colors to the PiBlaster device
|
|
|
|
///
|
|
|
|
/// @param ledValues The color value for each led
|
|
|
|
///
|
|
|
|
/// @return Zero on success else negative
|
|
|
|
///
|
|
|
|
int write(const std::vector<ColorRgb> &ledValues);
|
|
|
|
|
|
|
|
/// 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
|
|
|
};
|