2017-01-17 21:53:35 +01:00
|
|
|
$(document).ready(function() {
|
|
|
|
var modalOpened = false;
|
|
|
|
var ledsim_width = 540;
|
|
|
|
var ledsim_height = 489;
|
|
|
|
var dialog;
|
|
|
|
var leds;
|
2017-02-08 14:36:28 +01:00
|
|
|
var lC = false;
|
2018-12-20 14:33:28 +01:00
|
|
|
var imageCanvasNodeCtx;
|
|
|
|
var ledsCanvasNodeCtx;
|
|
|
|
var canvas_height;
|
|
|
|
var canvas_width;
|
|
|
|
var twoDPaths = [];
|
2019-01-06 19:49:56 +01:00
|
|
|
var toggleLeds, toggleLedsNum = false;
|
2018-12-20 14:33:28 +01:00
|
|
|
|
|
|
|
/// add prototype for simple canvas clear() method
|
|
|
|
CanvasRenderingContext2D.prototype.clear = function(){
|
|
|
|
this.clearRect(0, 0, this.canvas.width, this.canvas.height)
|
|
|
|
};
|
|
|
|
|
|
|
|
function create2dPaths(){
|
|
|
|
twoDPaths = [];
|
|
|
|
for(var idx=0; idx<leds.length; idx++)
|
|
|
|
{
|
|
|
|
var led = leds[idx];
|
2020-02-26 18:54:56 +01:00
|
|
|
twoDPaths.push( build2DPath(led.hmin * canvas_width, led.vmin * canvas_height, (led.hmax-led.hmin) * canvas_width, (led.vmax-led.vmin) * canvas_height, 5) );
|
2018-12-20 14:33:28 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Draws a rounded rectangle into a new Path2D object, returns the created path.
|
|
|
|
* If you omit the last three params, it will draw a rectangle
|
|
|
|
* outline with a 5 pixel border radius
|
|
|
|
* @param {Number} x The top left x coordinate
|
|
|
|
* @param {Number} y The top left y coordinate
|
|
|
|
* @param {Number} width The width of the rectangle
|
|
|
|
* @param {Number} height The height of the rectangle
|
|
|
|
* @param {Number} [radius = 5] The corner radius; It can also be an object
|
|
|
|
* to specify different radii for corners
|
|
|
|
* @param {Number} [radius.tl = 0] Top left
|
|
|
|
* @param {Number} [radius.tr = 0] Top right
|
|
|
|
* @param {Number} [radius.br = 0] Bottom right
|
|
|
|
* @param {Number} [radius.bl = 0] Bottom left
|
|
|
|
* @return {Path2D} The final path
|
|
|
|
*/
|
|
|
|
function build2DPath(x, y, width, height, radius) {
|
2019-06-05 18:19:08 +02:00
|
|
|
if (typeof radius == 'number') {
|
2018-12-20 14:33:28 +01:00
|
|
|
radius = {tl: radius, tr: radius, br: radius, bl: radius};
|
|
|
|
} else {
|
|
|
|
var defaultRadius = {tl: 0, tr: 0, br: 0, bl: 0};
|
|
|
|
for (var side in defaultRadius) {
|
|
|
|
radius[side] = radius[side] || defaultRadius[side];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-05 18:19:08 +02:00
|
|
|
var path = new Path2D();
|
2018-12-20 14:33:28 +01:00
|
|
|
|
|
|
|
path.moveTo(x + radius.tl, y);
|
|
|
|
path.lineTo(x + width - radius.tr, y);
|
|
|
|
path.quadraticCurveTo(x + width, y, x + width, y + radius.tr);
|
|
|
|
path.lineTo(x + width, y + height - radius.br);
|
|
|
|
path.quadraticCurveTo(x + width, y + height, x + width - radius.br, y + height);
|
|
|
|
path.lineTo(x + radius.bl, y + height);
|
|
|
|
path.quadraticCurveTo(x, y + height, x, y + height - radius.bl);
|
|
|
|
path.lineTo(x, y + radius.tl);
|
|
|
|
path.quadraticCurveTo(x, y, x + radius.tl, y);
|
|
|
|
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
|
2019-06-05 18:19:08 +02:00
|
|
|
$(window.hyperion).one("ready",function(){
|
|
|
|
leds = window.serverConfig.leds;
|
2018-12-20 14:33:28 +01:00
|
|
|
|
2019-06-05 18:19:08 +02:00
|
|
|
if(window.showOptHelp)
|
2017-02-08 14:36:28 +01:00
|
|
|
{
|
|
|
|
createHint('intro', $.i18n('main_ledsim_text'), 'ledsim_text');
|
|
|
|
$('#ledsim_text').css({'margin':'10px 15px 0px 15px'});
|
2017-07-30 14:36:23 +02:00
|
|
|
$('#ledsim_text .bs-callout').css("margin","0px")
|
2017-02-08 14:36:28 +01:00
|
|
|
}
|
2018-12-20 14:33:28 +01:00
|
|
|
|
2017-02-08 14:36:28 +01:00
|
|
|
if(getStorage('ledsim_width') != null)
|
2017-01-17 21:53:35 +01:00
|
|
|
{
|
|
|
|
ledsim_width = getStorage('ledsim_width');
|
|
|
|
ledsim_height = getStorage('ledsim_height');
|
|
|
|
}
|
2018-12-20 14:33:28 +01:00
|
|
|
|
2017-01-17 21:53:35 +01:00
|
|
|
dialog = $("#ledsim_dialog").dialog({
|
|
|
|
uiLibrary: 'bootstrap',
|
|
|
|
resizable: true,
|
|
|
|
modal: false,
|
|
|
|
minWidth: 250,
|
|
|
|
width: ledsim_width,
|
|
|
|
minHeight: 350,
|
|
|
|
height: ledsim_height,
|
|
|
|
closeOnEscape: true,
|
|
|
|
autoOpen: false,
|
|
|
|
title: $.i18n('main_ledsim_title'),
|
|
|
|
resize: function (e) {
|
|
|
|
updateLedLayout();
|
|
|
|
},
|
|
|
|
opened: function (e) {
|
2017-02-08 14:36:28 +01:00
|
|
|
if(!lC)
|
|
|
|
{
|
|
|
|
updateLedLayout();
|
|
|
|
lC = true;
|
|
|
|
}
|
2017-01-17 21:53:35 +01:00
|
|
|
modalOpened = true;
|
|
|
|
requestLedColorsStart();
|
2018-12-20 14:33:28 +01:00
|
|
|
|
2021-05-01 17:00:44 +02:00
|
|
|
setClassByBool('#leds_toggle_live_video', window.imageStreamActive, "btn-danger", "btn-success");
|
2017-01-17 21:53:35 +01:00
|
|
|
if($('#leds_toggle_live_video').hasClass('btn-success'))
|
|
|
|
requestLedImageStart();
|
|
|
|
},
|
|
|
|
closed: function (e) {
|
|
|
|
modalOpened = false;
|
|
|
|
},
|
|
|
|
resizeStop: function (e) {
|
2017-02-08 14:36:28 +01:00
|
|
|
setStorage("ledsim_width", $("#ledsim_dialog").outerWidth());
|
2018-12-20 14:33:28 +01:00
|
|
|
setStorage("ledsim_height", $("#ledsim_dialog").outerHeight());
|
2017-01-17 21:53:35 +01:00
|
|
|
}
|
2017-02-08 14:36:28 +01:00
|
|
|
});
|
2018-12-20 14:33:28 +01:00
|
|
|
// apply new serverinfos
|
2019-06-05 18:19:08 +02:00
|
|
|
$(window.hyperion).on("cmd-config-getconfig",function(event){
|
2018-12-20 14:33:28 +01:00
|
|
|
leds = event.response.info.leds;
|
|
|
|
updateLedLayout();
|
|
|
|
});
|
2017-01-17 21:53:35 +01:00
|
|
|
});
|
2018-12-20 14:33:28 +01:00
|
|
|
|
|
|
|
function printLedsToCanvas(colors)
|
2017-01-17 21:53:35 +01:00
|
|
|
{
|
2018-12-20 14:33:28 +01:00
|
|
|
// toggle leds, do not print
|
|
|
|
if(toggleLeds)
|
2019-06-05 18:19:08 +02:00
|
|
|
return;
|
2018-12-20 14:33:28 +01:00
|
|
|
|
|
|
|
var useColor = false;
|
2019-08-25 16:32:19 +02:00
|
|
|
var cPos = 0;
|
2018-12-20 14:33:28 +01:00
|
|
|
ledsCanvasNodeCtx.clear();
|
|
|
|
if(typeof colors != "undefined")
|
|
|
|
useColor = true;
|
|
|
|
|
2019-08-25 16:32:19 +02:00
|
|
|
// check size of ledcolors with leds length
|
|
|
|
if(colors && colors.length/3 < leds.length)
|
|
|
|
return;
|
|
|
|
|
2017-01-17 21:53:35 +01:00
|
|
|
for(var idx=0; idx<leds.length; idx++)
|
|
|
|
{
|
2018-12-20 14:33:28 +01:00
|
|
|
var led = leds[idx];
|
|
|
|
// can be used as fallback when Path2D is not available
|
2020-02-26 18:54:56 +01:00
|
|
|
//roundRect(ledsCanvasNodeCtx, led.hmin * canvas_width, led.vmin * canvas_height, (led.hmax-led.hmin) * canvas_width, (led.vmax-led.vmin) * canvas_height, 4, true, colors[idx])
|
|
|
|
//ledsCanvasNodeCtx.fillRect(led.hmin * canvas_width, led.vmin * canvas_height, (led.hmax-led.hmin) * canvas_width, (led.vmax-led.vmin) * canvas_height);
|
2019-08-25 16:32:19 +02:00
|
|
|
|
add Hue EntertainmentAPI + Forwarder & other Fixes (#592)
* whitespaces + typo fixes
* JS / LGTM fixes
* SSDP Handler crash fix
* MessageForwarder handlePriorityChanges Slave fixes
* use aboutToQuit Signal
* complete rewriten Hue Entertainment API structure
combined Philips Hue and Entertainment API
with new MbedTLS based SSL UDP Provider
* add required cross-compile submodules
* logical rebuild fn: initLeds, setLights + new logs
-more detailed checks and error handling inside iniLeds and setLights
- logical script procedure before ProviderUdpSSL init
- first steps for multiple ProviderUdpSSL usage
- better fallback support to old RestAPI, if entertainment api is not supported
- just 4 u LordGrey: new log fn for cosmetic config outputs ;)
* add OSX CompileHowTo - undo from CrossCompileHowTo
* whitespace fixes
* lightID toString fix
* fix unsigned int E-API + debug output
* bugfixes, reworked black signal detection, wizard:
- change device config field light-ids from int to string -> real unsigned int fix
- add signal detection brightness minimum threshold value
0.0 for 0% brightness - 1.0 for 100% brightness to count for blacklight signal detection
reason: input may not 100% black, like mine - i have a deep dark gray input signal
-> my threshold value is set to 0.005 for 0.5% minimum brightness = 1 (from max 255) to count as black
- wizard optimations, with fallback without entertainment support (beta state)
- whitespace fixes
* cleanup + minor fixes
* change fixed Hue UPD SSL config to _devConfig paras
* Hotfix SSL Connection, new light models, wizard:
- Fix UPD SSL Connection failed Problems
- add new supported gamut C light models: LCG002, LCA001, LCA002, LCA003
- wizard: extend fallback support to classic mode + hints
* whitespace, typo fix
* uncheck useEntertainmentAPI, if noAPISupport detected + hint
* coredump fix -> add _blackLightsTimer nullptr init
* code cleanup / remove old debugs + whitespacefixes
* add gamut C LCP001, LCP002
* SSL UDP config made more flexible + remove qDebug
-> switch to hyerion.ng _log
-> replace logCommand with verbose
-> code cleanups etc...
* extended mbedtls debugging infos
* add adjustable ssl timeout settings
* error handling
* streamdebugger bugfixes
* UPDSSL psk / psk_identity bugfixes! + hue wizard fn typo fix +
- verbose option available without dependencies
- whitespace fixes
* Philips Hue Assistant now recognizes non-original bridges better...
+ Added note if no clientkey is set when using the entertainment API
+ User creation (+ clientkey) for non-original bridges can now also be used
+ Minor changes and bug fixes
* CMAKE mbedTLS detection
* minor bug fixes + code cleanups
* FindMbedTLS.cmake remove Path-Hints + wizard.js: ajax timeout handling
Test - content_grabber.js: run relevant code only, if V4L2_AVAIL is true:
conf_grabber don't displays other devices, if V4L2 is not available
* compile mbedtls via cmake as static lib
* remove libmbedtls-dev from compileHowto / scripts
* Fix Windows build
* Fix windows build (part 2)
* removed unnecessary osx x11 include directory path
* QTimer Shutdown bugfix
* cmake win32 fix + minor bugfixes
* cmake debug msg used mbedtls libs
* Bugfix: noSignalDetection wasn't switchedOn again
if no signal was previously detected
* Some code fixes based on alerts from lgtm.com
Co-authored-by: Paulchen Panther <16664240+Paulchen-Panther@users.noreply.github.com>
2020-05-22 19:40:50 +02:00
|
|
|
ledsCanvasNodeCtx.fillStyle = (useColor) ? "rgba("+colors[cPos]+","+colors[cPos+1]+","+colors[cPos+2]+",0.75)" : "hsla("+(idx*360/leds.length)+",100%,50%,0.75)";
|
2018-12-20 14:33:28 +01:00
|
|
|
ledsCanvasNodeCtx.fill(twoDPaths[idx]);
|
|
|
|
ledsCanvasNodeCtx.stroke(twoDPaths[idx]);
|
2019-01-06 19:49:56 +01:00
|
|
|
|
|
|
|
if(toggleLedsNum)
|
|
|
|
{
|
add Hue EntertainmentAPI + Forwarder & other Fixes (#592)
* whitespaces + typo fixes
* JS / LGTM fixes
* SSDP Handler crash fix
* MessageForwarder handlePriorityChanges Slave fixes
* use aboutToQuit Signal
* complete rewriten Hue Entertainment API structure
combined Philips Hue and Entertainment API
with new MbedTLS based SSL UDP Provider
* add required cross-compile submodules
* logical rebuild fn: initLeds, setLights + new logs
-more detailed checks and error handling inside iniLeds and setLights
- logical script procedure before ProviderUdpSSL init
- first steps for multiple ProviderUdpSSL usage
- better fallback support to old RestAPI, if entertainment api is not supported
- just 4 u LordGrey: new log fn for cosmetic config outputs ;)
* add OSX CompileHowTo - undo from CrossCompileHowTo
* whitespace fixes
* lightID toString fix
* fix unsigned int E-API + debug output
* bugfixes, reworked black signal detection, wizard:
- change device config field light-ids from int to string -> real unsigned int fix
- add signal detection brightness minimum threshold value
0.0 for 0% brightness - 1.0 for 100% brightness to count for blacklight signal detection
reason: input may not 100% black, like mine - i have a deep dark gray input signal
-> my threshold value is set to 0.005 for 0.5% minimum brightness = 1 (from max 255) to count as black
- wizard optimations, with fallback without entertainment support (beta state)
- whitespace fixes
* cleanup + minor fixes
* change fixed Hue UPD SSL config to _devConfig paras
* Hotfix SSL Connection, new light models, wizard:
- Fix UPD SSL Connection failed Problems
- add new supported gamut C light models: LCG002, LCA001, LCA002, LCA003
- wizard: extend fallback support to classic mode + hints
* whitespace, typo fix
* uncheck useEntertainmentAPI, if noAPISupport detected + hint
* coredump fix -> add _blackLightsTimer nullptr init
* code cleanup / remove old debugs + whitespacefixes
* add gamut C LCP001, LCP002
* SSL UDP config made more flexible + remove qDebug
-> switch to hyerion.ng _log
-> replace logCommand with verbose
-> code cleanups etc...
* extended mbedtls debugging infos
* add adjustable ssl timeout settings
* error handling
* streamdebugger bugfixes
* UPDSSL psk / psk_identity bugfixes! + hue wizard fn typo fix +
- verbose option available without dependencies
- whitespace fixes
* Philips Hue Assistant now recognizes non-original bridges better...
+ Added note if no clientkey is set when using the entertainment API
+ User creation (+ clientkey) for non-original bridges can now also be used
+ Minor changes and bug fixes
* CMAKE mbedTLS detection
* minor bug fixes + code cleanups
* FindMbedTLS.cmake remove Path-Hints + wizard.js: ajax timeout handling
Test - content_grabber.js: run relevant code only, if V4L2_AVAIL is true:
conf_grabber don't displays other devices, if V4L2 is not available
* compile mbedtls via cmake as static lib
* remove libmbedtls-dev from compileHowto / scripts
* Fix Windows build
* Fix windows build (part 2)
* removed unnecessary osx x11 include directory path
* QTimer Shutdown bugfix
* cmake win32 fix + minor bugfixes
* cmake debug msg used mbedtls libs
* Bugfix: noSignalDetection wasn't switchedOn again
if no signal was previously detected
* Some code fixes based on alerts from lgtm.com
Co-authored-by: Paulchen Panther <16664240+Paulchen-Panther@users.noreply.github.com>
2020-05-22 19:40:50 +02:00
|
|
|
//ledsCanvasNodeCtx.shadowOffsetX = 1;
|
|
|
|
//ledsCanvasNodeCtx.shadowOffsetY = 1;
|
|
|
|
//ledsCanvasNodeCtx.shadowColor = "black";
|
|
|
|
//ledsCanvasNodeCtx.shadowBlur = 4;
|
|
|
|
ledsCanvasNodeCtx.fillStyle = "white";
|
2019-01-06 19:49:56 +01:00
|
|
|
ledsCanvasNodeCtx.textAlign = "center";
|
add Hue EntertainmentAPI + Forwarder & other Fixes (#592)
* whitespaces + typo fixes
* JS / LGTM fixes
* SSDP Handler crash fix
* MessageForwarder handlePriorityChanges Slave fixes
* use aboutToQuit Signal
* complete rewriten Hue Entertainment API structure
combined Philips Hue and Entertainment API
with new MbedTLS based SSL UDP Provider
* add required cross-compile submodules
* logical rebuild fn: initLeds, setLights + new logs
-more detailed checks and error handling inside iniLeds and setLights
- logical script procedure before ProviderUdpSSL init
- first steps for multiple ProviderUdpSSL usage
- better fallback support to old RestAPI, if entertainment api is not supported
- just 4 u LordGrey: new log fn for cosmetic config outputs ;)
* add OSX CompileHowTo - undo from CrossCompileHowTo
* whitespace fixes
* lightID toString fix
* fix unsigned int E-API + debug output
* bugfixes, reworked black signal detection, wizard:
- change device config field light-ids from int to string -> real unsigned int fix
- add signal detection brightness minimum threshold value
0.0 for 0% brightness - 1.0 for 100% brightness to count for blacklight signal detection
reason: input may not 100% black, like mine - i have a deep dark gray input signal
-> my threshold value is set to 0.005 for 0.5% minimum brightness = 1 (from max 255) to count as black
- wizard optimations, with fallback without entertainment support (beta state)
- whitespace fixes
* cleanup + minor fixes
* change fixed Hue UPD SSL config to _devConfig paras
* Hotfix SSL Connection, new light models, wizard:
- Fix UPD SSL Connection failed Problems
- add new supported gamut C light models: LCG002, LCA001, LCA002, LCA003
- wizard: extend fallback support to classic mode + hints
* whitespace, typo fix
* uncheck useEntertainmentAPI, if noAPISupport detected + hint
* coredump fix -> add _blackLightsTimer nullptr init
* code cleanup / remove old debugs + whitespacefixes
* add gamut C LCP001, LCP002
* SSL UDP config made more flexible + remove qDebug
-> switch to hyerion.ng _log
-> replace logCommand with verbose
-> code cleanups etc...
* extended mbedtls debugging infos
* add adjustable ssl timeout settings
* error handling
* streamdebugger bugfixes
* UPDSSL psk / psk_identity bugfixes! + hue wizard fn typo fix +
- verbose option available without dependencies
- whitespace fixes
* Philips Hue Assistant now recognizes non-original bridges better...
+ Added note if no clientkey is set when using the entertainment API
+ User creation (+ clientkey) for non-original bridges can now also be used
+ Minor changes and bug fixes
* CMAKE mbedTLS detection
* minor bug fixes + code cleanups
* FindMbedTLS.cmake remove Path-Hints + wizard.js: ajax timeout handling
Test - content_grabber.js: run relevant code only, if V4L2_AVAIL is true:
conf_grabber don't displays other devices, if V4L2 is not available
* compile mbedtls via cmake as static lib
* remove libmbedtls-dev from compileHowto / scripts
* Fix Windows build
* Fix windows build (part 2)
* removed unnecessary osx x11 include directory path
* QTimer Shutdown bugfix
* cmake win32 fix + minor bugfixes
* cmake debug msg used mbedtls libs
* Bugfix: noSignalDetection wasn't switchedOn again
if no signal was previously detected
* Some code fixes based on alerts from lgtm.com
Co-authored-by: Paulchen Panther <16664240+Paulchen-Panther@users.noreply.github.com>
2020-05-22 19:40:50 +02:00
|
|
|
ledsCanvasNodeCtx.fillText(((led.name) ? led.name : idx), (led.hmin * canvas_width) + ( ((led.hmax-led.hmin) * canvas_width) / 2), (led.vmin * canvas_height) + ( ((led.vmax-led.vmin) * canvas_height) / 2));
|
2019-01-06 19:49:56 +01:00
|
|
|
}
|
2019-08-25 16:32:19 +02:00
|
|
|
|
|
|
|
// increment colorsPosition
|
|
|
|
cPos += 3;
|
2017-01-17 21:53:35 +01:00
|
|
|
}
|
2018-12-20 14:33:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function updateLedLayout()
|
|
|
|
{
|
|
|
|
//calculate body size
|
|
|
|
canvas_height = $('#ledsim_dialog').outerHeight()-$('#ledsim_text').outerHeight()-$('[data-role=footer]').outerHeight()-$('[data-role=header]').outerHeight()-40;
|
|
|
|
canvas_width = $('#ledsim_dialog').outerWidth()-30;
|
|
|
|
|
|
|
|
$('#leds_canvas').html("");
|
2019-06-05 18:19:08 +02:00
|
|
|
var leds_html = '<canvas id="image_preview_canv" width="'+canvas_width+'" height="'+canvas_height+'" style="position: absolute; left: 0; top: 0; z-index: 99998;"></canvas>';
|
2018-12-20 14:33:28 +01:00
|
|
|
leds_html += '<canvas id="leds_preview_canv" width="'+canvas_width+'" height="'+canvas_height+'" style="position: absolute; left: 0; top: 0; z-index: 99999;"></canvas>';
|
|
|
|
|
2017-01-17 21:53:35 +01:00
|
|
|
$('#leds_canvas').html(leds_html);
|
2018-12-20 14:33:28 +01:00
|
|
|
|
|
|
|
imageCanvasNodeCtx = document.getElementById("image_preview_canv").getContext("2d");
|
|
|
|
ledsCanvasNodeCtx = document.getElementById("leds_preview_canv").getContext("2d");
|
|
|
|
create2dPaths();
|
|
|
|
printLedsToCanvas();
|
2019-06-05 18:19:08 +02:00
|
|
|
resetImage();
|
2017-01-17 21:53:35 +01:00
|
|
|
}
|
|
|
|
|
2018-12-20 14:33:28 +01:00
|
|
|
// ------------------------------------------------------------------
|
2019-01-06 19:49:56 +01:00
|
|
|
$('#leds_toggle_num').off().on("click", function() {
|
|
|
|
toggleLedsNum = !toggleLedsNum
|
|
|
|
toggleClass('#leds_toggle_num', "btn-danger", "btn-success");
|
|
|
|
});
|
2017-01-17 21:53:35 +01:00
|
|
|
// ------------------------------------------------------------------
|
2018-12-20 14:33:28 +01:00
|
|
|
|
2017-01-17 21:53:35 +01:00
|
|
|
$('#leds_toggle').off().on("click", function() {
|
2018-12-20 14:33:28 +01:00
|
|
|
toggleLeds = !toggleLeds
|
|
|
|
ledsCanvasNodeCtx.clear();
|
2017-01-17 21:53:35 +01:00
|
|
|
toggleClass('#leds_toggle', "btn-success", "btn-danger");
|
|
|
|
});
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------
|
|
|
|
$('#leds_toggle_live_video').off().on("click", function() {
|
2019-06-05 18:19:08 +02:00
|
|
|
setClassByBool('#leds_toggle_live_video',window.imageStreamActive,"btn-success","btn-danger");
|
|
|
|
if ( window.imageStreamActive )
|
2017-01-17 21:53:35 +01:00
|
|
|
{
|
|
|
|
requestLedImageStop();
|
2018-12-20 14:33:28 +01:00
|
|
|
resetImage();
|
2017-01-17 21:53:35 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
requestLedImageStart();
|
|
|
|
}
|
|
|
|
});
|
2018-12-20 14:33:28 +01:00
|
|
|
|
2017-01-17 21:53:35 +01:00
|
|
|
// ------------------------------------------------------------------
|
2019-06-05 18:19:08 +02:00
|
|
|
$(window.hyperion).on("cmd-ledcolors-ledstream-update",function(event){
|
2017-01-17 21:53:35 +01:00
|
|
|
if (!modalOpened)
|
|
|
|
{
|
|
|
|
requestLedColorsStop();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-12-20 14:33:28 +01:00
|
|
|
printLedsToCanvas(event.response.result.leds)
|
2017-01-17 21:53:35 +01:00
|
|
|
}
|
|
|
|
});
|
2018-12-20 14:33:28 +01:00
|
|
|
|
2017-01-17 21:53:35 +01:00
|
|
|
// ------------------------------------------------------------------
|
2019-06-05 18:19:08 +02:00
|
|
|
$(window.hyperion).on("cmd-ledcolors-imagestream-update",function(event){
|
2021-05-01 17:00:44 +02:00
|
|
|
setClassByBool('#leds_toggle_live_video', window.imageStreamActive, "btn-danger", "btn-success");
|
2017-01-17 21:53:35 +01:00
|
|
|
if (!modalOpened)
|
|
|
|
{
|
2021-05-01 17:00:44 +02:00
|
|
|
if ($('#leds_prev_toggle_live_video').length > 0)
|
|
|
|
return;
|
2017-01-17 21:53:35 +01:00
|
|
|
requestLedImageStop();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-06-05 18:19:08 +02:00
|
|
|
var imageData = (event.response.result.image);
|
2018-12-20 14:33:28 +01:00
|
|
|
|
|
|
|
var image = new Image();
|
|
|
|
image.onload = function() {
|
|
|
|
imageCanvasNodeCtx.drawImage(image, 0, 0, canvas_width, canvas_height);
|
|
|
|
};
|
|
|
|
image.src = imageData;
|
2017-01-17 21:53:35 +01:00
|
|
|
}
|
|
|
|
});
|
2018-12-20 14:33:28 +01:00
|
|
|
|
2017-01-17 21:53:35 +01:00
|
|
|
$("#btn_open_ledsim").off().on("click", function(event) {
|
|
|
|
dialog.open();
|
|
|
|
});
|
2018-12-20 14:33:28 +01:00
|
|
|
|
2018-12-28 18:12:45 +01:00
|
|
|
// ------------------------------------------------------------------
|
2019-06-05 18:19:08 +02:00
|
|
|
$(window.hyperion).on("cmd-settings-update",function(event){
|
2021-04-25 17:22:59 +02:00
|
|
|
|
2018-12-28 18:12:45 +01:00
|
|
|
var obj = event.response.data
|
2021-04-25 17:22:59 +02:00
|
|
|
if ( obj.leds) {
|
|
|
|
console.log("ledsim: cmd-settings-update", event.response.data);
|
|
|
|
Object.getOwnPropertyNames(obj).forEach(function(val, idx, array) {
|
|
|
|
window.serverInfo[val] = obj[val];
|
|
|
|
});
|
|
|
|
leds = window.serverConfig.leds
|
|
|
|
updateLedLayout();
|
|
|
|
}
|
2018-12-28 18:12:45 +01:00
|
|
|
});
|
2018-12-31 15:48:29 +01:00
|
|
|
|
|
|
|
function resetImage(){
|
2021-05-01 17:00:44 +02:00
|
|
|
if (getStorage("darkMode", false) == "on") {
|
|
|
|
imageCanvasNodeCtx.clear();
|
|
|
|
} else {
|
|
|
|
imageCanvasNodeCtx.fillStyle = "rgb(225,225,225)"
|
|
|
|
imageCanvasNodeCtx.fillRect(0, 0, canvas_width, canvas_height);
|
|
|
|
}
|
|
|
|
|
|
|
|
var image = document.getElementById('navbar_brand_logo');
|
|
|
|
imageCanvasNodeCtx.drawImage(image, canvas_width / 2 - image.width / 2, canvas_height / 2 - image.height / 2, image.width, image.height);
|
2018-12-31 15:48:29 +01:00
|
|
|
}
|
2018-12-20 14:33:28 +01:00
|
|
|
});
|