mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
refresh time for all devices + schema fixes (#305)
* refresh for all :-) remove dups * - integrate refresh leds for all devices - fix schemas for led devices * add minimum for rewrite time * rewriteTime: add missing info in config examples
This commit is contained in:
parent
9ddbf81810
commit
96e8c29582
@ -16,13 +16,15 @@
|
||||
/// APA102, WS2801, P9813, LPD6803, LPD8806, ---------PWM---------, WS2812b (just RPi1), WS281X (RPi1, RPi2, RPi3), --------OTHER--------, PhilipsHUE, AtmoOrb, PiBlaster, Tinkerforge, FadeCandy, RawHID (USB), UDP, SEDU, TPM2, USBASP-WS2801, USBASP-WS2812, ------3rd PARTY------, Adalight, AdalightAPA102, Atmo, Lightpack, Multi-Lightpack, Paintpack, Test (file), None)
|
||||
/// * [device type specific configuration]
|
||||
/// * 'colorOrder' : The order of the color bytes ('rgb', 'rbg', 'bgr', etc.).
|
||||
/// * 'rewriteTime': in ms. Data is resend to leds, if no new data is available in thistime. 0 means no refresh
|
||||
"device" :
|
||||
{
|
||||
"name" : "MyHyperionConfig",
|
||||
"type" : "file",
|
||||
"output" : "/dev/null",
|
||||
"rate" : 1000000,
|
||||
"colorOrder" : "rgb"
|
||||
"colorOrder" : "rgb",
|
||||
"rewriteTime": 0
|
||||
},
|
||||
|
||||
/// Color manipulation configuration used to tune the output colors to specific surroundings.
|
||||
|
@ -10,7 +10,8 @@
|
||||
"type" : "file",
|
||||
"output" : "/dev/null",
|
||||
"rate" : 1000000,
|
||||
"colorOrder" : "rgb"
|
||||
"colorOrder" : "rgb",
|
||||
"rewriteTime": 0
|
||||
},
|
||||
|
||||
"color" :
|
||||
|
@ -68,6 +68,7 @@ protected:
|
||||
/// @return Zero on success else negative
|
||||
///
|
||||
virtual int write(const std::vector<ColorRgb>& ledValues) = 0;
|
||||
virtual bool init(const QJsonObject &deviceConfig);
|
||||
|
||||
/// The common Logger instance for all LedDevices
|
||||
Logger * _log;
|
||||
@ -87,6 +88,7 @@ protected:
|
||||
/// Timer object which makes sure that led data is written at a minimum rate
|
||||
/// e.g. Adalight device will switch off when it does not receive data at least every 15 seconds
|
||||
QTimer _refresh_timer;
|
||||
unsigned int _refresh_timer_interval;
|
||||
|
||||
protected slots:
|
||||
/// Write the last data to the leds again
|
||||
|
@ -24,7 +24,7 @@
|
||||
"type" : "object",
|
||||
"title" : "LED Device General",
|
||||
"required" : true,
|
||||
"defaultProperties": ["name","ledCount","colorOrder"],
|
||||
"defaultProperties": ["name","ledCount","colorOrder","rewriteTime"],
|
||||
"properties" :
|
||||
{
|
||||
"name" :
|
||||
@ -52,6 +52,14 @@
|
||||
"title" : "RGB byte order",
|
||||
"enum" : ["rgb", "bgr", "rbg", "brg", "gbr", "grb"],
|
||||
"propertyOrder" : 3
|
||||
},
|
||||
"rewriteTime": {
|
||||
"type": "integer",
|
||||
"title":"Refresh time",
|
||||
"default": 5000,
|
||||
"append" : "ms",
|
||||
"minimum": 0,
|
||||
"propertOrder" : 4
|
||||
}
|
||||
},
|
||||
"additionalProperties" : true
|
||||
|
@ -18,6 +18,7 @@ LedDevice::LedDevice()
|
||||
, _ledBuffer(0)
|
||||
, _deviceReady(true)
|
||||
, _refresh_timer()
|
||||
, _refresh_timer_interval(0)
|
||||
{
|
||||
LedDevice::getLedDeviceSchemas();
|
||||
|
||||
@ -49,6 +50,12 @@ void LedDevice::setActiveDevice(std::string dev)
|
||||
_activeDevice = dev;
|
||||
}
|
||||
|
||||
bool LedDevice::init(const QJsonObject &deviceConfig)
|
||||
{
|
||||
_refresh_timer.setInterval( deviceConfig["rewriteTime"].toInt(_refresh_timer_interval) );
|
||||
return true;
|
||||
}
|
||||
|
||||
QJsonObject LedDevice::getLedDeviceSchemas()
|
||||
{
|
||||
// make sure the resources are loaded (they may be left out after static linking)
|
||||
|
@ -22,6 +22,9 @@ bool LedDeviceFile::init(const QJsonObject &deviceConfig)
|
||||
_ofs.close();
|
||||
}
|
||||
|
||||
_refresh_timer_interval = 0;
|
||||
LedDevice::init(deviceConfig);
|
||||
|
||||
std::string fileName = deviceConfig["output"].toString("/dev/null").toStdString();
|
||||
_ofs.open( fileName.c_str() );
|
||||
|
||||
|
@ -39,6 +39,8 @@ LedDeviceHyperionUsbasp::~LedDeviceHyperionUsbasp()
|
||||
|
||||
bool LedDeviceHyperionUsbasp::init(const QJsonObject &deviceConfig)
|
||||
{
|
||||
LedDevice::init(deviceConfig);
|
||||
|
||||
std::string ledType = deviceConfig["output"].toString("ws2801").toStdString();
|
||||
if (ledType != "ws2801" && ledType != "ws2812")
|
||||
{
|
||||
|
@ -71,6 +71,7 @@ LedDeviceLightpack::~LedDeviceLightpack()
|
||||
|
||||
bool LedDeviceLightpack::init(const QJsonObject &deviceConfig)
|
||||
{
|
||||
LedDevice::init(deviceConfig);
|
||||
_serialNumber = deviceConfig["output"].toString("").toStdString();
|
||||
|
||||
return true;
|
||||
|
@ -17,10 +17,11 @@ bool compareLightpacks(LedDeviceLightpack * lhs, LedDeviceLightpack * rhs)
|
||||
return lhs->getSerialNumber() < rhs->getSerialNumber();
|
||||
}
|
||||
|
||||
LedDeviceMultiLightpack::LedDeviceMultiLightpack(const QJsonObject &)
|
||||
LedDeviceMultiLightpack::LedDeviceMultiLightpack(const QJsonObject &deviceConfig)
|
||||
: LedDevice()
|
||||
, _lightpacks()
|
||||
{
|
||||
LedDevice::init(deviceConfig);
|
||||
}
|
||||
|
||||
LedDeviceMultiLightpack::~LedDeviceMultiLightpack()
|
||||
|
@ -179,6 +179,8 @@ LedDevicePhilipsHue::~LedDevicePhilipsHue()
|
||||
|
||||
bool LedDevicePhilipsHue::init(const QJsonObject &deviceConfig)
|
||||
{
|
||||
LedDevice::init(deviceConfig);
|
||||
|
||||
host = deviceConfig["output"].toString().toStdString().c_str();
|
||||
username = deviceConfig["username"].toString("newdeveloper").toStdString().c_str();
|
||||
switchOffOnBlack = deviceConfig["switchOffOnBlack"].toBool(true);
|
||||
|
@ -42,7 +42,9 @@ LedDevicePiBlaster::~LedDevicePiBlaster()
|
||||
|
||||
bool LedDevicePiBlaster::init(const QJsonObject &deviceConfig)
|
||||
{
|
||||
_deviceName = deviceConfig["output"].toString("").toStdString();
|
||||
LedDevice::init(deviceConfig);
|
||||
|
||||
_deviceName = deviceConfig["output"].toString("/dev/pi-blaster").toStdString();
|
||||
QJsonArray gpioMapping = deviceConfig["gpiomap"].toArray();
|
||||
|
||||
if (gpioMapping.isEmpty())
|
||||
|
@ -3,19 +3,10 @@
|
||||
// Use feature report HID device
|
||||
LedDeviceRawHID::LedDeviceRawHID(const QJsonObject &deviceConfig)
|
||||
: ProviderHID()
|
||||
, _timer()
|
||||
{
|
||||
ProviderHID::init(deviceConfig);
|
||||
_useFeature = true;
|
||||
_ledBuffer.resize(_ledRGBCount);
|
||||
|
||||
// setup the timer
|
||||
_timer.setSingleShot(false);
|
||||
_timer.setInterval(5000);
|
||||
connect(&_timer, SIGNAL(timeout()), this, SLOT(rewriteLeds()));
|
||||
|
||||
// start the timer
|
||||
_timer.start();
|
||||
}
|
||||
|
||||
LedDevice* LedDeviceRawHID::construct(const QJsonObject &deviceConfig)
|
||||
@ -25,9 +16,6 @@ LedDevice* LedDeviceRawHID::construct(const QJsonObject &deviceConfig)
|
||||
|
||||
int LedDeviceRawHID::write(const std::vector<ColorRgb> & ledValues)
|
||||
{
|
||||
// restart the timer
|
||||
_timer.start();
|
||||
|
||||
// write data
|
||||
memcpy(_ledBuffer.data(), ledValues.data(), _ledRGBCount);
|
||||
return writeBytes(_ledBuffer.size(), _ledBuffer.data());
|
||||
|
@ -36,9 +36,4 @@ private:
|
||||
/// @return Zero on succes else negative
|
||||
///
|
||||
virtual int write(const std::vector<ColorRgb> & ledValues);
|
||||
|
||||
/// Timer object which makes sure that led data is written at a minimum rate
|
||||
/// The RawHID device will switch off when it does not receive data at least
|
||||
/// every 15 seconds
|
||||
QTimer _timer;
|
||||
};
|
||||
|
@ -2,31 +2,31 @@
|
||||
<qresource prefix="/leddevices/">
|
||||
<file alias="schema-adalight">schemas/schema-adalight.json</file>
|
||||
<file alias="schema-apa102">schemas/schema-apa102.json</file>
|
||||
<file alias="schema-atmo">schemas/schema-atmo.json</file>
|
||||
<file alias="schema-atmoorb">schemas/schema-atmoorb.json</file>
|
||||
<file alias="schema-e131">schemas/schema-e131.json</file>
|
||||
<file alias="schema-atmo">schemas/schema-atmo.json</file>
|
||||
<file alias="schema-dmx">schemas/schema-dmx.json</file>
|
||||
<file alias="schema-fadecandy">schemas/schema-fadecandy.json</file>
|
||||
<file alias="schema-file">schemas/schema-file.json</file>
|
||||
<file alias="schema-hyperion-usbasp">schemas/schema-hyperion-usbasp.json</file>
|
||||
<file alias="schema-hyperionusbasp">schemas/schema-hyperionusbasp.json</file>
|
||||
<file alias="schema-lightpack">schemas/schema-lightpack.json</file>
|
||||
<file alias="schema-lpd6803">schemas/schema-lpd6803.json</file>
|
||||
<file alias="schema-lpd8806">schemas/schema-lpd8806.json</file>
|
||||
<file alias="schema-multi-lightpack">schemas/schema-multi-lightpack.json</file>
|
||||
<file alias="schema-multilightpack">schemas/schema-multilightpack.json</file>
|
||||
<file alias="schema-p9813">schemas/schema-p9813.json</file>
|
||||
<file alias="schema-paintpack">schemas/schema-paintpack.json</file>
|
||||
<file alias="schema-philipshue">schemas/schema-philipshue.json</file>
|
||||
<file alias="schema-piblaster">schemas/schema-piblaster.json</file>
|
||||
<file alias="schema-rawhid">schemas/schema-rawhid.json</file>
|
||||
<file alias="schema-sedu">schemas/schema-sedu.json</file>
|
||||
<file alias="schema-dmx">schemas/schema-dmx.json</file>
|
||||
<file alias="schema-sk6812spi">schemas/schema-sk6812spi.json</file>
|
||||
<file alias="schema-tinkerforge">schemas/schema-tinkerforge.json</file>
|
||||
<file alias="schema-tpm2net">schemas/schema-tpm2net.json</file>
|
||||
<file alias="schema-tpm2.json">schemas/schema-tpm2.json</file>
|
||||
<file alias="schema-tpm2">schemas/schema-tpm2.json</file>
|
||||
<file alias="schema-udpe131">schemas/schema-e131.json</file>
|
||||
<file alias="schema-udph801">schemas/schema-h801.json</file>
|
||||
<file alias="schema-udpraw">schemas/schema-udpraw.json</file>
|
||||
<file alias="schema-ws2801">schemas/schema-ws2801.json</file>
|
||||
<file alias="schema-ws2812spi">schemas/schema-ws2812spi.json</file>
|
||||
<file alias="schema-ws281x">schemas/schema-ws281x.json</file>
|
||||
<file alias="schema-h801">schemas/schema-h801.json</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
@ -33,6 +33,8 @@ LedDeviceTinkerforge::~LedDeviceTinkerforge()
|
||||
|
||||
bool LedDeviceTinkerforge::init(const QJsonObject &deviceConfig)
|
||||
{
|
||||
LedDevice::init(deviceConfig);
|
||||
|
||||
_host = deviceConfig["output"].toString("127.0.0.1").toStdString();
|
||||
_port = deviceConfig["port"].toInt(4223);
|
||||
_uid = deviceConfig["uid"].toString().toStdString();
|
||||
|
@ -18,6 +18,8 @@ LedDeviceWS281x::~LedDeviceWS281x()
|
||||
|
||||
bool LedDeviceWS281x::init(const QJsonObject &deviceConfig)
|
||||
{
|
||||
LedDevice::init(deviceConfig);
|
||||
|
||||
std::string whiteAlgorithm = deviceConfig["white_algorithm"].toString("white_off").toStdString();
|
||||
_whiteAlgorithm = RGBW::stringToWhiteAlgorithm(whiteAlgorithm);
|
||||
Debug( _log, "whiteAlgorithm : %s", whiteAlgorithm.c_str());
|
||||
|
@ -29,6 +29,8 @@ ProviderHID::~ProviderHID()
|
||||
|
||||
bool ProviderHID::init(const QJsonObject &deviceConfig)
|
||||
{
|
||||
LedDevice::init(deviceConfig);
|
||||
|
||||
_delayAfterConnect_ms = deviceConfig["delayAfterConnect"].toInt(0);
|
||||
auto VendorIdString = deviceConfig["VID"].toString("0x2341").toStdString();
|
||||
auto ProductIdString = deviceConfig["PID"].toString("0x8036").toStdString();
|
||||
|
@ -26,10 +26,12 @@ ProviderRs232::ProviderRs232()
|
||||
bool ProviderRs232::init(const QJsonObject &deviceConfig)
|
||||
{
|
||||
closeDevice();
|
||||
|
||||
LedDevice::init(deviceConfig);
|
||||
|
||||
_deviceName = deviceConfig["output"].toString().toStdString();
|
||||
_baudRate_Hz = deviceConfig["rate"].toInt();
|
||||
_delayAfterConnect_ms = deviceConfig["delayAfterConnect"].toInt(250);
|
||||
_refresh_timer.setInterval( deviceConfig["rewriteTime"].toInt(5000) );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -33,6 +33,8 @@ ProviderSpi::~ProviderSpi()
|
||||
|
||||
bool ProviderSpi::init(const QJsonObject &deviceConfig)
|
||||
{
|
||||
LedDevice::init(deviceConfig);
|
||||
|
||||
_deviceName = deviceConfig["output"].toString(QString::fromStdString(_deviceName)).toStdString();
|
||||
_baudRate_Hz = deviceConfig["rate"].toInt(_baudRate_Hz);
|
||||
_latchTime_ns = deviceConfig["latchtime"].toInt(_latchTime_ns);
|
||||
|
@ -30,6 +30,8 @@ ProviderUdp::~ProviderUdp()
|
||||
|
||||
bool ProviderUdp::init(const QJsonObject &deviceConfig, std::string defaultHost)
|
||||
{
|
||||
LedDevice::init(deviceConfig);
|
||||
|
||||
QString host = deviceConfig["host"].toString(QString::fromStdString(defaultHost));
|
||||
|
||||
if (_address.setAddress(host) )
|
||||
|
@ -5,6 +5,7 @@
|
||||
"output": {
|
||||
"type": "string",
|
||||
"title":"Output path",
|
||||
"default":"/dev/ttyACM0",
|
||||
"propertyOrder" : 1
|
||||
},
|
||||
"rate": {
|
||||
@ -20,19 +21,12 @@
|
||||
"append" : "ms",
|
||||
"propertyOrder" : 3
|
||||
},
|
||||
"rewriteTime": {
|
||||
"type": "integer",
|
||||
"title":"refresh time",
|
||||
"default": 5000,
|
||||
"append" : "ms",
|
||||
"propertyOrder" : 4
|
||||
},
|
||||
"lightberry_apa102_mode": {
|
||||
"type": "boolean",
|
||||
"format": "checkbox",
|
||||
"title":"LightBerry APA102 Mode",
|
||||
"default": false,
|
||||
"propertyOrder" : 5
|
||||
"propertyOrder" : 4
|
||||
}
|
||||
},
|
||||
"additionalProperties": true
|
||||
|
@ -19,13 +19,6 @@
|
||||
"default": 250,
|
||||
"append" : "ms",
|
||||
"propertyOrder" : 3
|
||||
},
|
||||
"rewriteTime": {
|
||||
"type": "integer",
|
||||
"title":"refresh time",
|
||||
"default": 5000,
|
||||
"append" : "ms",
|
||||
"propertyOrder" : 4
|
||||
}
|
||||
},
|
||||
"additionalProperties": true
|
||||
|
@ -2,10 +2,6 @@
|
||||
"type":"object",
|
||||
"required":true,
|
||||
"properties":{
|
||||
"output": {
|
||||
"type": "string",
|
||||
"title":"Serial number"
|
||||
}
|
||||
},
|
||||
"additionalProperties": true
|
||||
}
|
@ -2,6 +2,52 @@
|
||||
"type":"object",
|
||||
"required":true,
|
||||
"properties":{
|
||||
"output": {
|
||||
"type": "string",
|
||||
"title":"Pi-Blaster FiFo",
|
||||
"default" : "/dev/pi-blaster",
|
||||
"propertyOrder" : 1
|
||||
},
|
||||
"gpiomap": {
|
||||
"type": "array",
|
||||
"title":"GPIO Map",
|
||||
"propertyOrder" : 2,
|
||||
"minimum" : 1,
|
||||
"maximum" : 27,
|
||||
"items" : {
|
||||
"type" : "object",
|
||||
"required" : true,
|
||||
"properties" :
|
||||
{
|
||||
"gpio" :
|
||||
{
|
||||
"type" : "integer",
|
||||
"title" : "GPIO BCMxx",
|
||||
"minimum" : 0,
|
||||
"maximum" : 27,
|
||||
"required" : true,
|
||||
"propertyOrder" : 1
|
||||
},
|
||||
"ledindex" :
|
||||
{
|
||||
"type" : "integer",
|
||||
"title" : "LED index",
|
||||
"minimum" : 0,
|
||||
"required" : true,
|
||||
"propertyOrder" : 2
|
||||
},
|
||||
"ledcolor" :
|
||||
{
|
||||
"type" : "string",
|
||||
"title" : "Color component",
|
||||
"enum" : ["r","g","b","w"],
|
||||
"required" : true,
|
||||
"propertyOrder" : 3
|
||||
}
|
||||
}
|
||||
},
|
||||
"propertyOrder" : 3
|
||||
}
|
||||
},
|
||||
"additionalProperties": true
|
||||
}
|
||||
|
@ -18,13 +18,6 @@
|
||||
"title":"Delay after connect",
|
||||
"default": 250,
|
||||
"propertyOrder" : 3
|
||||
},
|
||||
"rewriteTime": {
|
||||
"type": "integer",
|
||||
"title":"refresh time",
|
||||
"default": 5000,
|
||||
"append" : "ms",
|
||||
"propertyOrder" : 4
|
||||
}
|
||||
},
|
||||
"additionalProperties": true
|
||||
|
@ -18,13 +18,6 @@
|
||||
"title":"Delay after connect",
|
||||
"default": 250,
|
||||
"propertyOrder" : 3
|
||||
},
|
||||
"rewriteTime": {
|
||||
"type": "integer",
|
||||
"title":"refresh time",
|
||||
"default": 5000,
|
||||
"append" : "ms",
|
||||
"propertyOrder" : 4
|
||||
}
|
||||
},
|
||||
"additionalProperties": true
|
||||
|
Loading…
Reference in New Issue
Block a user