Correct PR1312 and LEDSim fixes (#1336)

* Revert Refactor/Optimization of PR1312

* LED Layout - Only update preview image when visible

* Revert Debug updates

* Correct Refactor/Optimization of PR1312

* LedSim: Do not stream LED data when not required, LedS-im/Layout: Sync on video streaming

* Remove initial switch to instance 0 during API init
This commit is contained in:
LordGrey 2021-09-20 08:44:09 +02:00 committed by GitHub
parent da49f25b4e
commit 8134917c51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 49 additions and 31 deletions

View File

@ -9,8 +9,7 @@
"name": "Run hyperion with debug option and external console", "name": "Run hyperion with debug option and external console",
"args": [ "args": [
"-d", "-d",
"-c", "-c"
"-u test"
], ],
"externalConsole": true "externalConsole": true
} }

10
assets/webconfig/js/content_index.js Executable file → Normal file
View File

@ -25,6 +25,8 @@ $(document).ready(function () {
// comps // comps
window.comps = event.response.info.components window.comps = event.response.info.components
$(window.hyperion).trigger("ready");
window.comps.forEach(function (obj) { window.comps.forEach(function (obj) {
if (obj.name == "ALL") { if (obj.name == "ALL") {
if (obj.enabled) if (obj.enabled)
@ -40,7 +42,6 @@ $(document).ready(function () {
$('#btn_hypinstanceswitch').toggle(true) $('#btn_hypinstanceswitch').toggle(true)
else else
$('#btn_hypinstanceswitch').toggle(false) $('#btn_hypinstanceswitch').toggle(false)
updateSessions(); updateSessions();
}); // end cmd-serverinfo }); // end cmd-serverinfo
@ -121,11 +122,12 @@ $(document).ready(function () {
//Switch to last selected instance and load related config //Switch to last selected instance and load related config
var lastSelectedInstance = getStorage('lastSelectedInstance', false); var lastSelectedInstance = getStorage('lastSelectedInstance', false);
if (!window.serverInfo.instance[lastSelectedInstance]) { if (lastSelectedInstance == null || window.serverInfo.instance && !window.serverInfo.instance[lastSelectedInstance]) {
lastSelectedInstance = 0; lastSelectedInstance = 0;
} }
instanceSwitch(lastSelectedInstance); instanceSwitch(lastSelectedInstance);
requestSysInfo();
}); });
$(window.hyperion).on("cmd-config-getconfig", function (event) { $(window.hyperion).on("cmd-config-getconfig", function (event) {
@ -157,8 +159,6 @@ $(document).ready(function () {
if (event.response.hasOwnProperty('info')) if (event.response.hasOwnProperty('info'))
setStorage("loginToken", event.response.info.token, true); setStorage("loginToken", event.response.info.token, true);
requestSysInfo();
requestServerInfo();
requestServerConfigSchema(); requestServerConfigSchema();
}); });
@ -218,7 +218,7 @@ $(document).ready(function () {
}); });
$(window.hyperion).one("ready", function (event) { $(window.hyperion).one("ready", function (event) {
loadContent(); // Content will be loaded by the instance load/switch
}); });
$(window.hyperion).on("cmd-adjustment-update", function (event) { $(window.hyperion).on("cmd-adjustment-update", function (event) {

View File

@ -1,4 +1,5 @@
var ledsCustomCfgInitialized = false; var ledsCustomCfgInitialized = false;
var onLedLayoutTab = false;
var nonBlacklistLedArray = []; var nonBlacklistLedArray = [];
var ledBlacklist = []; var ledBlacklist = [];
var finalLedArray = []; var finalLedArray = [];
@ -568,9 +569,12 @@ $(document).ready(function () {
// toggle live video // toggle live video
$('#leds_prev_toggle_live_video').off().on("click", function () { $('#leds_prev_toggle_live_video').off().on("click", function () {
setClassByBool('#leds_prev_toggle_live_video', window.imageStreamActive, "btn-success", "btn-danger"); setClassByBool('#leds_prev_toggle_live_video', window.imageStreamActive, "btn-success", "btn-danger");
if (window.imageStreamActive) {
requestLedImageStop(); if (onLedLayoutTab && window.imageStreamActive) {
imageCanvasNodeCtx.clear(); imageCanvasNodeCtx.clear();
if (!$('#leds_toggle_live_video').hasClass("btn-success")) {
requestLedImageStop();
}
} }
else { else {
requestLedImageStart(); requestLedImageStart();
@ -578,14 +582,17 @@ $(document).ready(function () {
}); });
$(window.hyperion).on("cmd-ledcolors-imagestream-update", function (event) { $(window.hyperion).on("cmd-ledcolors-imagestream-update", function (event) {
setClassByBool('#leds_prev_toggle_live_video', window.imageStreamActive, "btn-danger", "btn-success"); //Only update Image, if LED Layout Tab is visible
var imageData = (event.response.result.image); if (onLedLayoutTab && window.imageStreamActive) {
setClassByBool('#leds_prev_toggle_live_video', window.imageStreamActive, "btn-danger", "btn-success");
var imageData = (event.response.result.image);
var image = new Image(); var image = new Image();
image.onload = function () { image.onload = function () {
imageCanvasNodeCtx.drawImage(image, 0, 0, imageCanvasNodeCtx.canvas.width, imageCanvasNodeCtx.canvas.height); imageCanvasNodeCtx.drawImage(image, 0, 0, imageCanvasNodeCtx.canvas.width, imageCanvasNodeCtx.canvas.height);
}; };
image.src = imageData; image.src = imageData;
}
}); });
// open checklist // open checklist
@ -605,9 +612,14 @@ $(document).ready(function () {
// nav // nav
$('#leds_cfg_nav a[data-toggle="tab"]').off().on('shown.bs.tab', function (e) { $('#leds_cfg_nav a[data-toggle="tab"]').off().on('shown.bs.tab', function (e) {
var target = $(e.target).attr("href") // activated tab var target = $(e.target).attr("href") // activated tab
if (target == "#menu_gencfg" && !ledsCustomCfgInitialized) { if (target == "#menu_gencfg") {
$('#leds_custom_updsim').trigger('click'); onLedLayoutTab = true;
ledsCustomCfgInitialized = true; if (!ledsCustomCfgInitialized) {
$('#leds_custom_updsim').trigger('click');
ledsCustomCfgInitialized = true;
}
} else {
onLedLayoutTab = false;
} }
blacklist_editor.on('change', function () { blacklist_editor.on('change', function () {

View File

@ -11,7 +11,7 @@ $(document).ready(function () {
var canvas_height; var canvas_height;
var canvas_width; var canvas_width;
var twoDPaths = []; var twoDPaths = [];
var toggleLeds = false; var toggleLeds = true;
var toggleLedsNum = false; var toggleLedsNum = false;
var toggleSigDetectArea = false; var toggleSigDetectArea = false;
@ -109,7 +109,10 @@ $(document).ready(function () {
lC = true; lC = true;
} }
modalOpened = true; modalOpened = true;
requestLedColorsStart();
setClassByBool('#leds_toggle', toggleLeds, "btn-danger", "btn-success");
if ($('#leds_toggle').hasClass('btn-success'))
requestLedColorsStart();
setClassByBool('#leds_toggle_live_video', window.imageStreamActive, "btn-danger", "btn-success"); setClassByBool('#leds_toggle_live_video', window.imageStreamActive, "btn-danger", "btn-success");
if ($('#leds_toggle_live_video').hasClass('btn-success')) if ($('#leds_toggle_live_video').hasClass('btn-success'))
@ -145,7 +148,7 @@ $(document).ready(function () {
} }
// toggle leds, do not print // toggle leds, do not print
if (toggleLeds) if (!toggleLeds)
return; return;
var useColor = false; var useColor = false;
@ -220,10 +223,16 @@ $(document).ready(function () {
$('#leds_toggle').off().on("click", function () { $('#leds_toggle').off().on("click", function () {
toggleLeds = !toggleLeds toggleLeds = !toggleLeds
ledsCanvasNodeCtx.clear();
if (window.ledStreamActive) {
requestLedColorsStop();
ledsCanvasNodeCtx.clear();
} else {
requestLedColorsStart();
}
toggleClass('#leds_toggle', "btn-success", "btn-danger"); toggleClass('#leds_toggle', "btn-success", "btn-danger");
if (!toggleLeds) { if (toggleLeds) {
$("#leds_toggle_num").show(); $("#leds_toggle_num").show();
} else { } else {
$("#leds_toggle_num").hide(); $("#leds_toggle_num").hide();
@ -234,6 +243,7 @@ $(document).ready(function () {
$('#leds_toggle_live_video').off().on("click", function () { $('#leds_toggle_live_video').off().on("click", function () {
setClassByBool('#leds_toggle_live_video', window.imageStreamActive, "btn-success", "btn-danger"); setClassByBool('#leds_toggle_live_video', window.imageStreamActive, "btn-success", "btn-danger");
if (window.imageStreamActive) { if (window.imageStreamActive) {
$('#leds_prev_toggle_live_video').trigger('click');
requestLedImageStop(); requestLedImageStop();
resetImage(); resetImage();
} }
@ -260,12 +270,11 @@ $(document).ready(function () {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
$(window.hyperion).on("cmd-ledcolors-imagestream-update", function (event) { $(window.hyperion).on("cmd-ledcolors-imagestream-update", function (event) {
//console.log("cmd-ledcolors-imagestream-update", event.response);
setClassByBool('#leds_toggle_live_video', window.imageStreamActive, "btn-danger", "btn-success"); setClassByBool('#leds_toggle_live_video', window.imageStreamActive, "btn-danger", "btn-success");
if (!modalOpened) { if (!modalOpened) {
if ($('#leds_prev_toggle_live_video').length > 0) if (!$('#leds_prev_toggle_live_video').hasClass("btn-success")) {
return; requestLedImageStop();
requestLedImageStop(); }
} }
else { else {
var imageData = (event.response.result.image); var imageData = (event.response.result.image);

View File

@ -98,8 +98,6 @@ void JsonAPI::initialize()
{ {
// init API, REQUIRED! // init API, REQUIRED!
API::init(); API::init();
// REMOVE when jsonCB is migrated
handleInstanceSwitch(0);
// setup auth interface // setup auth interface
connect(this, &API::onPendingTokenRequest, this, &JsonAPI::newPendingTokenRequest); connect(this, &API::onPendingTokenRequest, this, &JsonAPI::newPendingTokenRequest);

View File

@ -10,7 +10,7 @@
// Constants // Constants
namespace { namespace {
const bool verbose = true; const bool verbose = false;
// Configuration settings // Configuration settings
const char CONFIG_ADDRESS[] = "host"; const char CONFIG_ADDRESS[] = "host";