Const correctness, override keyword, a bunch of stuff..

This commit is contained in:
Murat
2020-08-08 23:12:43 +02:00
parent 4099d12d9a
commit 4a688b932a
144 changed files with 622 additions and 566 deletions

View File

@@ -43,14 +43,14 @@ public:
///
/// Destructor of the LedDevice; closes the output device if it is open
///
virtual ~LedDeviceHyperionUsbasp() override;
~LedDeviceHyperionUsbasp() override;
public slots:
///
/// Closes the output device.
/// Includes switching-off the device and stopping refreshes
///
virtual int close() override;
int close() override;
protected:
///
@@ -67,7 +67,7 @@ protected:
///
/// @return Zero on success else negative
///
virtual int write(const std::vector<ColorRgb>& ledValues) override;
int write(const std::vector<ColorRgb>& ledValues) override;
///
/// Test if the device is a Hyperion Usbasp device

View File

@@ -34,7 +34,7 @@ public:
///
/// @brief Destructor of the LedDevice
///
virtual ~LedDeviceLightpack() override;
~LedDeviceLightpack() override;
///
/// @brief Constructs the LED-device
@@ -50,28 +50,28 @@ public:
/// @param[in] deviceConfig the JSON device configuration
/// @return True, if success
///
virtual bool init(const QJsonObject &deviceConfig) override;
bool init(const QJsonObject &deviceConfig) override;
///
/// @brief Opens the output device.
///
/// @return Zero on success (i.e. device is ready), else negative
///
virtual int open() override;
int open() override;
///
/// @brief Closes the output device.
///
/// @return Zero on success (i.e. device is closed), else negative
///
virtual int close() override;
int close() override;
///
/// @brief Power-/turn off the Nanoleaf device.
///
/// @return True if success
///
virtual bool powerOff() override;
bool powerOff() override;
///
/// @brief Writes the RGB-Color values to the LEDs.
@@ -100,7 +100,7 @@ protected:
/// @param[in] ledValues The RGB-color per LED
/// @return Zero on success, else negative
///
virtual int write(const std::vector<ColorRgb> & ledValues) override;
int write(const std::vector<ColorRgb> & ledValues) override;
private:

View File

@@ -31,7 +31,7 @@ public:
///
/// @brief Destructor of the LedDevice
///
virtual ~LedDeviceMultiLightpack() override;
~LedDeviceMultiLightpack() override;
///
/// @brief Constructs the LED-device
@@ -49,28 +49,28 @@ protected:
/// @param[in] deviceConfig the JSON device configuration
/// @return True, if success
///
virtual bool init(const QJsonObject &deviceConfig) override;
bool init(const QJsonObject &deviceConfig) override;
///
/// @brief Opens the output device.
///
/// @return Zero on success (i.e. device is ready), else negative
///
virtual int open() override;
int open() override;
///
/// @brief Closes the output device.
///
/// @return Zero on success (i.e. device is closed), else negative
///
virtual int close() override;
int close() override;
///
/// @brief Power-/turn off the Nanoleaf device.
///
/// @return True if success
///
virtual bool powerOff() override;
bool powerOff() override;
///
/// @brief Writes the RGB-Color values to the LEDs.

View File

@@ -34,7 +34,7 @@ private:
/// @param[in] deviceConfig the JSON device configuration
/// @return True, if success
///
virtual bool init(const QJsonObject &deviceConfig) override;
bool init(const QJsonObject &deviceConfig) override;
///
/// @brief Writes the RGB-Color values to the LEDs.
@@ -42,7 +42,7 @@ private:
/// @param[in] ledValues The RGB-color per LED
/// @return Zero on success, else negative
///
virtual int write(const std::vector<ColorRgb> & ledValues) override;
int write(const std::vector<ColorRgb> & ledValues) override;
};
#endif // LEDEVICEPAINTTPACK_H

View File

@@ -37,7 +37,7 @@ private:
/// @param[in] deviceConfig the JSON device configuration
/// @return True, if success
///
virtual bool init(const QJsonObject &deviceConfig) override;
bool init(const QJsonObject &deviceConfig) override;
///
/// @brief Writes the RGB-Color values to the LEDs.
@@ -45,7 +45,7 @@ private:
/// @param[in] ledValues The RGB-color per LED
/// @return Zero on success, else negative
///
virtual int write(const std::vector<ColorRgb> & ledValues) override;
int write(const std::vector<ColorRgb> & ledValues) override;
};
#endif // LEDEVICERAWHID_H

View File

@@ -156,28 +156,30 @@ int ProviderHID::writeBytes(unsigned size, const uint8_t * data)
else{
ret = hid_write(_deviceHandle, ledData, size + 1);
}
// Handle first error
if(ret < 0){
if(ret < 0)
{
Error(_log,"Failed to write to HID device.");
// Try again
if(_useFeature){
if(_useFeature)
{
ret = hid_send_feature_report(_deviceHandle, ledData, size + 1);
}
else{
else
{
ret = hid_write(_deviceHandle, ledData, size + 1);
}
// Writing failed again, device might have disconnected
if(ret < 0){
Error(_log,"Failed to write to HID device.");
hid_close(_deviceHandle);
_deviceHandle = nullptr;
}
}
return ret;
}

View File

@@ -26,14 +26,14 @@ public:
///
/// @brief Destructor of the LedDevice
///
virtual ~ProviderHID() override;
~ProviderHID() override;
///
/// @brief Discover HIB (USB) devices available (for configuration).
///
/// @return A JSON structure holding a list of devices found
///
virtual QJsonObject discover() override;
QJsonObject discover() override;
protected:
@@ -43,21 +43,21 @@ protected:
/// @param[in] deviceConfig the JSON device configuration
/// @return True, if success
///
virtual bool init(const QJsonObject &deviceConfig) override;
bool init(const QJsonObject &deviceConfig) override;
///
/// @brief Opens the output device.
///
/// @return Zero on success (i.e. device is ready), else negative
///
virtual int open() override;
int open() override;
///
/// @brief Closes the output device.
///
/// @return Zero on success (i.e. device is closed), else negative
///
virtual int close() override;
int close() override;
///
/// @brief Write the given bytes to the HID-device