refactor: Led layout, clearAll (#703)

* add SSDP name field

* YALL - yet another led layout

* led layout migration

* add initial vscode config

* merge clearAll with clear, rename Hyperion::compStateChange

* simpler components api

* Corrected code formatting

+ triggered PR build

* fix: regression from #636

* Support for color patterns

Co-authored-by: Paulchen Panther <16664240+Paulchen-Panther@users.noreply.github.com>
This commit is contained in:
brindosch 2020-02-26 18:54:56 +01:00 committed by GitHub
parent ef51d28463
commit 8db85c9a5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
47 changed files with 656 additions and 738 deletions

18
.vscode/c_cpp_properties.json vendored Normal file
View File

@ -0,0 +1,18 @@
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"/usr/include/**"
],
"defines": [],
"compilerPath": "/usr/bin/gcc-5",
"intelliSenseMode": "gcc-x64",
"cppStandard": "c++11",
"cStandard": "c11",
"configurationProvider": "ms-vscode.cmake-tools"
}
],
"version": 4
}

View File

@ -40,10 +40,10 @@ function createLedPreview(leds, origin){
var led = leds[idx];
var led_id='ledc_'+[idx];
var bgcolor = "background-color:hsl("+(idx*360/leds.length)+",100%,50%);";
var pos = "left:"+(led.h.min * canvas_width)+"px;"+
"top:"+(led.v.min * canvas_height)+"px;"+
"width:"+((led.h.max-led.h.min) * (canvas_width-1))+"px;"+
"height:"+((led.v.max-led.v.min) * (canvas_height-1))+"px;";
var pos = "left:"+(led.hmin * canvas_width)+"px;"+
"top:"+(led.vmin * canvas_height)+"px;"+
"width:"+((led.hmax-led.hmin) * (canvas_width-1))+"px;"+
"height:"+((led.vmax-led.vmin) * (canvas_height-1))+"px;";
leds_html += '<div id="'+led_id+'" class="led" style="'+bgcolor+pos+'" title="'+idx+'"><span id="'+led_id+'_num" class="led_prev_num">'+idx+'</span></div>';
}
$('#leds_preview').html(leds_html);
@ -91,11 +91,11 @@ function createClassicLeds(){
function createFinalArray(array){
finalLedArray = [];
for(var i = 0; i<array.length; i++){
var hmin = array[i].h.min;
var hmax = array[i].h.max;
var vmin = array[i].v.min;
var vmax = array[i].v.max;
finalLedArray[i] = { "h": { "max" : hmax, "min" : hmin }, "v": { "max": vmax, "min": vmin}}
var hmin = array[i].hmin;
var hmax = array[i].hmax;
var vmin = array[i].vmin;
var vmax = array[i].vmax;
finalLedArray[i] = { "hmax": hmax, "hmin": hmin, "vmax": vmax, "vmin": vmin }
}
createLedPreview(finalLedArray, 'classic');
}
@ -138,7 +138,7 @@ function createClassicLeds(){
hmax = round(hmax);
vmin = round(vmin);
vmax = round(vmax);
ledArray.push( { "h" : { "min" : hmin, "max" : hmax }, "v": { "min": vmin, "max": vmax }} );
ledArray.push({ "hmin": hmin, "hmax": hmax, "vmin": vmin, "vmax": vmax });
}
function createTopLeds(){
@ -268,14 +268,10 @@ function createMatrixLeds(){
vscanMax = round(vscanMax);
leds.push({
h: {
min: hscanMin,
max: hscanMax
},
v: {
min: vscanMin,
max: vscanMax
}
hmin: hscanMin,
hmax: hscanMax,
vmin: vscanMin,
vmax: vscanMax
})
}
@ -446,7 +442,7 @@ $(document).ready(function() {
});
// v4 of json schema with diff required assignment - remove when hyperion schema moved to v4
var ledschema = {"items":{"additionalProperties":false,"required":["h","v"],"properties":{"colorOrder":{"enum":["rgb","bgr","rbg","brg","gbr","grb"],"type":"string"},"h":{"additionalProperties":false,"properties":{"max":{"maximum":1,"minimum":0,"type":"number"},"min":{"maximum":1,"minimum":0,"type":"number"}},"type":"object"},"v":{"additionalProperties":false,"properties":{"max":{"maximum":1,"minimum":0,"type":"number"},"min":{"maximum":1,"minimum":0,"type":"number"}},"type":"object"}},"type":"object"},"type":"array"};
var ledschema = { "items": { "additionalProperties": false, "required": ["hmin", "hmax", "vmin", "vmax"], "properties": { "name": { "type": "string" }, "colorOrder": { "enum": ["rgb", "bgr", "rbg", "brg", "gbr", "grb"], "type": "string" }, "hmin": { "maximum": 1, "minimum": 0, "type": "number" }, "hmax": { "maximum": 1, "minimum": 0, "type": "number" }, "vmin": { "maximum": 1, "minimum": 0, "type": "number" }, "vmax": { "maximum": 1, "minimum": 0, "type": "number" } }, "type": "object" }, "type": "array" };
//create jsonace editor
aceEdt = new JSONACEEditor(document.getElementById("aceedit"),{
mode: 'code',

View File

@ -22,7 +22,7 @@ $(document).ready(function() {
for(var idx=0; idx<leds.length; idx++)
{
var led = leds[idx];
twoDPaths.push( build2DPath(led.h.min * canvas_width, led.v.min * canvas_height, (led.h.max-led.h.min) * canvas_width, (led.v.max-led.v.min) * canvas_height, 5) );
twoDPaths.push( build2DPath(led.hmin * canvas_width, led.vmin * canvas_height, (led.hmax-led.hmin) * canvas_width, (led.vmax-led.vmin) * canvas_height, 5) );
}
}
@ -144,8 +144,8 @@ $(document).ready(function() {
{
var led = leds[idx];
// can be used as fallback when Path2D is not available
//roundRect(ledsCanvasNodeCtx, led.h.min * canvas_width, led.v.min * canvas_height, (led.h.max-led.h.min) * canvas_width, (led.v.max-led.v.min) * canvas_height, 4, true, colors[idx])
//ledsCanvasNodeCtx.fillRect(led.h.min * canvas_width, led.v.min * canvas_height, (led.h.max-led.h.min) * canvas_width, (led.v.max-led.v.min) * canvas_height);
//roundRect(ledsCanvasNodeCtx, led.hmin * canvas_width, led.vmin * canvas_height, (led.hmax-led.hmin) * canvas_width, (led.vmax-led.vmin) * canvas_height, 4, true, colors[idx])
//ledsCanvasNodeCtx.fillRect(led.hmin * canvas_width, led.vmin * canvas_height, (led.hmax-led.hmin) * canvas_width, (led.vmax-led.vmin) * canvas_height);
ledsCanvasNodeCtx.fillStyle = (useColor) ? "rgba("+colors[cPos]+","+colors[cPos+1]+","+colors[cPos+2]+",0.9)" : "hsl("+(idx*360/leds.length)+",100%,50%)";
ledsCanvasNodeCtx.fill(twoDPaths[idx]);
@ -155,7 +155,7 @@ $(document).ready(function() {
{
ledsCanvasNodeCtx.fillStyle = "blue";
ledsCanvasNodeCtx.textAlign = "center";
ledsCanvasNodeCtx.fillText(idx, (led.h.min * canvas_width) + ( ((led.h.max-led.h.min) * canvas_width) / 2), (led.v.min * canvas_height) + ( ((led.v.max-led.v.min) * canvas_height) / 2));
ledsCanvasNodeCtx.fillText(idx, (led.hmin * canvas_width) + ( ((led.hmax-led.hmin) * canvas_width) / 2), (led.vmin * canvas_height) + ( ((led.vmax-led.vmin) * canvas_height) / 2));
}
// increment colorsPosition

View File

@ -518,11 +518,11 @@ $('#btn_wizard_colorcalibration').off().on('click', startWizardCC);
var hueIPs = [];
var hueIPsinc = 0;
var lightIDs = null;
var huePosTop = {h: {max: 0.85, min: 0.15}, v: {max: 0.2, min: 0}};
var huePosBottom = {h: {max: 0.85, min: 0.15}, v: {max: 1, min: 0.8}};
var huePosLeft = {h: {max: 0.15, min: 0}, v: {max: 0.85, min: 0.15}};
var huePosRight = {h: {max: 1, min: 0.85}, v: {max: 0.85, min: 0.15}};
var huePosEntire = {h: {max: 1.0, min: 0.0}, v: {max: 1.0, min: 0.0}};
var huePosTop = {hmax: 0.85, hmin: 0.15, vmax: 0.2, vmin: 0};
var huePosBottom = {hmax: 0.85, hmin: 0.15, vmax: 1, vmin: 0.8};
var huePosLeft = {hmax: 0.15, hmin: 0, vmax: 0.85, vmin: 0.15};
var huePosRight = {hmax: 1, hmin: 0.85, vmax: 0.85, vmin: 0.15};
var huePosEntire = {hmax: 1.0, hmin: 0.0, vmax: 1.0, vmin: 0.0};
function startWizardPhilipsHue()
{

View File

@ -6,6 +6,7 @@ execute_process( COMMAND sh -c "git remote --verbose | grep origin | grep fetch
STRING ( STRIP "${BUILD_ID}" BUILD_ID )
STRING ( STRIP "${VERSION_ID}" VERSION_ID )
STRING ( STRIP "${GIT_REMOTE_PATH}" GIT_REMOTE_PATH )
SET ( HYPERION_BUILD_ID "${VERSION_ID} (${BUILD_ID}) Git Remote: ${GIT_REMOTE_PATH}" )
SET ( HYPERION_BUILD_ID "${VERSION_ID} (${BUILD_ID})" )
SET ( HYPERION_GIT_REMOTE "${GIT_REMOTE_PATH}" )
message ( STATUS "Current Version: ${HYPERION_VERSION}" )
message ( STATUS " - Build: ${HYPERION_BUILD_ID}" )

View File

@ -325,6 +325,8 @@
/// Recreate and save led layouts made with web config. These values are just helpers for ui, not for Hyperion.
"ledConfig" :
{
"classic":
{
"top" : 8,
"bottom" : 8,
@ -338,277 +340,185 @@
"vdepth" : 5,
"overlap" : 0,
"edgegap" : 0
},
"matrix":
{
"ledshoriz": 10,
"ledsvert" : 10,
"cabling" : "snake",
"start" : "top-left"
}
},
/// The configuration for each individual led. This contains the specification of the area
/// averaged of an input image for each led to determine its color. Each item in the list
/// contains the following fields:
/// * h: The fractional part of the image along the horizontal used for the averaging
/// (min and max inclusive)
/// * v: The fractional part of the image along the vertical used for the averaging
/// (min and max inclusive)
/// * hmin: The fractional part of the image along the horizontal used for the averaging (minimum)
/// * hmax: The fractional part of the image along the horizontal used for the averaging (maximum)
/// * vmin: The fractional part of the image along the vertical used for the averaging (minimum)
/// * vmax: The fractional part of the image along the vertical used for the averaging (maximum)
/// * colorOrder: Usually the global colorOrder is set at the device section, you can overwrite it here per led
"leds":
[
{
"h": {
"max": 0.125,
"min": 0
},
"v": {
"max": 0.08,
"min": 0
}
"hmax": 0.125,
"hmin": 0,
"vmax": 0.08,
"vmin": 0
},
{
"h": {
"max": 0.25,
"min": 0.125
},
"v": {
"max": 0.08,
"min": 0
}
"hmax": 0.25,
"hmin": 0.125,
"vmax": 0.08,
"vmin": 0
},
{
"h": {
"max": 0.375,
"min": 0.25
},
"v": {
"max": 0.08,
"min": 0
}
"hmax": 0.375,
"hmin": 0.25,
"vmax": 0.08,
"vmin": 0
},
{
"h": {
"max": 0.5,
"min": 0.375
},
"v": {
"max": 0.08,
"min": 0
}
"hmax": 0.5,
"hmin": 0.375,
"vmax": 0.08,
"vmin": 0
},
{
"h": {
"max": 0.625,
"min": 0.5
},
"v": {
"max": 0.08,
"min": 0
}
"hmax": 0.625,
"hmin": 0.5,
"vmax": 0.08,
"vmin": 0
},
{
"h": {
"max": 0.75,
"min": 0.625
},
"v": {
"max": 0.08,
"min": 0
}
"hmax": 0.75,
"hmin": 0.625,
"vmax": 0.08,
"vmin": 0
},
{
"h": {
"max": 0.875,
"min": 0.75
},
"v": {
"max": 0.08,
"min": 0
}
"hmax": 0.875,
"hmin": 0.75,
"vmax": 0.08,
"vmin": 0
},
{
"h": {
"max": 1,
"min": 0.875
},
"v": {
"max": 0.08,
"min": 0
}
"hmax": 1,
"hmin": 0.875,
"vmax": 0.08,
"vmin": 0
},
{
"h": {
"max": 1,
"min": 0.95
},
"v": {
"max": 0.2,
"min": 0
}
"hmax": 1,
"hmin": 0.95,
"vmax": 0.2,
"vmin": 0
},
{
"h": {
"max": 1,
"min": 0.95
},
"v": {
"max": 0.4,
"min": 0.2
}
"hmax": 1,
"hmin": 0.95,
"vmax": 0.4,
"vmin": 0.2
},
{
"h": {
"max": 1,
"min": 0.95
},
"v": {
"max": 0.6,
"min": 0.4
}
"hmax": 1,
"hmin": 0.95,
"vmax": 0.6,
"vmin": 0.4
},
{
"h": {
"max": 1,
"min": 0.95
},
"v": {
"max": 0.8,
"min": 0.6
}
"hmax": 1,
"hmin": 0.95,
"vmax": 0.8,
"vmin": 0.6
},
{
"h": {
"max": 1,
"min": 0.95
},
"v": {
"max": 1,
"min": 0.8
}
"hmax": 1,
"hmin": 0.95,
"vmax": 1,
"vmin": 0.8
},
{
"h": {
"max": 1,
"min": 0.875
},
"v": {
"max": 1,
"min": 0.92
}
"hmax": 1,
"hmin": 0.875,
"vmax": 1,
"vmin": 0.92
},
{
"h": {
"max": 0.875,
"min": 0.75
},
"v": {
"max": 1,
"min": 0.92
}
"hmax": 0.875,
"hmin": 0.75,
"vmax": 1,
"vmin": 0.92
},
{
"h": {
"max": 0.75,
"min": 0.625
},
"v": {
"max": 1,
"min": 0.92
}
"hmax": 0.75,
"hmin": 0.625,
"vmax": 1,
"vmin": 0.92
},
{
"h": {
"max": 0.625,
"min": 0.5
},
"v": {
"max": 1,
"min": 0.92
}
"hmax": 0.625,
"hmin": 0.5,
"vmax": 1,
"vmin": 0.92
},
{
"h": {
"max": 0.5,
"min": 0.375
},
"v": {
"max": 1,
"min": 0.92
}
"hmax": 0.5,
"hmin": 0.375,
"vmax": 1,
"vmin": 0.92
},
{
"h": {
"max": 0.375,
"min": 0.25
},
"v": {
"max": 1,
"min": 0.92
}
"hmax": 0.375,
"hmin": 0.25,
"vmax": 1,
"vmin": 0.92
},
{
"h": {
"max": 0.25,
"min": 0.125
},
"v": {
"max": 1,
"min": 0.92
}
"hmax": 0.25,
"hmin": 0.125,
"vmax": 1,
"vmin": 0.92
},
{
"h": {
"max": 0.125,
"min": 0
},
"v": {
"max": 1,
"min": 0.92
}
"hmax": 0.125,
"hmin": 0,
"vmax": 1,
"vmin": 0.92
},
{
"h": {
"max": 0.05,
"min": 0
},
"v": {
"max": 1,
"min": 0.8
}
"hmax": 0.05,
"hmin": 0,
"vmax": 1,
"vmin": 0.8
},
{
"h": {
"max": 0.05,
"min": 0
},
"v": {
"max": 0.8,
"min": 0.6
}
"hmax": 0.05,
"hmin": 0,
"vmax": 0.8,
"vmin": 0.6
},
{
"h": {
"max": 0.05,
"min": 0
},
"v": {
"max": 0.6,
"min": 0.4
}
"hmax": 0.05,
"hmin": 0,
"vmax": 0.6,
"vmin": 0.4
},
{
"h": {
"max": 0.05,
"min": 0
},
"v": {
"max": 0.4,
"min": 0.2
}
"hmax": 0.05,
"hmin": 0,
"vmax": 0.4,
"vmin": 0.2
},
{
"h": {
"max": 0.05,
"min": 0
},
"v": {
"max": 0.2,
"min": 0
}
"hmax": 0.05,
"hmin": 0,
"vmax": 0.2,
"vmin": 0
}
]
}

View File

@ -216,264 +216,160 @@
"leds":
[
{
"h": {
"max": 0.125,
"min": 0
},
"v": {
"max": 0.08,
"min": 0
}
"hmax": 0.125,
"hmin": 0,
"vmax": 0.08,
"vmin": 0
},
{
"h": {
"max": 0.25,
"min": 0.125
},
"v": {
"max": 0.08,
"min": 0
}
"hmax": 0.25,
"hmin": 0.125,
"vmax": 0.08,
"vmin": 0
},
{
"h": {
"max": 0.375,
"min": 0.25
},
"v": {
"max": 0.08,
"min": 0
}
"hmax": 0.375,
"hmin": 0.25,
"vmax": 0.08,
"vmin": 0
},
{
"h": {
"max": 0.5,
"min": 0.375
},
"v": {
"max": 0.08,
"min": 0
}
"hmax": 0.5,
"hmin": 0.375,
"vmax": 0.08,
"vmin": 0
},
{
"h": {
"max": 0.625,
"min": 0.5
},
"v": {
"max": 0.08,
"min": 0
}
"hmax": 0.625,
"hmin": 0.5,
"vmax": 0.08,
"vmin": 0
},
{
"h": {
"max": 0.75,
"min": 0.625
},
"v": {
"max": 0.08,
"min": 0
}
"hmax": 0.75,
"hmin": 0.625,
"vmax": 0.08,
"vmin": 0
},
{
"h": {
"max": 0.875,
"min": 0.75
},
"v": {
"max": 0.08,
"min": 0
}
"hmax": 0.875,
"hmin": 0.75,
"vmax": 0.08,
"vmin": 0
},
{
"h": {
"max": 1,
"min": 0.875
},
"v": {
"max": 0.08,
"min": 0
}
"hmax": 1,
"hmin": 0.875,
"vmax": 0.08,
"vmin": 0
},
{
"h": {
"max": 1,
"min": 0.95
},
"v": {
"max": 0.2,
"min": 0
}
"hmax": 1,
"hmin": 0.95,
"vmax": 0.2,
"vmin": 0
},
{
"h": {
"max": 1,
"min": 0.95
},
"v": {
"max": 0.4,
"min": 0.2
}
"hmax": 1,
"hmin": 0.95,
"vmax": 0.4,
"vmin": 0.2
},
{
"h": {
"max": 1,
"min": 0.95
},
"v": {
"max": 0.6,
"min": 0.4
}
"hmax": 1,
"hmin": 0.95,
"vmax": 0.6,
"vmin": 0.4
},
{
"h": {
"max": 1,
"min": 0.95
},
"v": {
"max": 0.8,
"min": 0.6
}
"hmax": 1,
"hmin": 0.95,
"vmax": 0.8,
"vmin": 0.6
},
{
"h": {
"max": 1,
"min": 0.95
},
"v": {
"max": 1,
"min": 0.8
}
"hmax": 1,
"hmin": 0.95,
"vmax": 1,
"vmin": 0.8
},
{
"h": {
"max": 1,
"min": 0.875
},
"v": {
"max": 1,
"min": 0.92
}
"hmax": 1,
"hmin": 0.875,
"vmax": 1,
"vmin": 0.92
},
{
"h": {
"max": 0.875,
"min": 0.75
},
"v": {
"max": 1,
"min": 0.92
}
"hmax": 0.875,
"hmin": 0.75,
"vmax": 1,
"vmin": 0.92
},
{
"h": {
"max": 0.75,
"min": 0.625
},
"v": {
"max": 1,
"min": 0.92
}
"hmax": 0.75,
"hmin": 0.625,
"vmax": 1,
"vmin": 0.92
},
{
"h": {
"max": 0.625,
"min": 0.5
},
"v": {
"max": 1,
"min": 0.92
}
"hmax": 0.625,
"hmin": 0.5,
"vmax": 1,
"vmin": 0.92
},
{
"h": {
"max": 0.5,
"min": 0.375
},
"v": {
"max": 1,
"min": 0.92
}
"hmax": 0.5,
"hmin": 0.375,
"vmax": 1,
"vmin": 0.92
},
{
"h": {
"max": 0.375,
"min": 0.25
},
"v": {
"max": 1,
"min": 0.92
}
"hmax": 0.375,
"hmin": 0.25,
"vmax": 1,
"vmin": 0.92
},
{
"h": {
"max": 0.25,
"min": 0.125
},
"v": {
"max": 1,
"min": 0.92
}
"hmax": 0.25,
"hmin": 0.125,
"vmax": 1,
"vmin": 0.92
},
{
"h": {
"max": 0.125,
"min": 0
},
"v": {
"max": 1,
"min": 0.92
}
"hmax": 0.125,
"hmin": 0,
"vmax": 1,
"vmin": 0.92
},
{
"h": {
"max": 0.05,
"min": 0
},
"v": {
"max": 1,
"min": 0.8
}
"hmax": 0.05,
"hmin": 0,
"vmax": 1,
"vmin": 0.8
},
{
"h": {
"max": 0.05,
"min": 0
},
"v": {
"max": 0.8,
"min": 0.6
}
"hmax": 0.05,
"hmin": 0,
"vmax": 0.8,
"vmin": 0.6
},
{
"h": {
"max": 0.05,
"min": 0
},
"v": {
"max": 0.6,
"min": 0.4
}
"hmax": 0.05,
"hmin": 0,
"vmax": 0.6,
"vmin": 0.4
},
{
"h": {
"max": 0.05,
"min": 0
},
"v": {
"max": 0.4,
"min": 0.2
}
"hmax": 0.05,
"hmin": 0,
"vmax": 0.4,
"vmin": 0.2
},
{
"h": {
"max": 0.05,
"min": 0
},
"v": {
"max": 0.2,
"min": 0
}
"hmax": 0.05,
"hmin": 0,
"vmax": 0.2,
"vmin": 0
}
]
}

View File

@ -105,7 +105,7 @@ namespace hyperion
///
/// @brief Handle component state changes, it's not possible for BB to be enabled, when a hardDisable is active
///
void componentStateChanged(const hyperion::Components component, bool enable);
void handleCompStateChangeRequest(const hyperion::Components component, bool enable);
private:
/// Hyperion instance

View File

@ -54,7 +54,7 @@ public slots:
///
void stop();
void componentStateChanged(const hyperion::Components component, bool enable);
void compStateChangeRequest(const hyperion::Components component, bool enable);
///
/// @brief Handle settings update from Hyperion Settingsmanager emit or this constructor

View File

@ -90,7 +90,7 @@ public slots:
void stop();
void componentStateChanged(const hyperion::Components component, bool enable);
void compStateChangeRequest(const hyperion::Components component, bool enable);
signals:
void newFrame(const Image<ColorRgb> & image);

View File

@ -27,7 +27,7 @@ public slots:
void setDeviceVideoStandard(QString device, VideoStandard videoStandard);
signals:
void componentStateChanged(const hyperion::Components component, bool enable);
void compStateChangeRequest(const hyperion::Components component, bool enable);
private slots:
void newFrame(const Image<ColorRgb> & image);

View File

@ -46,13 +46,15 @@ private slots:
const QJsonValue bgColorConfig = BGEffectConfig["color"];
if (bgTypeConfig.contains("color"))
{
ColorRgb bg_color = {
std::vector<ColorRgb> bg_color = {
ColorRgb {
(uint8_t)BGCONFIG_ARRAY.at(0).toInt(0),
(uint8_t)BGCONFIG_ARRAY.at(1).toInt(0),
(uint8_t)BGCONFIG_ARRAY.at(2).toInt(0)
}
};
_hyperion->setColor(254, bg_color);
Info(Logger::getInstance("HYPERION"),"Inital background color set (%d %d %d)",bg_color.red,bg_color.green,bg_color.blue);
Info(Logger::getInstance("HYPERION"),"Inital background color set (%d %d %d)",bg_color.at(0).red, bg_color.at(0).green, bg_color.at(0).blue);
}
else
{

View File

@ -28,7 +28,7 @@ private slots:
/// @param component The component from enum
/// @param enable The new state
///
void componentStateChanged(const hyperion::Components component, bool enable);
void handleCompStateChangeRequest(const hyperion::Components component, bool enable);
///
/// @brief Handle settings update from Hyperion Settingsmanager emit or this constructor

View File

@ -22,14 +22,6 @@ public:
ComponentRegister(Hyperion* hyperion);
~ComponentRegister();
///
/// @brief Enable or disable Hyperion (all components)
/// @param state The new state of Hyperion
///
/// @return Returns true on success, false when Hyperion is already at the requested state
///
bool setHyperionEnable(const bool& state);
///
/// @brief Check if a component is currently enabled
/// @param comp The component from enum
@ -50,11 +42,17 @@ signals:
public slots:
///
/// @brief is called whenever a component change a state, DO NOT CALL FROM API (use hyperion->setComponentState() instead)
/// @brief is called whenever a component change a state, DO NOT CALL FROM API, use signal hyperion->compStateChangeRequest
/// @param comp The component
/// @param state The new state of the component
///
void componentStateChanged(const hyperion::Components comp, const bool activated);
void setNewComponentState(const hyperion::Components comp, const bool activated);
private slots:
///
/// @brief Handle COMP_ALL changes from Hyperion->compStateChangeRequest
///
void handleCompStateChangeRequest(const hyperion::Components comp, const bool activated);
private:
/// Hyperion instance
@ -65,4 +63,6 @@ private:
std::map<hyperion::Components, bool> _componentStates;
/// on hyperion off we save the previous states of all components
std::map<hyperion::Components, bool> _prevComponentStates;
// helper to prevent self emit chains
bool _inProgress = false;
};

View File

@ -101,7 +101,7 @@ signals:
///
/// @brief PIPE component state changes from HyperionDaemon to V4L2Grabber
///
void componentStateChanged(const hyperion::Components component, bool enable);
void compStateChangeRequest(const hyperion::Components component, bool enable);
protected:
ImageResampler _imageResampler;

View File

@ -206,12 +206,17 @@ public:
void setNewComponentState(const hyperion::Components& component, const bool& state);
///
/// @brief Enable/Disable components during runtime, called from external API (requests)
/// @brief Get a list of all contrable components and their current state
/// @return list of components
///
/// @param component The component from enum
/// @param state The state of the component [true | false]
std::map<hyperion::Components, bool> getAllComponents();
///
void setComponentState(const hyperion::Components component, const bool state);
/// @brief Test if a component is enabled
/// @param The component to test
/// @return Component state
///
int isComponentEnabled(const hyperion::Components& comp);
ComponentRegister& getComponentRegister() { return _componentRegister; };
@ -278,12 +283,12 @@ public slots:
/// Should be never used to update leds continuous
///
/// @param[in] priority The priority of the written color
/// @param[in] ledColor The color to write to the leds
/// @param[in] ledColors The color to write to the leds
/// @param[in] timeout_ms The time the leds are set to the given color [ms]
/// @param[in] origin The setter
/// @param clearEffect Should be true when NOT called from an effect
///
void setColor(const int priority, const ColorRgb &ledColor, const int timeout_ms = -1, const QString& origin = "System" ,bool clearEffects = true);
void setColor(const int priority, const std::vector<ColorRgb> &ledColors, const int timeout_ms = -1, const QString& origin = "System" ,bool clearEffects = true);
///
/// @brief Set the given priority to inactive
@ -311,15 +316,11 @@ public slots:
/// Clears the given priority channel. This will switch the led-colors to the colors of the next
/// lower priority channel (or off if no more channels are set)
///
/// @param[in] priority The priority channel
/// @param[in] priority The priority channel. -1 clears all priorities
/// @param[in] forceClearAll Force the clear
/// @return True on success else false (not found)
///
bool clear(const int priority);
///
/// @brief Clears all priority channels. This will switch the leds off until a new priority is written.
///
void clearall(bool forceClearAll=false);
bool clear(const int priority, bool forceClearAll=false);
/// Run the specified effect on the given priority channel and optionally specify a timeout
/// @param effectName Name of the effec to run
@ -375,7 +376,7 @@ signals:
/// @param component The component from enum
/// @param enabled The new state of the component
///
void componentStateChanged(const hyperion::Components component, bool enabled);
void compStateChangeRequest(const hyperion::Components component, bool enabled);
///
/// @brief Emits whenever the imageToLedsMapping has changed

View File

@ -130,7 +130,7 @@ signals:
///
/// @brief PIPE component state changes from Hyperion to HyperionDaemon
///
void componentStateChanged(const hyperion::Components component, bool enable);
void compStateChangeRequest(const hyperion::Components component, bool enable);
private slots:
///

View File

@ -52,7 +52,7 @@ private slots:
/// @param component The component from enum
/// @param enable The new state
///
void componentStateChanged(const hyperion::Components component, bool enable);
void handleCompStateChangeRequest(const hyperion::Components component, bool enable);
///
/// @brief Handle priority updates from Priority Muxer

View File

@ -53,6 +53,14 @@ signals:
void settingsChanged(const settings::type& type, const QJsonDocument& data);
private:
///
/// @brief Add possile migrations steps for config here
/// @param config The configuration object
/// @return True when a migration has been triggered
///
bool handleConfigUpgrade(QJsonObject& config);
/// Hyperion instance
Hyperion* _hyperion;

View File

@ -19,7 +19,7 @@ class QNetworkConfigurationManager;
class SSDPHandler : public SSDPServer{
Q_OBJECT
public:
SSDPHandler(WebServer* webserver, const quint16& flatBufPort, const quint16& jsonServerPort, QObject * parent = nullptr);
SSDPHandler(WebServer* webserver, const quint16& flatBufPort, const quint16& jsonServerPort, const QString &name, QObject * parent = nullptr);
~SSDPHandler();
public slots:

View File

@ -93,6 +93,17 @@ public:
///
quint16 getJsonServerPort() { return _jssPort.toInt(); };
///
/// @brief set new hyperion name
///
void setHyperionName(const QString &name) { _name = name; };
///
/// @brief get hyperion name
///
QString getHyperionName() { return _name; };
signals:
///
/// @brief Emits whenever a new SSDP search "man : ssdp:discover" is received along with the service type
@ -111,6 +122,7 @@ private:
QString _uuid;
QString _fbsPort;
QString _jssPort;
QString _name;
QString _descAddress;
bool _running;

View File

@ -58,14 +58,10 @@ signals:
///
/// @brief PIPE the clear command for the global priority channel over HyperionDaemon to Hyperion class
/// @param[in] priority The priority channel
/// @param[in] priority The priority channel (-1 to clear all possible priorities)
/// @param[in] forceclearAll Force the clear
///
void clearGlobalInput(int priority);
///
/// @brief PIPE the clearAll command over HyperionDaemon to Hyperion class
///
void clearAllGlobalInput(bool forceClearAll=false);
void clearGlobalInput(int priority, bool forceClearAll=false);
///
/// @brief PIPE external images over HyperionDaemon to Hyperion class
@ -84,7 +80,7 @@ signals:
/// @param[in] origin The setter
/// @param clearEffect Should be true when NOT called from an effect
///
void setGlobalColor(const int priority, const ColorRgb &ledColor, const int timeout_ms, const QString& origin = "External" ,bool clearEffects = true);
void setGlobalColor(const int priority, const std::vector<ColorRgb> &ledColor, const int timeout_ms, const QString& origin = "External" ,bool clearEffects = true);
///////////////////////////////////////
//////////// FROM HYPERION ////////////

View File

@ -34,13 +34,15 @@ namespace hyperion {
}
if ( fgTypeConfig.contains("color") )
{
ColorRgb fg_color = {
std::vector<ColorRgb> fg_color = {
ColorRgb {
(uint8_t)FGCONFIG_ARRAY.at(0).toInt(0),
(uint8_t)FGCONFIG_ARRAY.at(1).toInt(0),
(uint8_t)FGCONFIG_ARRAY.at(2).toInt(0)
}
};
hyperion->setColor(FG_PRIORITY, fg_color, fg_duration_ms);
Info(Logger::getInstance("HYPERION"),"Initial foreground color set (%d %d %d)",fg_color.red,fg_color.green,fg_color.blue);
Info(Logger::getInstance("HYPERION"),"Initial foreground color set (%d %d %d)",fg_color.at(0).red,fg_color.at(0).green,fg_color.at(0).blue);
}
else
{
@ -195,15 +197,13 @@ namespace hyperion {
for (signed i = 0; i < ledConfigArray.size(); ++i)
{
const QJsonObject& index = ledConfigArray[i].toObject();
const QJsonObject& ledConfig = ledConfigArray[i].toObject();
Led led;
const QJsonObject& hscanConfig = ledConfigArray[i].toObject()["h"].toObject();
const QJsonObject& vscanConfig = ledConfigArray[i].toObject()["v"].toObject();
led.minX_frac = qMax(0.0, qMin(1.0, hscanConfig["min"].toDouble()));
led.maxX_frac = qMax(0.0, qMin(1.0, hscanConfig["max"].toDouble()));
led.minY_frac = qMax(0.0, qMin(1.0, vscanConfig["min"].toDouble()));
led.maxY_frac = qMax(0.0, qMin(1.0, vscanConfig["max"].toDouble()));
led.minX_frac = qMax(0.0, qMin(1.0, ledConfig["hmin"].toDouble()));
led.maxX_frac = qMax(0.0, qMin(1.0, ledConfig["hmax"].toDouble()));
led.minY_frac = qMax(0.0, qMin(1.0, ledConfig["vmin"].toDouble()));
led.maxY_frac = qMax(0.0, qMin(1.0, ledConfig["vmax"].toDouble()));
// Fix if the user swapped min and max
if (led.minX_frac > led.maxX_frac)
{
@ -215,7 +215,7 @@ namespace hyperion {
}
// Get the order of the rgb channels for this led (default is device order)
led.colorOrder = stringToColorOrder(index["colorOrder"].toString(deviceOrderStr));
led.colorOrder = stringToColorOrder(ledConfig["colorOrder"].toString(deviceOrderStr));
ledString.leds().push_back(led);
}
return ledString;
@ -228,12 +228,12 @@ namespace hyperion {
for (signed i = 0; i < ledConfigArray.size(); ++i)
{
const QJsonObject& hscanConfig = ledConfigArray[i].toObject()["h"].toObject();
const QJsonObject& vscanConfig = ledConfigArray[i].toObject()["v"].toObject();
double minX_frac = qMax(0.0, qMin(1.0, hscanConfig["min"].toDouble()));
double maxX_frac = qMax(0.0, qMin(1.0, hscanConfig["max"].toDouble()));
double minY_frac = qMax(0.0, qMin(1.0, vscanConfig["min"].toDouble()));
double maxY_frac = qMax(0.0, qMin(1.0, vscanConfig["max"].toDouble()));
const QJsonObject& ledConfig = ledConfigArray[i].toObject();
double minX_frac = qMax(0.0, qMin(1.0, ledConfig["hmin"].toDouble()));
double maxX_frac = qMax(0.0, qMin(1.0, ledConfig["hmax"].toDouble()));
double minY_frac = qMax(0.0, qMin(1.0, ledConfig["vmin"].toDouble()));
double maxY_frac = qMax(0.0, qMin(1.0, ledConfig["vmax"].toDouble()));
// Fix if the user swapped min and max
if (minX_frac > maxX_frac)
{

View File

@ -204,17 +204,29 @@ void JsonAPI::handleMessage(const QString& messageString, const QString& httpAut
void JsonAPI::handleColorCommand(const QJsonObject& message, const QString& command, const int tan)
{
emit forwardJsonMessage(message);
// extract parameters
int priority = message["priority"].toInt();
int duration = message["duration"].toInt(-1);
const QString origin = message["origin"].toString("JsonRpc") + "@"+_peerAddress;
const QString origin = message["origin"].toString("JsonRpc") + "@" + _peerAddress;
const QJsonArray & jsonColor = message["color"].toArray();
const ColorRgb color = {uint8_t(jsonColor.at(0).toInt()),uint8_t(jsonColor.at(1).toInt()),uint8_t(jsonColor.at(2).toInt())};
const QJsonArray &jsonColor = message["color"].toArray();
std::vector<uint8_t> colors;
// TODO faster copy
for (const auto &entry : jsonColor)
{
colors.emplace_back(uint8_t(entry.toInt()));
}
std::vector<ColorRgb> fledColors;
if (colors.size() % 3 == 0)
{
for (unsigned i = 0; i < colors.size(); i += 3)
{
fledColors.emplace_back(ColorRgb{colors[i], colors[i + 1], colors[i + 2]});
}
}
// set color
_hyperion->setColor(priority, color, duration, origin);
_hyperion->setColor(priority, fledColors, duration, origin);
// send reply
sendSuccessReply(command, tan);
@ -562,7 +574,7 @@ void JsonAPI::handleServerInfoCommand(const QJsonObject& message, const QString&
// get available components
QJsonArray component;
std::map<hyperion::Components, bool> components = _hyperion->getComponentRegister().getRegister();
std::map<hyperion::Components, bool> components = _hyperion->getAllComponents();
for(auto comp : components)
{
QJsonObject item;
@ -744,7 +756,7 @@ void JsonAPI::handleClearCommand(const QJsonObject& message, const QString& comm
if(priority > 0)
_hyperion->clear(priority);
else if(priority < 0)
_hyperion->clearall();
_hyperion->clear(-1);
else
{
sendErrorReply("Priority 0 is not allowed", command, tan);
@ -760,7 +772,7 @@ void JsonAPI::handleClearallCommand(const QJsonObject& message, const QString& c
emit forwardJsonMessage(message);
// clear priority
_hyperion->clearall();
_hyperion->clear(-1);
// send reply
sendSuccessReply(command, tan);
@ -920,7 +932,7 @@ void JsonAPI::handleConfigSetCommand(const QJsonObject& message, const QString &
if (message.contains("config"))
{
QJsonObject config = message["config"].toObject();
if(_hyperion->getComponentRegister().isComponentEnabled(hyperion::COMP_ALL))
if(_hyperion->isComponentEnabled(hyperion::COMP_ALL))
{
if(_hyperion->saveSettings(config, true))
sendSuccessReply(command,tan);
@ -1004,18 +1016,11 @@ void JsonAPI::handleComponentStateCommand(const QJsonObject& message, const QStr
Components component = stringToComponent(compStr);
if (compStr == "ALL" )
{
if(_hyperion->getComponentRegister().setHyperionEnable(compState))
sendSuccessReply(command, tan);
return;
}
else if (component != COMP_INVALID)
if (component != COMP_INVALID)
{
// send result before apply
sendSuccessReply(command, tan);
_hyperion->setComponentState(component, compState);
emit _hyperion->compStateChangeRequest(component, compState);
return;
}
sendErrorReply("invalid component name", command, tan);

View File

@ -32,7 +32,7 @@ BlackBorderProcessor::BlackBorderProcessor(Hyperion* hyperion, QObject* parent)
connect(_hyperion, &Hyperion::settingsChanged, this, &BlackBorderProcessor::handleSettingsUpdate);
// listen for component state changes
connect(_hyperion, &Hyperion::componentStateChanged, this, &BlackBorderProcessor::componentStateChanged);
connect(_hyperion, &Hyperion::compStateChangeRequest, this, &BlackBorderProcessor::handleCompStateChangeRequest);
}
BlackBorderProcessor::~BlackBorderProcessor()
@ -65,11 +65,11 @@ void BlackBorderProcessor::handleSettingsUpdate(const settings::type& type, cons
Debug(Logger::getInstance("BLACKBORDER"), "Set mode to: %s", QSTRING_CSTR(_detectionMode));
// eval the comp state
componentStateChanged(hyperion::COMP_BLACKBORDER, obj["enable"].toBool(true));
handleCompStateChangeRequest(hyperion::COMP_BLACKBORDER, obj["enable"].toBool(true));
}
}
void BlackBorderProcessor::componentStateChanged(const hyperion::Components component, bool enable)
void BlackBorderProcessor::handleCompStateChangeRequest(const hyperion::Components component, bool enable)
{
if(component == hyperion::COMP_BLACKBORDER)
{
@ -85,7 +85,7 @@ void BlackBorderProcessor::componentStateChanged(const hyperion::Components comp
_enabled = enable;
}
_hyperion->getComponentRegister().componentStateChanged(hyperion::COMP_BLACKBORDER, enable);
_hyperion->setNewComponentState(hyperion::COMP_BLACKBORDER, enable);
}
}

View File

@ -28,7 +28,7 @@ BoblightServer::BoblightServer(Hyperion* hyperion,const QJsonDocument& config)
Debug(_log, "Instance created");
// listen for component change
connect(_hyperion, SIGNAL(componentStateChanged(hyperion::Components,bool)), this, SLOT(componentStateChanged(hyperion::Components,bool)));
connect(_hyperion, SIGNAL(compStateChangeRequest(hyperion::Components,bool)), this, SLOT(compStateChangeRequest(hyperion::Components,bool)));
// listen new connection signal from server
connect(_server, SIGNAL(newConnection()), this, SLOT(newConnection()));
@ -51,7 +51,7 @@ void BoblightServer::start()
Info(_log, "Started on port %d", _port);
_hyperion->getComponentRegister().componentStateChanged(COMP_BOBLIGHTSERVER, _server->isListening());
_hyperion->setNewComponentState(COMP_BOBLIGHTSERVER, _server->isListening());
}
void BoblightServer::stop()
@ -65,7 +65,7 @@ void BoblightServer::stop()
_server->close();
Info(_log, "Stopped");
_hyperion->getComponentRegister().componentStateChanged(COMP_BOBLIGHTSERVER, _server->isListening());
_hyperion->setNewComponentState(COMP_BOBLIGHTSERVER, _server->isListening());
}
bool BoblightServer::active()
@ -73,7 +73,7 @@ bool BoblightServer::active()
return _server->isListening();
}
void BoblightServer::componentStateChanged(const hyperion::Components component, bool enable)
void BoblightServer::compStateChangeRequest(const hyperion::Components component, bool enable)
{
if (component == COMP_BOBLIGHTSERVER)
{

View File

@ -95,10 +95,7 @@ void FlatBufferClient::handleColorCommand(const hyperionnet::Color *colorReq)
{
// extract parameters
const int32_t rgbData = colorReq->data();
ColorRgb color;
color.red = qRed(rgbData);
color.green = qGreen(rgbData);
color.blue = qBlue(rgbData);
std::vector<ColorRgb> color{ ColorRgb{ uint8_t(qRed(rgbData)), uint8_t(qGreen(rgbData)), uint8_t(qBlue(rgbData)) } };
// set output
emit setGlobalInputColor(_priority, color, colorReq->duration());
@ -172,17 +169,12 @@ void FlatBufferClient::handleClearCommand(const hyperionnet::Clear *clear)
// extract parameters
const int priority = clear->priority();
if (priority == -1) {
emit clearAllGlobalInput();
}
else {
// Check if we are clearing ourselves.
if (priority == _priority) {
_priority = -1;
}
emit clearGlobalInput(priority);
}
sendSuccessReply();
}

View File

@ -41,12 +41,7 @@ signals:
///
/// @brief Forward clear command to HyperionDaemon
///
void clearGlobalInput(const int priority);
///
/// @brief Forward clearAll command to HyperionDaemon
///
void clearAllGlobalInput(bool forceClearAll=false);
void clearGlobalInput(const int priority, bool forceClearAll=false);
///
/// @brief forward prepared image to HyperionDaemon
@ -56,7 +51,7 @@ signals:
///
/// @brief Forward requested color
///
void setGlobalInputColor(const int priority, const ColorRgb &ledColor, const int timeout_ms, const QString& origin = "FlatBuffer" ,bool clearEffects = true);
void setGlobalInputColor(const int priority, const std::vector<ColorRgb> &ledColor, const int timeout_ms, const QString& origin = "FlatBuffer" ,bool clearEffects = true);
///
/// @brief Emits whenever the client disconnected

View File

@ -71,7 +71,6 @@ void FlatBufferServer::newConnection()
connect(client, &FlatBufferClient::clientDisconnected, this, &FlatBufferServer::clientDisconnected);
connect(client, &FlatBufferClient::registerGlobalInput, GlobalSignals::getInstance(), &GlobalSignals::registerGlobalInput);
connect(client, &FlatBufferClient::clearGlobalInput, GlobalSignals::getInstance(), &GlobalSignals::clearGlobalInput);
connect(client, &FlatBufferClient::clearAllGlobalInput, GlobalSignals::getInstance(), &GlobalSignals::clearAllGlobalInput);
connect(client, &FlatBufferClient::setGlobalInputImage, GlobalSignals::getInstance(), &GlobalSignals::setGlobalImage);
connect(client, &FlatBufferClient::setGlobalInputColor, GlobalSignals::getInstance(), &GlobalSignals::setGlobalColor);
connect(GlobalSignals::getInstance(), &GlobalSignals::globalRegRequired, client, &FlatBufferClient::registationRequired);

View File

@ -60,7 +60,7 @@ V4L2Grabber::V4L2Grabber(const QString & device
// connect componentStateChange only for build-in grabber
if (HyperionIManager::HIMinstance)
connect(this, &Grabber::componentStateChanged, this, &V4L2Grabber::componentStateChanged);
connect(this, &Grabber::compStateChangeRequest, this, &V4L2Grabber::compStateChangeRequest);
// init
setDeviceVideoStandard(device, videoStandard);
@ -1176,7 +1176,7 @@ void V4L2Grabber::setDeviceVideoStandard(QString device, VideoStandard videoStan
}
}
void V4L2Grabber::componentStateChanged(const hyperion::Components component, bool enable)
void V4L2Grabber::compStateChangeRequest(const hyperion::Components component, bool enable)
{
if (component == hyperion::COMP_V4L)
{

View File

@ -24,7 +24,7 @@ V4L2Wrapper::V4L2Wrapper(const QString &device,
connect(&_grabber, SIGNAL(newFrame(Image<ColorRgb>)), this, SLOT(newFrame(Image<ColorRgb>)), Qt::DirectConnection);
connect(&_grabber, SIGNAL(readError(const char*)), this, SLOT(readError(const char*)), Qt::DirectConnection);
connect(this, &V4L2Wrapper::componentStateChanged, _ggrabber, &Grabber::componentStateChanged);
connect(this, &V4L2Wrapper::compStateChangeRequest, _ggrabber, &Grabber::compStateChangeRequest);
}
bool V4L2Wrapper::start()

View File

@ -25,7 +25,7 @@ CaptureCont::CaptureCont(Hyperion* hyperion)
connect(_hyperion, &Hyperion::settingsChanged, this, &CaptureCont::handleSettingsUpdate);
// comp changes
connect(_hyperion, &Hyperion::componentStateChanged, this, &CaptureCont::componentStateChanged);
connect(_hyperion, &Hyperion::compStateChangeRequest, this, &CaptureCont::handleCompStateChangeRequest);
// inactive timer system
connect(_systemInactiveTimer, &QTimer::timeout, this, &CaptureCont::setSystemInactive);
@ -85,8 +85,8 @@ void CaptureCont::setSystemCaptureEnable(const bool& enable)
_systemCaptName = "";
}
_systemCaptEnabled = enable;
_hyperion->getComponentRegister().componentStateChanged(hyperion::COMP_GRABBER, enable);
_hyperion->setComponentState(hyperion::COMP_GRABBER, enable);
_hyperion->setNewComponentState(hyperion::COMP_GRABBER, enable);
//emit _hyperion->compStateChangeRequest(hyperion::COMP_GRABBER, enable);
}
}
@ -108,8 +108,8 @@ void CaptureCont::setV4LCaptureEnable(const bool& enable)
_v4lCaptName = "";
}
_v4lCaptEnabled = enable;
_hyperion->getComponentRegister().componentStateChanged(hyperion::COMP_V4L, enable);
_hyperion->setComponentState(hyperion::COMP_V4L, enable);
_hyperion->setNewComponentState(hyperion::COMP_V4L, enable);
//emit _hyperion->compStateChangeRequest(hyperion::COMP_V4L, enable);
}
}
@ -134,7 +134,7 @@ void CaptureCont::handleSettingsUpdate(const settings::type& type, const QJsonDo
}
}
void CaptureCont::componentStateChanged(const hyperion::Components component, bool enable)
void CaptureCont::handleCompStateChangeRequest(const hyperion::Components component, bool enable)
{
if(component == hyperion::COMP_GRABBER)
{

View File

@ -16,51 +16,20 @@ ComponentRegister::ComponentRegister(Hyperion* hyperion)
{
_componentStates.emplace(e, ((e == COMP_ALL) ? true : false));
}
connect(_hyperion, &Hyperion::compStateChangeRequest, this, &ComponentRegister::handleCompStateChangeRequest);
}
ComponentRegister::~ComponentRegister()
{
}
bool ComponentRegister::setHyperionEnable(const bool& state)
{
if(!state && _prevComponentStates.empty())
{
Debug(_log,"Disable Hyperion, store current component states");
for(const auto comp : _componentStates)
{
// save state
_prevComponentStates.emplace(comp.first, comp.second);
// disable if enabled
if(comp.second)
_hyperion->setComponentState(comp.first, false);
}
componentStateChanged(COMP_ALL, false);
return true;
}
else if(state && !_prevComponentStates.empty())
{
Debug(_log,"Enable Hyperion, recover previous component states");
for(const auto comp : _prevComponentStates)
{
// if comp was enabled, enable again
if(comp.second)
_hyperion->setComponentState(comp.first, true);
}
_prevComponentStates.clear();
componentStateChanged(COMP_ALL, true);
return true;
}
return false;
}
int ComponentRegister::isComponentEnabled(const hyperion::Components& comp) const
{
return (_componentStates.count(comp)) ? _componentStates.at(comp) : -1;
}
void ComponentRegister::componentStateChanged(const hyperion::Components comp, const bool activated)
void ComponentRegister::setNewComponentState(const hyperion::Components comp, const bool activated)
{
if(_componentStates[comp] != activated)
{
@ -70,3 +39,38 @@ void ComponentRegister::componentStateChanged(const hyperion::Components comp, c
emit updatedComponentState(comp, activated);
}
}
void ComponentRegister::handleCompStateChangeRequest(const hyperion::Components comp, const bool activated)
{
if(comp == COMP_ALL && !_inProgress)
{
_inProgress = true;
if(!activated && _prevComponentStates.empty())
{
Debug(_log,"Disable Hyperion, store current component states");
for(const auto comp : _componentStates)
{
// save state
_prevComponentStates.emplace(comp.first, comp.second);
// disable if enabled
if(comp.second)
emit _hyperion->compStateChangeRequest(comp.first, false);
}
setNewComponentState(COMP_ALL, false);
}
else if(activated && !_prevComponentStates.empty())
{
Debug(_log,"Enable Hyperion, recover previous component states");
for(const auto comp : _prevComponentStates)
{
// if comp was enabled, enable again
if(comp.second)
emit _hyperion->compStateChangeRequest(comp.first, true);
}
_prevComponentStates.clear();
setNewComponentState(COMP_ALL, true);
}
_inProgress = false;
}
}

View File

@ -104,7 +104,7 @@ void Hyperion::start()
ledDevice["currentLedCount"] = int(_hwLedCount); // Inject led count info
_ledDeviceWrapper = new LedDeviceWrapper(this);
connect(this, &Hyperion::componentStateChanged, _ledDeviceWrapper, &LedDeviceWrapper::handleComponentState);
connect(this, &Hyperion::compStateChangeRequest, _ledDeviceWrapper, &LedDeviceWrapper::handleComponentState);
connect(this, &Hyperion::ledDeviceData, _ledDeviceWrapper, &LedDeviceWrapper::updateLeds);
_ledDeviceWrapper->createLedDevice(ledDevice);
@ -132,7 +132,6 @@ void Hyperion::start()
// forwards global signals to the corresponding slots
connect(GlobalSignals::getInstance(), &GlobalSignals::registerGlobalInput, this, &Hyperion::registerInput);
connect(GlobalSignals::getInstance(), &GlobalSignals::clearGlobalInput, this, &Hyperion::clear);
connect(GlobalSignals::getInstance(), &GlobalSignals::clearAllGlobalInput, this, &Hyperion::clearall);
connect(GlobalSignals::getInstance(), &GlobalSignals::setGlobalColor, this, &Hyperion::setColor);
connect(GlobalSignals::getInstance(), &GlobalSignals::setGlobalImage, this, &Hyperion::setInputImage);
@ -157,7 +156,7 @@ void Hyperion::stop()
void Hyperion::freeObjects(bool emitCloseSignal)
{
// switch off all leds
clearall(true);
clear(-1,true);
if (emitCloseSignal)
{
@ -309,13 +308,17 @@ bool Hyperion::sourceAutoSelectEnabled()
void Hyperion::setNewComponentState(const hyperion::Components& component, const bool& state)
{
_componentRegister.componentStateChanged(component, state);
_componentRegister.setNewComponentState(component, state);
}
void Hyperion::setComponentState(const hyperion::Components component, const bool state)
std::map<hyperion::Components, bool> Hyperion::getAllComponents()
{
// TODO REMOVE THIS STEP
emit componentStateChanged(component, state);
return _componentRegister.getRegister();
}
int Hyperion::isComponentEnabled(const hyperion::Components &comp)
{
return _componentRegister.isComponentEnabled(comp);
}
void Hyperion::registerInput(const int priority, const hyperion::Components& component, const QString& origin, const QString& owner, unsigned smooth_cfg)
@ -372,14 +375,25 @@ bool Hyperion::setInputInactive(const quint8& priority)
return _muxer.setInputInactive(priority);
}
void Hyperion::setColor(const int priority, const ColorRgb &color, const int timeout_ms, const QString& origin, bool clearEffects)
void Hyperion::setColor(const int priority, const std::vector<ColorRgb> &ledColors, const int timeout_ms, const QString &origin, bool clearEffects)
{
// clear effect if this call does not come from an effect
if(clearEffects)
if (clearEffects)
_effectEngine->channelCleared(priority);
// create led vector from single color
std::vector<ColorRgb> ledColors(_ledString.leds().size(), color);
// create full led vector from single/multiple colors
unsigned int size = _ledString.leds().size();
std::vector<ColorRgb> newLedColors;
while (true)
{
for (const auto &entry : ledColors)
{
newLedColors.emplace_back(entry);
if (newLedColors.size() == size)
goto end;
}
}
end:
if (getPriorityInfo(priority).componentId != hyperion::COMP_COLOR)
clear(priority);
@ -388,8 +402,8 @@ void Hyperion::setColor(const int priority, const ColorRgb &color, const int tim
registerInput(priority, hyperion::COMP_COLOR, origin);
// write color to muxer & queuePush
setInput(priority, ledColors, timeout_ms);
if(timeout_ms <= 0)
setInput(priority, newLedColors, timeout_ms);
if (timeout_ms <= 0)
_muxer.queuePush();
}
@ -409,24 +423,26 @@ void Hyperion::adjustmentsUpdated()
update();
}
bool Hyperion::clear(const int priority)
{
// send clear signal to the effect engine
// (outside the check so the effect gets cleared even when the effect is not sending colors)
_effectEngine->channelCleared(priority);
if(_muxer.clearInput(priority))
return true;
return false;
}
void Hyperion::clearall(bool forceClearAll)
bool Hyperion::clear(const int priority, bool forceClearAll)
{
if (priority < 0)
{
_muxer.clearAll(forceClearAll);
// send clearall signal to the effect engine
_effectEngine->allChannelsCleared();
return true;
}
else
{
// send clear signal to the effect engine
// (outside the check so the effect gets cleared even when the effect is not sending colors)
_effectEngine->channelCleared(priority);
if (_muxer.clearInput(priority))
return true;
}
return false;
}
int Hyperion::getCurrentPriority() const

View File

@ -76,7 +76,7 @@ bool HyperionIManager::startInstance(const quint8& inst, const bool& block)
// from Hyperion
connect(hyperion, &Hyperion::settingsChanged, this, &HyperionIManager::settingsChanged);
connect(hyperion, &Hyperion::videoMode, this, &HyperionIManager::requestVideoMode);
connect(hyperion, &Hyperion::componentStateChanged, this, &HyperionIManager::componentStateChanged);
connect(hyperion, &Hyperion::compStateChangeRequest, this, &HyperionIManager::compStateChangeRequest);
// to Hyperion
connect(this, &HyperionIManager::newVideoMode, hyperion, &Hyperion::newVideoMode);

View File

@ -38,7 +38,7 @@ LinearColorSmoothing::LinearColorSmoothing(const QJsonDocument& config, Hyperion
_cfgList.append(cfg);
// listen for comp changes
connect(_hyperion, &Hyperion::componentStateChanged, this, &LinearColorSmoothing::componentStateChange);
connect(_hyperion, &Hyperion::compStateChangeRequest, this, &LinearColorSmoothing::componentStateChange);
// timer
connect(_timer, &QTimer::timeout, this, &LinearColorSmoothing::updateLeds);
}
@ -235,7 +235,7 @@ void LinearColorSmoothing::setEnable(bool enable)
clearQueuedColors();
}
// update comp register
_hyperion->getComponentRegister().componentStateChanged(hyperion::COMP_SMOOTHING, enable);
_hyperion->setNewComponentState(hyperion::COMP_SMOOTHING, enable);
}
void LinearColorSmoothing::setPause(bool pause)

View File

@ -28,7 +28,7 @@ MessageForwarder::MessageForwarder(Hyperion *hyperion)
connect(_hyperion, &Hyperion::settingsChanged, this, &MessageForwarder::handleSettingsUpdate);
// component changes
connect(_hyperion, &Hyperion::componentStateChanged, this, &MessageForwarder::componentStateChanged);
connect(_hyperion, &Hyperion::compStateChangeRequest, this, &MessageForwarder::handleCompStateChangeRequest);
// connect with Muxer visible priority changes
connect(_muxer, &PriorityMuxer::visiblePriorityChanged, this, &MessageForwarder::handlePriorityChanges);
@ -91,18 +91,18 @@ void MessageForwarder::handleSettingsUpdate(const settings::type &type, const QJ
}
// update comp state
_hyperion->getComponentRegister().componentStateChanged(hyperion::COMP_FORWARDER, obj["enable"].toBool(true));
_hyperion->setNewComponentState(hyperion::COMP_FORWARDER, obj["enable"].toBool(true));
}
}
void MessageForwarder::componentStateChanged(const hyperion::Components component, bool enable)
void MessageForwarder::handleCompStateChangeRequest(const hyperion::Components component, bool enable)
{
if (component == hyperion::COMP_FORWARDER && _forwarder_enabled != enable)
{
_forwarder_enabled = enable;
handleSettingsUpdate(settings::NETFORWARD, _hyperion->getSetting(settings::NETFORWARD));
Info(_log, "Forwarder change state to %s", (_forwarder_enabled ? "enabled" : "disabled"));
_hyperion->getComponentRegister().componentStateChanged(component, _forwarder_enabled);
_hyperion->setNewComponentState(component, _forwarder_enabled);
}
}

View File

@ -74,6 +74,13 @@ SettingsManager::SettingsManager(const quint8& instance, QObject* parent)
dbConfig[key] = doc.object();
}
// possible data upgrade steps to prevent data loss
if(handleConfigUpgrade(dbConfig))
{
saveSettings(dbConfig, true);
}
// validate full dbconfig against schema, on error we need to rewrite entire table
QJsonSchemaChecker schemaChecker;
schemaChecker.setSchema(schemaJson);
@ -108,6 +115,9 @@ const QJsonDocument SettingsManager::getSetting(const settings::type& type)
bool SettingsManager::saveSettings(QJsonObject config, const bool& correct)
{
// optional data upgrades e.g. imported legacy/older configs
// handleConfigUpgrade(config);
// we need to validate data against schema
QJsonSchemaChecker schemaChecker;
schemaChecker.setSchema(schemaJson);
@ -156,3 +166,66 @@ bool SettingsManager::saveSettings(QJsonObject config, const bool& correct)
}
return true;
}
bool SettingsManager::handleConfigUpgrade(QJsonObject& config)
{
bool migrated = false;
// LED LAYOUT UPGRADE
// from { hscan: { minimum: 0.2, maximum: 0.3 }, vscan: { minimum: 0.2, maximumn: 0.3 } }
// from { h: { min: 0.2, max: 0.3 }, v: { min: 0.2, max: 0.3 } }
// to { hmin: 0.2, hmax: 0.3, vmin: 0.2, vmax: 0.3}
if(config.contains("leds"))
{
const QJsonArray ledarr = config["leds"].toArray();
const QJsonObject led = ledarr[0].toObject();
if(led.contains("hscan") || led.contains("h"))
{
const bool whscan = led.contains("hscan");
QJsonArray newLedarr;
for(const auto & entry : ledarr)
{
const QJsonObject led = entry.toObject();
QJsonObject hscan;
QJsonObject vscan;
QJsonValue hmin;
QJsonValue hmax;
QJsonValue vmin;
QJsonValue vmax;
QJsonObject nL;
if(whscan)
{
hscan = led["hscan"].toObject();
vscan = led["vscan"].toObject();
hmin = hscan["minimum"];
hmax = hscan["maximum"];
vmin = vscan["minimum"];
vmax = vscan["maximum"];
}
else
{
hscan = led["h"].toObject();
vscan = led["v"].toObject();
hmin = hscan["min"];
hmax = hscan["max"];
vmin = vscan["min"];
vmax = vscan["max"];
}
// append to led object
nL["hmin"] = hmin;
nL["hmax"] = hmax;
nL["vmin"] = vmin;
nL["vmax"] = vmax;
newLedarr.append(nL);
}
// replace
config["leds"] = newLedarr;
migrated = true;
Debug(_log,"LED Layout migrated");
}
}
return migrated;
}

View File

@ -1,72 +1,64 @@
{
"type":"array",
"required":true,
"minItems":1,
"items":
{
"type":"object",
"required" : true,
"properties":
{
"h":
{
"type":"object",
"required" : true,
"properties":
{
"min":
{
"type":"number",
"minimum" : 0,
"maximum" : 1,
"required":true,
"default" : 0
"type": "array",
"required": true,
"minItems": 1,
"items": {
"type": "object",
"required": true,
"properties": {
"hmin": {
"type": "number",
"minimum": 0,
"maximum": 1,
"required": true,
"default": 0
},
"max":
{
"type":"number",
"minimum" : 0,
"maximum" : 1,
"required":true,
"default" : 0.1
}
"hmax": {
"type": "number",
"minimum": 0,
"maximum": 1,
"required": true,
"default": 0.1
},
"additionalProperties" : false
"vmin": {
"type": "number",
"minimum": 0,
"maximum": 1,
"required": true,
"default": 0
},
"v":
{
"type":"object",
"required" : true,
"properties":
{
"min":
{
"type":"number",
"minimum" : 0,
"maximum" : 1,
"required":true,
"default" : 0
"vmax": {
"type": "number",
"minimum": 0,
"maximum": 1,
"required": true,
"default": 0.1
},
"max":
{
"type":"number",
"minimum" : 0,
"maximum" : 1,
"required":true,
"default" : 0.1
}
},
"additionalProperties" : false
},
"colorOrder":
{
"colorOrder": {
"type": "string",
"enum" : ["rgb", "bgr", "rbg", "brg", "gbr", "grb"],
"options" : {
"enum_titles" : ["edt_conf_enum_rgb", "edt_conf_enum_bgr", "edt_conf_enum_rbg", "edt_conf_enum_brg", "edt_conf_enum_gbr", "edt_conf_enum_grb"]
}
"enum": [
"rgb",
"bgr",
"rbg",
"brg",
"gbr",
"grb"
],
"options": {
"enum_titles": [
"edt_conf_enum_rgb",
"edt_conf_enum_bgr",
"edt_conf_enum_rbg",
"edt_conf_enum_brg",
"edt_conf_enum_gbr",
"edt_conf_enum_grb"
]
}
},
"additionalProperties" : false
"name": {
"type": "string"
}
},
"additionalProperties": false
}
}

View File

@ -119,10 +119,7 @@ void ProtoClientConnection::handleColorCommand(const proto::ColorRequest &messag
// extract parameters
int priority = message.priority();
int duration = message.has_duration() ? message.duration() : -1;
ColorRgb color;
color.red = qRed(message.rgbcolor());
color.green = qGreen(message.rgbcolor());
color.blue = qBlue(message.rgbcolor());
std::vector<ColorRgb> color{ ColorRgb{ uint8_t(qRed(message.rgbcolor())), uint8_t(qGreen(message.rgbcolor())), uint8_t(qBlue(message.rgbcolor())) } };
if (priority < 100 || priority >= 200)
{
@ -202,7 +199,7 @@ void ProtoClientConnection::handleClearCommand(const proto::ClearRequest &messag
void ProtoClientConnection::handleClearallCommand()
{
// clear all priority
emit clearAllGlobalInput();
emit clearGlobalInput(-1);
// send reply
sendSuccessReply();

View File

@ -41,12 +41,7 @@ signals:
///
/// @brief Forward clear command to HyperionDaemon
///
void clearGlobalInput(const int priority);
///
/// @brief Forward clearAll command to HyperionDaemon
///
void clearAllGlobalInput(bool forceClearAll=false);
void clearGlobalInput(const int priority, bool forceClearAll=false);
///
/// @brief forward prepared image to HyperionDaemon
@ -56,7 +51,7 @@ signals:
///
/// @brief Forward requested color
///
void setGlobalInputColor(const int priority, const ColorRgb &ledColor, const int timeout_ms, const QString& origin = "ProtoBuffer" ,bool clearEffects = true);
void setGlobalInputColor(const int priority, const std::vector<ColorRgb> &ledColor, const int timeout_ms, const QString& origin = "ProtoBuffer" ,bool clearEffects = true);
///
/// @brief Emits whenever the client disconnected

View File

@ -71,7 +71,6 @@ void ProtoServer::newConnection()
connect(client, &ProtoClientConnection::clientDisconnected, this, &ProtoServer::clientDisconnected);
connect(client, &ProtoClientConnection::registerGlobalInput, GlobalSignals::getInstance(), &GlobalSignals::registerGlobalInput);
connect(client, &ProtoClientConnection::clearGlobalInput, GlobalSignals::getInstance(), &GlobalSignals::clearGlobalInput);
connect(client, &ProtoClientConnection::clearAllGlobalInput, GlobalSignals::getInstance(), &GlobalSignals::clearAllGlobalInput);
connect(client, &ProtoClientConnection::setGlobalInputImage, GlobalSignals::getInstance(), &GlobalSignals::setGlobalImage);
connect(client, &ProtoClientConnection::setGlobalInputColor, GlobalSignals::getInstance(), &GlobalSignals::setGlobalColor);
connect(GlobalSignals::getInstance(), &GlobalSignals::globalRegRequired, client, &ProtoClientConnection::registationRequired);

View File

@ -9,7 +9,7 @@
#include <QNetworkInterface>
#include <QNetworkConfigurationManager>
SSDPHandler::SSDPHandler(WebServer* webserver, const quint16& flatBufPort, const quint16& jsonServerPort, QObject * parent)
SSDPHandler::SSDPHandler(WebServer* webserver, const quint16& flatBufPort, const quint16& jsonServerPort, const QString& name, QObject * parent)
: SSDPServer(parent)
, _webserver(webserver)
, _localAddress()
@ -17,6 +17,7 @@ SSDPHandler::SSDPHandler(WebServer* webserver, const quint16& flatBufPort, const
{
setFlatBufPort(flatBufPort);
setJsonServerPort(jsonServerPort);
setHyperionName(name);
}
SSDPHandler::~SSDPHandler()
@ -76,6 +77,15 @@ void SSDPHandler::handleSettingsUpdate(const settings::type& type, const QJsonDo
SSDPServer::setJsonServerPort(obj["port"].toInt());
}
}
if (type == settings::GENERAL)
{
const QJsonObject &obj = config.object();
if (obj["name"].toString() != SSDPServer::getHyperionName())
{
SSDPServer::setHyperionName(obj["name"].toString());
}
}
}
void SSDPHandler::handleWebServerStateChange(const bool newState)

View File

@ -28,6 +28,7 @@ static const QString UPNP_ALIVE_MESSAGE = "NOTIFY * HTTP/1.1\r\n"
"USN: uuid:%5\r\n"
"HYPERION-FBS-PORT: %6\r\n"
"HYPERION-JSS-PORT: %7\r\n"
"HYPERION-NAME: %8\r\n"
"\r\n";
// Implement ssdp:update as per spec 1.1, section 1.2.4
@ -72,6 +73,7 @@ static const QString UPNP_MSEARCH_RESPONSE = "HTTP/1.1 200 OK\r\n"
"USN: uuid:%6\r\n"
"HYPERION-FBS-PORT: %7\r\n"
"HYPERION-JSS-PORT: %8\r\n"
"HYPERION-NAME: %9\r\n"
"\r\n";
SSDPServer::SSDPServer(QObject * parent)
@ -172,7 +174,8 @@ void SSDPServer::sendMSearchResponse(const QString& st, const QString& senderIp,
, st
, _uuid
, _fbsPort
, _jssPort );
, _jssPort
, _name );
_udpSocket->writeDatagram(message.toUtf8(),
QHostAddress(senderIp),
@ -203,7 +206,8 @@ void SSDPServer::sendAlive(const QString& st)
, _serverHeader
, tempUSN
, _fbsPort
, _jssPort );
, _jssPort
, _name );
// we repeat 3 times
quint8 rep = 0;

View File

@ -112,7 +112,7 @@ HyperionDaemon::HyperionDaemon(const QString rootPath, QObject *parent, const bo
// pipe settings changes and component state changes from HyperionIManager to Daemon
connect(_instanceManager, &HyperionIManager::settingsChanged, this, &HyperionDaemon::settingsChanged);
connect(_instanceManager, &HyperionIManager::componentStateChanged, this, &HyperionDaemon::componentStateChanged);
connect(_instanceManager, &HyperionIManager::compStateChangeRequest, this, &HyperionDaemon::compStateChangeRequest);
// listen for setting changes of framegrabber and v4l2
connect(this, &HyperionDaemon::settingsChanged, this, &HyperionDaemon::handleSettingsUpdate);
@ -247,7 +247,7 @@ void HyperionDaemon::startNetworkServices()
sslWsThread->start();
// Create SSDP server in thread
_ssdp = new SSDPHandler(_webserver, getSetting(settings::FLATBUFSERVER).object()["port"].toInt(), getSetting(settings::JSONSERVER).object()["port"].toInt());
_ssdp = new SSDPHandler(_webserver, getSetting(settings::FLATBUFSERVER).object()["port"].toInt(), getSetting(settings::JSONSERVER).object()["port"].toInt(), getSetting(settings::GENERAL).object()["name"].toString());
QThread* ssdpThread = new QThread(this);
_ssdp->moveToThread(ssdpThread);
connect( ssdpThread, &QThread::started, _ssdp, &SSDPHandler::initServer );
@ -436,7 +436,7 @@ void HyperionDaemon::handleSettingsUpdate(const settings::type& settingsType, co
// connect to HyperionDaemon signal
connect(this, &HyperionDaemon::videoMode, _v4l2Grabber, &V4L2Wrapper::setVideoMode);
connect(this, &HyperionDaemon::settingsChanged, _v4l2Grabber, &V4L2Wrapper::handleSettingsUpdate);
connect(this, &HyperionDaemon::componentStateChanged, _v4l2Grabber, &V4L2Wrapper::componentStateChanged);
connect(this, &HyperionDaemon::compStateChangeRequest, _v4l2Grabber, &V4L2Wrapper::compStateChangeRequest);
#else
Error(_log, "The v4l2 grabber can not be instantiated, because it has been left out from the build");
#endif

View File

@ -120,7 +120,7 @@ signals:
///
/// @brief PIPE component state changes events from Hyperion class to HyperionDaemon components
///
void componentStateChanged(const hyperion::Components component, bool enable);
void compStateChangeRequest(const hyperion::Components component, bool enable);
private slots:
///

View File

@ -102,10 +102,7 @@ void SysTray::createTrayIcon()
void SysTray::setColor(const QColor & color)
{
ColorRgb rgbColor;
rgbColor.red = color.red();
rgbColor.green = color.green();
rgbColor.blue =color.blue();
std::vector<ColorRgb> rgbColor{ ColorRgb{ (uint8_t)color.red(), (uint8_t)color.green(), (uint8_t)color.blue() } };
_hyperion->setColor(1 ,rgbColor, 0);
}