mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
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:
@@ -105,7 +105,7 @@ namespace hyperion
|
||||
///
|
||||
/// @brief Handle component state changes, it's not possible for BB to be enabled, when a hardDisable is active
|
||||
///
|
||||
void componentStateChanged(const hyperion::Components component, bool enable);
|
||||
void handleCompStateChangeRequest(const hyperion::Components component, bool enable);
|
||||
|
||||
private:
|
||||
/// Hyperion instance
|
||||
|
@@ -54,7 +54,7 @@ public slots:
|
||||
///
|
||||
void stop();
|
||||
|
||||
void componentStateChanged(const hyperion::Components component, bool enable);
|
||||
void compStateChangeRequest(const hyperion::Components component, bool enable);
|
||||
|
||||
///
|
||||
/// @brief Handle settings update from Hyperion Settingsmanager emit or this constructor
|
||||
|
@@ -90,7 +90,7 @@ public slots:
|
||||
|
||||
void stop();
|
||||
|
||||
void componentStateChanged(const hyperion::Components component, bool enable);
|
||||
void compStateChangeRequest(const hyperion::Components component, bool enable);
|
||||
|
||||
signals:
|
||||
void newFrame(const Image<ColorRgb> & image);
|
||||
|
@@ -27,7 +27,7 @@ public slots:
|
||||
void setDeviceVideoStandard(QString device, VideoStandard videoStandard);
|
||||
|
||||
signals:
|
||||
void componentStateChanged(const hyperion::Components component, bool enable);
|
||||
void compStateChangeRequest(const hyperion::Components component, bool enable);
|
||||
|
||||
private slots:
|
||||
void newFrame(const Image<ColorRgb> & image);
|
||||
|
@@ -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
|
||||
{
|
||||
|
@@ -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
|
||||
|
@@ -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;
|
||||
};
|
||||
|
@@ -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;
|
||||
|
@@ -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
|
||||
|
@@ -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:
|
||||
///
|
||||
|
@@ -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
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -19,7 +19,7 @@ class QNetworkConfigurationManager;
|
||||
class SSDPHandler : public SSDPServer{
|
||||
Q_OBJECT
|
||||
public:
|
||||
SSDPHandler(WebServer* webserver, const quint16& flatBufPort, const quint16& jsonServerPort, QObject * parent = nullptr);
|
||||
SSDPHandler(WebServer* webserver, const quint16& flatBufPort, const quint16& jsonServerPort, const QString &name, QObject * parent = nullptr);
|
||||
~SSDPHandler();
|
||||
|
||||
public slots:
|
||||
|
@@ -93,6 +93,17 @@ public:
|
||||
///
|
||||
quint16 getJsonServerPort() { return _jssPort.toInt(); };
|
||||
|
||||
///
|
||||
/// @brief set new hyperion name
|
||||
///
|
||||
void setHyperionName(const QString &name) { _name = name; };
|
||||
|
||||
///
|
||||
/// @brief get hyperion name
|
||||
///
|
||||
QString getHyperionName() { return _name; };
|
||||
|
||||
|
||||
signals:
|
||||
///
|
||||
/// @brief Emits whenever a new SSDP search "man : ssdp:discover" is received along with the service type
|
||||
@@ -111,6 +122,7 @@ private:
|
||||
QString _uuid;
|
||||
QString _fbsPort;
|
||||
QString _jssPort;
|
||||
QString _name;
|
||||
QString _descAddress;
|
||||
bool _running;
|
||||
|
||||
|
@@ -58,14 +58,10 @@ signals:
|
||||
|
||||
///
|
||||
/// @brief PIPE the clear command for the global priority channel over HyperionDaemon to Hyperion class
|
||||
/// @param[in] priority The priority channel
|
||||
/// @param[in] priority The priority channel (-1 to clear all possible priorities)
|
||||
/// @param[in] forceclearAll Force the clear
|
||||
///
|
||||
void clearGlobalInput(int priority);
|
||||
|
||||
///
|
||||
/// @brief PIPE the clearAll command over HyperionDaemon to Hyperion class
|
||||
///
|
||||
void clearAllGlobalInput(bool forceClearAll=false);
|
||||
void clearGlobalInput(int priority, bool forceClearAll=false);
|
||||
|
||||
///
|
||||
/// @brief PIPE external images over HyperionDaemon to Hyperion class
|
||||
@@ -84,7 +80,7 @@ signals:
|
||||
/// @param[in] origin The setter
|
||||
/// @param clearEffect Should be true when NOT called from an effect
|
||||
///
|
||||
void setGlobalColor(const int priority, const ColorRgb &ledColor, const int timeout_ms, const QString& origin = "External" ,bool clearEffects = true);
|
||||
void setGlobalColor(const int priority, const std::vector<ColorRgb> &ledColor, const int timeout_ms, const QString& origin = "External" ,bool clearEffects = true);
|
||||
|
||||
///////////////////////////////////////
|
||||
//////////// FROM HYPERION ////////////
|
||||
|
@@ -34,13 +34,15 @@ namespace hyperion {
|
||||
}
|
||||
if ( fgTypeConfig.contains("color") )
|
||||
{
|
||||
ColorRgb fg_color = {
|
||||
(uint8_t)FGCONFIG_ARRAY.at(0).toInt(0),
|
||||
(uint8_t)FGCONFIG_ARRAY.at(1).toInt(0),
|
||||
(uint8_t)FGCONFIG_ARRAY.at(2).toInt(0)
|
||||
std::vector<ColorRgb> fg_color = {
|
||||
ColorRgb {
|
||||
(uint8_t)FGCONFIG_ARRAY.at(0).toInt(0),
|
||||
(uint8_t)FGCONFIG_ARRAY.at(1).toInt(0),
|
||||
(uint8_t)FGCONFIG_ARRAY.at(2).toInt(0)
|
||||
}
|
||||
};
|
||||
hyperion->setColor(FG_PRIORITY, fg_color, fg_duration_ms);
|
||||
Info(Logger::getInstance("HYPERION"),"Initial foreground color set (%d %d %d)",fg_color.red,fg_color.green,fg_color.blue);
|
||||
Info(Logger::getInstance("HYPERION"),"Initial foreground color set (%d %d %d)",fg_color.at(0).red,fg_color.at(0).green,fg_color.at(0).blue);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -195,15 +197,13 @@ namespace hyperion {
|
||||
|
||||
for (signed i = 0; i < ledConfigArray.size(); ++i)
|
||||
{
|
||||
const QJsonObject& index = ledConfigArray[i].toObject();
|
||||
const QJsonObject& ledConfig = ledConfigArray[i].toObject();
|
||||
Led led;
|
||||
|
||||
const QJsonObject& hscanConfig = ledConfigArray[i].toObject()["h"].toObject();
|
||||
const QJsonObject& vscanConfig = ledConfigArray[i].toObject()["v"].toObject();
|
||||
led.minX_frac = qMax(0.0, qMin(1.0, hscanConfig["min"].toDouble()));
|
||||
led.maxX_frac = qMax(0.0, qMin(1.0, hscanConfig["max"].toDouble()));
|
||||
led.minY_frac = qMax(0.0, qMin(1.0, vscanConfig["min"].toDouble()));
|
||||
led.maxY_frac = qMax(0.0, qMin(1.0, vscanConfig["max"].toDouble()));
|
||||
led.minX_frac = qMax(0.0, qMin(1.0, ledConfig["hmin"].toDouble()));
|
||||
led.maxX_frac = qMax(0.0, qMin(1.0, ledConfig["hmax"].toDouble()));
|
||||
led.minY_frac = qMax(0.0, qMin(1.0, ledConfig["vmin"].toDouble()));
|
||||
led.maxY_frac = qMax(0.0, qMin(1.0, ledConfig["vmax"].toDouble()));
|
||||
// Fix if the user swapped min and max
|
||||
if (led.minX_frac > led.maxX_frac)
|
||||
{
|
||||
@@ -215,7 +215,7 @@ namespace hyperion {
|
||||
}
|
||||
|
||||
// Get the order of the rgb channels for this led (default is device order)
|
||||
led.colorOrder = stringToColorOrder(index["colorOrder"].toString(deviceOrderStr));
|
||||
led.colorOrder = stringToColorOrder(ledConfig["colorOrder"].toString(deviceOrderStr));
|
||||
ledString.leds().push_back(led);
|
||||
}
|
||||
return ledString;
|
||||
@@ -228,12 +228,12 @@ namespace hyperion {
|
||||
|
||||
for (signed i = 0; i < ledConfigArray.size(); ++i)
|
||||
{
|
||||
const QJsonObject& hscanConfig = ledConfigArray[i].toObject()["h"].toObject();
|
||||
const QJsonObject& vscanConfig = ledConfigArray[i].toObject()["v"].toObject();
|
||||
double minX_frac = qMax(0.0, qMin(1.0, hscanConfig["min"].toDouble()));
|
||||
double maxX_frac = qMax(0.0, qMin(1.0, hscanConfig["max"].toDouble()));
|
||||
double minY_frac = qMax(0.0, qMin(1.0, vscanConfig["min"].toDouble()));
|
||||
double maxY_frac = qMax(0.0, qMin(1.0, vscanConfig["max"].toDouble()));
|
||||
const QJsonObject& ledConfig = ledConfigArray[i].toObject();
|
||||
|
||||
double minX_frac = qMax(0.0, qMin(1.0, ledConfig["hmin"].toDouble()));
|
||||
double maxX_frac = qMax(0.0, qMin(1.0, ledConfig["hmax"].toDouble()));
|
||||
double minY_frac = qMax(0.0, qMin(1.0, ledConfig["vmin"].toDouble()));
|
||||
double maxY_frac = qMax(0.0, qMin(1.0, ledConfig["vmax"].toDouble()));
|
||||
// Fix if the user swapped min and max
|
||||
if (minX_frac > maxX_frac)
|
||||
{
|
||||
|
Reference in New Issue
Block a user