Differentiate between LED-Device Enable/Disable and Switch On/Off (#960)

* Switch Off devices, when no input source

* Realign Enable/SwitchOn, Disable/SwitchOff

* Align to updated LedDevice-Flow

* Remove debug statements slipped in

* Send last color update after enabling again

* Fix WLED getProperties API call

* Remove unused signals

* LedDevice process flow documentation

* LedDevice process flow documentation

Co-authored-by: Paulchen Panther <16664240+Paulchen-Panther@users.noreply.github.com>
This commit is contained in:
LordGrey
2020-09-14 17:19:14 +02:00
committed by GitHub
parent fbd8167458
commit 4aabe175cd
15 changed files with 247 additions and 146 deletions

View File

@@ -64,13 +64,6 @@ public:
///
void setLedCount(unsigned int ledCount);
///
/// @brief Check, if the device is enabled.
///
/// @return True, if enabled
///
bool isEnabled() const { return _isEnabled; }
///
/// @brief Set a device's latch time.
///
@@ -81,6 +74,15 @@ public:
///
void setLatchTime(int latchTime_ms);
///
/// @brief Set a device's rewrite time.
///
/// Rewrite time is the time frame a devices requires to be refreshed, if no updated happened in the meantime.
///
/// @param[in] rewriteTime_ms Rewrite time in milliseconds
///
void setRewriteTime(int rewriteTime_ms);
///
/// @brief Discover devices of this type available (for configuration).
/// @note Mainly used for network devices. Allows to find devices, e.g. via ssdp, mDNS or cloud ways.
@@ -172,15 +174,6 @@ public slots:
///
virtual int updateLeds(const std::vector<ColorRgb>& ledValues);
///
/// @brief Enables/disables the device for output.
///
/// If the device is not ready, it will not be enabled.
///
/// @param[in] enable The new state of the device
///
void setEnable(bool enable);
///
/// @brief Get the currently defined LatchTime.
///
@@ -188,6 +181,13 @@ public slots:
///
int getLatchTime() const { return _latchTime_ms; }
///
/// @brief Get the currently defined RewriteTime.
///
/// @return Rewrite time in milliseconds
///
int getRewriteTime() const { return _refreshTimerInterval_ms; }
///
/// @brief Get the number of LEDs supported by the device.
///
@@ -212,7 +212,46 @@ public slots:
///
/// @return True, if enabled
///
inline bool componentState() const { return isEnabled(); }
inline bool componentState() const { return _isEnabled; }
///
/// @brief Enables the device for output.
///
/// If the device is not ready, it will not be enabled.
///
void enable();
///
/// @brief Disables the device for output.
///
void disable();
///
/// @brief Switch the LEDs on.
///
/// Takes care that the device is opened and powered-on.
/// Depending on the configuration, the device may store its current state for later restore.
/// @see powerOn, storeState
///
/// @return True, if success
///
virtual bool switchOn();
///
/// @brief Switch the LEDs off.
///
/// Takes care that the LEDs and device are switched-off and device is closed.
/// Depending on the configuration, the device may be powered-off or restored to its previous state.
/// @see powerOff, restoreState
///
/// @return True, if success
///
virtual bool switchOff();
bool switchOnOff(bool onState)
{
return onState == true ? switchOn() : switchOff();
}
signals:
///
@@ -264,28 +303,6 @@ protected:
///
virtual int writeBlack(int numberOfBlack=1);
///
/// @brief Switch the LEDs on.
///
/// Takes care that the device is opened and powered-on.
/// Depending on the configuration, the device may store its current state for later restore.
/// @see powerOn, storeState
///
/// @return True, if success
///
virtual bool switchOn();
///
/// @brief Switch the LEDs off.
///
/// Takes care that the LEDs and device are switched-off and device is closed.
/// Depending on the configuration, the device may be powered-off or restored to its previous state.
/// @see powerOff, restoreState
///
/// @return True, if success
///
virtual bool switchOff();
///
/// @brief Power-/turn on the LED-device.
///
@@ -378,6 +395,9 @@ protected:
/// Is the device ready for processing?
bool _isDeviceReady;
/// Is the device switched on?
bool _isOn;
/// Is the device in error state and stopped?
bool _isDeviceInError;

View File

@@ -90,8 +90,27 @@ signals:
///
int updateLeds(const std::vector<ColorRgb>& ledValues);
void setEnable(bool enable);
void closeLedDevice();
///
/// @brief Enables the LED-Device.
///
void enable();
///
/// @brief Disables the LED-Device.
///
void disable();
///
/// @brief Switch the LEDs on.
///
void switchOn();
///
/// @brief Switch the LEDs off.
///
void switchOff();
void stopLedDevice();
private slots:
///