refactor: Led layout, clearAll (#703)

* add SSDP name field

* YALL - yet another led layout

* led layout migration

* add initial vscode config

* merge clearAll with clear, rename Hyperion::compStateChange

* simpler components api

* Corrected code formatting

+ triggered PR build

* fix: regression from #636

* Support for color patterns

Co-authored-by: Paulchen Panther <16664240+Paulchen-Panther@users.noreply.github.com>
This commit is contained in:
brindosch
2020-02-26 18:54:56 +01:00
committed by GitHub
parent ef51d28463
commit 8db85c9a5a
47 changed files with 656 additions and 738 deletions

View File

@@ -46,13 +46,15 @@ private slots:
const QJsonValue bgColorConfig = BGEffectConfig["color"];
if (bgTypeConfig.contains("color"))
{
ColorRgb bg_color = {
(uint8_t)BGCONFIG_ARRAY.at(0).toInt(0),
(uint8_t)BGCONFIG_ARRAY.at(1).toInt(0),
(uint8_t)BGCONFIG_ARRAY.at(2).toInt(0)
std::vector<ColorRgb> bg_color = {
ColorRgb {
(uint8_t)BGCONFIG_ARRAY.at(0).toInt(0),
(uint8_t)BGCONFIG_ARRAY.at(1).toInt(0),
(uint8_t)BGCONFIG_ARRAY.at(2).toInt(0)
}
};
_hyperion->setColor(254, bg_color);
Info(Logger::getInstance("HYPERION"),"Inital background color set (%d %d %d)",bg_color.red,bg_color.green,bg_color.blue);
Info(Logger::getInstance("HYPERION"),"Inital background color set (%d %d %d)",bg_color.at(0).red, bg_color.at(0).green, bg_color.at(0).blue);
}
else
{

View File

@@ -28,7 +28,7 @@ private slots:
/// @param component The component from enum
/// @param enable The new state
///
void componentStateChanged(const hyperion::Components component, bool enable);
void handleCompStateChangeRequest(const hyperion::Components component, bool enable);
///
/// @brief Handle settings update from Hyperion Settingsmanager emit or this constructor

View File

@@ -22,14 +22,6 @@ public:
ComponentRegister(Hyperion* hyperion);
~ComponentRegister();
///
/// @brief Enable or disable Hyperion (all components)
/// @param state The new state of Hyperion
///
/// @return Returns true on success, false when Hyperion is already at the requested state
///
bool setHyperionEnable(const bool& state);
///
/// @brief Check if a component is currently enabled
/// @param comp The component from enum
@@ -50,11 +42,17 @@ signals:
public slots:
///
/// @brief is called whenever a component change a state, DO NOT CALL FROM API (use hyperion->setComponentState() instead)
/// @brief is called whenever a component change a state, DO NOT CALL FROM API, use signal hyperion->compStateChangeRequest
/// @param comp The component
/// @param state The new state of the component
///
void componentStateChanged(const hyperion::Components comp, const bool activated);
void setNewComponentState(const hyperion::Components comp, const bool activated);
private slots:
///
/// @brief Handle COMP_ALL changes from Hyperion->compStateChangeRequest
///
void handleCompStateChangeRequest(const hyperion::Components comp, const bool activated);
private:
/// Hyperion instance
@@ -65,4 +63,6 @@ private:
std::map<hyperion::Components, bool> _componentStates;
/// on hyperion off we save the previous states of all components
std::map<hyperion::Components, bool> _prevComponentStates;
// helper to prevent self emit chains
bool _inProgress = false;
};

View File

@@ -101,7 +101,7 @@ signals:
///
/// @brief PIPE component state changes from HyperionDaemon to V4L2Grabber
///
void componentStateChanged(const hyperion::Components component, bool enable);
void compStateChangeRequest(const hyperion::Components component, bool enable);
protected:
ImageResampler _imageResampler;

View File

@@ -206,12 +206,17 @@ public:
void setNewComponentState(const hyperion::Components& component, const bool& state);
///
/// @brief Enable/Disable components during runtime, called from external API (requests)
/// @brief Get a list of all contrable components and their current state
/// @return list of components
///
/// @param component The component from enum
/// @param state The state of the component [true | false]
std::map<hyperion::Components, bool> getAllComponents();
///
void setComponentState(const hyperion::Components component, const bool state);
/// @brief Test if a component is enabled
/// @param The component to test
/// @return Component state
///
int isComponentEnabled(const hyperion::Components& comp);
ComponentRegister& getComponentRegister() { return _componentRegister; };
@@ -278,12 +283,12 @@ public slots:
/// Should be never used to update leds continuous
///
/// @param[in] priority The priority of the written color
/// @param[in] ledColor The color to write to the leds
/// @param[in] ledColors The color to write to the leds
/// @param[in] timeout_ms The time the leds are set to the given color [ms]
/// @param[in] origin The setter
/// @param clearEffect Should be true when NOT called from an effect
///
void setColor(const int priority, const ColorRgb &ledColor, const int timeout_ms = -1, const QString& origin = "System" ,bool clearEffects = true);
void setColor(const int priority, const std::vector<ColorRgb> &ledColors, const int timeout_ms = -1, const QString& origin = "System" ,bool clearEffects = true);
///
/// @brief Set the given priority to inactive
@@ -311,15 +316,11 @@ public slots:
/// Clears the given priority channel. This will switch the led-colors to the colors of the next
/// lower priority channel (or off if no more channels are set)
///
/// @param[in] priority The priority channel
/// @param[in] priority The priority channel. -1 clears all priorities
/// @param[in] forceClearAll Force the clear
/// @return True on success else false (not found)
///
bool clear(const int priority);
///
/// @brief Clears all priority channels. This will switch the leds off until a new priority is written.
///
void clearall(bool forceClearAll=false);
bool clear(const int priority, bool forceClearAll=false);
/// Run the specified effect on the given priority channel and optionally specify a timeout
/// @param effectName Name of the effec to run
@@ -375,7 +376,7 @@ signals:
/// @param component The component from enum
/// @param enabled The new state of the component
///
void componentStateChanged(const hyperion::Components component, bool enabled);
void compStateChangeRequest(const hyperion::Components component, bool enabled);
///
/// @brief Emits whenever the imageToLedsMapping has changed

View File

@@ -130,7 +130,7 @@ signals:
///
/// @brief PIPE component state changes from Hyperion to HyperionDaemon
///
void componentStateChanged(const hyperion::Components component, bool enable);
void compStateChangeRequest(const hyperion::Components component, bool enable);
private slots:
///

View File

@@ -52,7 +52,7 @@ private slots:
/// @param component The component from enum
/// @param enable The new state
///
void componentStateChanged(const hyperion::Components component, bool enable);
void handleCompStateChangeRequest(const hyperion::Components component, bool enable);
///
/// @brief Handle priority updates from Priority Muxer

View File

@@ -53,6 +53,14 @@ signals:
void settingsChanged(const settings::type& type, const QJsonDocument& data);
private:
///
/// @brief Add possile migrations steps for config here
/// @param config The configuration object
/// @return True when a migration has been triggered
///
bool handleConfigUpgrade(QJsonObject& config);
/// Hyperion instance
Hyperion* _hyperion;