Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct PR1312 and LEDSim fixes #1336

Merged
merged 6 commits into from
Sep 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .vs/launch.vs.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
"name": "Run hyperion with debug option and external console",
"args": [
"-d",
"-c",
"-u test"
"-c"
],
"externalConsole": true
}
Expand Down
10 changes: 5 additions & 5 deletions assets/webconfig/js/content_index.js
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ $(document).ready(function () {
// comps
window.comps = event.response.info.components

$(window.hyperion).trigger("ready");

window.comps.forEach(function (obj) {
if (obj.name == "ALL") {
if (obj.enabled)
Expand All @@ -40,7 +42,6 @@ $(document).ready(function () {
$('#btn_hypinstanceswitch').toggle(true)
else
$('#btn_hypinstanceswitch').toggle(false)

updateSessions();
}); // end cmd-serverinfo

Expand Down Expand Up @@ -121,11 +122,12 @@ $(document).ready(function () {

//Switch to last selected instance and load related config
var lastSelectedInstance = getStorage('lastSelectedInstance', false);
if (!window.serverInfo.instance[lastSelectedInstance]) {
if (lastSelectedInstance == null || window.serverInfo.instance && !window.serverInfo.instance[lastSelectedInstance]) {
lastSelectedInstance = 0;
}
instanceSwitch(lastSelectedInstance);

requestSysInfo();
});

$(window.hyperion).on("cmd-config-getconfig", function (event) {
Expand Down Expand Up @@ -157,8 +159,6 @@ $(document).ready(function () {
if (event.response.hasOwnProperty('info'))
setStorage("loginToken", event.response.info.token, true);

requestSysInfo();
requestServerInfo();
requestServerConfigSchema();
});

Expand Down Expand Up @@ -218,7 +218,7 @@ $(document).ready(function () {
});

$(window.hyperion).one("ready", function (event) {
loadContent();
// Content will be loaded by the instance load/switch
});

$(window.hyperion).on("cmd-adjustment-update", function (event) {
Expand Down
38 changes: 25 additions & 13 deletions assets/webconfig/js/content_leds.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
var ledsCustomCfgInitialized = false;
var onLedLayoutTab = false;
var nonBlacklistLedArray = [];
var ledBlacklist = [];
var finalLedArray = [];
Expand Down Expand Up @@ -568,24 +569,30 @@ $(document).ready(function () {
// toggle live video
$('#leds_prev_toggle_live_video').off().on("click", function () {
setClassByBool('#leds_prev_toggle_live_video', window.imageStreamActive, "btn-success", "btn-danger");
if (window.imageStreamActive) {
requestLedImageStop();

if (onLedLayoutTab && window.imageStreamActive) {
imageCanvasNodeCtx.clear();
if (!$('#leds_toggle_live_video').hasClass("btn-success")) {
requestLedImageStop();
}
}
else {
requestLedImageStart();
}
});

$(window.hyperion).on("cmd-ledcolors-imagestream-update", function (event) {
setClassByBool('#leds_prev_toggle_live_video', window.imageStreamActive, "btn-danger", "btn-success");
var imageData = (event.response.result.image);

var image = new Image();
image.onload = function () {
imageCanvasNodeCtx.drawImage(image, 0, 0, imageCanvasNodeCtx.canvas.width, imageCanvasNodeCtx.canvas.height);
};
image.src = imageData;
//Only update Image, if LED Layout Tab is visible
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();
image.onload = function () {
imageCanvasNodeCtx.drawImage(image, 0, 0, imageCanvasNodeCtx.canvas.width, imageCanvasNodeCtx.canvas.height);
};
image.src = imageData;
}
});

// open checklist
Expand All @@ -605,9 +612,14 @@ $(document).ready(function () {
// nav
$('#leds_cfg_nav a[data-toggle="tab"]').off().on('shown.bs.tab', function (e) {
var target = $(e.target).attr("href") // activated tab
if (target == "#menu_gencfg" && !ledsCustomCfgInitialized) {
$('#leds_custom_updsim').trigger('click');
ledsCustomCfgInitialized = true;
if (target == "#menu_gencfg") {
onLedLayoutTab = true;
if (!ledsCustomCfgInitialized) {
$('#leds_custom_updsim').trigger('click');
ledsCustomCfgInitialized = true;
}
} else {
onLedLayoutTab = false;
}

blacklist_editor.on('change', function () {
Expand Down
27 changes: 18 additions & 9 deletions assets/webconfig/js/ledsim.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ $(document).ready(function () {
var canvas_height;
var canvas_width;
var twoDPaths = [];
var toggleLeds = false;
var toggleLeds = true;
var toggleLedsNum = false;
var toggleSigDetectArea = false;

Expand Down Expand Up @@ -109,7 +109,10 @@ $(document).ready(function () {
lC = 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");
if ($('#leds_toggle_live_video').hasClass('btn-success'))
Expand Down Expand Up @@ -145,7 +148,7 @@ $(document).ready(function () {
}

// toggle leds, do not print
if (toggleLeds)
if (!toggleLeds)
return;

var useColor = false;
Expand Down Expand Up @@ -220,10 +223,16 @@ $(document).ready(function () {

$('#leds_toggle').off().on("click", function () {
toggleLeds = !toggleLeds
ledsCanvasNodeCtx.clear();

if (window.ledStreamActive) {
requestLedColorsStop();
ledsCanvasNodeCtx.clear();
} else {
requestLedColorsStart();
}
toggleClass('#leds_toggle', "btn-success", "btn-danger");

if (!toggleLeds) {
if (toggleLeds) {
$("#leds_toggle_num").show();
} else {
$("#leds_toggle_num").hide();
Expand All @@ -234,6 +243,7 @@ $(document).ready(function () {
$('#leds_toggle_live_video').off().on("click", function () {
setClassByBool('#leds_toggle_live_video', window.imageStreamActive, "btn-success", "btn-danger");
if (window.imageStreamActive) {
$('#leds_prev_toggle_live_video').trigger('click');
requestLedImageStop();
resetImage();
}
Expand All @@ -260,12 +270,11 @@ $(document).ready(function () {

// ------------------------------------------------------------------
$(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");
if (!modalOpened) {
if ($('#leds_prev_toggle_live_video').length > 0)
return;
requestLedImageStop();
if (!$('#leds_prev_toggle_live_video').hasClass("btn-success")) {
requestLedImageStop();
}
}
else {
var imageData = (event.response.result.image);
Expand Down
2 changes: 0 additions & 2 deletions libsrc/api/JsonAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@ void JsonAPI::initialize()
{
// init API, REQUIRED!
API::init();
// REMOVE when jsonCB is migrated
handleInstanceSwitch(0);

// setup auth interface
connect(this, &API::onPendingTokenRequest, this, &JsonAPI::newPendingTokenRequest);
Expand Down
2 changes: 1 addition & 1 deletion libsrc/leddevice/dev_net/LedDeviceWled.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
// Constants
namespace {

const bool verbose = true;
const bool verbose = false;

// Configuration settings
const char CONFIG_ADDRESS[] = "host";
Expand Down