mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
update adjustments and ui (#384)
* update
* update
* testit
* Revert "testit"
This reverts commit b1cc645161
.
* update schema
* update
* add adjustment to serverinfo
* remove Adjustbool
* remove v4l2only
* fix json check for create effect
* update deb
* update
* update remote adjust
* update
* add eff schemas
This commit is contained in:
@@ -5,21 +5,6 @@ var IntListIds;
|
||||
var StrListIds;
|
||||
var BoolListIds;
|
||||
|
||||
function get_hue_lights(){
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: 'http://'+$("#ip").val()+'/api/'+$("#user").val()+'/lights',
|
||||
processData: false,
|
||||
contentType: 'application/json',
|
||||
success: function(r) {
|
||||
for(var lightid in r){
|
||||
//console.log(r[lightid].name);
|
||||
$('#hue_lights').append('ID: '+lightid+' Name: '+r[lightid].name+'<br />');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function validateText(){
|
||||
e = isJsonString($("#ledconfig").val());
|
||||
|
||||
@@ -34,6 +19,7 @@ function loadStoredValues()
|
||||
{
|
||||
if (storageComp() && getStorage('ip_cl_ledstop') != null)
|
||||
{
|
||||
|
||||
for(var i = 0; i < IntListIds.length; i++)
|
||||
{
|
||||
$('#'+IntListIds[i]).val(parseInt(getStorage(IntListIds[i])));
|
||||
@@ -139,22 +125,21 @@ function createClassicLeds(){
|
||||
var reverse = $("#ip_cl_reverse").is(":checked");
|
||||
|
||||
//advanced values
|
||||
var rawledsvdepth = parseInt($("#ip_cl_rawledsvdepth").val());
|
||||
var rawledshdepth = parseInt($("#ip_cl_rawledshdepth").val());
|
||||
var rawledsedgegap = parseInt($("#ip_cl_rawledsedgegap").val());
|
||||
var rawledscornergap = parseInt($("#ip_cl_rawledscornergap").val());
|
||||
var ledsVDepth = parseInt($("#ip_cl_ledsvdepth").val())/100;
|
||||
var ledsHDepth = parseInt($("#ip_cl_ledshdepth").val())/100;
|
||||
var edgeVGap = parseInt($("#ip_cl_ledsedgegap").val())/100/2;
|
||||
//var cornerVGap = parseInt($("#ip_cl_ledscornergap").val())/100/2;
|
||||
var overlap = $("#ip_cl_overlap").val()/4000;
|
||||
|
||||
//helper
|
||||
var ledsVDepth = rawledsvdepth /100;
|
||||
var ledsHDepth = rawledshdepth /100;
|
||||
var edgeVGap = rawledsedgegap /100/2;
|
||||
var edgeHGap = edgeVGap/(16/9);
|
||||
var cornerVGap = rawledscornergap /100/2;
|
||||
var cornerHGap = cornerVGap/(16/9);
|
||||
//var cornerHGap = cornerVGap/(16/9);
|
||||
var Vmin = 0.0 + edgeVGap;
|
||||
var Vmax = 1.0 - edgeVGap;
|
||||
var Hmin = 0.0 + edgeHGap;
|
||||
var Hmax = 1.0 - edgeHGap;
|
||||
var Hdiff = Hmax-Hmin;
|
||||
var Vdiff = Vmax-Vmin;
|
||||
var ledArray = [];
|
||||
|
||||
function createFinalArray(array){
|
||||
@@ -168,15 +153,7 @@ function createClassicLeds(){
|
||||
}
|
||||
createLedPreview(finalLedArray, 'classic');
|
||||
}
|
||||
|
||||
function validateGap(){
|
||||
if (ledsgpos+ledsglength > ledArray.length){
|
||||
showInfoDialog('error', $.i18n('infoDialog_leds_gap_title'), $.i18n('infoDialog_leds_gap_text'));
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
function rotateArray(array, times){
|
||||
if (times > "0"){
|
||||
while( times-- ){
|
||||
@@ -193,6 +170,23 @@ function createClassicLeds(){
|
||||
}
|
||||
}
|
||||
|
||||
function valScan(val)
|
||||
{
|
||||
if(val > 1)
|
||||
return val = 1;
|
||||
if(val < 0)
|
||||
return val = 0;
|
||||
return val;
|
||||
}
|
||||
|
||||
function ovl(scan,val)
|
||||
{
|
||||
if(scan == "+")
|
||||
return valScan(val += overlap);
|
||||
else
|
||||
return valScan(val -= overlap);
|
||||
}
|
||||
|
||||
function createLedArray(hmin, hmax, vmin, vmax){
|
||||
hmin = round(hmin);
|
||||
hmax = round(hmax);
|
||||
@@ -203,79 +197,82 @@ function createClassicLeds(){
|
||||
|
||||
function createTopLeds(){
|
||||
step=(Hmax-Hmin)/ledstop;
|
||||
hmin=Hmin
|
||||
if(cornerVGap != '0'){
|
||||
step=(Hmax-Hmin-(cornerHGap*2))/ledstop;
|
||||
hmin=Hmin+(cornerHGap);
|
||||
}
|
||||
vmin=Vmin
|
||||
//if(cornerVGap != '0')
|
||||
// step=(Hmax-Hmin-(cornerHGap*2))/ledstop;
|
||||
|
||||
vmin=Vmin;
|
||||
vmax=vmin+ledsHDepth;
|
||||
hmax=hmin+step
|
||||
for (var i = 0; i<ledstop; i++){
|
||||
hmin = ovl("-",(Hdiff/ledstop*[i])+edgeHGap);
|
||||
hmax = ovl("+",(Hdiff/ledstop*[i])+step+edgeHGap);
|
||||
createLedArray(hmin, hmax, vmin, vmax);
|
||||
hmin += step
|
||||
hmax += step
|
||||
}
|
||||
}
|
||||
|
||||
function createLeftLeds(){
|
||||
step=(Vmax-Vmin)/ledsleft;
|
||||
vmax=Vmax
|
||||
if(cornerVGap != '0'){
|
||||
step=(Vmax-Vmin-(cornerVGap*2))/ledsleft;
|
||||
vmax=Vmax-(cornerVGap);
|
||||
}
|
||||
//if(cornerVGap != '0')
|
||||
// step=(Vmax-Vmin-(cornerVGap*2))/ledsleft;
|
||||
|
||||
hmin=Hmin;
|
||||
hmax=hmin+ledsVDepth;
|
||||
vmin=vmax-step
|
||||
for (var i = ledsleft; i>0; i--){
|
||||
for (var i = ledsleft-1; i>-1; --i){
|
||||
vmin = ovl("-",(Vdiff/ledsleft*[i])+edgeVGap);
|
||||
vmax = ovl("+",(Vdiff/ledsleft*[i])+step+edgeVGap);
|
||||
createLedArray(hmin, hmax, vmin, vmax);
|
||||
vmin -= step
|
||||
vmax -= step
|
||||
}
|
||||
}
|
||||
|
||||
function createRightLeds(){
|
||||
step=(Vmax-Vmin)/ledsright;
|
||||
vmin=Vmin
|
||||
if(cornerVGap != '0'){
|
||||
step=(Vmax-Vmin-(cornerVGap*2))/ledsright;
|
||||
vmin=Vmin+(cornerVGap);
|
||||
}
|
||||
//if(cornerVGap != '0')
|
||||
// step=(Vmax-Vmin-(cornerVGap*2))/ledsright;
|
||||
|
||||
hmax=Hmax;
|
||||
hmin=hmax-ledsVDepth;
|
||||
vmax=vmin+step
|
||||
for (var i = 0; i<ledsright; i++){
|
||||
createLedArray(hmin, hmax, vmin, vmax);
|
||||
vmin += step
|
||||
vmax += step
|
||||
vmin = ovl("-",(Vdiff/ledsright*[i])+edgeVGap);
|
||||
vmax = ovl("+",(Vdiff/ledsright*[i])+step+edgeVGap);
|
||||
createLedArray(hmin, hmax, vmin, vmax);
|
||||
}
|
||||
}
|
||||
|
||||
function createBottomLeds(){
|
||||
step=(Hmax-Hmin)/ledsbottom;
|
||||
hmax=Hmax
|
||||
if(cornerVGap != '0'){
|
||||
step=(Hmax-Hmin-(cornerHGap*2))/ledsbottom;
|
||||
hmax=Hmax-(cornerHGap);
|
||||
}
|
||||
//if(cornerVGap != '0')
|
||||
// step=(Hmax-Hmin-(cornerHGap*2))/ledsbottom;
|
||||
|
||||
vmax=Vmax;
|
||||
vmin=vmax-ledsHDepth;
|
||||
hmin=hmax-step
|
||||
for (var i = ledsbottom; i>0; i--){
|
||||
for (var i = ledsbottom-1; i>-1; i--){
|
||||
hmin = ovl("-",(Hdiff/ledsbottom*[i])+edgeHGap);
|
||||
hmax = ovl("+",(Hdiff/ledsbottom*[i])+step+edgeHGap);
|
||||
createLedArray(hmin, hmax, vmin, vmax);
|
||||
hmin -= step;
|
||||
hmax -= step;
|
||||
}
|
||||
}
|
||||
|
||||
createLeftLeds(createBottomLeds(createRightLeds(createTopLeds())));
|
||||
|
||||
if(ledsglength != "0" && validateGap()){
|
||||
//check led gap pos
|
||||
if (ledsgpos+ledsglength > ledArray.length)
|
||||
{
|
||||
var mpos = Math.max(0,ledArray.length-ledsglength);
|
||||
$('#ip_cl_ledsgpos').val(mpos);
|
||||
ledsgpos = mpos;
|
||||
}
|
||||
|
||||
//check led gap length
|
||||
if(ledsglength >= ledArray.length)
|
||||
{
|
||||
$('#ip_cl_ledsglength').val(ledArray.length-1);
|
||||
ledsglength = ledArray.length-ledsglength-1;
|
||||
}
|
||||
|
||||
if(ledsglength != 0){
|
||||
ledArray.splice(ledsgpos, ledsglength);
|
||||
}
|
||||
|
||||
if (position != "0"){
|
||||
if (position != 0){
|
||||
rotateArray(ledArray, position);
|
||||
}
|
||||
|
||||
@@ -368,11 +365,19 @@ $(document).ready(function() {
|
||||
// translate
|
||||
performTranslation();
|
||||
|
||||
//add intros
|
||||
if(showOptHelp)
|
||||
{
|
||||
createHintH("intro", $.i18n('conf_leds_device_intro'), "leddevice_intro");
|
||||
createHintH("intro", $.i18n('conf_leds_layout_intro'), "layout_intro");
|
||||
$('#led_vis_help').html('<div><div class="led_ex" style="background-color:black;margin-right:5px;margin-top:3px"></div><div style="display:inline-block;vertical-align:top">'+$.i18n('conf_leds_layout_preview_l1')+'</div></div><div class="led_ex" style="background-color:grey;margin-top:3px;margin-right:2px"></div><div class="led_ex" style="background-color: rgb(169, 169, 169);margin-right:5px;margin-top:3px;"></div><div style="display:inline-block;vertical-align:top">'+$.i18n('conf_leds_layout_preview_l2')+'</div>');
|
||||
}
|
||||
|
||||
//gather ids
|
||||
IntListIds = $('.led_val_int').map(function() { return this.id; }).get();
|
||||
StrListIds = $('.led_val_string').map(function() { return this.id; }).get();
|
||||
BoolListIds = $('.led_val_bool').map(function() { return this.id; }).get();
|
||||
|
||||
|
||||
// restore values from storage
|
||||
loadStoredValues();
|
||||
|
||||
@@ -420,54 +425,82 @@ $(document).ready(function() {
|
||||
});
|
||||
|
||||
// fill textfield with current led conf and copy to finalLedArray
|
||||
$(hyperion).one("cmd-config-getconfig",function(event){
|
||||
$("#ledconfig").text(JSON.stringify(event.response.result.leds, null, "\t"));
|
||||
finalLedArray = event.response.result.leds;
|
||||
$("#ledconfig").text(JSON.stringify(serverConfig.leds, null, "\t"));
|
||||
finalLedArray = serverConfig.leds;
|
||||
|
||||
// create and update editor
|
||||
var conf_editor = null;
|
||||
$("#leddevices").off().on("change", function() {
|
||||
generalOptions = serverSchema.properties.device;
|
||||
specificOptions = serverSchema.properties.alldevices[$(this).val()];
|
||||
conf_editor = createJsonEditor('editor_container', {
|
||||
generalOptions : generalOptions,
|
||||
specificOptions : specificOptions,
|
||||
});
|
||||
|
||||
values_general = {};
|
||||
values_specific = {};
|
||||
isCurrentDevice = (serverInfo.info.ledDevices.active == $(this).val());
|
||||
|
||||
for(var key in serverConfig.device){
|
||||
if (key != "type" && key in generalOptions.properties)
|
||||
values_general[key] = serverConfig.device[key];
|
||||
};
|
||||
conf_editor.getEditor("root.generalOptions").setValue( values_general );
|
||||
|
||||
if (isCurrentDevice)
|
||||
{
|
||||
specificOptions_val = conf_editor.getEditor("root.specificOptions").getValue()
|
||||
for(var key in specificOptions_val){
|
||||
values_specific[key] = (key in serverConfig.device) ? serverConfig.device[key] : specificOptions_val[key];
|
||||
};
|
||||
|
||||
conf_editor.getEditor("root.specificOptions").setValue( values_specific );
|
||||
};
|
||||
|
||||
// change save button state based on validation result
|
||||
conf_editor.validate().length ? $('#btn_submit_controller').attr('disabled', true) : $('#btn_submit_controller').attr('disabled', false);
|
||||
});
|
||||
|
||||
// create led device selection
|
||||
$(hyperion).one("cmd-serverinfo",function(event){
|
||||
server = event.response;
|
||||
ledDevices = server.info.ledDevices.available
|
||||
devRPiSPI = ['apa102', 'ws2801', 'lpd6803', 'lpd8806', 'p9813', 'sk6812spi', 'ws2812spi'];
|
||||
devRPiPWM = ['ws281x'];
|
||||
devRPiGPIO = ['piblaster'];
|
||||
devNET = ['atmoorb', 'fadecandy', 'philipshue', 'tinkerforge', 'tpm2net', 'udpe131', 'udph801', 'udpraw'];
|
||||
devUSB = ['adalight', 'dmx', 'atmo', 'hyperionusbasp', 'lightpack', 'multilightpack', 'paintpack', 'rawhid', 'sedu', 'tpm2'];
|
||||
|
||||
var optArr = [[]];
|
||||
optArr[1]=[];
|
||||
optArr[2]=[];
|
||||
optArr[3]=[];
|
||||
optArr[4]=[];
|
||||
optArr[5]=[];
|
||||
|
||||
for (idx=0; idx<ledDevices.length; idx++)
|
||||
{
|
||||
if($.inArray(ledDevices[idx], devRPiSPI) != -1)
|
||||
optArr[0].push(ledDevices[idx]);
|
||||
else if($.inArray(ledDevices[idx], devRPiPWM) != -1)
|
||||
optArr[1].push(ledDevices[idx]);
|
||||
else if($.inArray(ledDevices[idx], devRPiGPIO) != -1)
|
||||
optArr[2].push(ledDevices[idx]);
|
||||
else if($.inArray(ledDevices[idx], devNET) != -1)
|
||||
optArr[3].push(ledDevices[idx]);
|
||||
else if($.inArray(ledDevices[idx], devUSB) != -1)
|
||||
optArr[4].push(ledDevices[idx]);
|
||||
else
|
||||
optArr[5].push(ledDevices[idx]);
|
||||
}
|
||||
|
||||
$("#leddevices").append(createSel(optArr[0], $.i18n('conf_leds_optgroup_RPiSPI')));
|
||||
$("#leddevices").append(createSel(optArr[1], $.i18n('conf_leds_optgroup_RPiPWM')));
|
||||
$("#leddevices").append(createSel(optArr[2], $.i18n('conf_leds_optgroup_RPiGPIO')));
|
||||
$("#leddevices").append(createSel(optArr[3], $.i18n('conf_leds_optgroup_network')));
|
||||
$("#leddevices").append(createSel(optArr[4], $.i18n('conf_leds_optgroup_usb')));
|
||||
$("#leddevices").append(createSel(optArr[5], $.i18n('conf_leds_optgroup_debug')));
|
||||
|
||||
$("#leddevices").val(server.info.ledDevices.active);
|
||||
$("#leddevices").trigger("change");
|
||||
});
|
||||
ledDevices = serverInfo.info.ledDevices.available
|
||||
devRPiSPI = ['apa102', 'ws2801', 'lpd6803', 'lpd8806', 'p9813', 'sk6812spi', 'ws2812spi'];
|
||||
devRPiPWM = ['ws281x'];
|
||||
devRPiGPIO = ['piblaster'];
|
||||
devNET = ['atmoorb', 'fadecandy', 'philipshue', 'tinkerforge', 'tpm2net', 'udpe131', 'udph801', 'udpraw'];
|
||||
devUSB = ['adalight', 'dmx', 'atmo', 'hyperionusbasp', 'lightpack', 'multilightpack', 'paintpack', 'rawhid', 'sedu', 'tpm2'];
|
||||
|
||||
var optArr = [[]];
|
||||
optArr[1]=[];
|
||||
optArr[2]=[];
|
||||
optArr[3]=[];
|
||||
optArr[4]=[];
|
||||
optArr[5]=[];
|
||||
|
||||
for (idx=0; idx<ledDevices.length; idx++)
|
||||
{
|
||||
if($.inArray(ledDevices[idx], devRPiSPI) != -1)
|
||||
optArr[0].push(ledDevices[idx]);
|
||||
else if($.inArray(ledDevices[idx], devRPiPWM) != -1)
|
||||
optArr[1].push(ledDevices[idx]);
|
||||
else if($.inArray(ledDevices[idx], devRPiGPIO) != -1)
|
||||
optArr[2].push(ledDevices[idx]);
|
||||
else if($.inArray(ledDevices[idx], devNET) != -1)
|
||||
optArr[3].push(ledDevices[idx]);
|
||||
else if($.inArray(ledDevices[idx], devUSB) != -1)
|
||||
optArr[4].push(ledDevices[idx]);
|
||||
else
|
||||
optArr[5].push(ledDevices[idx]);
|
||||
}
|
||||
|
||||
$("#leddevices").append(createSel(optArr[0], $.i18n('conf_leds_optgroup_RPiSPI')));
|
||||
$("#leddevices").append(createSel(optArr[1], $.i18n('conf_leds_optgroup_RPiPWM')));
|
||||
$("#leddevices").append(createSel(optArr[2], $.i18n('conf_leds_optgroup_RPiGPIO')));
|
||||
$("#leddevices").append(createSel(optArr[3], $.i18n('conf_leds_optgroup_network')));
|
||||
$("#leddevices").append(createSel(optArr[4], $.i18n('conf_leds_optgroup_usb')));
|
||||
$("#leddevices").append(createSel(optArr[5], $.i18n('conf_leds_optgroup_debug')));
|
||||
$("#leddevices").val(serverInfo.info.ledDevices.active);
|
||||
$("#leddevices").trigger("change");
|
||||
|
||||
// validate textfield and update preview
|
||||
$("#leds_custom_updsim").off().on("click", function() {
|
||||
@@ -494,6 +527,21 @@ $(document).ready(function() {
|
||||
toggleClass('#leds_prev_toggle_num', "btn-danger", "btn-success");
|
||||
});
|
||||
|
||||
// open checklist
|
||||
$('#leds_prev_checklist').off().on("click", function() {
|
||||
var liList = [$.i18n('conf_leds_leyout_checkp1'),$.i18n('conf_leds_leyout_checkp3'),$.i18n('conf_leds_leyout_checkp2'),$.i18n('conf_leds_leyout_checkp4')];
|
||||
var ul = document.createElement("ul");
|
||||
ul.className = "checklist"
|
||||
|
||||
for(var i = 0; i<liList.length; i++)
|
||||
{
|
||||
var li = document.createElement("li");
|
||||
li.innerHTML = liList[i];
|
||||
ul.appendChild(li);
|
||||
}
|
||||
showInfoDialog('checklist', "", ul);
|
||||
});
|
||||
|
||||
// nav
|
||||
$('#leds_cfg_nav a[data-toggle="tab"]').off().on('shown.bs.tab', function (e) {
|
||||
var target = $(e.target).attr("href") // activated tab
|
||||
@@ -503,57 +551,6 @@ $(document).ready(function() {
|
||||
ledsCustomCfgInitialized = true;
|
||||
}
|
||||
});
|
||||
|
||||
// create and update editor
|
||||
var conf_editor = null;
|
||||
$("#leddevices").off().on("change", function(event) {
|
||||
generalOptions = parsedConfSchemaJSON.properties.device;
|
||||
specificOptions = parsedConfSchemaJSON.properties.alldevices[$(this).val()];
|
||||
conf_editor = createJsonEditor('editor_container', {
|
||||
generalOptions : generalOptions,
|
||||
specificOptions : specificOptions,
|
||||
});
|
||||
|
||||
values_general = {};
|
||||
values_specific = {};
|
||||
isCurrentDevice = (server.info.ledDevices.active == $(this).val());
|
||||
|
||||
for(var key in parsedConfJSON.device){
|
||||
if (key != "type" && key in generalOptions.properties)
|
||||
values_general[key] = parsedConfJSON.device[key];
|
||||
};
|
||||
conf_editor.getEditor("root.generalOptions").setValue( values_general );
|
||||
|
||||
if (isCurrentDevice)
|
||||
{
|
||||
specificOptions_val = conf_editor.getEditor("root.specificOptions").getValue()
|
||||
for(var key in specificOptions_val){
|
||||
values_specific[key] = (key in parsedConfJSON.device) ? parsedConfJSON.device[key] : specificOptions_val[key];
|
||||
};
|
||||
|
||||
conf_editor.getEditor("root.specificOptions").setValue( values_specific );
|
||||
};
|
||||
|
||||
if ($(this).val() == "philipshue")
|
||||
{
|
||||
$("#huebridge").show();
|
||||
|
||||
$("#ip").attr('value', values_specific.output);
|
||||
$("#user").attr('value', values_specific.username);
|
||||
|
||||
if($("#ip").val() != '' && $("#user").val() != '') {
|
||||
get_hue_lights();
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#huebridge").hide();
|
||||
}
|
||||
|
||||
// change save button state based on validation result
|
||||
conf_editor.validate().length ? $('#btn_submit_controller').attr('disabled', true) : $('#btn_submit_controller').attr('disabled', false);
|
||||
});
|
||||
|
||||
// save led device config
|
||||
$("#btn_submit_controller").off().on("click", function(event) {
|
||||
@@ -574,7 +571,7 @@ $(document).ready(function() {
|
||||
requestWriteConfig(result)
|
||||
});
|
||||
|
||||
requestServerConfig();
|
||||
removeOverlay();
|
||||
});
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user