mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
webui: initial support for leddevice options (#232)
* initial support for leddevice options * fix schema and editor init * fix led editor labels and schema * add some led schemas * led config: insert current values. not yet perfect, but it works
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
#include <leddevice/LedDevice.h>
|
||||
|
||||
#include <QResource>
|
||||
#include <QStringList>
|
||||
#include <QDir>
|
||||
#include <json/json.h>
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
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<const char *>(schemaData.data()), reinterpret_cast<const char *>(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;
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<qresource prefix="/leddevices/">
|
||||
<file alias="schema-adalightapa102">schemas/schema-adalightapa102.json</file>
|
||||
<file alias="schema-adalight">schemas/schema-adalight.json</file>
|
||||
<file alias="schema-apa102">schemas/schema-apa102.json</file>
|
||||
|
@@ -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);
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
}
|
||||
|
||||
|
@@ -5,7 +5,7 @@
|
||||
"output": {
|
||||
"type": "string",
|
||||
"title":"Output",
|
||||
"default" : "/dev/null",
|
||||
"default" : "/dev/null"
|
||||
}
|
||||
},
|
||||
"additionalProperties": true
|
||||
|
@@ -18,7 +18,7 @@
|
||||
"transitiontime": {
|
||||
"type": "integer",
|
||||
"title":"Transistion time (x100ms)",
|
||||
"default" : 1,
|
||||
"default" : 1
|
||||
},
|
||||
"switchOffOnBlack": {
|
||||
"type": "boolean",
|
||||
|
@@ -2,6 +2,15 @@
|
||||
"type":"object",
|
||||
"required":true,
|
||||
"properties":{
|
||||
"host" : {
|
||||
"type": "string",
|
||||
"title":"Target IP"
|
||||
},
|
||||
"port" : {
|
||||
"type": "integer",
|
||||
"title":"Port",
|
||||
"default": 5568
|
||||
}
|
||||
},
|
||||
"additionalProperties": true
|
||||
}
|
||||
|
Reference in New Issue
Block a user