diff --git a/assets/webconfig/js/light_source.js b/assets/webconfig/js/light_source.js
index ba591ca49..20bd2d150 100644
--- a/assets/webconfig/js/light_source.js
+++ b/assets/webconfig/js/light_source.js
@@ -559,6 +559,33 @@ $(document).ready(function()
$('#ip_ma_' + key).val(slConfig.matrix[key]);
}
+ async function deviceListRefresh(ledTypeTarget, discoveryResult, targetDiscoveryEditor, targetDiscoveryFirstLabel, targetDiscoverySecondLabel = 'main_menu_update_token')
+ {
+ let receiver = $("#deviceListInstances");
+ receiver.off();
+ receiver.empty();
+
+ $("", {value: "", text: $.i18n(targetDiscoveryFirstLabel)}).appendTo(receiver);
+
+ if (discoveryResult.info != null && discoveryResult.info.devices != null)
+ {
+ (discoveryResult.info.devices).forEach(function (val) {
+ $("", {value: val.value, text: val.name}).appendTo(receiver);
+ });
+ }
+
+ $("", {value: -1, text: $.i18n(targetDiscoverySecondLabel)}).appendTo(receiver);
+
+ receiver.on('change', function ()
+ {
+ let selVal = $("#deviceListInstances").val();
+ if (selVal == -1)
+ requestLedDeviceDiscovery(ledTypeTarget).then( (newResult) => deviceListRefresh(ledTypeTarget, newResult, targetDiscoveryEditor, targetDiscoveryFirstLabel, targetDiscoverySecondLabel));
+ else if (selVal != "")
+ conf_editor.getEditor(targetDiscoveryEditor).setValue(selVal);
+ });
+ }
+
function saveValues()
{
var ledConfig = {
@@ -802,14 +829,6 @@ $(document).ready(function()
});
$("input[name='root[specificOptions][useEntertainmentAPI]']").trigger("change");
}
- /*
- else if(ledType == "wled") {
- var ledWizardType = (this.checked) ? "wled" : ledType;
- var data = { type: ledWizardType };
- var wled_title = 'wiz_wled_title';
- changeWizard(data, wled_title, startWizardWLED);
- }
- */
else if (ledType == "atmoorb")
{
var ledWizardType = (this.checked) ? "atmoorb" : ledType;
@@ -836,63 +855,26 @@ $(document).ready(function()
};
var yeelight_title = 'wiz_yeelight_title';
changeWizard(data, yeelight_title, startWizardYeelight);
- }
- else if (ledType == "adalight")
+ }
+ else if (["apa102", "apa104", "awa_spi", "lpd6803", "lpd8806", "p9813", "sk6812spi", "sk6822spi", "sk9822", "ws2801", "ws2812spi", "wled", "adalight", "atmo", "dmx", "karate", "sedu", "tpm2"].includes(ledType))
{
- if (!(window.serverInfo.serialPorts == null || window.serverInfo.serialPorts.length == 0 || $("#selectPortSerial").length > 0))
- {
- let sPort = $("");
- sPort.addClass("form-select bg-warning").css('width', String(40)+'%');
-
- $("", {value: "auto", text: $.i18n("edt_dev_spec_outputPath_title")}).appendTo(sPort);
- (window.serverInfo.serialPorts).forEach(function (val) {
- $("", {value: val.port, text: val.desc}).appendTo(sPort);
- });
-
- $("input[name='root[specificOptions][output]']")[0].style.width = String(58) + "%";
- $("input[name='root[specificOptions][output]']")[0].parentElement.appendChild(sPort[0]);
-
- sPort.off().on('change', function () {
- conf_editor.getEditor('root.specificOptions.output').setValue(sPort.val());
- });
- }
- }
- else if (ledType == "wled")
- {
- async function wledRefresh(result)
- {
- let receiver = $("#selectWledInstances");
- receiver.off();
- receiver.empty();
-
- $("", {value: "", text: $.i18n("select_wled_intro")}).appendTo(receiver);
+ let selectorControl = $("");
+ let targetControl = 'output';
- if (result.info != null && result.info.devices != null)
- {
- (result.info.devices).forEach(function (val) {
- $("", {value: val.value, text: val.name}).appendTo(receiver);
- });
- }
-
- $("", {value: -1, text: $.i18n("select_wled_rescan")}).appendTo(receiver);
+ selectorControl.addClass("form-select bg-warning").css('width', String(40)+'%');
- receiver.on('change', function ()
- {
- let selVal = $("#selectWledInstances").val();
- if (selVal == -1)
- requestLedDeviceDiscovery('wled').then( (result) => wledRefresh(result));
- else if (selVal != "")
- conf_editor.getEditor('root.specificOptions.host').setValue(selVal);
- });
+ if (ledType == "wled")
+ {
+ requestLedDeviceDiscovery(ledType).then( (result) => deviceListRefresh(ledType, result, 'root.specificOptions.host','select_wled_intro','select_wled_rescan'));
+ targetControl = 'host';
}
-
- let sPort = $("");
- sPort.addClass("form-select bg-warning").css('width', String(40)+'%');
-
- requestLedDeviceDiscovery('wled').then( (result) => wledRefresh(result));
+ else if (["adalight", "atmo", "dmx", "karate", "sedu", "tpm2"].includes(ledType))
+ requestLedDeviceDiscovery(ledType).then( (result) => deviceListRefresh(ledType, result, 'root.specificOptions.output','edt_dev_spec_outputPath_title'));
+ else
+ requestLedDeviceDiscovery(ledType).then( (result) => deviceListRefresh(ledType, result, 'root.specificOptions.output', 'edt_dev_spec_spipath_title'));
- $("input[name='root[specificOptions][host]']")[0].style.width = String(58) + "%";
- $("input[name='root[specificOptions][host]']")[0].parentElement.appendChild(sPort[0]);
+ $(`input[name='root[specificOptions][${targetControl}]']`)[0].style.width = String(58) + "%";
+ $(`input[name='root[specificOptions][${targetControl}]']`)[0].parentElement.appendChild(selectorControl[0]);
}
function changeWizard(data, hint, fn)
diff --git a/sources/api/JsonAPI.cpp b/sources/api/JsonAPI.cpp
index fbf11534a..883e7957c 100644
--- a/sources/api/JsonAPI.cpp
+++ b/sources/api/JsonAPI.cpp
@@ -16,7 +16,6 @@
#include
#include
#include
-#include
#include
#include
@@ -529,18 +528,6 @@ void JsonAPI::handleServerInfoCommand(const QJsonObject& message, const QString&
ledDevices["available"] = availableLedDevices;
info["ledDevices"] = ledDevices;
- // serial port
- QJsonArray availableSerialPorts;
- const auto infoSerial = QSerialPortInfo::availablePorts();
- for (const QSerialPortInfo& info : infoSerial) {
- QJsonObject serialPort;
- serialPort["port"] = info.portName();
- serialPort["desc"] = QString("%2 (%1)").arg(info.systemLocation()).arg(info.description());
- availableSerialPorts.append(serialPort);
- }
- info["serialPorts"] = availableSerialPorts;
-
-
#if defined(ENABLE_SOUNDCAPLINUX) || defined(ENABLE_SOUNDCAPWINDOWS) || defined(ENABLE_SOUNDCAPMACOS)
if (SoundCapture::getInstance() != NULL)
{
diff --git a/sources/base/HyperHdrInstance.cpp b/sources/base/HyperHdrInstance.cpp
index 0d611c89f..2bbd9e32e 100644
--- a/sources/base/HyperHdrInstance.cpp
+++ b/sources/base/HyperHdrInstance.cpp
@@ -125,7 +125,7 @@ void HyperHdrInstance::start()
}
// handle hwLedCount
- _hwLedCount = qMax(getSetting(settings::type::DEVICE).object()["hardwareLedCount"].toInt(getLedCount()), getLedCount());
+ _hwLedCount = qMax(getSetting(settings::type::DEVICE).object()["hardwareLedCount"].toInt(1), getLedCount());
connect(&_muxer, &PriorityMuxer::visiblePriorityChanged, this, &HyperHdrInstance::update);
connect(&_muxer, &PriorityMuxer::visiblePriorityChanged, this, &HyperHdrInstance::handlePriorityChangedLedDevice);
@@ -259,7 +259,7 @@ void HyperHdrInstance::handleSettingsUpdate(settings::type type, const QJsonDocu
_globalLedBuffer = color;
// handle hwLedCount update
- _hwLedCount = qMax(getSetting(settings::type::DEVICE).object()["hardwareLedCount"].toInt(getLedCount()), getLedCount());
+ _hwLedCount = qMax(getSetting(settings::type::DEVICE).object()["hardwareLedCount"].toInt(1), getLedCount());
// change in leds are also reflected in adjustment
delete _raw2ledAdjustment;
@@ -273,7 +273,7 @@ void HyperHdrInstance::handleSettingsUpdate(settings::type type, const QJsonDocu
QJsonObject dev = config.object();
// handle hwLedCount update
- _hwLedCount = qMax(dev["hardwareLedCount"].toInt(getLedCount()), getLedCount());
+ _hwLedCount = qMax(dev["hardwareLedCount"].toInt(1), getLedCount());
// force ledString update, if device ByteOrder changed
if (_ledString.colorOrder != stringToColorOrder(dev["colorOrder"].toString("rgb")))
diff --git a/sources/base/schema/schema-device.json b/sources/base/schema/schema-device.json
index 5a271961a..1c0e5badc 100644
--- a/sources/base/schema/schema-device.json
+++ b/sources/base/schema/schema-device.json
@@ -2,7 +2,7 @@
"type" : "object",
"title" : "edt_dev_general_heading_title",
"required" : true,
- "defaultProperties": ["hardwareLedCount", "colorOrder", "refreshTime"],
+ "defaultProperties": ["colorOrder", "refreshTime"],
"properties" :
{
"type" :
@@ -12,16 +12,6 @@
"required" : true,
"propertyOrder" : 0
},
- "hardwareLedCount" :
- {
- "type" : "integer",
- "title" : "edt_dev_general_hardwareLedCount_title",
- "minimum" : 1,
- "default" : 1,
- "access" : "expert",
- "required" : true,
- "propertyOrder" : 1
- },
"colorOrder" :
{
"type" : "string",
diff --git a/sources/leddevice/dev_serial/ProviderRs232.cpp b/sources/leddevice/dev_serial/ProviderRs232.cpp
index b0867c68f..f87be2f7b 100644
--- a/sources/leddevice/dev_serial/ProviderRs232.cpp
+++ b/sources/leddevice/dev_serial/ProviderRs232.cpp
@@ -271,28 +271,21 @@ QString ProviderRs232::discoverFirst()
QJsonObject ProviderRs232::discover(const QJsonObject& /*params*/)
{
QJsonObject devicesDiscovered;
- devicesDiscovered.insert("ledDeviceType", _activeDeviceType);
-
QJsonArray deviceList;
- // Discover serial Devices
- for (auto& port : QSerialPortInfo::availablePorts())
- {
- if (!port.isNull())
- {
- QJsonObject portInfo;
- portInfo.insert("description", port.description());
- portInfo.insert("manufacturer", port.manufacturer());
- portInfo.insert("portName", port.portName());
- portInfo.insert("productIdentifier", QString("0x%1").arg(port.productIdentifier(), 0, 16));
- portInfo.insert("serialNumber", port.serialNumber());
- portInfo.insert("systemLocation", port.systemLocation());
- portInfo.insert("vendorIdentifier", QString("0x%1").arg(port.vendorIdentifier(), 0, 16));
-
- deviceList.append(portInfo);
- }
- }
+ deviceList.push_back(QJsonObject{
+ {"value", "auto"},
+ { "name", "Auto"} });
+
+ for (const QSerialPortInfo& info : QSerialPortInfo::availablePorts())
+ deviceList.push_back(QJsonObject{
+ {"value", info.portName()},
+ { "name", QString("%2 (%1)").arg(info.systemLocation()).arg(info.description()) } });
+ devicesDiscovered.insert("ledDeviceType", _activeDeviceType);
devicesDiscovered.insert("devices", deviceList);
+
+ Debug(_log, "Serial devices discovered: [%s]", QString(QJsonDocument(devicesDiscovered).toJson(QJsonDocument::Compact)).toUtf8().constData());
+
return devicesDiscovered;
}
diff --git a/sources/leddevice/dev_spi/ProviderSpi.cpp b/sources/leddevice/dev_spi/ProviderSpi.cpp
index 2cd530eb4..f56ed6c98 100644
--- a/sources/leddevice/dev_spi/ProviderSpi.cpp
+++ b/sources/leddevice/dev_spi/ProviderSpi.cpp
@@ -14,6 +14,8 @@
#include "ProviderSpi.h"
#include
+#include
+
ProviderSpi::ProviderSpi(const QJsonObject& deviceConfig)
: LedDevice(deviceConfig)
, _deviceName("/dev/spidev0.0")
@@ -222,3 +224,27 @@ int ProviderSpi::writeBytesEsp32(unsigned size, const uint8_t* data)
return retVal;
}
+
+QJsonObject ProviderSpi::discover(const QJsonObject& /*params*/)
+{
+ QJsonObject devicesDiscovered;
+ QJsonArray deviceList;
+ QStringList files;
+ QDirIterator it("/dev", QStringList() << "spidev*", QDir::System);
+
+ while (it.hasNext())
+ files << it.next();
+ files.sort();
+
+ for (const auto& path : files)
+ deviceList.push_back(QJsonObject{
+ {"value", path},
+ { "name", path } });
+
+ devicesDiscovered.insert("ledDeviceType", _activeDeviceType);
+ devicesDiscovered.insert("devices", deviceList);
+
+ Debug(_log, "SPI devices discovered: [%s]", QString(QJsonDocument(devicesDiscovered).toJson(QJsonDocument::Compact)).toUtf8().constData());
+
+ return devicesDiscovered;
+}
diff --git a/sources/leddevice/dev_spi/ProviderSpi.h b/sources/leddevice/dev_spi/ProviderSpi.h
index 7a4a96616..bf952ee7c 100644
--- a/sources/leddevice/dev_spi/ProviderSpi.h
+++ b/sources/leddevice/dev_spi/ProviderSpi.h
@@ -36,6 +36,8 @@ class ProviderSpi : public LedDevice
///
int open() override;
+ QJsonObject discover(const QJsonObject& params) override;
+
public slots:
///
/// Closes the output device.
diff --git a/sources/leddevice/schemas/schema-apa102.json b/sources/leddevice/schemas/schema-apa102.json
index e7a84f122..dabe3f5c2 100644
--- a/sources/leddevice/schemas/schema-apa102.json
+++ b/sources/leddevice/schemas/schema-apa102.json
@@ -5,10 +5,6 @@
"output": {
"type": "string",
"title":"edt_dev_spec_spipath_title",
- "enum" : ["/dev/spidev0.0","/dev/spidev0.1","/dev/spidev1.0","/dev/spidev1.1"],
- "options" : {
- "enum_titles" : ["/dev/spidev0.0","/dev/spidev0.1","/dev/spidev1.0","/dev/spidev1.1"]
- },
"default" : "/dev/spidev0.0",
"required" : true,
"propertyOrder" : 1
diff --git a/sources/leddevice/schemas/schema-apa104.json b/sources/leddevice/schemas/schema-apa104.json
index 37eedb83e..4f6ef7c17 100644
--- a/sources/leddevice/schemas/schema-apa104.json
+++ b/sources/leddevice/schemas/schema-apa104.json
@@ -5,10 +5,6 @@
"output": {
"type": "string",
"title":"edt_dev_spec_spipath_title",
- "enum" : ["/dev/spidev0.0","/dev/spidev0.1","/dev/spidev1.0","/dev/spidev1.1"],
- "options" : {
- "enum_titles" : ["/dev/spidev0.0","/dev/spidev0.1","/dev/spidev1.0","/dev/spidev1.1"]
- },
"default" : "/dev/spidev0.0",
"required" : true,
"propertyOrder" : 1
diff --git a/sources/leddevice/schemas/schema-awa_spi.json b/sources/leddevice/schemas/schema-awa_spi.json
index eb2dd39d1..385197418 100644
--- a/sources/leddevice/schemas/schema-awa_spi.json
+++ b/sources/leddevice/schemas/schema-awa_spi.json
@@ -5,10 +5,6 @@
"output": {
"type": "string",
"title":"edt_dev_spec_spipath_title",
- "enum" : ["/dev/spidev0.0","/dev/spidev0.1","/dev/spidev1.0","/dev/spidev1.1"],
- "options" : {
- "enum_titles" : ["/dev/spidev0.0","/dev/spidev0.1","/dev/spidev1.0","/dev/spidev1.1"]
- },
"default" : "/dev/spidev0.0",
"required" : true,
"propertyOrder" : 1
diff --git a/sources/leddevice/schemas/schema-cololight.json b/sources/leddevice/schemas/schema-cololight.json
index b7468e7c8..ee66131a2 100644
--- a/sources/leddevice/schemas/schema-cololight.json
+++ b/sources/leddevice/schemas/schema-cololight.json
@@ -1,7 +1,16 @@
{
"type":"object",
"required":true,
- "properties": {
+ "properties": {
+ "hardwareLedCount" : {
+ "type" : "integer",
+ "title" : "edt_dev_general_hardwareLedCount_title",
+ "minimum" : 1,
+ "default" : 1,
+ "access" : "expert",
+ "required" : true,
+ "propertyOrder" : 1
+ },
"host" : {
"type": "string",
"title":"edt_dev_spec_targetIpHost_title",
diff --git a/sources/leddevice/schemas/schema-lpd6803.json b/sources/leddevice/schemas/schema-lpd6803.json
index 05b1ebb93..eb7fd692f 100644
--- a/sources/leddevice/schemas/schema-lpd6803.json
+++ b/sources/leddevice/schemas/schema-lpd6803.json
@@ -5,10 +5,6 @@
"output": {
"type": "string",
"title":"edt_dev_spec_spipath_title",
- "enum" : ["/dev/spidev0.0","/dev/spidev0.1","/dev/spidev1.0","/dev/spidev1.1"],
- "options" : {
- "enum_titles" : ["/dev/spidev0.0","/dev/spidev0.1","/dev/spidev1.0","/dev/spidev1.1"]
- },
"default" : "/dev/spidev0.0",
"required" : true,
"propertyOrder" : 1
diff --git a/sources/leddevice/schemas/schema-lpd8806.json b/sources/leddevice/schemas/schema-lpd8806.json
index 05b1ebb93..eb7fd692f 100644
--- a/sources/leddevice/schemas/schema-lpd8806.json
+++ b/sources/leddevice/schemas/schema-lpd8806.json
@@ -5,10 +5,6 @@
"output": {
"type": "string",
"title":"edt_dev_spec_spipath_title",
- "enum" : ["/dev/spidev0.0","/dev/spidev0.1","/dev/spidev1.0","/dev/spidev1.1"],
- "options" : {
- "enum_titles" : ["/dev/spidev0.0","/dev/spidev0.1","/dev/spidev1.0","/dev/spidev1.1"]
- },
"default" : "/dev/spidev0.0",
"required" : true,
"propertyOrder" : 1
diff --git a/sources/leddevice/schemas/schema-nanoleaf.json b/sources/leddevice/schemas/schema-nanoleaf.json
index 97fac11f2..3ecc25ef6 100644
--- a/sources/leddevice/schemas/schema-nanoleaf.json
+++ b/sources/leddevice/schemas/schema-nanoleaf.json
@@ -1,7 +1,16 @@
{
"type":"object",
"required":true,
- "properties":{
+ "properties": {
+ "hardwareLedCount": {
+ "type" : "integer",
+ "title" : "edt_dev_general_hardwareLedCount_title",
+ "minimum" : 1,
+ "default" : 1,
+ "access" : "expert",
+ "required" : true,
+ "propertyOrder" : 1
+ },
"host": {
"type": "string",
"title":"edt_dev_spec_targetIpHost_title",
diff --git a/sources/leddevice/schemas/schema-p9813.json b/sources/leddevice/schemas/schema-p9813.json
index 05b1ebb93..eb7fd692f 100644
--- a/sources/leddevice/schemas/schema-p9813.json
+++ b/sources/leddevice/schemas/schema-p9813.json
@@ -5,10 +5,6 @@
"output": {
"type": "string",
"title":"edt_dev_spec_spipath_title",
- "enum" : ["/dev/spidev0.0","/dev/spidev0.1","/dev/spidev1.0","/dev/spidev1.1"],
- "options" : {
- "enum_titles" : ["/dev/spidev0.0","/dev/spidev0.1","/dev/spidev1.0","/dev/spidev1.1"]
- },
"default" : "/dev/spidev0.0",
"required" : true,
"propertyOrder" : 1
diff --git a/sources/leddevice/schemas/schema-sk6812spi.json b/sources/leddevice/schemas/schema-sk6812spi.json
index 769a90345..df9832bed 100644
--- a/sources/leddevice/schemas/schema-sk6812spi.json
+++ b/sources/leddevice/schemas/schema-sk6812spi.json
@@ -5,10 +5,6 @@
"output": {
"type": "string",
"title":"edt_dev_spec_spipath_title",
- "enum" : ["/dev/spidev0.0","/dev/spidev0.1","/dev/spidev1.0","/dev/spidev1.1"],
- "options" : {
- "enum_titles" : ["/dev/spidev0.0","/dev/spidev0.1","/dev/spidev1.0","/dev/spidev1.1"]
- },
"default" : "/dev/spidev0.0",
"required" : true,
"propertyOrder" : 1
diff --git a/sources/leddevice/schemas/schema-sk6822spi.json b/sources/leddevice/schemas/schema-sk6822spi.json
index 874e5cc73..61cf08f72 100644
--- a/sources/leddevice/schemas/schema-sk6822spi.json
+++ b/sources/leddevice/schemas/schema-sk6822spi.json
@@ -5,10 +5,6 @@
"output": {
"type": "string",
"title":"edt_dev_spec_spipath_title",
- "enum" : ["/dev/spidev0.0","/dev/spidev0.1","/dev/spidev1.0","/dev/spidev1.1"],
- "options" : {
- "enum_titles" : ["/dev/spidev0.0","/dev/spidev0.1","/dev/spidev1.0","/dev/spidev1.1"]
- },
"default" : "/dev/spidev0.0",
"required" : true,
"propertyOrder" : 1
diff --git a/sources/leddevice/schemas/schema-sk9822.json b/sources/leddevice/schemas/schema-sk9822.json
index ddf83c0ad..9cc51a34e 100644
--- a/sources/leddevice/schemas/schema-sk9822.json
+++ b/sources/leddevice/schemas/schema-sk9822.json
@@ -5,10 +5,6 @@
"output": {
"type": "string",
"title":"edt_dev_spec_spipath_title",
- "enum" : ["/dev/spidev0.0","/dev/spidev0.1","/dev/spidev1.0","/dev/spidev1.1"],
- "options" : {
- "enum_titles" : ["/dev/spidev0.0","/dev/spidev0.1","/dev/spidev1.0","/dev/spidev1.1"]
- },
"default" : "/dev/spidev0.0",
"required" : true,
"propertyOrder" : 1
diff --git a/sources/leddevice/schemas/schema-ws2801.json b/sources/leddevice/schemas/schema-ws2801.json
index 05b1ebb93..eb7fd692f 100644
--- a/sources/leddevice/schemas/schema-ws2801.json
+++ b/sources/leddevice/schemas/schema-ws2801.json
@@ -5,10 +5,6 @@
"output": {
"type": "string",
"title":"edt_dev_spec_spipath_title",
- "enum" : ["/dev/spidev0.0","/dev/spidev0.1","/dev/spidev1.0","/dev/spidev1.1"],
- "options" : {
- "enum_titles" : ["/dev/spidev0.0","/dev/spidev0.1","/dev/spidev1.0","/dev/spidev1.1"]
- },
"default" : "/dev/spidev0.0",
"required" : true,
"propertyOrder" : 1
diff --git a/sources/leddevice/schemas/schema-ws2812spi.json b/sources/leddevice/schemas/schema-ws2812spi.json
index 374084a55..30785064c 100644
--- a/sources/leddevice/schemas/schema-ws2812spi.json
+++ b/sources/leddevice/schemas/schema-ws2812spi.json
@@ -5,10 +5,6 @@
"output": {
"type": "string",
"title":"edt_dev_spec_spipath_title",
- "enum" : ["/dev/spidev0.0","/dev/spidev0.1","/dev/spidev1.0","/dev/spidev1.1"],
- "options" : {
- "enum_titles" : ["/dev/spidev0.0","/dev/spidev0.1","/dev/spidev1.0","/dev/spidev1.1"]
- },
"default" : "/dev/spidev0.0",
"required" : true,
"propertyOrder" : 1