mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
Improve Led Device on/off and background effect (#1502)
* Queue On-Off calls * Do not switch-off LED-device when Background effect is enabled * Fix LGTM Warnings * Address LGTM findings
This commit is contained in:
parent
e17ce6cd4e
commit
a2266b177f
@ -182,8 +182,9 @@ $(document).ready(function () {
|
|||||||
|
|
||||||
// Disable or enable Delete Effect Button
|
// Disable or enable Delete Effect Button
|
||||||
$('#effectsdellist').off().on('change', function () {
|
$('#effectsdellist').off().on('change', function () {
|
||||||
$(this).val() == null ? $('#btn_edit, #btn_delete').prop('disabled', true) : "";
|
var value = $(this).val();
|
||||||
$(this).val().startsWith("int_") ? $('#btn_delete').prop('disabled', true) : $('#btn_delete').prop('disabled', false);
|
value == null ? $('#btn_edit, #btn_delete').prop('disabled', true) : "";
|
||||||
|
value.startsWith("int_") ? $('#btn_delete').prop('disabled', true) : $('#btn_delete').prop('disabled', false);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Load Effect
|
// Load Effect
|
||||||
|
@ -272,7 +272,7 @@ $(document).ready(function () {
|
|||||||
|
|
||||||
function updateForwarderServiceSections(type) {
|
function updateForwarderServiceSections(type) {
|
||||||
|
|
||||||
var editorPath = "root.forwarder." + type
|
var editorPath = "root.forwarder." + type;
|
||||||
var selectedServices = conf_editor_forw.getEditor(editorPath + "select").getValue();
|
var selectedServices = conf_editor_forw.getEditor(editorPath + "select").getValue();
|
||||||
|
|
||||||
if (jQuery.isEmptyObject(selectedServices) || selectedServices[0] === "NONE") {
|
if (jQuery.isEmptyObject(selectedServices) || selectedServices[0] === "NONE") {
|
||||||
@ -301,7 +301,7 @@ $(document).ready(function () {
|
|||||||
|
|
||||||
function updateForwarderSelectList(type) {
|
function updateForwarderSelectList(type) {
|
||||||
|
|
||||||
var selectionElement = type + "select"
|
var selectionElement = type + "select";
|
||||||
|
|
||||||
var enumVals = [];
|
var enumVals = [];
|
||||||
var enumTitelVals = [];
|
var enumTitelVals = [];
|
||||||
|
@ -226,7 +226,7 @@ function pluralRuleParser(rule, number) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = parseFloat(number, 10);
|
result = parseFloat(number, 10); //lgtm [js/superfluous-trailing-arguments]
|
||||||
debug(' -- passed n ', result);
|
debug(' -- passed n ', result);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -1310,7 +1310,7 @@ function isValidIPv6(value) {
|
|||||||
|
|
||||||
function isValidHostname(value) {
|
function isValidHostname(value) {
|
||||||
if (value.match(
|
if (value.match(
|
||||||
'^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])(\.([a-zA-Z0-9]|[_a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9]))*$'
|
'^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9])(.([a-zA-Z0-9]|[_a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9]))*$' //lgtm [js/redos]
|
||||||
))
|
))
|
||||||
return true;
|
return true;
|
||||||
else
|
else
|
||||||
@ -1319,7 +1319,7 @@ function isValidHostname(value) {
|
|||||||
|
|
||||||
function isValidServicename(value) {
|
function isValidServicename(value) {
|
||||||
if (value.match(
|
if (value.match(
|
||||||
'^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9 \-]{0,61}[a-zA-Z0-9])(\.([a-zA-Z0-9]|[_a-zA-Z0-9][a-zA-Z0-9\-]{0,61}[a-zA-Z0-9]))*$'
|
'^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9 -]{0,61}[a-zA-Z0-9])(.([a-zA-Z0-9]|[_a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9]))*$' //lgtm [js/redos]
|
||||||
))
|
))
|
||||||
return true;
|
return true;
|
||||||
else
|
else
|
||||||
|
@ -466,7 +466,7 @@ function startWizardCC() {
|
|||||||
|
|
||||||
$('#wiz_cc_kodiip').off().on('change', function () {
|
$('#wiz_cc_kodiip').off().on('change', function () {
|
||||||
|
|
||||||
kodiAddress = $(this).val().trim();
|
kodiAddress = encodeURIComponent($(this).val().trim());
|
||||||
|
|
||||||
$('#kodi_status').html('');
|
$('#kodi_status').html('');
|
||||||
if (kodiAddress !== "") {
|
if (kodiAddress !== "") {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#pragma once
|
#ifndef BGEFFECTHANDLER_H
|
||||||
|
#define BGEFFECTHANDLER_H
|
||||||
|
|
||||||
#include <utils/Logger.h>
|
#include <utils/Logger.h>
|
||||||
#include <hyperion/Hyperion.h>
|
#include <hyperion/Hyperion.h>
|
||||||
@ -8,18 +9,20 @@
|
|||||||
|
|
||||||
///
|
///
|
||||||
/// @brief Handle the background Effect settings, reacts on runtime to settings changes
|
/// @brief Handle the background Effect settings, reacts on runtime to settings changes
|
||||||
///
|
///
|
||||||
class BGEffectHandler : public QObject
|
class BGEffectHandler : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BGEffectHandler(Hyperion* hyperion)
|
BGEffectHandler(Hyperion* hyperion)
|
||||||
: QObject(hyperion)
|
: QObject(hyperion)
|
||||||
, _hyperion(hyperion)
|
, _hyperion(hyperion)
|
||||||
, _prioMuxer(_hyperion->getMuxerInstance())
|
, _prioMuxer(_hyperion->getMuxerInstance())
|
||||||
, _isBgEffectConfigured(false)
|
, _isBgEffectEnabled(false)
|
||||||
{
|
{
|
||||||
|
QString subComponent = parent()->property("instance").toString();
|
||||||
|
_log = Logger::getInstance("HYPERION", subComponent);
|
||||||
|
|
||||||
// listen for config changes
|
// listen for config changes
|
||||||
connect(_hyperion, &Hyperion::settingsChanged, this, [=] (settings::type type, const QJsonDocument& config) {
|
connect(_hyperion, &Hyperion::settingsChanged, this, [=] (settings::type type, const QJsonDocument& config) {
|
||||||
@ -34,6 +37,12 @@ public:
|
|||||||
handleSettingsUpdate(settings::BGEFFECT, _hyperion->getSetting(settings::BGEFFECT));
|
handleSettingsUpdate(settings::BGEFFECT, _hyperion->getSetting(settings::BGEFFECT));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// @brief Check, if background effect processing is enabled.
|
||||||
|
/// @return True, background effect processing is enabled.
|
||||||
|
///
|
||||||
|
bool _isEnabled () const { return _isBgEffectEnabled; }
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
///
|
///
|
||||||
/// @brief Handle settings update from Hyperion Settingsmanager emit or this constructor
|
/// @brief Handle settings update from Hyperion Settingsmanager emit or this constructor
|
||||||
@ -44,7 +53,6 @@ private slots:
|
|||||||
{
|
{
|
||||||
if(type == settings::BGEFFECT)
|
if(type == settings::BGEFFECT)
|
||||||
{
|
{
|
||||||
_isBgEffectConfigured = false;
|
|
||||||
_bgEffectConfig = config;
|
_bgEffectConfig = config;
|
||||||
|
|
||||||
const QJsonObject& BGEffectConfig = _bgEffectConfig.object();
|
const QJsonObject& BGEffectConfig = _bgEffectConfig.object();
|
||||||
@ -54,11 +62,11 @@ private slots:
|
|||||||
{
|
{
|
||||||
_hyperion->clear(PriorityMuxer::BG_PRIORITY);
|
_hyperion->clear(PriorityMuxer::BG_PRIORITY);
|
||||||
}
|
}
|
||||||
// initial background effect/color
|
_isBgEffectEnabled = BGEffectConfig["enable"].toBool(true);
|
||||||
if (BGEffectConfig["enable"].toBool(true))
|
|
||||||
{
|
|
||||||
_isBgEffectConfigured = true;
|
|
||||||
|
|
||||||
|
// initial background effect/color
|
||||||
|
if (_isBgEffectEnabled)
|
||||||
|
{
|
||||||
#if defined(ENABLE_EFFECTENGINE)
|
#if defined(ENABLE_EFFECTENGINE)
|
||||||
const QString bgTypeConfig = BGEffectConfig["type"].toString("effect");
|
const QString bgTypeConfig = BGEffectConfig["type"].toString("effect");
|
||||||
const QString bgEffectConfig = BGEffectConfig["effect"].toString("Warm mood blobs");
|
const QString bgEffectConfig = BGEffectConfig["effect"].toString("Warm mood blobs");
|
||||||
@ -69,20 +77,20 @@ private slots:
|
|||||||
if (bgTypeConfig.contains("color"))
|
if (bgTypeConfig.contains("color"))
|
||||||
{
|
{
|
||||||
std::vector<ColorRgb> bg_color = {
|
std::vector<ColorRgb> bg_color = {
|
||||||
ColorRgb {
|
ColorRgb {
|
||||||
static_cast<uint8_t>(BGCONFIG_ARRAY.at(0).toInt(0)),
|
static_cast<uint8_t>(BGCONFIG_ARRAY.at(0).toInt(0)),
|
||||||
static_cast<uint8_t>(BGCONFIG_ARRAY.at(1).toInt(0)),
|
static_cast<uint8_t>(BGCONFIG_ARRAY.at(1).toInt(0)),
|
||||||
static_cast<uint8_t>(BGCONFIG_ARRAY.at(2).toInt(0))
|
static_cast<uint8_t>(BGCONFIG_ARRAY.at(2).toInt(0))
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
_hyperion->setColor(PriorityMuxer::BG_PRIORITY, bg_color);
|
_hyperion->setColor(PriorityMuxer::BG_PRIORITY, bg_color);
|
||||||
Info(Logger::getInstance("HYPERION"),"Initial background color set (%d %d %d)",bg_color.at(0).red, bg_color.at(0).green, bg_color.at(0).blue);
|
Info(_log,"Initial background color set (%d %d %d)",bg_color.at(0).red, bg_color.at(0).green, bg_color.at(0).blue);
|
||||||
}
|
}
|
||||||
#if defined(ENABLE_EFFECTENGINE)
|
#if defined(ENABLE_EFFECTENGINE)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int result = _hyperion->setEffect(bgEffectConfig, PriorityMuxer::BG_PRIORITY, PriorityMuxer::ENDLESS);
|
int result = _hyperion->setEffect(bgEffectConfig, PriorityMuxer::BG_PRIORITY, PriorityMuxer::ENDLESS);
|
||||||
Info(Logger::getInstance("HYPERION"),"Initial background effect '%s' %s", QSTRING_CSTR(bgEffectConfig), ((result == 0) ? "started" : "failed"));
|
Info(_log,"Initial background effect '%s' %s", QSTRING_CSTR(bgEffectConfig), ((result == 0) ? "started" : "failed"));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -98,12 +106,12 @@ private slots:
|
|||||||
{
|
{
|
||||||
if (_prioMuxer->getCurrentPriority() < PriorityMuxer::BG_PRIORITY && _prioMuxer->hasPriority(PriorityMuxer::BG_PRIORITY))
|
if (_prioMuxer->getCurrentPriority() < PriorityMuxer::BG_PRIORITY && _prioMuxer->hasPriority(PriorityMuxer::BG_PRIORITY))
|
||||||
{
|
{
|
||||||
Debug(Logger::getInstance("HYPERION"),"Stop background (color-) effect as it moved out of scope");
|
Debug(_log,"Stop background (color-) effect as it moved out of scope");
|
||||||
_hyperion->clear(PriorityMuxer::BG_PRIORITY);
|
_hyperion->clear(PriorityMuxer::BG_PRIORITY);
|
||||||
}
|
}
|
||||||
else if (_prioMuxer->getCurrentPriority() == PriorityMuxer::LOWEST_PRIORITY && _isBgEffectConfigured)
|
else if (_prioMuxer->getCurrentPriority() == PriorityMuxer::LOWEST_PRIORITY && _isBgEffectEnabled)
|
||||||
{
|
{
|
||||||
Debug(Logger::getInstance("HYPERION"),"Start background (color-) effect as it moved in scope");
|
Debug(_log,"Start background (color-) effect as it moved in scope");
|
||||||
emit handleSettingsUpdate (settings::BGEFFECT, _bgEffectConfig);
|
emit handleSettingsUpdate (settings::BGEFFECT, _bgEffectConfig);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -111,9 +119,13 @@ private slots:
|
|||||||
private:
|
private:
|
||||||
/// Hyperion instance pointer
|
/// Hyperion instance pointer
|
||||||
Hyperion* _hyperion;
|
Hyperion* _hyperion;
|
||||||
|
Logger * _log;
|
||||||
|
|
||||||
/// priority muxer instance
|
/// priority muxer instance
|
||||||
PriorityMuxer* _prioMuxer;
|
PriorityMuxer* _prioMuxer;
|
||||||
|
|
||||||
QJsonDocument _bgEffectConfig;
|
QJsonDocument _bgEffectConfig;
|
||||||
bool _isBgEffectConfigured;
|
bool _isBgEffectEnabled;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif // BGEFFECTHANDLER_H
|
||||||
|
@ -617,13 +617,18 @@ void Hyperion::handleVisibleComponentChanged(hyperion::Components comp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Hyperion::handleSourceAvailability(int priority)
|
void Hyperion::handleSourceAvailability(int priority)
|
||||||
{ int previousPriority = _muxer->getPreviousPriority();
|
{
|
||||||
|
int previousPriority = _muxer->getPreviousPriority();
|
||||||
|
|
||||||
if ( priority == PriorityMuxer::LOWEST_PRIORITY)
|
if ( priority == PriorityMuxer::LOWEST_PRIORITY)
|
||||||
{
|
{
|
||||||
Debug(_log,"No source left -> Pause output processing and switch LED-Device off");
|
// Keep LED-device on, as background effect will kick-in shortly
|
||||||
emit _ledDeviceWrapper->switchOff();
|
if (!_BGEffectHandler->_isEnabled())
|
||||||
emit _deviceSmooth->setPause(true);
|
{
|
||||||
|
Debug(_log,"No source left -> Pause output processing and switch LED-Device off");
|
||||||
|
emit _ledDeviceWrapper->switchOff();
|
||||||
|
emit _deviceSmooth->setPause(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -67,8 +67,8 @@ void LedDeviceWrapper::createLedDevice(const QJsonObject& config)
|
|||||||
// further signals
|
// further signals
|
||||||
connect(this, &LedDeviceWrapper::updateLeds, _ledDevice, &LedDevice::updateLeds, Qt::QueuedConnection);
|
connect(this, &LedDeviceWrapper::updateLeds, _ledDevice, &LedDevice::updateLeds, Qt::QueuedConnection);
|
||||||
|
|
||||||
connect(this, &LedDeviceWrapper::switchOn, _ledDevice, &LedDevice::switchOn);
|
connect(this, &LedDeviceWrapper::switchOn, _ledDevice, &LedDevice::switchOn, Qt::BlockingQueuedConnection);
|
||||||
connect(this, &LedDeviceWrapper::switchOff, _ledDevice, &LedDevice::switchOff);
|
connect(this, &LedDeviceWrapper::switchOff, _ledDevice, &LedDevice::switchOff, Qt::BlockingQueuedConnection);
|
||||||
|
|
||||||
connect(this, &LedDeviceWrapper::stopLedDevice, _ledDevice, &LedDevice::stop, Qt::BlockingQueuedConnection);
|
connect(this, &LedDeviceWrapper::stopLedDevice, _ledDevice, &LedDevice::stop, Qt::BlockingQueuedConnection);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user