diff --git a/assets/webconfig/content/grabber.html b/assets/webconfig/content/grabber.html
index f8eee33d..982c594f 100644
--- a/assets/webconfig/content/grabber.html
+++ b/assets/webconfig/content/grabber.html
@@ -10,7 +10,7 @@
- ... device specific options ... we need some cpp code extension to get schema for all leds
+
+
+
+
diff --git a/assets/webconfig/js/content_grabber.js b/assets/webconfig/js/content_grabber.js
index 78f8acea..49495b53 100644
--- a/assets/webconfig/js/content_grabber.js
+++ b/assets/webconfig/js/content_grabber.js
@@ -49,7 +49,7 @@ $(hyperion).one("cmd-config-getschema", function(event) {
$(document).ready( function() {
requestServerConfigSchema();
- document.getElementById('submit').addEventListener('click',function() {
+ document.getElementById('btn_submit').addEventListener('click',function() {
// Get the value from the editor
//console.log(general_conf_editor.getValue());
});
diff --git a/assets/webconfig/js/content_index.js b/assets/webconfig/js/content_index.js
index a6d33603..10a5c452 100644
--- a/assets/webconfig/js/content_index.js
+++ b/assets/webconfig/js/content_index.js
@@ -15,10 +15,6 @@ $(document).ready( function() {
//Change all Checkboxes to Switches
$("[type='checkbox']").bootstrapSwitch();
- $(hyperion).on("open",function(event){
- requestServerInfo();
- });
-
$(hyperion).on("cmd-serverinfo",function(event){
parsedServerInfoJSON = event.response;
currentVersion = parsedServerInfoJSON.info.hyperion[0].version;
@@ -57,9 +53,20 @@ $(document).ready( function() {
});
}); // end cmd-serverinfo
+ $(hyperion).one("cmd-config-getschema", function(event) {
+ parsedConfSchemaJSON = event.response.result;
+ });
+
+
$(hyperion).on("error",function(event){
showErrorDialog("error", event.reason);
});
+
+ $(hyperion).on("open",function(event){
+ requestServerConfigSchema();
+ requestServerInfo();
+ });
+
});
$(function(){
diff --git a/assets/webconfig/js/content_leds.js b/assets/webconfig/js/content_leds.js
index 2c37bede..635b28a0 100644
--- a/assets/webconfig/js/content_leds.js
+++ b/assets/webconfig/js/content_leds.js
@@ -41,6 +41,7 @@ $(document).ready(function() {
}
$("#leddevices").html(ledDevicesHtml);
$("#leddevices").val(server.info.ledDevices.active);
+ $("#leddevices").trigger("change");
});
// ------------------------------------------------------------------
@@ -120,6 +121,48 @@ $(document).ready(function() {
});
$("#leddevices").off().on("change", function(event) {
+ generalOptions = parsedConfSchemaJSON.properties.device;
+ specificOptions = parsedConfSchemaJSON.properties.alldevices[$(this).val()];
+ //$('#ledDeviceOptions').html(JSON.stringify(generalOptions)+"
"+JSON.stringify(specificOptions));
+ $('#editor_container').off();
+ $('#editor_container').html("");
+ var element = document.getElementById('editor_container');
+
+ var grabber_conf_editor = new JSONEditor(element,{
+ theme: 'bootstrap3',
+ disable_collapse: 'true',
+ form_name_root: 'sa',
+ disable_edit_json: 'true',
+ disable_properties: 'true',
+ no_additional_properties: 'true',
+ schema: {
+ title:' ',
+ properties: {
+ generalOptions,
+ specificOptions,
+ }
+ }
+ });
+
+ values_general = {};
+ values_specific = {};
+ isCurrentDevice = (server.info.ledDevices.active == parsedConfJSON.device.type);
+
+ for(var key in parsedConfJSON.device){
+ if (key in generalOptions.properties)
+ values_general[key] = parsedConfJSON.device[key];
+ };
+ grabber_conf_editor.setValue( { "generalOptions" : values_general, "specificOptions" : specificOptions });
+
+ if (isCurrentDevice)
+ {
+ for(var key in parsedConfJSON.device){
+ if (key in specificOptions.properties)
+ values_specific[key] = parsedConfJSON.device[key];
+ };
+ grabber_conf_editor.setValue( { "generalOptions" : values_general, "specificOptions" : values_specific });
+ };
+
if ($(this).val() == "philipshue")
{
$("#huebridge").show();
diff --git a/include/leddevice/LedDevice.h b/include/leddevice/LedDevice.h
index f253591c..83abd080 100644
--- a/include/leddevice/LedDevice.h
+++ b/include/leddevice/LedDevice.h
@@ -55,6 +55,8 @@ public:
static const LedDeviceRegistry& getDeviceMap();
static void setActiveDevice(std::string dev);
static std::string activeDevice() { return _activeDevice; };
+ static Json::Value getLedDeviceSchemas();
+
protected:
/// The common Logger instance for all LedDevices
Logger * _log;
diff --git a/libsrc/hyperion/hyperion.schema.json b/libsrc/hyperion/hyperion.schema.json
index 9181dd0c..e39d83ee 100644
--- a/libsrc/hyperion/hyperion.schema.json
+++ b/libsrc/hyperion/hyperion.schema.json
@@ -23,33 +23,34 @@
"device" :
{
"type" : "object",
- "title" : "LED Device",
+ "title" : "LED Device General",
"required" : true,
+ "defaultProperties": ["name","ledCount","colorOrder"],
"properties" :
{
"name" :
{
"type" : "string",
- "required" : true
+ "required" : true,
+ "propertyOrder" : 1
},
"type" :
{
"type" : "string",
"required" : true
},
- "output" :
- {
- "type" : "string"
- },
- "rate" :
+ "ledCount" :
{
"type" : "integer",
- "minimum" : 0
+ "minimum" : 0,
+ "title" : "Count of all hardware LEDs",
+ "propertyOrder" : 2
},
"colorOrder" :
{
"type" : "string",
- "enum" : ["rgb", "bgr", "rbg", "brg", "gbr", "grb"]
+ "enum" : ["rgb", "bgr", "rbg", "brg", "gbr", "grb"],
+ "propertyOrder" : 3
}
},
"additionalProperties" : true
diff --git a/libsrc/jsonserver/JsonClientConnection.cpp b/libsrc/jsonserver/JsonClientConnection.cpp
index fed1504a..4dbc75f4 100644
--- a/libsrc/jsonserver/JsonClientConnection.cpp
+++ b/libsrc/jsonserver/JsonClientConnection.cpp
@@ -911,6 +911,8 @@ void JsonClientConnection::handleSchemaGetCommand(const Json::Value & message, c
result["tan"] = tan;
Json::Value & schemaJson = result["result"];
+
+
// make sure the resources are loaded (they may be left out after static linking)
Q_INIT_RESOURCE(resource);
@@ -923,6 +925,7 @@ void JsonClientConnection::handleSchemaGetCommand(const Json::Value & message, c
{
throw std::runtime_error("ERROR: Json schema wrong: " + jsonReader.getFormattedErrorMessages()) ;
}
+ result["result"]["properties"]["alldevices"] = LedDevice::getLedDeviceSchemas();
// send the result
sendMessage(result);
diff --git a/libsrc/leddevice/LedDevice.cpp b/libsrc/leddevice/LedDevice.cpp
index e38a7d81..88349b19 100644
--- a/libsrc/leddevice/LedDevice.cpp
+++ b/libsrc/leddevice/LedDevice.cpp
@@ -1,5 +1,10 @@
#include
+#include
+#include
+#include
+#include
+
LedDeviceRegistry LedDevice::_ledDeviceMap = LedDeviceRegistry();
std::string LedDevice::_activeDevice = "";
@@ -10,6 +15,7 @@ LedDevice::LedDevice()
, _ledBuffer(0)
{
+ LedDevice::getLedDeviceSchemas();
}
// dummy implemention
@@ -32,4 +38,32 @@ const LedDeviceRegistry& LedDevice::getDeviceMap()
void LedDevice::setActiveDevice(std::string dev)
{
_activeDevice = dev;
-}
\ No newline at end of file
+}
+
+Json::Value LedDevice::getLedDeviceSchemas()
+{
+ // make sure the resources are loaded (they may be left out after static linking)
+ Q_INIT_RESOURCE(LedDeviceSchemas);
+
+ // read the json schema from the resource
+ QDir d(":/leddevices/");
+ QStringList l = d.entryList();
+ Json::Value result;
+ for(QString &item : l)
+ {
+ QResource schemaData(QString(":/leddevices/")+item);
+ std::string devName = item.remove("schema-").toStdString();
+ Json::Value & schemaJson = result[devName];
+
+ Json::Reader jsonReader;
+ if (!jsonReader.parse(reinterpret_cast(schemaData.data()), reinterpret_cast(schemaData.data()) + schemaData.size(), schemaJson, false))
+ {
+ Error(Logger::getInstance("LedDevice"), "LedDevice JSON schema error in %s (%s)", item.toUtf8().constData(), jsonReader.getFormattedErrorMessages().c_str() );
+ throw std::runtime_error("ERROR: Json schema wrong: " + jsonReader.getFormattedErrorMessages()) ;
+ }
+ schemaJson["title"] = "LED Device Specific";
+
+ }
+
+ return result;
+}
diff --git a/libsrc/leddevice/LedDeviceSchemas.qrc b/libsrc/leddevice/LedDeviceSchemas.qrc
index f2b16b5b..e35a8789 100644
--- a/libsrc/leddevice/LedDeviceSchemas.qrc
+++ b/libsrc/leddevice/LedDeviceSchemas.qrc
@@ -1,5 +1,5 @@
-
+
schemas/schema-adalightapa102.json
schemas/schema-adalight.json
schemas/schema-apa102.json
diff --git a/libsrc/leddevice/LedDeviceSk6812SPI.cpp b/libsrc/leddevice/LedDeviceSk6812SPI.cpp
index 5bef4db8..e68e6441 100644
--- a/libsrc/leddevice/LedDeviceSk6812SPI.cpp
+++ b/libsrc/leddevice/LedDeviceSk6812SPI.cpp
@@ -34,7 +34,7 @@ bool LedDeviceSk6812SPI::setConfig(const Json::Value &deviceConfig)
{
ProviderSpi::setConfig(deviceConfig);
- _baudRate_Hz = deviceConfig.get("rate",3000000).asInt();
+ _baudRate_Hz = deviceConfig.get("rate",3000000).asInt();
if ( (_baudRate_Hz < 2050000) || (_baudRate_Hz > 4000000) )
{
Warning(_log, "SPI rate %d outside recommended range (2050000 -> 4000000)", _baudRate_Hz);
diff --git a/libsrc/leddevice/schemas/schema-e131.json b/libsrc/leddevice/schemas/schema-e131.json
index 54fe696b..104bd3f2 100644
--- a/libsrc/leddevice/schemas/schema-e131.json
+++ b/libsrc/leddevice/schemas/schema-e131.json
@@ -2,6 +2,15 @@
"type":"object",
"required":true,
"properties":{
+ "host" : {
+ "type": "string",
+ "title":"Target IP"
+ },
+ "port" : {
+ "type": "integer",
+ "title":"Port",
+ "default": 5568
+ },
"universe": {
"type": "integer",
"title":"Universe",
@@ -14,7 +23,7 @@
},
"cid": {
"type": "string",
- "title":"CID",
+ "title":"CID"
}
},
"additionalProperties": true
diff --git a/libsrc/leddevice/schemas/schema-fadecandy.json b/libsrc/leddevice/schemas/schema-fadecandy.json
index 0bce7984..b36fef22 100644
--- a/libsrc/leddevice/schemas/schema-fadecandy.json
+++ b/libsrc/leddevice/schemas/schema-fadecandy.json
@@ -2,6 +2,64 @@
"type":"object",
"required":true,
"properties":{
+ "output" : {
+ "type": "string",
+ "title":"Target IP",
+ "propertyOrder" : 1
+ },
+ "port" : {
+ "type": "integer",
+ "title":"Port",
+ "default": 7890,
+ "propertyOrder" : 2
+ },
+ "setFcConfig": {
+ "type": "boolean",
+ "title":"Set fadecandy Configuration",
+ "default": false,
+ "propertyOrder" : 3
+ },
+ "manualLed": {
+ "type": "boolean",
+ "title":"Manual control of fadecandy LED",
+ "default": false,
+ "propertyOrder" : 4
+ },
+ "ledOn": {
+ "type": "boolean",
+ "title":"Fadecandy LED set to on",
+ "default": false,
+ "propertyOrder" : 5
+ },
+ "interpolation": {
+ "type": "boolean",
+ "title":"Interpolation",
+ "default": false,
+ "propertyOrder" : 6
+ },
+ "dither": {
+ "type": "boolean",
+ "title":"Dithering",
+ "default": false,
+ "propertyOrder" : 7
+ },
+ "gamma" : {
+ "type" : "number",
+ "minimum" : 0.0,
+ "maximum": 100.0,
+ "propertyOrder" : 8
+ },
+ "whitepoint" : {
+ "type" : "array",
+ "propertyOrder" : 9,
+ "items" : {
+ "type" : "number",
+ "minimum" : 0.0,
+ "maximum": 1.0,
+ "default" : 1.0
+ }
+ }
},
"additionalProperties": true
}
+
diff --git a/libsrc/leddevice/schemas/schema-file.json b/libsrc/leddevice/schemas/schema-file.json
index 88bd5f2f..b07f1146 100644
--- a/libsrc/leddevice/schemas/schema-file.json
+++ b/libsrc/leddevice/schemas/schema-file.json
@@ -5,7 +5,7 @@
"output": {
"type": "string",
"title":"Output",
- "default" : "/dev/null",
+ "default" : "/dev/null"
}
},
"additionalProperties": true
diff --git a/libsrc/leddevice/schemas/schema-philipshue.json b/libsrc/leddevice/schemas/schema-philipshue.json
index 3d14aca1..c0a444a0 100644
--- a/libsrc/leddevice/schemas/schema-philipshue.json
+++ b/libsrc/leddevice/schemas/schema-philipshue.json
@@ -18,7 +18,7 @@
"transitiontime": {
"type": "integer",
"title":"Transistion time (x100ms)",
- "default" : 1,
+ "default" : 1
},
"switchOffOnBlack": {
"type": "boolean",
diff --git a/libsrc/leddevice/schemas/schema-udpraw.json b/libsrc/leddevice/schemas/schema-udpraw.json
index 0bce7984..836920ec 100644
--- a/libsrc/leddevice/schemas/schema-udpraw.json
+++ b/libsrc/leddevice/schemas/schema-udpraw.json
@@ -2,6 +2,15 @@
"type":"object",
"required":true,
"properties":{
+ "host" : {
+ "type": "string",
+ "title":"Target IP"
+ },
+ "port" : {
+ "type": "integer",
+ "title":"Port",
+ "default": 5568
+ }
},
"additionalProperties": true
}