mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Implement ftdi led device - 2 (#1746)
This commit is contained in:
76
libsrc/leddevice/dev_ftdi/ProviderFtdi.h
Normal file
76
libsrc/leddevice/dev_ftdi/ProviderFtdi.h
Normal file
@@ -0,0 +1,76 @@
|
||||
#ifndef PROVIDERFtdi_H
|
||||
#define PROVIDERFtdi_H
|
||||
|
||||
// LedDevice includes
|
||||
#include <leddevice/LedDevice.h>
|
||||
|
||||
#include <ftdi.h>
|
||||
|
||||
///
|
||||
/// The ProviderFtdi implements an abstract base-class for LedDevices using a Ftdi-device.
|
||||
///
|
||||
class ProviderFtdi : public LedDevice
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
///
|
||||
/// @brief Constructs a Ftdi LED-device
|
||||
///
|
||||
ProviderFtdi(const QJsonObject& deviceConfig);
|
||||
|
||||
static const QString AUTO_SETTING;
|
||||
|
||||
protected:
|
||||
///
|
||||
/// @brief Opens the output device.
|
||||
///
|
||||
/// @return Zero on success (i.e. device is ready), else negative
|
||||
///
|
||||
int open() override;
|
||||
|
||||
///
|
||||
/// Sets configuration
|
||||
///
|
||||
/// @param deviceConfig the json device config
|
||||
/// @return true if success
|
||||
bool init(const QJsonObject& deviceConfig) override;
|
||||
|
||||
///
|
||||
/// @brief Closes the UDP device.
|
||||
///
|
||||
/// @return Zero on success (i.e. device is closed), else negative
|
||||
///
|
||||
int close() override;
|
||||
|
||||
|
||||
/// @brief Write the given bytes to the Ftdi-device
|
||||
///
|
||||
/// @param[in[ size The length of the data
|
||||
/// @param[in] data The data
|
||||
/// @return Zero on success, else negative
|
||||
///
|
||||
int writeBytes(const qint64 size, const uint8_t* data);
|
||||
|
||||
|
||||
QJsonObject discover(const QJsonObject& params) override;
|
||||
|
||||
/// The Ftdi serial-device
|
||||
struct ftdi_context *_ftdic;
|
||||
|
||||
/// The used baud-rate of the output device
|
||||
qint32 _baudRate_Hz;
|
||||
QString _deviceName;
|
||||
|
||||
protected slots:
|
||||
|
||||
///
|
||||
/// @brief Set device in error state
|
||||
///
|
||||
/// @param errorMsg The error message to be logged
|
||||
///
|
||||
void setInError(const QString& errorMsg, bool isRecoverable=true) override;
|
||||
};
|
||||
|
||||
#endif // PROVIDERFtdi_H
|
Reference in New Issue
Block a user