mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
Limit maximum LEDs number for WLED and UDP-Raw (#1334)
* Have maximum 490 LEDs configured for WLED and UDP-Raw * Add additional Warning
This commit is contained in:
parent
8134917c51
commit
2a10ef955d
@ -57,6 +57,7 @@
|
|||||||
"conf_leds_device_intro": "Hyperion supports a lot of controllers to transmit data to your target device. Select a LED controller out of the sorted list and configure it. We have chosen the best default settings for each device.",
|
"conf_leds_device_intro": "Hyperion supports a lot of controllers to transmit data to your target device. Select a LED controller out of the sorted list and configure it. We have chosen the best default settings for each device.",
|
||||||
"conf_leds_error_hwled_gt_layout": "The hardware LED count ($1) is greater than LEDs configured via layout ($2),<br>$3 {{plural:$3|LED|LEDs}} will stay black if you continue.",
|
"conf_leds_error_hwled_gt_layout": "The hardware LED count ($1) is greater than LEDs configured via layout ($2),<br>$3 {{plural:$3|LED|LEDs}} will stay black if you continue.",
|
||||||
"conf_leds_error_hwled_lt_layout": "The hardware LED count ($1) is less than LEDs configured via layout ($2). <br> The number of LEDs configured in the layout must not exceed the available LEDs",
|
"conf_leds_error_hwled_lt_layout": "The hardware LED count ($1) is less than LEDs configured via layout ($2). <br> The number of LEDs configured in the layout must not exceed the available LEDs",
|
||||||
|
"conf_leds_error_hwled_gt_maxled": "The hardware LED count ($1) is greater than the maximum number of LEDs supported by the device ($2). <br> The hardware LED count is set to ($3).",
|
||||||
"conf_leds_info_ws281x": "Hyperion must run with 'root' privileges for this controller type!",
|
"conf_leds_info_ws281x": "Hyperion must run with 'root' privileges for this controller type!",
|
||||||
"conf_leds_layout_advanced": "Advanced Settings",
|
"conf_leds_layout_advanced": "Advanced Settings",
|
||||||
"conf_leds_layout_blacklist_num_title": "Number of LEDs",
|
"conf_leds_layout_blacklist_num_title": "Number of LEDs",
|
||||||
|
@ -943,6 +943,11 @@ $(document).ready(function () {
|
|||||||
params = { host: host, filter: "info" };
|
params = { host: host, filter: "info" };
|
||||||
getProperties_device(ledType, host, params);
|
getProperties_device(ledType, host, params);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "udpraw":
|
||||||
|
getProperties_device(ledType, host, params);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1579,11 +1584,11 @@ async function identify_device(type, params) {
|
|||||||
|
|
||||||
function updateElements(ledType, key) {
|
function updateElements(ledType, key) {
|
||||||
if (devicesProperties[ledType][key]) {
|
if (devicesProperties[ledType][key]) {
|
||||||
|
var hardwareLedCount = 1;
|
||||||
switch (ledType) {
|
switch (ledType) {
|
||||||
case "cololight":
|
case "cololight":
|
||||||
var ledProperties = devicesProperties[ledType][key];
|
var ledProperties = devicesProperties[ledType][key];
|
||||||
|
|
||||||
var hardwareLedCount = 1;
|
|
||||||
if (ledProperties) {
|
if (ledProperties) {
|
||||||
hardwareLedCount = ledProperties.ledCount;
|
hardwareLedCount = ledProperties.ledCount;
|
||||||
}
|
}
|
||||||
@ -1592,8 +1597,14 @@ function updateElements(ledType, key) {
|
|||||||
case "wled":
|
case "wled":
|
||||||
var ledProperties = devicesProperties[ledType][key];
|
var ledProperties = devicesProperties[ledType][key];
|
||||||
|
|
||||||
if (ledProperties && ledProperties.leds) {
|
if (ledProperties && ledProperties.leds && ledProperties.maxLedCount) {
|
||||||
hardwareLedCount = ledProperties.leds.count;
|
hardwareLedCount = ledProperties.leds.count;
|
||||||
|
var maxLedCount = ledProperties.maxLedCount
|
||||||
|
if (hardwareLedCount > maxLedCount)
|
||||||
|
{
|
||||||
|
showInfoDialog('warning', $.i18n("conf_leds_config_warning"), $.i18n('conf_leds_error_hwled_gt_maxled', hardwareLedCount, maxLedCount, maxLedCount));
|
||||||
|
hardwareLedCount = maxLedCount;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
conf_editor.getEditor("root.generalOptions.hardwareLedCount").setValue(hardwareLedCount);
|
conf_editor.getEditor("root.generalOptions.hardwareLedCount").setValue(hardwareLedCount);
|
||||||
break;
|
break;
|
||||||
@ -1615,6 +1626,21 @@ function updateElements(ledType, key) {
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "udpraw":
|
||||||
|
var ledProperties = devicesProperties[ledType][key];
|
||||||
|
|
||||||
|
if (ledProperties && ledProperties.maxLedCount) {
|
||||||
|
hardwareLedCount = conf_editor.getEditor("root.generalOptions.hardwareLedCount").getValue();
|
||||||
|
var maxLedCount = ledProperties.maxLedCount
|
||||||
|
if (hardwareLedCount > maxLedCount)
|
||||||
|
{
|
||||||
|
showInfoDialog('warning', $.i18n("conf_leds_config_warning"), $.i18n('conf_leds_error_hwled_gt_maxled', hardwareLedCount, maxLedCount, maxLedCount));
|
||||||
|
hardwareLedCount = maxLedCount;
|
||||||
|
}
|
||||||
|
updateJsonEditorRange(conf_editor, "root.generalOptions", "hardwareLedCount", 1, maxLedCount, hardwareLedCount);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case "atmo":
|
case "atmo":
|
||||||
case "karate":
|
case "karate":
|
||||||
var ledProperties = devicesProperties[ledType][key];
|
var ledProperties = devicesProperties[ledType][key];
|
||||||
|
@ -1,6 +1,14 @@
|
|||||||
#include "LedDeviceUdpRaw.h"
|
#include "LedDeviceUdpRaw.h"
|
||||||
|
|
||||||
|
// Constants
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
const bool verbose = false;
|
||||||
|
|
||||||
const ushort RAW_DEFAULT_PORT=5568;
|
const ushort RAW_DEFAULT_PORT=5568;
|
||||||
|
const int UDP_MAX_LED_NUM = 490;
|
||||||
|
|
||||||
|
} //End of constants
|
||||||
|
|
||||||
LedDeviceUdpRaw::LedDeviceUdpRaw(const QJsonObject &deviceConfig)
|
LedDeviceUdpRaw::LedDeviceUdpRaw(const QJsonObject &deviceConfig)
|
||||||
: ProviderUdp(deviceConfig)
|
: ProviderUdp(deviceConfig)
|
||||||
@ -16,8 +24,28 @@ bool LedDeviceUdpRaw::init(const QJsonObject &deviceConfig)
|
|||||||
{
|
{
|
||||||
_port = RAW_DEFAULT_PORT;
|
_port = RAW_DEFAULT_PORT;
|
||||||
|
|
||||||
|
bool isInitOK = false;
|
||||||
|
if ( LedDevice::init(deviceConfig) )
|
||||||
|
{
|
||||||
|
// Initialise LedDevice configuration and execution environment
|
||||||
|
int configuredLedCount = this->getLedCount();
|
||||||
|
Debug(_log, "DeviceType : %s", QSTRING_CSTR( this->getActiveDeviceType() ));
|
||||||
|
Debug(_log, "LedCount : %d", configuredLedCount);
|
||||||
|
Debug(_log, "ColorOrder : %s", QSTRING_CSTR( this->getColorOrder() ));
|
||||||
|
Debug(_log, "LatchTime : %d", this->getLatchTime());
|
||||||
|
|
||||||
|
if (configuredLedCount > UDP_MAX_LED_NUM)
|
||||||
|
{
|
||||||
|
QString errorReason = QString("Device type %1 can only be run with maximum %2 LEDs!").arg(this->getActiveDeviceType()).arg(UDP_MAX_LED_NUM);
|
||||||
|
this->setInError ( errorReason );
|
||||||
|
isInitOK = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
// Initialise sub-class
|
// Initialise sub-class
|
||||||
bool isInitOK = ProviderUdp::init(deviceConfig);
|
isInitOK = ProviderUdp::init(deviceConfig);
|
||||||
|
}
|
||||||
|
}
|
||||||
return isInitOK;
|
return isInitOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -27,3 +55,18 @@ int LedDeviceUdpRaw::write(const std::vector<ColorRgb> &ledValues)
|
|||||||
|
|
||||||
return writeBytes(_ledRGBCount, dataPtr);
|
return writeBytes(_ledRGBCount, dataPtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QJsonObject LedDeviceUdpRaw::getProperties(const QJsonObject& params)
|
||||||
|
{
|
||||||
|
DebugIf(verbose, _log, "params: [%s]", QString(QJsonDocument(params).toJson(QJsonDocument::Compact)).toUtf8().constData() );
|
||||||
|
QJsonObject properties;
|
||||||
|
|
||||||
|
QJsonObject propertiesDetails;
|
||||||
|
propertiesDetails.insert("maxLedCount", UDP_MAX_LED_NUM);
|
||||||
|
|
||||||
|
properties.insert("properties", propertiesDetails);
|
||||||
|
|
||||||
|
DebugIf(verbose, _log, "properties: [%s]", QString(QJsonDocument(properties).toJson(QJsonDocument::Compact)).toUtf8().constData() );
|
||||||
|
|
||||||
|
return properties;
|
||||||
|
}
|
||||||
|
@ -26,6 +26,14 @@ public:
|
|||||||
///
|
///
|
||||||
static LedDevice* construct(const QJsonObject &deviceConfig);
|
static LedDevice* construct(const QJsonObject &deviceConfig);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// @brief Get a UDP-Raw device's resource properties
|
||||||
|
///
|
||||||
|
/// @param[in] params Parameters to query device
|
||||||
|
/// @return A JSON structure holding the device's properties
|
||||||
|
///
|
||||||
|
QJsonObject getProperties(const QJsonObject& params) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
///
|
///
|
||||||
|
@ -21,6 +21,7 @@ const char CONFIG_SYNC_OVERWRITE[] = "overwriteSync";
|
|||||||
|
|
||||||
// UDP elements
|
// UDP elements
|
||||||
const quint16 STREAM_DEFAULT_PORT = 19446;
|
const quint16 STREAM_DEFAULT_PORT = 19446;
|
||||||
|
const int UDP_MAX_LED_NUM = 490;
|
||||||
|
|
||||||
// WLED JSON-API elements
|
// WLED JSON-API elements
|
||||||
const int API_DEFAULT_PORT = -1; //Use default port per communication scheme
|
const int API_DEFAULT_PORT = -1; //Use default port per communication scheme
|
||||||
@ -81,6 +82,13 @@ bool LedDeviceWled::init(const QJsonObject &deviceConfig)
|
|||||||
Debug(_log, "ColorOrder : %s", QSTRING_CSTR( this->getColorOrder() ));
|
Debug(_log, "ColorOrder : %s", QSTRING_CSTR( this->getColorOrder() ));
|
||||||
Debug(_log, "LatchTime : %d", this->getLatchTime());
|
Debug(_log, "LatchTime : %d", this->getLatchTime());
|
||||||
|
|
||||||
|
if (configuredLedCount > UDP_MAX_LED_NUM)
|
||||||
|
{
|
||||||
|
QString errorReason = QString("Device type %1 can only be run with maximum %2 LEDs!").arg(this->getActiveDeviceType()).arg(UDP_MAX_LED_NUM);
|
||||||
|
this->setInError ( errorReason );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
_isRestoreOrigState = _devConfig[CONFIG_RESTORE_STATE].toBool(DEFAULT_IS_RESTORE_STATE);
|
_isRestoreOrigState = _devConfig[CONFIG_RESTORE_STATE].toBool(DEFAULT_IS_RESTORE_STATE);
|
||||||
_isSyncOverwrite = _devConfig[CONFIG_SYNC_OVERWRITE].toBool(DEFAULT_IS_SYNC_OVERWRITE);
|
_isSyncOverwrite = _devConfig[CONFIG_SYNC_OVERWRITE].toBool(DEFAULT_IS_SYNC_OVERWRITE);
|
||||||
_isBrightnessOverwrite = _devConfig[CONFIG_BRIGHTNESS_OVERWRITE].toBool(DEFAULT_IS_BRIGHTNESS_OVERWRITE);
|
_isBrightnessOverwrite = _devConfig[CONFIG_BRIGHTNESS_OVERWRITE].toBool(DEFAULT_IS_BRIGHTNESS_OVERWRITE);
|
||||||
@ -348,7 +356,10 @@ QJsonObject LedDeviceWled::getProperties(const QJsonObject& params)
|
|||||||
Warning (_log, "%s get properties failed with error: '%s'", QSTRING_CSTR(_activeDeviceType), QSTRING_CSTR(response.getErrorReason()));
|
Warning (_log, "%s get properties failed with error: '%s'", QSTRING_CSTR(_activeDeviceType), QSTRING_CSTR(response.getErrorReason()));
|
||||||
}
|
}
|
||||||
|
|
||||||
properties.insert("properties", response.getBody().object());
|
QJsonObject propertiesDetails = response.getBody().object();
|
||||||
|
propertiesDetails.insert("maxLedCount", UDP_MAX_LED_NUM);
|
||||||
|
|
||||||
|
properties.insert("properties", propertiesDetails);
|
||||||
|
|
||||||
DebugIf(verbose, _log, "properties: [%s]", QString(QJsonDocument(properties).toJson(QJsonDocument::Compact)).toUtf8().constData() );
|
DebugIf(verbose, _log, "properties: [%s]", QString(QJsonDocument(properties).toJson(QJsonDocument::Compact)).toUtf8().constData() );
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user