hyperion.ng
ProviderSpi.h
1 #pragma once
2 
3 // Linux-SPI includes
4 #include <linux/spi/spidev.h>
5 
6 // Hyperion includes
7 #include <leddevice/LedDevice.h>
8 
12 class ProviderSpi : public LedDevice
13 {
14 public:
18  ProviderSpi();
19 
25  virtual bool init(const QJsonObject &deviceConfig);
26 
30  virtual ~ProviderSpi();
31 
37  int open();
38 
39 protected:
49  int writeBytes(const unsigned size, const uint8_t *data);
50 
52  QString _deviceName;
53 
56 
58  int _fid;
59 
61  int _spiMode;
62 
65 
67  spi_ioc_transfer _spi;
68 };
QString _deviceName
The name of the output device.
Definition: ProviderSpi.h:52
virtual ~ProviderSpi()
Destructor of the LedDevice; closes the output device if it is open.
Definition: ProviderSpi.cpp:29
int _baudRate_Hz
The used baudrate of the output device.
Definition: ProviderSpi.h:55
bool _spiDataInvert
1=>invert the data pattern
Definition: ProviderSpi.h:64
Interface (pure virtual base class) for LedDevices.
Definition: LedDevice.h:32
int _spiMode
which spi clock mode do we use? (0..3)
Definition: ProviderSpi.h:61
int open()
Opens and configures the output device.
Definition: ProviderSpi.cpp:46
ProviderSpi()
Constructs specific LedDevice.
Definition: ProviderSpi.cpp:17
spi_ioc_transfer _spi
The transfer structure for writing to the spi-device.
Definition: ProviderSpi.h:67
int _fid
The File Identifier of the opened output device (or -1 if not opened)
Definition: ProviderSpi.h:58
int writeBytes(const unsigned size, const uint8_t *data)
Writes the given bytes/bits to the SPI-device and sleeps the latch time to ensure that the values are...
Definition: ProviderSpi.cpp:79
The ProviderSpi implements an abstract base-class for LedDevices using the SPI-device.
Definition: ProviderSpi.h:12
virtual bool init(const QJsonObject &deviceConfig)
Sets configuration.
Definition: ProviderSpi.cpp:34