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 = leds[idx];
var led_id='ledc_'+[idx]; var led_id='ledc_'+[idx];
var bgcolor = "background-color:hsl("+(idx*360/leds.length)+",100%,50%);"; var bgcolor = "background-color:hsl("+(idx*360/leds.length)+",100%,50%);";
var pos = "left:"+(led.h.min * canvas_width)+"px;"+ var pos = "left:"+(led.hmin * canvas_width)+"px;"+
"top:"+(led.v.min * canvas_height)+"px;"+ "top:"+(led.vmin * canvas_height)+"px;"+
"width:"+((led.h.max-led.h.min) * (canvas_width-1))+"px;"+ "width:"+((led.hmax-led.hmin) * (canvas_width-1))+"px;"+
"height:"+((led.v.max-led.v.min) * (canvas_height-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_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); $('#leds_preview').html(leds_html);
@ -91,11 +91,11 @@ function createClassicLeds(){
function createFinalArray(array){ function createFinalArray(array){
finalLedArray = []; finalLedArray = [];
for(var i = 0; i<array.length; i++){ for(var i = 0; i<array.length; i++){
var hmin = array[i].h.min; var hmin = array[i].hmin;
var hmax = array[i].h.max; var hmax = array[i].hmax;
var vmin = array[i].v.min; var vmin = array[i].vmin;
var vmax = array[i].v.max; var vmax = array[i].vmax;
finalLedArray[i] = { "h": { "max" : hmax, "min" : hmin }, "v": { "max": vmax, "min": vmin}} finalLedArray[i] = { "hmax": hmax, "hmin": hmin, "vmax": vmax, "vmin": vmin }
} }
createLedPreview(finalLedArray, 'classic'); createLedPreview(finalLedArray, 'classic');
} }
@ -138,7 +138,7 @@ function createClassicLeds(){
hmax = round(hmax); hmax = round(hmax);
vmin = round(vmin); vmin = round(vmin);
vmax = round(vmax); 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(){ function createTopLeds(){
@ -268,14 +268,10 @@ function createMatrixLeds(){
vscanMax = round(vscanMax); vscanMax = round(vscanMax);
leds.push({ leds.push({
h: { hmin: hscanMin,
min: hscanMin, hmax: hscanMax,
max: hscanMax vmin: vscanMin,
}, vmax: vscanMax
v: {
min: vscanMin,
max: vscanMax
}
}) })
} }
@ -446,7 +442,7 @@ $(document).ready(function() {
}); });
// v4 of json schema with diff required assignment - remove when hyperion schema moved to v4 // 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 //create jsonace editor
aceEdt = new JSONACEEditor(document.getElementById("aceedit"),{ aceEdt = new JSONACEEditor(document.getElementById("aceedit"),{
mode: 'code', mode: 'code',

View File

@ -22,7 +22,7 @@ $(document).ready(function() {
for(var idx=0; idx<leds.length; idx++) for(var idx=0; idx<leds.length; idx++)
{ {
var led = leds[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]; var led = leds[idx];
// can be used as fallback when Path2D is not available // 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]) //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.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); //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.fillStyle = (useColor) ? "rgba("+colors[cPos]+","+colors[cPos+1]+","+colors[cPos+2]+",0.9)" : "hsl("+(idx*360/leds.length)+",100%,50%)";
ledsCanvasNodeCtx.fill(twoDPaths[idx]); ledsCanvasNodeCtx.fill(twoDPaths[idx]);
@ -155,7 +155,7 @@ $(document).ready(function() {
{ {
ledsCanvasNodeCtx.fillStyle = "blue"; ledsCanvasNodeCtx.fillStyle = "blue";
ledsCanvasNodeCtx.textAlign = "center"; 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 // increment colorsPosition

View File

@ -518,11 +518,11 @@ $('#btn_wizard_colorcalibration').off().on('click', startWizardCC);
var hueIPs = []; var hueIPs = [];
var hueIPsinc = 0; var hueIPsinc = 0;
var lightIDs = null; var lightIDs = null;
var huePosTop = {h: {max: 0.85, min: 0.15}, v: {max: 0.2, min: 0}}; var huePosTop = {hmax: 0.85, hmin: 0.15, vmax: 0.2, vmin: 0};
var huePosBottom = {h: {max: 0.85, min: 0.15}, v: {max: 1, min: 0.8}}; var huePosBottom = {hmax: 0.85, hmin: 0.15, vmax: 1, vmin: 0.8};
var huePosLeft = {h: {max: 0.15, min: 0}, v: {max: 0.85, min: 0.15}}; var huePosLeft = {hmax: 0.15, hmin: 0, vmax: 0.85, vmin: 0.15};
var huePosRight = {h: {max: 1, min: 0.85}, v: {max: 0.85, min: 0.15}}; var huePosRight = {hmax: 1, hmin: 0.85, vmax: 0.85, vmin: 0.15};
var huePosEntire = {h: {max: 1.0, min: 0.0}, v: {max: 1.0, min: 0.0}}; var huePosEntire = {hmax: 1.0, hmin: 0.0, vmax: 1.0, vmin: 0.0};
function startWizardPhilipsHue() 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 "${BUILD_ID}" BUILD_ID )
STRING ( STRIP "${VERSION_ID}" VERSION_ID ) STRING ( STRIP "${VERSION_ID}" VERSION_ID )
STRING ( STRIP "${GIT_REMOTE_PATH}" GIT_REMOTE_PATH ) 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 "Current Version: ${HYPERION_VERSION}" )
message ( STATUS " - Build: ${HYPERION_BUILD_ID}" ) 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. /// Recreate and save led layouts made with web config. These values are just helpers for ui, not for Hyperion.
"ledConfig" : "ledConfig" :
{
"classic":
{ {
"top" : 8, "top" : 8,
"bottom" : 8, "bottom" : 8,
@ -338,277 +340,185 @@
"vdepth" : 5, "vdepth" : 5,
"overlap" : 0, "overlap" : 0,
"edgegap" : 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 /// 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 /// averaged of an input image for each led to determine its color. Each item in the list
/// contains the following fields: /// contains the following fields:
/// * h: The fractional part of the image along the horizontal used for the averaging /// * hmin: The fractional part of the image along the horizontal used for the averaging (minimum)
/// (min and max inclusive) /// * hmax: The fractional part of the image along the horizontal used for the averaging (maximum)
/// * v: The fractional part of the image along the vertical used for the averaging /// * vmin: The fractional part of the image along the vertical used for the averaging (minimum)
/// (min and max inclusive) /// * 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": "leds":
[ [
{ {
"h": { "hmax": 0.125,
"max": 0.125, "hmin": 0,
"min": 0 "vmax": 0.08,
}, "vmin": 0
"v": {
"max": 0.08,
"min": 0
}
}, },
{ {
"h": { "hmax": 0.25,
"max": 0.25, "hmin": 0.125,
"min": 0.125 "vmax": 0.08,
}, "vmin": 0
"v": {
"max": 0.08,
"min": 0
}
}, },
{ {
"h": { "hmax": 0.375,
"max": 0.375, "hmin": 0.25,
"min": 0.25 "vmax": 0.08,
}, "vmin": 0
"v": {
"max": 0.08,
"min": 0
}
}, },
{ {
"h": { "hmax": 0.5,
"max": 0.5, "hmin": 0.375,
"min": 0.375 "vmax": 0.08,
}, "vmin": 0
"v": {
"max": 0.08,
"min": 0
}
}, },
{ {
"h": { "hmax": 0.625,
"max": 0.625, "hmin": 0.5,
"min": 0.5 "vmax": 0.08,
}, "vmin": 0
"v": {
"max": 0.08,
"min": 0
}
}, },
{ {
"h": { "hmax": 0.75,
"max": 0.75, "hmin": 0.625,
"min": 0.625 "vmax": 0.08,
}, "vmin": 0
"v": {
"max": 0.08,
"min": 0
}
}, },
{ {
"h": { "hmax": 0.875,
"max": 0.875, "hmin": 0.75,
"min": 0.75 "vmax": 0.08,
}, "vmin": 0
"v": {
"max": 0.08,
"min": 0
}
}, },
{ {
"h": { "hmax": 1,
"max": 1, "hmin": 0.875,
"min": 0.875 "vmax": 0.08,
}, "vmin": 0
"v": {
"max": 0.08,
"min": 0
}
}, },
{ {
"h": { "hmax": 1,
"max": 1, "hmin": 0.95,
"min": 0.95 "vmax": 0.2,
}, "vmin": 0
"v": {
"max": 0.2,
"min": 0
}
}, },
{ {
"h": { "hmax": 1,
"max": 1, "hmin": 0.95,
"min": 0.95 "vmax": 0.4,
}, "vmin": 0.2
"v": {
"max": 0.4,
"min": 0.2
}
}, },
{ {
"h": { "hmax": 1,
"max": 1, "hmin": 0.95,
"min": 0.95 "vmax": 0.6,
}, "vmin": 0.4
"v": {
"max": 0.6,
"min": 0.4
}
}, },
{ {
"h": { "hmax": 1,
"max": 1, "hmin": 0.95,
"min": 0.95 "vmax": 0.8,
}, "vmin": 0.6
"v": {
"max": 0.8,
"min": 0.6
}
}, },
{ {
"h": { "hmax": 1,
"max": 1, "hmin": 0.95,
"min": 0.95 "vmax": 1,
}, "vmin": 0.8
"v": {
"max": 1,
"min": 0.8
}
}, },
{ {
"h": { "hmax": 1,
"max": 1, "hmin": 0.875,
"min": 0.875 "vmax": 1,
}, "vmin": 0.92
"v": {
"max": 1,
"min": 0.92
}
}, },
{ {
"h": { "hmax": 0.875,
"max": 0.875, "hmin": 0.75,
"min": 0.75 "vmax": 1,
}, "vmin": 0.92
"v": {
"max": 1,
"min": 0.92
}
}, },
{ {
"h": { "hmax": 0.75,
"max": 0.75, "hmin": 0.625,
"min": 0.625 "vmax": 1,
}, "vmin": 0.92
"v": {
"max": 1,
"min": 0.92
}
}, },
{ {
"h": { "hmax": 0.625,
"max": 0.625, "hmin": 0.5,
"min": 0.5 "vmax": 1,
}, "vmin": 0.92
"v": {
"max": 1,
"min": 0.92
}
}, },
{ {
"h": { "hmax": 0.5,
"max": 0.5, "hmin": 0.375,
"min": 0.375 "vmax": 1,
}, "vmin": 0.92
"v": {
"max": 1,
"min": 0.92
}
}, },
{ {
"h": { "hmax": 0.375,
"max": 0.375, "hmin": 0.25,
"min": 0.25 "vmax": 1,
}, "vmin": 0.92
"v": {
"max": 1,
"min": 0.92
}
}, },
{ {
"h": { "hmax": 0.25,
"max": 0.25, "hmin": 0.125,
"min": 0.125 "vmax": 1,
}, "vmin": 0.92
"v": {
"max": 1,
"min": 0.92
}
}, },
{ {
"h": { "hmax": 0.125,
"max": 0.125, "hmin": 0,
"min": 0 "vmax": 1,
}, "vmin": 0.92
"v": {
"max": 1,
"min": 0.92
}
}, },
{ {
"h": { "hmax": 0.05,
"max": 0.05, "hmin": 0,
"min": 0 "vmax": 1,
}, "vmin": 0.8
"v": {
"max": 1,
"min": 0.8
}
}, },
{ {
"h": { "hmax": 0.05,
"max": 0.05, "hmin": 0,
"min": 0 "vmax": 0.8,
}, "vmin": 0.6
"v": {
"max": 0.8,
"min": 0.6
}
}, },
{ {
"h": { "hmax": 0.05,
"max": 0.05, "hmin": 0,
"min": 0 "vmax": 0.6,
}, "vmin": 0.4
"v": {
"max": 0.6,
"min": 0.4
}
}, },
{ {
"h": { "hmax": 0.05,
"max": 0.05, "hmin": 0,
"min": 0 "vmax": 0.4,
}, "vmin": 0.2
"v": {
"max": 0.4,
"min": 0.2
}
}, },
{ {
"h": { "hmax": 0.05,
"max": 0.05, "hmin": 0,
"min": 0 "vmax": 0.2,
}, "vmin": 0
"v": {
"max": 0.2,
"min": 0
}
} }
] ]
} }

View File

@ -216,264 +216,160 @@
"leds": "leds":
[ [
{ {
"h": { "hmax": 0.125,
"max": 0.125, "hmin": 0,
"min": 0 "vmax": 0.08,
}, "vmin": 0
"v": {
"max": 0.08,
"min": 0
}
}, },
{ {
"h": { "hmax": 0.25,
"max": 0.25, "hmin": 0.125,
"min": 0.125 "vmax": 0.08,
}, "vmin": 0
"v": {
"max": 0.08,
"min": 0
}
}, },
{ {
"h": { "hmax": 0.375,
"max": 0.375, "hmin": 0.25,
"min": 0.25 "vmax": 0.08,
}, "vmin": 0
"v": {
"max": 0.08,
"min": 0
}
}, },
{ {
"h": { "hmax": 0.5,
"max": 0.5, "hmin": 0.375,
"min": 0.375 "vmax": 0.08,
}, "vmin": 0
"v": {
"max": 0.08,
"min": 0
}
}, },
{ {
"h": { "hmax": 0.625,
"max": 0.625, "hmin": 0.5,
"min": 0.5 "vmax": 0.08,
}, "vmin": 0
"v": {
"max": 0.08,
"min": 0
}
}, },
{ {
"h": { "hmax": 0.75,
"max": 0.75, "hmin": 0.625,
"min": 0.625 "vmax": 0.08,
}, "vmin": 0
"v": {
"max": 0.08,
"min": 0
}
}, },
{ {
"h": { "hmax": 0.875,
"max": 0.875, "hmin": 0.75,
"min": 0.75 "vmax": 0.08,
}, "vmin": 0
"v": {
"max": 0.08,
"min": 0
}
}, },
{ {
"h": { "hmax": 1,
"max": 1, "hmin": 0.875,
"min": 0.875 "vmax": 0.08,
}, "vmin": 0
"v": {
"max": 0.08,
"min": 0
}
}, },
{ {
"h": { "hmax": 1,
"max": 1, "hmin": 0.95,
"min": 0.95 "vmax": 0.2,
}, "vmin": 0
"v": {
"max": 0.2,
"min": 0
}
}, },
{ {
"h": { "hmax": 1,
"max": 1, "hmin": 0.95,
"min": 0.95 "vmax": 0.4,
}, "vmin": 0.2
"v": {
"max": 0.4,
"min": 0.2
}
}, },
{ {
"h": { "hmax": 1,
"max": 1, "hmin": 0.95,
"min": 0.95 "vmax": 0.6,
}, "vmin": 0.4
"v": {
"max": 0.6,
"min": 0.4
}
}, },
{ {
"h": { "hmax": 1,
"max": 1, "hmin": 0.95,
"min": 0.95 "vmax": 0.8,
}, "vmin": 0.6
"v": {
"max": 0.8,
"min": 0.6
}
}, },
{ {
"h": { "hmax": 1,
"max": 1, "hmin": 0.95,
"min": 0.95 "vmax": 1,
}, "vmin": 0.8
"v": {
"max": 1,
"min": 0.8
}
}, },
{ {
"h": { "hmax": 1,
"max": 1, "hmin": 0.875,
"min": 0.875 "vmax": 1,
}, "vmin": 0.92
"v": {
"max": 1,
"min": 0.92
}
}, },
{ {
"h": { "hmax": 0.875,
"max": 0.875, "hmin": 0.75,
"min": 0.75 "vmax": 1,
}, "vmin": 0.92
"v": {
"max": 1,
"min": 0.92
}
}, },
{ {
"h": { "hmax": 0.75,
"max": 0.75, "hmin": 0.625,
"min": 0.625 "vmax": 1,
}, "vmin": 0.92
"v": {
"max": 1,
"min": 0.92
}
}, },
{ {
"h": { "hmax": 0.625,
"max": 0.625, "hmin": 0.5,
"min": 0.5 "vmax": 1,
}, "vmin": 0.92
"v": {
"max": 1,
"min": 0.92
}
}, },
{ {
"h": { "hmax": 0.5,
"max": 0.5, "hmin": 0.375,
"min": 0.375 "vmax": 1,
}, "vmin": 0.92
"v": {
"max": 1,
"min": 0.92
}
}, },
{ {
"h": { "hmax": 0.375,
"max": 0.375, "hmin": 0.25,
"min": 0.25 "vmax": 1,
}, "vmin": 0.92
"v": {
"max": 1,
"min": 0.92
}
}, },
{ {
"h": { "hmax": 0.25,
"max": 0.25, "hmin": 0.125,
"min": 0.125 "vmax": 1,
}, "vmin": 0.92
"v": {
"max": 1,
"min": 0.92
}
}, },
{ {
"h": { "hmax": 0.125,
"max": 0.125, "hmin": 0,
"min": 0 "vmax": 1,
}, "vmin": 0.92
"v": {
"max": 1,
"min": 0.92
}
}, },
{ {
"h": { "hmax": 0.05,
"max": 0.05, "hmin": 0,
"min": 0 "vmax": 1,
}, "vmin": 0.8
"v": {
"max": 1,
"min": 0.8
}
}, },
{ {
"h": { "hmax": 0.05,
"max": 0.05, "hmin": 0,
"min": 0 "vmax": 0.8,
}, "vmin": 0.6
"v": {
"max": 0.8,
"min": 0.6
}
}, },
{ {
"h": { "hmax": 0.05,
"max": 0.05, "hmin": 0,
"min": 0 "vmax": 0.6,
}, "vmin": 0.4
"v": {
"max": 0.6,
"min": 0.4
}
}, },
{ {
"h": { "hmax": 0.05,
"max": 0.05, "hmin": 0,
"min": 0 "vmax": 0.4,
}, "vmin": 0.2
"v": {
"max": 0.4,
"min": 0.2
}
}, },
{ {
"h": { "hmax": 0.05,
"max": 0.05, "hmin": 0,
"min": 0 "vmax": 0.2,
}, "vmin": 0
"v": {
"max": 0.2,
"min": 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 /// @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: private:
/// Hyperion instance /// Hyperion instance

View File

@ -54,7 +54,7 @@ public slots:
/// ///
void stop(); 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 /// @brief Handle settings update from Hyperion Settingsmanager emit or this constructor

View File

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

View File

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

View File

@ -46,13 +46,15 @@ private slots:
const QJsonValue bgColorConfig = BGEffectConfig["color"]; const QJsonValue bgColorConfig = BGEffectConfig["color"];
if (bgTypeConfig.contains("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(0).toInt(0),
(uint8_t)BGCONFIG_ARRAY.at(1).toInt(0), (uint8_t)BGCONFIG_ARRAY.at(1).toInt(0),
(uint8_t)BGCONFIG_ARRAY.at(2).toInt(0) (uint8_t)BGCONFIG_ARRAY.at(2).toInt(0)
}
}; };
_hyperion->setColor(254, bg_color); _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 else
{ {

View File

@ -28,7 +28,7 @@ private slots:
/// @param component The component from enum /// @param component The component from enum
/// @param enable The new state /// @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 /// @brief Handle settings update from Hyperion Settingsmanager emit or this constructor

View File

@ -22,14 +22,6 @@ public:
ComponentRegister(Hyperion* hyperion); ComponentRegister(Hyperion* hyperion);
~ComponentRegister(); ~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 /// @brief Check if a component is currently enabled
/// @param comp The component from enum /// @param comp The component from enum
@ -50,11 +42,17 @@ signals:
public slots: 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 comp The component
/// @param state The new state of 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: private:
/// Hyperion instance /// Hyperion instance
@ -65,4 +63,6 @@ private:
std::map<hyperion::Components, bool> _componentStates; std::map<hyperion::Components, bool> _componentStates;
/// on hyperion off we save the previous states of all components /// on hyperion off we save the previous states of all components
std::map<hyperion::Components, bool> _prevComponentStates; 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 /// @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: protected:
ImageResampler _imageResampler; ImageResampler _imageResampler;

View File

@ -206,12 +206,17 @@ public:
void setNewComponentState(const hyperion::Components& component, const bool& state); 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 std::map<hyperion::Components, bool> getAllComponents();
/// @param state The state of the component [true | false]
/// ///
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; }; ComponentRegister& getComponentRegister() { return _componentRegister; };
@ -278,12 +283,12 @@ public slots:
/// Should be never used to update leds continuous /// Should be never used to update leds continuous
/// ///
/// @param[in] priority The priority of the written color /// @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] timeout_ms The time the leds are set to the given color [ms]
/// @param[in] origin The setter /// @param[in] origin The setter
/// @param clearEffect Should be true when NOT called from an effect /// @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 /// @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 /// 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) /// 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) /// @return True on success else false (not found)
/// ///
bool clear(const int priority); bool clear(const int priority, bool forceClearAll=false);
///
/// @brief Clears all priority channels. This will switch the leds off until a new priority is written.
///
void clearall(bool forceClearAll=false);
/// Run the specified effect on the given priority channel and optionally specify a timeout /// Run the specified effect on the given priority channel and optionally specify a timeout
/// @param effectName Name of the effec to run /// @param effectName Name of the effec to run
@ -375,7 +376,7 @@ signals:
/// @param component The component from enum /// @param component The component from enum
/// @param enabled The new state of the component /// @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 /// @brief Emits whenever the imageToLedsMapping has changed

View File

@ -130,7 +130,7 @@ signals:
/// ///
/// @brief PIPE component state changes from Hyperion to HyperionDaemon /// @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: private slots:
/// ///

View File

@ -52,7 +52,7 @@ private slots:
/// @param component The component from enum /// @param component The component from enum
/// @param enable The new state /// @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 /// @brief Handle priority updates from Priority Muxer

View File

@ -53,6 +53,14 @@ signals:
void settingsChanged(const settings::type& type, const QJsonDocument& data); void settingsChanged(const settings::type& type, const QJsonDocument& data);
private: 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 instance
Hyperion* _hyperion; Hyperion* _hyperion;

View File

@ -19,7 +19,7 @@ class QNetworkConfigurationManager;
class SSDPHandler : public SSDPServer{ class SSDPHandler : public SSDPServer{
Q_OBJECT Q_OBJECT
public: 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(); ~SSDPHandler();
public slots: public slots:

View File

@ -93,6 +93,17 @@ public:
/// ///
quint16 getJsonServerPort() { return _jssPort.toInt(); }; 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: signals:
/// ///
/// @brief Emits whenever a new SSDP search "man : ssdp:discover" is received along with the service type /// @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 _uuid;
QString _fbsPort; QString _fbsPort;
QString _jssPort; QString _jssPort;
QString _name;
QString _descAddress; QString _descAddress;
bool _running; bool _running;

View File

@ -58,14 +58,10 @@ signals:
/// ///
/// @brief PIPE the clear command for the global priority channel over HyperionDaemon to Hyperion class /// @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); void clearGlobalInput(int priority, bool forceClearAll=false);
///
/// @brief PIPE the clearAll command over HyperionDaemon to Hyperion class
///
void clearAllGlobalInput(bool forceClearAll=false);
/// ///
/// @brief PIPE external images over HyperionDaemon to Hyperion class /// @brief PIPE external images over HyperionDaemon to Hyperion class
@ -84,7 +80,7 @@ signals:
/// @param[in] origin The setter /// @param[in] origin The setter
/// @param clearEffect Should be true when NOT called from an effect /// @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 //////////// //////////// FROM HYPERION ////////////

View File

@ -34,13 +34,15 @@ namespace hyperion {
} }
if ( fgTypeConfig.contains("color") ) 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(0).toInt(0),
(uint8_t)FGCONFIG_ARRAY.at(1).toInt(0), (uint8_t)FGCONFIG_ARRAY.at(1).toInt(0),
(uint8_t)FGCONFIG_ARRAY.at(2).toInt(0) (uint8_t)FGCONFIG_ARRAY.at(2).toInt(0)
}
}; };
hyperion->setColor(FG_PRIORITY, fg_color, fg_duration_ms); 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 else
{ {
@ -195,15 +197,13 @@ namespace hyperion {
for (signed i = 0; i < ledConfigArray.size(); ++i) for (signed i = 0; i < ledConfigArray.size(); ++i)
{ {
const QJsonObject& index = ledConfigArray[i].toObject(); const QJsonObject& ledConfig = ledConfigArray[i].toObject();
Led led; Led led;
const QJsonObject& hscanConfig = ledConfigArray[i].toObject()["h"].toObject(); led.minX_frac = qMax(0.0, qMin(1.0, ledConfig["hmin"].toDouble()));
const QJsonObject& vscanConfig = ledConfigArray[i].toObject()["v"].toObject(); led.maxX_frac = qMax(0.0, qMin(1.0, ledConfig["hmax"].toDouble()));
led.minX_frac = qMax(0.0, qMin(1.0, hscanConfig["min"].toDouble())); led.minY_frac = qMax(0.0, qMin(1.0, ledConfig["vmin"].toDouble()));
led.maxX_frac = qMax(0.0, qMin(1.0, hscanConfig["max"].toDouble())); led.maxY_frac = qMax(0.0, qMin(1.0, ledConfig["vmax"].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()));
// Fix if the user swapped min and max // Fix if the user swapped min and max
if (led.minX_frac > led.maxX_frac) 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) // 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); ledString.leds().push_back(led);
} }
return ledString; return ledString;
@ -228,12 +228,12 @@ namespace hyperion {
for (signed i = 0; i < ledConfigArray.size(); ++i) for (signed i = 0; i < ledConfigArray.size(); ++i)
{ {
const QJsonObject& hscanConfig = ledConfigArray[i].toObject()["h"].toObject(); const QJsonObject& ledConfig = ledConfigArray[i].toObject();
const QJsonObject& vscanConfig = ledConfigArray[i].toObject()["v"].toObject();
double minX_frac = qMax(0.0, qMin(1.0, hscanConfig["min"].toDouble())); double minX_frac = qMax(0.0, qMin(1.0, ledConfig["hmin"].toDouble()));
double maxX_frac = qMax(0.0, qMin(1.0, hscanConfig["max"].toDouble())); double maxX_frac = qMax(0.0, qMin(1.0, ledConfig["hmax"].toDouble()));
double minY_frac = qMax(0.0, qMin(1.0, vscanConfig["min"].toDouble())); double minY_frac = qMax(0.0, qMin(1.0, ledConfig["vmin"].toDouble()));
double maxY_frac = qMax(0.0, qMin(1.0, vscanConfig["max"].toDouble())); double maxY_frac = qMax(0.0, qMin(1.0, ledConfig["vmax"].toDouble()));
// Fix if the user swapped min and max // Fix if the user swapped min and max
if (minX_frac > maxX_frac) 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) void JsonAPI::handleColorCommand(const QJsonObject& message, const QString& command, const int tan)
{ {
emit forwardJsonMessage(message); emit forwardJsonMessage(message);
// extract parameters
int priority = message["priority"].toInt(); int priority = message["priority"].toInt();
int duration = message["duration"].toInt(-1); 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 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())}; 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 // set color
_hyperion->setColor(priority, color, duration, origin); _hyperion->setColor(priority, fledColors, duration, origin);
// send reply // send reply
sendSuccessReply(command, tan); sendSuccessReply(command, tan);
@ -562,7 +574,7 @@ void JsonAPI::handleServerInfoCommand(const QJsonObject& message, const QString&
// get available components // get available components
QJsonArray component; QJsonArray component;
std::map<hyperion::Components, bool> components = _hyperion->getComponentRegister().getRegister(); std::map<hyperion::Components, bool> components = _hyperion->getAllComponents();
for(auto comp : components) for(auto comp : components)
{ {
QJsonObject item; QJsonObject item;
@ -744,7 +756,7 @@ void JsonAPI::handleClearCommand(const QJsonObject& message, const QString& comm
if(priority > 0) if(priority > 0)
_hyperion->clear(priority); _hyperion->clear(priority);
else if(priority < 0) else if(priority < 0)
_hyperion->clearall(); _hyperion->clear(-1);
else else
{ {
sendErrorReply("Priority 0 is not allowed", command, tan); sendErrorReply("Priority 0 is not allowed", command, tan);
@ -760,7 +772,7 @@ void JsonAPI::handleClearallCommand(const QJsonObject& message, const QString& c
emit forwardJsonMessage(message); emit forwardJsonMessage(message);
// clear priority // clear priority
_hyperion->clearall(); _hyperion->clear(-1);
// send reply // send reply
sendSuccessReply(command, tan); sendSuccessReply(command, tan);
@ -920,7 +932,7 @@ void JsonAPI::handleConfigSetCommand(const QJsonObject& message, const QString &
if (message.contains("config")) if (message.contains("config"))
{ {
QJsonObject config = message["config"].toObject(); QJsonObject config = message["config"].toObject();
if(_hyperion->getComponentRegister().isComponentEnabled(hyperion::COMP_ALL)) if(_hyperion->isComponentEnabled(hyperion::COMP_ALL))
{ {
if(_hyperion->saveSettings(config, true)) if(_hyperion->saveSettings(config, true))
sendSuccessReply(command,tan); sendSuccessReply(command,tan);
@ -1004,18 +1016,11 @@ void JsonAPI::handleComponentStateCommand(const QJsonObject& message, const QStr
Components component = stringToComponent(compStr); Components component = stringToComponent(compStr);
if (compStr == "ALL" ) if (component != COMP_INVALID)
{
if(_hyperion->getComponentRegister().setHyperionEnable(compState))
sendSuccessReply(command, tan);
return;
}
else if (component != COMP_INVALID)
{ {
// send result before apply // send result before apply
sendSuccessReply(command, tan); sendSuccessReply(command, tan);
_hyperion->setComponentState(component, compState); emit _hyperion->compStateChangeRequest(component, compState);
return; return;
} }
sendErrorReply("invalid component name", command, tan); 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); connect(_hyperion, &Hyperion::settingsChanged, this, &BlackBorderProcessor::handleSettingsUpdate);
// listen for component state changes // listen for component state changes
connect(_hyperion, &Hyperion::componentStateChanged, this, &BlackBorderProcessor::componentStateChanged); connect(_hyperion, &Hyperion::compStateChangeRequest, this, &BlackBorderProcessor::handleCompStateChangeRequest);
} }
BlackBorderProcessor::~BlackBorderProcessor() 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)); Debug(Logger::getInstance("BLACKBORDER"), "Set mode to: %s", QSTRING_CSTR(_detectionMode));
// eval the comp state // 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) if(component == hyperion::COMP_BLACKBORDER)
{ {
@ -85,7 +85,7 @@ void BlackBorderProcessor::componentStateChanged(const hyperion::Components comp
_enabled = enable; _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"); Debug(_log, "Instance created");
// listen for component change // 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 // listen new connection signal from server
connect(_server, SIGNAL(newConnection()), this, SLOT(newConnection())); connect(_server, SIGNAL(newConnection()), this, SLOT(newConnection()));
@ -51,7 +51,7 @@ void BoblightServer::start()
Info(_log, "Started on port %d", _port); Info(_log, "Started on port %d", _port);
_hyperion->getComponentRegister().componentStateChanged(COMP_BOBLIGHTSERVER, _server->isListening()); _hyperion->setNewComponentState(COMP_BOBLIGHTSERVER, _server->isListening());
} }
void BoblightServer::stop() void BoblightServer::stop()
@ -65,7 +65,7 @@ void BoblightServer::stop()
_server->close(); _server->close();
Info(_log, "Stopped"); Info(_log, "Stopped");
_hyperion->getComponentRegister().componentStateChanged(COMP_BOBLIGHTSERVER, _server->isListening()); _hyperion->setNewComponentState(COMP_BOBLIGHTSERVER, _server->isListening());
} }
bool BoblightServer::active() bool BoblightServer::active()
@ -73,7 +73,7 @@ bool BoblightServer::active()
return _server->isListening(); 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) if (component == COMP_BOBLIGHTSERVER)
{ {

View File

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

View File

@ -41,12 +41,7 @@ signals:
/// ///
/// @brief Forward clear command to HyperionDaemon /// @brief Forward clear command to HyperionDaemon
/// ///
void clearGlobalInput(const int priority); void clearGlobalInput(const int priority, bool forceClearAll=false);
///
/// @brief Forward clearAll command to HyperionDaemon
///
void clearAllGlobalInput(bool forceClearAll=false);
/// ///
/// @brief forward prepared image to HyperionDaemon /// @brief forward prepared image to HyperionDaemon
@ -56,7 +51,7 @@ signals:
/// ///
/// @brief Forward requested color /// @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 /// @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::clientDisconnected, this, &FlatBufferServer::clientDisconnected);
connect(client, &FlatBufferClient::registerGlobalInput, GlobalSignals::getInstance(), &GlobalSignals::registerGlobalInput); connect(client, &FlatBufferClient::registerGlobalInput, GlobalSignals::getInstance(), &GlobalSignals::registerGlobalInput);
connect(client, &FlatBufferClient::clearGlobalInput, GlobalSignals::getInstance(), &GlobalSignals::clearGlobalInput); 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::setGlobalInputImage, GlobalSignals::getInstance(), &GlobalSignals::setGlobalImage);
connect(client, &FlatBufferClient::setGlobalInputColor, GlobalSignals::getInstance(), &GlobalSignals::setGlobalColor); connect(client, &FlatBufferClient::setGlobalInputColor, GlobalSignals::getInstance(), &GlobalSignals::setGlobalColor);
connect(GlobalSignals::getInstance(), &GlobalSignals::globalRegRequired, client, &FlatBufferClient::registationRequired); 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 // connect componentStateChange only for build-in grabber
if (HyperionIManager::HIMinstance) if (HyperionIManager::HIMinstance)
connect(this, &Grabber::componentStateChanged, this, &V4L2Grabber::componentStateChanged); connect(this, &Grabber::compStateChangeRequest, this, &V4L2Grabber::compStateChangeRequest);
// init // init
setDeviceVideoStandard(device, videoStandard); 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) 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(newFrame(Image<ColorRgb>)), this, SLOT(newFrame(Image<ColorRgb>)), Qt::DirectConnection);
connect(&_grabber, SIGNAL(readError(const char*)), this, SLOT(readError(const char*)), 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() bool V4L2Wrapper::start()

View File

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

View File

@ -16,51 +16,20 @@ ComponentRegister::ComponentRegister(Hyperion* hyperion)
{ {
_componentStates.emplace(e, ((e == COMP_ALL) ? true : false)); _componentStates.emplace(e, ((e == COMP_ALL) ? true : false));
} }
connect(_hyperion, &Hyperion::compStateChangeRequest, this, &ComponentRegister::handleCompStateChangeRequest);
} }
ComponentRegister::~ComponentRegister() 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 int ComponentRegister::isComponentEnabled(const hyperion::Components& comp) const
{ {
return (_componentStates.count(comp)) ? _componentStates.at(comp) : -1; 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) if(_componentStates[comp] != activated)
{ {
@ -70,3 +39,38 @@ void ComponentRegister::componentStateChanged(const hyperion::Components comp, c
emit updatedComponentState(comp, activated); 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 ledDevice["currentLedCount"] = int(_hwLedCount); // Inject led count info
_ledDeviceWrapper = new LedDeviceWrapper(this); _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); connect(this, &Hyperion::ledDeviceData, _ledDeviceWrapper, &LedDeviceWrapper::updateLeds);
_ledDeviceWrapper->createLedDevice(ledDevice); _ledDeviceWrapper->createLedDevice(ledDevice);
@ -132,7 +132,6 @@ void Hyperion::start()
// forwards global signals to the corresponding slots // forwards global signals to the corresponding slots
connect(GlobalSignals::getInstance(), &GlobalSignals::registerGlobalInput, this, &Hyperion::registerInput); connect(GlobalSignals::getInstance(), &GlobalSignals::registerGlobalInput, this, &Hyperion::registerInput);
connect(GlobalSignals::getInstance(), &GlobalSignals::clearGlobalInput, this, &Hyperion::clear); 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::setGlobalColor, this, &Hyperion::setColor);
connect(GlobalSignals::getInstance(), &GlobalSignals::setGlobalImage, this, &Hyperion::setInputImage); connect(GlobalSignals::getInstance(), &GlobalSignals::setGlobalImage, this, &Hyperion::setInputImage);
@ -157,7 +156,7 @@ void Hyperion::stop()
void Hyperion::freeObjects(bool emitCloseSignal) void Hyperion::freeObjects(bool emitCloseSignal)
{ {
// switch off all leds // switch off all leds
clearall(true); clear(-1,true);
if (emitCloseSignal) if (emitCloseSignal)
{ {
@ -309,13 +308,17 @@ bool Hyperion::sourceAutoSelectEnabled()
void Hyperion::setNewComponentState(const hyperion::Components& component, const bool& state) 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 return _componentRegister.getRegister();
emit componentStateChanged(component, state); }
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) 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); 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 // clear effect if this call does not come from an effect
if (clearEffects) if (clearEffects)
_effectEngine->channelCleared(priority); _effectEngine->channelCleared(priority);
// create led vector from single color // create full led vector from single/multiple colors
std::vector<ColorRgb> ledColors(_ledString.leds().size(), color); 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) if (getPriorityInfo(priority).componentId != hyperion::COMP_COLOR)
clear(priority); clear(priority);
@ -388,7 +402,7 @@ void Hyperion::setColor(const int priority, const ColorRgb &color, const int tim
registerInput(priority, hyperion::COMP_COLOR, origin); registerInput(priority, hyperion::COMP_COLOR, origin);
// write color to muxer & queuePush // write color to muxer & queuePush
setInput(priority, ledColors, timeout_ms); setInput(priority, newLedColors, timeout_ms);
if (timeout_ms <= 0) if (timeout_ms <= 0)
_muxer.queuePush(); _muxer.queuePush();
} }
@ -409,7 +423,17 @@ void Hyperion::adjustmentsUpdated()
update(); update();
} }
bool Hyperion::clear(const int priority) 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 // send clear signal to the effect engine
// (outside the check so the effect gets cleared even when the effect is not sending colors) // (outside the check so the effect gets cleared even when the effect is not sending colors)
@ -417,16 +441,8 @@ bool Hyperion::clear(const int priority)
if (_muxer.clearInput(priority)) if (_muxer.clearInput(priority))
return true; return true;
return false;
} }
return false;
void Hyperion::clearall(bool forceClearAll)
{
_muxer.clearAll(forceClearAll);
// send clearall signal to the effect engine
_effectEngine->allChannelsCleared();
} }
int Hyperion::getCurrentPriority() const int Hyperion::getCurrentPriority() const

View File

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

View File

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

View File

@ -28,7 +28,7 @@ MessageForwarder::MessageForwarder(Hyperion *hyperion)
connect(_hyperion, &Hyperion::settingsChanged, this, &MessageForwarder::handleSettingsUpdate); connect(_hyperion, &Hyperion::settingsChanged, this, &MessageForwarder::handleSettingsUpdate);
// component changes // component changes
connect(_hyperion, &Hyperion::componentStateChanged, this, &MessageForwarder::componentStateChanged); connect(_hyperion, &Hyperion::compStateChangeRequest, this, &MessageForwarder::handleCompStateChangeRequest);
// connect with Muxer visible priority changes // connect with Muxer visible priority changes
connect(_muxer, &PriorityMuxer::visiblePriorityChanged, this, &MessageForwarder::handlePriorityChanges); connect(_muxer, &PriorityMuxer::visiblePriorityChanged, this, &MessageForwarder::handlePriorityChanges);
@ -91,18 +91,18 @@ void MessageForwarder::handleSettingsUpdate(const settings::type &type, const QJ
} }
// update comp state // 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) if (component == hyperion::COMP_FORWARDER && _forwarder_enabled != enable)
{ {
_forwarder_enabled = enable; _forwarder_enabled = enable;
handleSettingsUpdate(settings::NETFORWARD, _hyperion->getSetting(settings::NETFORWARD)); handleSettingsUpdate(settings::NETFORWARD, _hyperion->getSetting(settings::NETFORWARD));
Info(_log, "Forwarder change state to %s", (_forwarder_enabled ? "enabled" : "disabled")); 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(); 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 // validate full dbconfig against schema, on error we need to rewrite entire table
QJsonSchemaChecker schemaChecker; QJsonSchemaChecker schemaChecker;
schemaChecker.setSchema(schemaJson); schemaChecker.setSchema(schemaJson);
@ -108,6 +115,9 @@ const QJsonDocument SettingsManager::getSetting(const settings::type& type)
bool SettingsManager::saveSettings(QJsonObject config, const bool& correct) 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 // we need to validate data against schema
QJsonSchemaChecker schemaChecker; QJsonSchemaChecker schemaChecker;
schemaChecker.setSchema(schemaJson); schemaChecker.setSchema(schemaJson);
@ -156,3 +166,66 @@ bool SettingsManager::saveSettings(QJsonObject config, const bool& correct)
} }
return true; 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

@ -2,69 +2,61 @@
"type": "array", "type": "array",
"required": true, "required": true,
"minItems": 1, "minItems": 1,
"items": "items": {
{
"type": "object", "type": "object",
"required": true, "required": true,
"properties": "properties": {
{ "hmin": {
"h":
{
"type":"object",
"required" : true,
"properties":
{
"min":
{
"type": "number", "type": "number",
"minimum": 0, "minimum": 0,
"maximum": 1, "maximum": 1,
"required": true, "required": true,
"default": 0 "default": 0
}, },
"max": "hmax": {
{
"type": "number", "type": "number",
"minimum": 0, "minimum": 0,
"maximum": 1, "maximum": 1,
"required": true, "required": true,
"default": 0.1 "default": 0.1
}
}, },
"additionalProperties" : false "vmin": {
},
"v":
{
"type":"object",
"required" : true,
"properties":
{
"min":
{
"type": "number", "type": "number",
"minimum": 0, "minimum": 0,
"maximum": 1, "maximum": 1,
"required": true, "required": true,
"default": 0 "default": 0
}, },
"max": "vmax": {
{
"type": "number", "type": "number",
"minimum": 0, "minimum": 0,
"maximum": 1, "maximum": 1,
"required": true, "required": true,
"default": 0.1 "default": 0.1
}
}, },
"additionalProperties" : false "colorOrder": {
},
"colorOrder":
{
"type": "string", "type": "string",
"enum" : ["rgb", "bgr", "rbg", "brg", "gbr", "grb"], "enum": [
"rgb",
"bgr",
"rbg",
"brg",
"gbr",
"grb"
],
"options": { "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_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"
]
} }
},
"name": {
"type": "string"
} }
}, },
"additionalProperties": false "additionalProperties": false

View File

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

View File

@ -41,12 +41,7 @@ signals:
/// ///
/// @brief Forward clear command to HyperionDaemon /// @brief Forward clear command to HyperionDaemon
/// ///
void clearGlobalInput(const int priority); void clearGlobalInput(const int priority, bool forceClearAll=false);
///
/// @brief Forward clearAll command to HyperionDaemon
///
void clearAllGlobalInput(bool forceClearAll=false);
/// ///
/// @brief forward prepared image to HyperionDaemon /// @brief forward prepared image to HyperionDaemon
@ -56,7 +51,7 @@ signals:
/// ///
/// @brief Forward requested color /// @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 /// @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::clientDisconnected, this, &ProtoServer::clientDisconnected);
connect(client, &ProtoClientConnection::registerGlobalInput, GlobalSignals::getInstance(), &GlobalSignals::registerGlobalInput); connect(client, &ProtoClientConnection::registerGlobalInput, GlobalSignals::getInstance(), &GlobalSignals::registerGlobalInput);
connect(client, &ProtoClientConnection::clearGlobalInput, GlobalSignals::getInstance(), &GlobalSignals::clearGlobalInput); 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::setGlobalInputImage, GlobalSignals::getInstance(), &GlobalSignals::setGlobalImage);
connect(client, &ProtoClientConnection::setGlobalInputColor, GlobalSignals::getInstance(), &GlobalSignals::setGlobalColor); connect(client, &ProtoClientConnection::setGlobalInputColor, GlobalSignals::getInstance(), &GlobalSignals::setGlobalColor);
connect(GlobalSignals::getInstance(), &GlobalSignals::globalRegRequired, client, &ProtoClientConnection::registationRequired); connect(GlobalSignals::getInstance(), &GlobalSignals::globalRegRequired, client, &ProtoClientConnection::registationRequired);

View File

@ -9,7 +9,7 @@
#include <QNetworkInterface> #include <QNetworkInterface>
#include <QNetworkConfigurationManager> #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) : SSDPServer(parent)
, _webserver(webserver) , _webserver(webserver)
, _localAddress() , _localAddress()
@ -17,6 +17,7 @@ SSDPHandler::SSDPHandler(WebServer* webserver, const quint16& flatBufPort, const
{ {
setFlatBufPort(flatBufPort); setFlatBufPort(flatBufPort);
setJsonServerPort(jsonServerPort); setJsonServerPort(jsonServerPort);
setHyperionName(name);
} }
SSDPHandler::~SSDPHandler() SSDPHandler::~SSDPHandler()
@ -76,6 +77,15 @@ void SSDPHandler::handleSettingsUpdate(const settings::type& type, const QJsonDo
SSDPServer::setJsonServerPort(obj["port"].toInt()); 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) 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" "USN: uuid:%5\r\n"
"HYPERION-FBS-PORT: %6\r\n" "HYPERION-FBS-PORT: %6\r\n"
"HYPERION-JSS-PORT: %7\r\n" "HYPERION-JSS-PORT: %7\r\n"
"HYPERION-NAME: %8\r\n"
"\r\n"; "\r\n";
// Implement ssdp:update as per spec 1.1, section 1.2.4 // 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" "USN: uuid:%6\r\n"
"HYPERION-FBS-PORT: %7\r\n" "HYPERION-FBS-PORT: %7\r\n"
"HYPERION-JSS-PORT: %8\r\n" "HYPERION-JSS-PORT: %8\r\n"
"HYPERION-NAME: %9\r\n"
"\r\n"; "\r\n";
SSDPServer::SSDPServer(QObject * parent) SSDPServer::SSDPServer(QObject * parent)
@ -172,7 +174,8 @@ void SSDPServer::sendMSearchResponse(const QString& st, const QString& senderIp,
, st , st
, _uuid , _uuid
, _fbsPort , _fbsPort
, _jssPort ); , _jssPort
, _name );
_udpSocket->writeDatagram(message.toUtf8(), _udpSocket->writeDatagram(message.toUtf8(),
QHostAddress(senderIp), QHostAddress(senderIp),
@ -203,7 +206,8 @@ void SSDPServer::sendAlive(const QString& st)
, _serverHeader , _serverHeader
, tempUSN , tempUSN
, _fbsPort , _fbsPort
, _jssPort ); , _jssPort
, _name );
// we repeat 3 times // we repeat 3 times
quint8 rep = 0; 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 // pipe settings changes and component state changes from HyperionIManager to Daemon
connect(_instanceManager, &HyperionIManager::settingsChanged, this, &HyperionDaemon::settingsChanged); 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 // listen for setting changes of framegrabber and v4l2
connect(this, &HyperionDaemon::settingsChanged, this, &HyperionDaemon::handleSettingsUpdate); connect(this, &HyperionDaemon::settingsChanged, this, &HyperionDaemon::handleSettingsUpdate);
@ -247,7 +247,7 @@ void HyperionDaemon::startNetworkServices()
sslWsThread->start(); sslWsThread->start();
// Create SSDP server in thread // 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); QThread* ssdpThread = new QThread(this);
_ssdp->moveToThread(ssdpThread); _ssdp->moveToThread(ssdpThread);
connect( ssdpThread, &QThread::started, _ssdp, &SSDPHandler::initServer ); connect( ssdpThread, &QThread::started, _ssdp, &SSDPHandler::initServer );
@ -436,7 +436,7 @@ void HyperionDaemon::handleSettingsUpdate(const settings::type& settingsType, co
// connect to HyperionDaemon signal // connect to HyperionDaemon signal
connect(this, &HyperionDaemon::videoMode, _v4l2Grabber, &V4L2Wrapper::setVideoMode); connect(this, &HyperionDaemon::videoMode, _v4l2Grabber, &V4L2Wrapper::setVideoMode);
connect(this, &HyperionDaemon::settingsChanged, _v4l2Grabber, &V4L2Wrapper::handleSettingsUpdate); connect(this, &HyperionDaemon::settingsChanged, _v4l2Grabber, &V4L2Wrapper::handleSettingsUpdate);
connect(this, &HyperionDaemon::componentStateChanged, _v4l2Grabber, &V4L2Wrapper::componentStateChanged); connect(this, &HyperionDaemon::compStateChangeRequest, _v4l2Grabber, &V4L2Wrapper::compStateChangeRequest);
#else #else
Error(_log, "The v4l2 grabber can not be instantiated, because it has been left out from the build"); Error(_log, "The v4l2 grabber can not be instantiated, because it has been left out from the build");
#endif #endif

View File

@ -120,7 +120,7 @@ signals:
/// ///
/// @brief PIPE component state changes events from Hyperion class to HyperionDaemon components /// @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: private slots:
/// ///

View File

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