1
0
Fork 0
mirror of https://github.com/iNavFlight/inav-configurator.git synced 2025-07-16 21:05:28 +03:00

Convert to CommonJS Modules

This commit is contained in:
Andi Kanzler 2024-02-26 11:58:56 -03:00
parent 7df8253099
commit 91f1699659
100 changed files with 9685 additions and 3735 deletions

5
.vscode/launch.json vendored
View file

@ -11,7 +11,8 @@
}, },
"args": ["--inspect"], "args": ["--inspect"],
"env": { "env": {
"NODE_ENV": "development" "NODE_ENV": "development",
"NODE_PATH": "${workspaceFolder}/js/"
}, },
"cwd": "${workspaceFolder}", "cwd": "${workspaceFolder}",
"console": "integratedTerminal" "console": "integratedTerminal"
@ -25,7 +26,7 @@
"windows": { "windows": {
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron.cmd" "runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron.cmd"
}, },
"args" : ["."], "args" : [".", "--trace-warnings"],
"outputCapture": "std" "outputCapture": "std"
} }
] ]

View file

@ -1,32 +1,37 @@
module.exports = { module.exports = {
packagerConfig: { packagerConfig: {
asar: true, asar: false,
icon: 'images/inav'
}, },
rebuildConfig: {}, rebuildConfig: {},
makers: [ makers: [
/*
{ {
name: '@electron-forge/maker-squirrel', name: '@electron-forge/maker-squirrel',
config: {}, config: {
iconUrl: "https://raw.githubusercontent.com/iNavFlight/inav-configurator/master/images/inav.ico",
loadingGif: "images/inav-installing.gif"
}, },
*/ },
{ {
name: '@electron-forge/maker-zip', name: '@electron-forge/maker-zip',
platforms: ['win32', 'darwin'], platforms: ['win32', 'darwin'],
}, },
{ {
name: '@electron-forge/maker-deb', name: '@electron-forge/maker-deb',
config: {}, config: {
options: {
icon: "images/inav_icon_128.png"
}
},
}, },
{ {
name: '@electron-forge/maker-rpm', name: '@electron-forge/maker-rpm',
config: {}, config: {
options: {
icon: "images/inav_icon_128.png"
}
}, },
],
plugins: [
{
name: '@electron-forge/plugin-auto-unpack-natives',
config: {},
}, },
], ],
}; };

BIN
images/inav-installing.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

View file

@ -4,109 +4,9 @@
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link type="text/css" rel="stylesheet" href="./src/css/styles.css" media="all" /> <link type="text/css" rel="stylesheet" href="./src/css/styles.css" media="all" />
<script type="text/javascript">require('./js/configurator_main.js');</script>
<script>if (typeof module === 'object') {window.module = module; module = undefined;}</script>
<script type="text/javascript" src="./js/main.js"></script>
<script type="text/javascript" src="./js/sitl.js"></script>
<script type="text/javascript" src="./js/CliAutoComplete.js"></script>
<script type="text/javascript" src="./js/libraries/d3.min.js"></script>
<script type="text/javascript" src="./js/libraries/jquery.nouislider.all.min.js"></script>
<script type="text/javascript" src="./js/libraries/three/three.min.js"></script> <script type="text/javascript" src="./js/libraries/three/three.min.js"></script>
<script type="text/javascript" src="./js/libraries/three/GLTFLoader.js"></script> <script type="text/javascript" src="./js/libraries/three/GLTFLoader.js"></script>
<script type="text/javascript" src="./js/libraries/three/OrbitControls.js"></script>
<script type="text/javascript" src="./js/libraries/bundle_xml2js.js"></script>
<script type="text/javascript" src="./js/libraries/Projector.js"></script>
<script type="text/javascript" src="./js/libraries/CanvasRenderer.js"></script>
<script type="text/javascript" src="./js/libraries/jquery.flightindicators.js"></script>
<script type="text/javascript" src="./js/libraries/semver.js"></script>
<script type="text/javascript" src="./js/libraries/jbox/jBox.min.js"></script>
<script type="text/javascript" src="./js/libraries/switchery/switchery.js"></script>
<script type="text/javascript" src="./js/libraries/jquery.ba-throttle-debounce.js"></script>
<script type="text/javascript" src="./js/helpers.js"></script>
<script type="text/javascript" src="./js/injected_methods.js"></script>
<script type="text/javascript" src="./js/intervals.js"></script>
<script type="text/javascript" src="./js/timeouts.js"></script>
<script type="text/javascript" src="./js/pid_controller.js"></script>
<script type="text/javascript" src="./js/simple_smooth_filter.js"></script>
<script type="text/javascript" src="./js/walking_average_filter.js"></script>
<script type="text/javascript" src="./js/gui.js"></script>
<script type="text/javascript" src="./js/msp/MSPCodes.js"></script>
<script type="text/javascript" src="./js/msp/MSPHelper.js"></script>
<script type="text/javascript" src="./js/msp/MSPchainer.js"></script>
<script type="text/javascript" src="./js/port_handler.js"></script>
<script type="text/javascript" src="./js/connection/connection.js"></script>
<script type="text/javascript" src="./js/connection/connectionBle.js"></script>
<script type="text/javascript" src="./js/connection/connectionSerial.js"></script>
<script type="text/javascript" src="./js/connection/connectionTcp.js"></script>
<script type="text/javascript" src="./js/connection/connectionUdp.js"></script>
<script type="text/javascript" src="./js/servoMixRule.js"></script>
<script type="text/javascript" src="./js/motorMixRule.js"></script>
<script type="text/javascript" src="./js/logicCondition.js"></script>
<script type="text/javascript" src="./js/settings.js"></script>
<script type="text/javascript" src="./js/outputMapping.js"></script>
<script type="text/javascript" src="./js/model.js"></script>
<script type="text/javascript" src="./js/serial_backend.js"></script>
<script type="text/javascript" src="./js/data_storage.js"></script>
<script type="text/javascript" src="./js/fc.js"></script>
<script type="text/javascript" src="./js/msp.js"></script>
<script type="text/javascript" src="./js/protocols/stm32.js"></script>
<script type="text/javascript" src="./js/protocols/stm32usbdfu.js"></script>
<script type="text/javascript" src="./js/localization.js"></script>
<script type="text/javascript" src="./js/boards.js"></script>
<script type="text/javascript" src="./js/servoMixerRuleCollection.js"></script>
<script type="text/javascript" src="./js/motorMixerRuleCollection.js"></script>
<script type="text/javascript" src="./js/logicConditionsCollection.js"></script>
<script type="text/javascript" src="./js/logicConditionsStatus.js"></script>
<script type="text/javascript" src="./js/globalVariablesStatus.js"></script>
<script type="text/javascript" src="./js/programmingPid.js"></script>
<script type="text/javascript" src="./js/programmingPidCollection.js"></script>
<script type="text/javascript" src="./js/programmingPidStatus.js"></script>
<script type="text/javascript" src="./js/vtx.js"></script>
<script type="text/javascript" src="./js/tabs.js"></script>
<script type="text/javascript" src="./js/eventFrequencyAnalyzer.js"></script>
<script type="text/javascript" src="./js/periodicStatusUpdater.js"></script>
<script type="text/javascript" src="./js/serial_queue.js"></script>
<script type="text/javascript" src="./js/msp_balanced_interval.js"></script>gt
<script type="text/javascript" src="./js/peripherals.js"></script>
<script type="text/javascript" src="./js/appUpdater.js"></script>
<script type="text/javascript" src="./js/feature_framework.js"></script>
<script type="text/javascript" src="./js/defaults_dialog.js"></script>
<script type="text/javascript" src="./js/safehomeCollection.js"></script>
<script type="text/javascript" src="./js/safehome.js"></script>
<script type="text/javascript" src="./js/waypointCollection.js"></script>
<script type="text/javascript" src="./js/waypoint.js"></script>
<script type="text/javascript" src="./js/libraries/plotly-latest.min.js"></script>
<script type="text/javascript" src="./tabs/adjustments.js"></script>
<script type="text/javascript" src="./tabs/advanced_tuning.js"></script>
<script type="text/javascript" src="./tabs/auxiliary.js"></script>
<script type="text/javascript" src="./tabs/calibration.js"></script>
<script type="text/javascript" src="./tabs/cli.js"></script>
<script type="text/javascript" src="./tabs/configuration.js"></script>
<script type="text/javascript" src="./tabs/ez_tune.js"></script>
<script type="text/javascript" src="./tabs/failsafe.js"></script>
<script type="text/javascript" src="./tabs/firmware_flasher.js"></script>
<script type="text/javascript" src="./tabs/gps.js"></script>
<script type="text/javascript" src="./tabs/landing.js"></script>
<script type="text/javascript" src="./tabs/led_strip.js"></script>
<script type="text/javascript" src="./tabs/logging.js"></script>
<script type="text/javascript" src="./tabs/magnetometer.js"></script>
<script type="text/javascript" src="./tabs/mission_control.js"></script>
<script type="text/javascript" src="./tabs/mixer.js"></script>
<script type="text/javascript" src="./tabs/modes.js"></script>
<script type="text/javascript" src="./tabs/onboard_logging.js"></script>
<script type="text/javascript" src="./tabs/osd.js"></script>
<script type="text/javascript" src="./tabs/outputs.js"></script>
<script type="text/javascript" src="./tabs/pid_tuning.js"></script>
<script type="text/javascript" src="./tabs/ports.js"></script>
<script type="text/javascript" src="./tabs/programming.js"></script>
<script type="text/javascript" src="./tabs/receiver.js"></script>
<script type="text/javascript" src="./tabs/receiver_msp.js"></script>
<script type="text/javascript" src="./tabs/sensors.js"></script>
<script type="text/javascript" src="./tabs/setup.js"></script>
<script type="text/javascript" src="./tabs/sitl.js"></script>
<script>if (window.module) module = window.module;</script>
<title></title> <title></title>
</head> </head>

View file

@ -552,3 +552,5 @@ CliAutoComplete._initTextcomplete = function() {
}), }),
]); ]);
}; };
module.exports = CliAutoComplete;

View file

@ -5,7 +5,7 @@ var appUpdater = appUpdater || {};
appUpdater.checkRelease = function (currVersion) { appUpdater.checkRelease = function (currVersion) {
var modalStart; var modalStart;
$.get('https://api.github.com/repos/iNavFlight/inav-configurator/releases', function (releaseData) { $.get('https://api.github.com/repos/iNavFlight/inav-configurator/releases', function (releaseData) {
GUI.log(localization.getMessage('loadedReleaseInfo')); GUI.log(i18n.getMessage('loadedReleaseInfo'));
//Git return sorted list, 0 - last release //Git return sorted list, 0 - last release
let newVersion = releaseData[0].tag_name; let newVersion = releaseData[0].tag_name;
@ -15,7 +15,7 @@ appUpdater.checkRelease = function (currVersion) {
GUI.log(newVersion, app.getVersion()); GUI.log(newVersion, app.getVersion());
GUI.log(currVersion); GUI.log(currVersion);
GUI.log(localization.getMessage('newVersionAvailable')); GUI.log(i18n.getMessage('newVersionAvailable'));
modalStart = new jBox('Modal', { modalStart = new jBox('Modal', {
width: 400, width: 400,
height: 200, height: 200,

34
js/bitHelper.js Normal file
View file

@ -0,0 +1,34 @@
'use strict'
var BitHelper = function() {
var self = {};
self.highByte = function (num) {
return num >> 8;
}
self.lowByte = function (num) {
return 0x00FF & num;
}
self.specificByte = function (num, pos) {
return 0x000000FF & (num >> (8 * pos));
}
self.bit_check = function (num, bit) {
return ((num >> bit) % 2 != 0);
}
self.bit_set = function (num, bit) {
return num | 1 << bit;
}
self.bit_clear = function(num, bit) {
return num & ~(1 << bit);
}
return self;
}();
module.exports = BitHelper;

View file

@ -59,3 +59,6 @@ BOARD.findDefinition = function (identifier) {
} }
return DEFAULT_BOARD_DEFINITION; return DEFAULT_BOARD_DEFINITION;
}; };
module.exports = BOARD;

611
js/configurator_main.js Normal file
View file

@ -0,0 +1,611 @@
window.$ = window.jQuery = require('jquery'),
require('jquery-ui-dist/jquery-ui'),
require('jquery-textcomplete'),
require('./libraries/jquery.flightindicators.js');
const { app } = require('@electron/remote');
const d3 = require('./libraries/d3.min.js');
const Store = require('electron-store');
const store = new Store();
const { GUI, TABS } = require('./gui');
const CONFIGURATOR = require('./data_storage');
const FC = require('./fc');
const { globalSettings, UnitType } = require('./globalSettings');
const { PLATFORM } = require('./model.js')
const i18n = require('./localization');
const SerialBackend = require('./serial_backend');
const MSP = require('./msp');
const mspHelper = require('./msp/MSPHelper.js');
const update = require('./globalUpdates.js');
process.on('uncaughtException', function (error) {
if (process.env.NODE_ENV !== 'development') {
GUI.log(i18n.getMessage('unexpectedError', error));
if (GUI.connected_to || GUI.connecting_to) {
GUI.log(i18n.getMessage('disconnecting'));
$('a.connect').trigger('click');
}
} else {
throw error;
}
});
// Set how the units render on the configurator only
$(function() {
i18n.init( () => {
i18n.localize();
MSP.init();
mspHelper.init();
SerialBackend.init();
GUI.updateEzTuneTabVisibility = function(loadMixerConfig) {
let useEzTune = true;
if (CONFIGURATOR.connectionValid) {
if (loadMixerConfig) {
mspHelper.loadMixerConfig(function () {
if (FC.MIXER_CONFIG.platformType == PLATFORM.MULTIROTOR || FC.MIXER_CONFIG.platformType == PLATFORM.TRICOPTER) {
$('.tab_ez_tune').removeClass("is-hidden");
} else {
$('.tab_ez_tune').addClass("is-hidden");
useEzTune = false;
}
});
} else {
if (FC.MIXER_CONFIG.platformType == PLATFORM.MULTIROTOR || FC.MIXER_CONFIG.platformType == PLATFORM.TRICOPTER) {
$('.tab_ez_tune').removeClass("is-hidden");
} else {
$('.tab_ez_tune').addClass("is-hidden");
useEzTune = false;
}
}
}
return useEzTune;
};
globalSettings.unitType = store.get('unit_type', UnitType.none);
globalSettings.mapProviderType = store.get('map_provider_type', 'osm');
globalSettings.mapApiKey = store.get('map_api_key', '');
globalSettings.proxyURL = store.get('proxyurl', 'http://192.168.1.222/mapproxy/service?');
globalSettings.proxyLayer = store.get('proxylayer', 'your_proxy_layer_name');
globalSettings.showProfileParameters = store.get('show_profile_parameters', 1);
updateProfilesHighlightColours();
if (store.get('cli_autocomplete', true)) {
globalSettings.cliAutocomplete = true;
//CliAutoComplete.setEnabled(true);
};
// Resets the OSD units used by the unit coversion when the FC is disconnected.
if (!CONFIGURATOR.connectionValid) {
globalSettings.osdUnits = null;
}
// alternative - window.navigator.appVersion.match(/Chrome\/([0-9.]*)/)[1];
GUI.log(i18n.getMessage('getRunningOS') + GUI.operating_system + '</strong>, ' +
'Chrome: <strong>' + process.versions['chrome'] + '</strong>, ' +
i18n.getMessage('getConfiguratorVersion') + app.getVersion() + '</strong>');
$('#status-bar .version').text(app.getVersion());
$('#logo .version').text(app.getVersion());
update.firmwareVersion();
if (store.get('logopen', false)) {
$("#showlog").trigger('click');
}
if (store.get('update_notify', true)) { 34
//appUpdater.checkRelease(app.getVersion());
}
// log library versions in console to make version tracking easier
console.log('Libraries: jQuery - ' + $.fn.jquery + ', d3 - ' + d3.version + ', three.js - ' + THREE.REVISION);
// Tabs
var ui_tabs = $('#tabs > ul');
$('a', ui_tabs).on('click', function() {
if ($(this).parent().hasClass("tab_help")) {
return;
}
if ($(this).parent().hasClass('active') == false && !GUI.tab_switch_in_progress) { // only initialize when the tab isn't already active
var self = this,
tabClass = $(self).parent().prop('class');
var tabRequiresConnection = $(self).parent().hasClass('mode-connected');
var tab = tabClass.substring(4);
var tabName = $(self).text();
if (tabRequiresConnection && !CONFIGURATOR.connectionValid) {
GUI.log(i18n.getMessage('tabSwitchConnectionRequired'));
return;
}
if (GUI.connect_lock) { // tab switching disabled while operation is in progress
GUI.log(i18n.getMessage('tabSwitchWaitForOperation'));
return;
}
if (GUI.allowedTabs.indexOf(tab) < 0) {
GUI.log(i18n.getMessage('tabSwitchUpgradeRequired', [tabName]));
return;
}
GUI.tab_switch_in_progress = true;
GUI.tab_switch_cleanup(function () {
// disable previously active tab highlight
$('li', ui_tabs).removeClass('active');
// Highlight selected tab
$(self).parent().addClass('active');
// detach listeners and remove element data
var content = $('#content');
content.data('empty', !!content.is(':empty'));
content.empty();
// display loading screen
$('#cache .data-loading').clone().appendTo(content);
function content_ready() {
GUI.tab_switch_in_progress = false;
// Update CSS on to show highlighing or not
updateProfilesHighlightColours();
}
switch (tab) {
case 'landing':
require('./../tabs/landing')
TABS.landing.initialize(content_ready);
break;
case 'firmware_flasher':
require('./../tabs/firmware_flasher')
TABS.firmware_flasher.initialize(content_ready);
break;
case 'sitl':
require('./../tabs/sitl')
TABS.sitl.initialize(content_ready);
break;
case 'auxiliary':
require('./../tabs/auxiliary')
TABS.auxiliary.initialize(content_ready);
break;
case 'adjustments':
require('./../tabs/adjustments')
TABS.adjustments.initialize(content_ready);
break;
case 'ports':
require('./../tabs/ports');
TABS.ports.initialize(content_ready);
break;
case 'led_strip':
require('./../tabs/led_strip');
TABS.led_strip.initialize(content_ready);
break;
case 'failsafe':
require('./../tabs/failsafe');
TABS.failsafe.initialize(content_ready);
break;
case 'setup':
require('./../tabs/setup');
TABS.setup.initialize(content_ready);
break;
case 'calibration':
require('./../tabs/calibration');
TABS.calibration.initialize(content_ready);
break;
case 'configuration':
require('./../tabs/configuration');
TABS.configuration.initialize(content_ready);
break;
case 'pid_tuning':
require('./../tabs/pid_tuning');
TABS.pid_tuning.initialize(content_ready);
break;
case 'receiver':
require('./../tabs/receiver');
TABS.receiver.initialize(content_ready);
break;
case 'modes':
require('./../tabs/modes');
TABS.modes.initialize(content_ready);
break;
case 'gps':
require('./../tabs');
TABS.gps.initialize(content_ready);
break;
case 'magnetometer':
require('./../tabs');
TABS.magnetometer.initialize(content_ready);
break;
case 'mission_control':
require('./../tabs');
TABS.mission_control.initialize(content_ready);
break;
case 'mixer':
require('./../tabs');
TABS.mixer.initialize(content_ready);
break;
case 'outputs':
require('./../tabs/outputs');
TABS.outputs.initialize(content_ready);
break;
case 'osd':
require('./../tabs/osd');
TABS.osd.initialize(content_ready);
break;
case 'sensors':
require('./../tabs/sensors');
TABS.sensors.initialize(content_ready);
break;
case 'logging':
require('./../tabs/logging');
TABS.logging.initialize(content_ready);
break;
case 'onboard_logging':
require('./../tabs/onboard_logging');
TABS.onboard_logging.initialize(content_ready);
break;
case 'advanced_tuning':
require('./../tabs/advanced_tuning');
TABS.advanced_tuning.initialize(content_ready);
break;
case 'programming':
require('./../tabs/programming');
TABS.programming.initialize(content_ready);
break;
case 'cli':
require('./../tabs/cli');
TABS.cli.initialize(content_ready);
break;
case 'ez_tune':
require('./../tabs/ez_tune');
TABS.ez_tune.initialize(content_ready);
break;
default:
console.log('Tab not found:' + tab);
}
});
}
});
$('#tabs ul.mode-disconnected li a:first').trigger( "click" );
// options
$('#options').on('click', function() {
var el = $(this);
if (!el.hasClass('active')) {
el.addClass('active');
el.after('<div id="options-window"></div>');
$('div#options-window').load('./tabs/options.html', function () {
// translate to user-selected language
i18n.localize();
// if notifications are enabled, or wasn't set, check the notifications checkbox
if (store.get('update_notify', true)) {
$('div.notifications input').prop('checked', true);
}
$('div.notifications input').on('change', function () {
var check = $(this).is(':checked');
store.set('update_notify', check);
});
$('div.statistics input').on('change', function () {
var check = $(this).is(':checked');
});
$('div.show_profile_parameters input').on('change', function () {
globalSettings.showProfileParameters = $(this).is(':checked');
store.set('show_profile_parameters', globalSettings.showProfileParameters);
// Update CSS on select boxes
updateProfilesHighlightColours();
// Horrible way to reload the tab
const activeTab = $('#tabs li.active');
activeTab.removeClass('active');
activeTab.find('a').trigger( "click" );
});
$('div.cli_autocomplete input').on('change', function () {
globalSettings.cliAutocomplete = $(this).is(':checked');
store.set('cli_autocomplete', globalSettings.cliAutocomplete);
CliAutoComplete.setEnabled($(this).is(':checked'));
});
$('#ui-unit-type').val(globalSettings.unitType);
$('#map-provider-type').val(globalSettings.mapProviderType);
$('#map-api-key').val(globalSettings.mapApiKey);
$('#proxyurl').val(globalSettings.proxyURL);
$('#proxylayer').val(globalSettings.proxyLayer);
$('#showProfileParameters').prop('checked', globalSettings.showProfileParameters);
$('#cliAutocomplete').prop('checked', globalSettings.cliAutocomplete);
i18n.getLanguages().forEach(lng => {
$('#languageOption').append("<option value='{0}'>{1}</option>".format(lng, i18n.getMessage("language_" + lng)));
});
$('#languageOption').val(i18n.getCurrentLanguage());
$('#languageOption').on('change', () => {
i18n.changeLanguage($('#languageOption').val());
});
// Set the value of the unit type
// none, OSD, imperial, metric
$('#ui-unit-type').on('change', function () {
store.set('unit_type', $(this).val());
globalSettings.unitType = $(this).val();
// Update the osd units in global settings
// but only if we need it
if (globalSettings.unitType === UnitType.OSD) {
get_osd_settings();
}
// Horrible way to reload the tab
const activeTab = $('#tabs li.active');
activeTab.removeClass('active');
activeTab.find('a').trigger( "click" );
});
$('#map-provider-type').on('change', function () {
store.set('map_provider_type', $(this).val());
globalSettings.mapProviderType = $(this).val();
});
$('#map-api-key').on('change', function () {
store.set('map_api_key', $(this).val());
globalSettings.mapApiKey = $(this).val();
});
$('#proxyurl').on('change', function () {
store.set('proxyurl', $(this).val());
globalSettings.proxyURL = $(this).val();
});
$('#proxylayer').on('change', function () {
store.set('proxylayer', $(this).val());
globalSettings.proxyLayer = $(this).val();
});
$('#demoModeReset').on('click', function () {
SITLProcess.deleteEepromFile('demo.bin');
});
function close_and_cleanup(e) {
if (e.type == 'click' && !$.contains($('div#options-window')[0], e.target) || e.type == 'keyup' && e.keyCode == 27) {
$(document).unbind('click keyup', close_and_cleanup);
$('div#options-window').slideUp(250, function () {
el.removeClass('active');
$(this).empty().remove();
});
}
}
$(document).bind('click keyup', close_and_cleanup);
$(this).slideDown(250);
});
}
});
var $content = $("#content");
// listen to all input change events and adjust the value within limits if necessary
$content.on('focus', 'input[type="number"]', function () {
var element = $(this),
val = element.val();
if (!isNaN(val)) {
element.data('previousValue', parseFloat(val));
}
});
$content.on('keydown', 'input[type="number"]', function (e) {
// whitelist all that we need for numeric control
var whitelist = [
96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, // numpad and standard number keypad
109, 189, // minus on numpad and in standard keyboard
8, 46, 9, // backspace, delete, tab
190, 110, // decimal point
37, 38, 39, 40, 13 // arrows and enter
];
if (whitelist.indexOf(e.keyCode) == -1) {
e.preventDefault();
}
});
$content.on('change', 'input[type="number"]', function () {
var element = $(this),
min = parseFloat(element.prop('min')),
max = parseFloat(element.prop('max')),
step = parseFloat(element.prop('step')),
val = parseFloat(element.val()),
decimal_places;
// only adjust minimal end if bound is set
if (element.prop('min')) {
if (val < min) {
element.val(min);
val = min;
}
}
// only adjust maximal end if bound is set
if (element.prop('max')) {
if (val > max) {
element.val(max);
val = max;
}
}
// if entered value is illegal use previous value instead
if (isNaN(val)) {
element.val(element.data('previousValue'));
val = element.data('previousValue');
}
// if step is not set or step is int and value is float use previous value instead
if (isNaN(step) || step % 1 === 0) {
if (val % 1 !== 0) {
element.val(element.data('previousValue'));
val = element.data('previousValue');
}
}
// if step is set and is float and value is int, convert to float, keep decimal places in float according to step *experimental*
if (!isNaN(step) && step % 1 !== 0) {
decimal_places = String(step).split('.')[1].length;
if (val % 1 === 0) {
element.val(val.toFixed(decimal_places));
} else if (String(val).split('.')[1].length != decimal_places) {
element.val(val.toFixed(decimal_places));
}
}
});
$("#showlog").on('click', function() {
var state = $(this).data('state'),
$log = $("#log");
if (state) {
$log.animate({height: 27}, 200, function() {
var command_log = $('div#log');
//noinspection JSValidateTypes
command_log.scrollTop($('div.wrapper', command_log).height());
});
$log.removeClass('active');
$("#content").removeClass('logopen');
$(".tab_container").removeClass('logopen');
$("#scrollicon").removeClass('active');
store.set('logopen', false);
state = false;
}else{
$log.animate({height: 111}, 200);
$log.addClass('active');
$("#content").addClass('logopen');
$(".tab_container").addClass('logopen');
$("#scrollicon").addClass('active');
store.set('logopen', true);
state = true;
}
$(this).html(state ? i18n.getMessage("mainHideLog") : i18n.getMessage("mainShowLog"));
$(this).data('state', state);
});
var mixerprofile_e = $('#mixerprofilechange');
mixerprofile_e.on('change', function () {
var mixerprofile = parseInt($(this).val());
MSP.send_message(MSPCodes.MSP2_INAV_SELECT_MIXER_PROFILE, [mixerprofile], false, function () {
GUI.log(i18n.getMessage('loadedMixerProfile', [mixerprofile + 1]));
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, function () {
GUI.log(i18n.getMessage('deviceRebooting'));
GUI.handleReconnect();
});
});
});
var profile_e = $('#profilechange');
profile_e.on('change', function () {
var profile = parseInt($(this).val());
MSP.send_message(MSPCodes.MSP_SELECT_SETTING, [profile], false, function () {
GUI.log(i18n.getMessage('pidTuning_LoadedProfile', [profile + 1]));
});
});
var batteryprofile_e = $('#batteryprofilechange');
batteryprofile_e.on('change', function () {
var batteryprofile = parseInt($(this).val());
MSP.send_message(MSPCodes.MSP2_INAV_SELECT_BATTERY_PROFILE, [batteryprofile], false, function () {
GUI.log(i18n.getMessage('loadedBatteryProfile', [batteryprofile + 1]));
});
});
});
});
function get_osd_settings() {
if (globalSettings.osdUnits !== undefined && globalSettings.osdUnits !== null) {
return;
}
MSP.promise(MSPCodes.MSP2_INAV_OSD_PREFERENCES).then(function (resp) {
var prefs = resp.data;
prefs.readU8();
prefs.readU8();
prefs.readU8();
prefs.readU8();
prefs.readU8();
prefs.readU8();
prefs.readU8();
globalSettings.osdUnits = prefs.readU8();
});
}
function updateProfilesHighlightColours() {
if (globalSettings.showProfileParameters) {
$('.dropdown-dark #profilechange').addClass('showProfileParams');
$('.dropdown-dark #batteryprofilechange').addClass('showProfileParams');
$('.batteryProfileHighlight').each(function () {
$(this).addClass('batteryProfileHighlightActive');
$(this).removeClass('batteryProfileHighlight');
});
$('.controlProfileHighlight').each(function () {
$(this).addClass('controlProfileHighlightActive');
$(this).removeClass('controlProfileHighlight');
});
} else {
$('.dropdown-dark #profilechange').removeClass('showProfileParams');
$('.dropdown-dark #batteryprofilechange').removeClass('showProfileParams');
$('.batteryProfileHighlightActive').each(function () {
$(this).addClass('batteryProfileHighlight');
$(this).removeClass('batteryProfileHighlightActive');
});
$('.controlProfileHighlightActive').each(function () {
$(this).addClass('controlProfileHighlight');
$(this).removeClass('controlProfileHighlightActive');
});
}
}
Number.prototype.clamp = function (min, max) {
return Math.min(Math.max(this, min), max);
};
/**
* String formatting now supports currying (partial application).
* For a format string with N replacement indices, you can call .format
* with M <= N arguments. The result is going to be a format string
* with N-M replacement indices, properly counting from 0 .. N-M.
* The following Example should explain the usage of partial applied format:
* "{0}:{1}:{2}".format("a","b","c") === "{0}:{1}:{2}".format("a","b").format("c")
* "{0}:{1}:{2}".format("a").format("b").format("c") === "{0}:{1}:{2}".format("a").format("b", "c")
**/
String.prototype.format = function () {
var args = arguments;
return this.replace(/\{(\d+)\}/g, function (t, i) {
return args[i] !== void 0 ? args[i] : "{" + (i - args.length) + "}";
});
};

View file

@ -1,5 +1,7 @@
'use strict'; 'use strict';
const { GUI } = require('./../gui');
const ConnectionType = { const ConnectionType = {
Serial: 0, Serial: 0,
TCP: 1, TCP: 1,
@ -20,6 +22,7 @@ class Connection {
this._outputBuffer = []; this._outputBuffer = [];
this._onReceiveListeners = []; this._onReceiveListeners = [];
this._onReceiveErrorListeners = []; this._onReceiveErrorListeners = [];
this._type = null;
if (this.constructor === Connection) { if (this.constructor === Connection) {
throw new TypeError("Abstract class, cannot be instanced."); throw new TypeError("Abstract class, cannot be instanced.");
@ -59,40 +62,8 @@ class Connection {
} }
get type() { get type() {
switch (this.constructor.name) { return this._type;
case ConnectionSerial.name:
return ConnectionType.Serial;
case ConnectionTcp.name:
return ConnectionType.TCP;
case ConnectionUdp.name:
return ConnectionType.UDP;
case ConnectionBle.name:
return ConnectionType.BLE;
} }
}
static create(type) {
if (Connection.instance && (Connection.instance.type == type || Connection.instance.connectionId)){
return Connection.instance;
}
switch (type) {
case ConnectionType.BLE:
Connection.instance = new ConnectionBle();
break;
case ConnectionType.TCP:
Connection.instance = new ConnectionTcp();
break;
case ConnectionType.UDP:
Connection.instance = new ConnectionUdp();
break;
default:
case ConnectionType.Serial:
Connection.instance = new ConnectionSerial();
break;
}
return Connection.instance;
};
connectImplementation(path, options, callback) { connectImplementation(path, options, callback) {
throw new TypeError("Abstract method"); throw new TypeError("Abstract method");
@ -289,3 +260,5 @@ class Connection {
} }
} }
} }
module.exports = { ConnectionType, Connection};

View file

@ -1,5 +1,10 @@
'use strict' 'use strict'
const { GUI } = require('./../gui');
const { ConnectionType, Connection } = require('./connection');
const i18n = require('./../localization');
// BLE 20 bytes buffer // BLE 20 bytes buffer
const BLE_WRITE_BUFFER_LENGTH = 20; const BLE_WRITE_BUFFER_LENGTH = 20;
@ -48,6 +53,7 @@ class ConnectionBle extends Connection {
this._reconnects = 0; this._reconnects = 0;
this._handleOnCharateristicValueChanged = false; this._handleOnCharateristicValueChanged = false;
this._handleDisconnect = false; this._handleDisconnect = false;
super._type = ConnectionType.BLE;
} }
get deviceDescription() { get deviceDescription() {
@ -59,7 +65,7 @@ class ConnectionBle extends Connection {
await this.openDevice() await this.openDevice()
.then(() => { .then(() => {
this.addOnReceiveErrorListener(error => { this.addOnReceiveErrorListener(error => {
GUI.log(localization.getMessage('connectionBleInterrupted')); GUI.log(i18n.getMessage('connectionBleInterrupted'));
this.abort(); this.abort();
}); });
@ -71,7 +77,7 @@ class ConnectionBle extends Connection {
}); });
} }
}).catch(error => { }).catch(error => {
GUI.log(localization.getMessage('connectionBleError', [error])); GUI.log(i18n.getMessage('connectionBleError', [error]));
if (callback) { if (callback) {
callback(false); callback(false);
} }
@ -119,7 +125,7 @@ class ConnectionBle extends Connection {
return device.gatt.connect() return device.gatt.connect()
.then(server => { .then(server => {
console.log("Connect to: " + device.name); console.log("Connect to: " + device.name);
GUI.log(localization.getMessage('connectionConnected', [device.name])); GUI.log(i18n.getMessage('connectionConnected', [device.name]));
return server.getPrimaryServices(); return server.getPrimaryServices();
}).then(services => { }).then(services => {
let connectedService = services.find(service => { let connectedService = services.find(service => {
@ -131,7 +137,7 @@ class ConnectionBle extends Connection {
throw new Error("Unsupported device (service UUID mismatch)."); throw new Error("Unsupported device (service UUID mismatch).");
} }
GUI.log(localization.getMessage('connectionBleType', [this._deviceDescription.name])); GUI.log(i18n.getMessage('connectionBleType', [this._deviceDescription.name]));
return connectedService.getCharacteristics(); return connectedService.getCharacteristics();
}).then(characteristics => { }).then(characteristics => {
characteristics.forEach(characteristic => { characteristics.forEach(characteristic => {
@ -259,3 +265,5 @@ class ConnectionBle extends Connection {
return ids; return ids;
} }
} }
module.exports = ConnectionBle;

View file

@ -0,0 +1,32 @@
'use strict'
const { ConnectionType } = require('./connection');
const ConnectionBle = require('./connectionBle');
const ConnectionSerial = require('./connectionSerial');
const ConnectionTcp = require('./connectionTcp');
const ConnectionUdp = require('./connectionUdp');
var connectionFactory = function(type, instance) {
if (instance && (instance.type == type || instance.connectionId)){
return instance;
}
switch (type) {
case ConnectionType.BLE:
instance = new ConnectionBle();
break;
case ConnectionType.TCP:
instance = new ConnectionTcp();
break;
case ConnectionType.UDP:
instance = new ConnectionUdp();
break;
default:
case ConnectionType.Serial:
instance = new ConnectionSerial();
break;
}
return instance;
};
module.exports = connectionFactory;

View file

@ -1,5 +1,9 @@
'use strict' 'use strict'
const { GUI } = require('./../gui');
const { ConnectionType, Connection } = require('./connection')
const { SerialPort } = require('serialport');
const { SerialPortStream } = require('@serialport/stream'); const { SerialPortStream } = require('@serialport/stream');
const { autoDetect } = require('@serialport/bindings-cpp') const { autoDetect } = require('@serialport/bindings-cpp')
const binding = autoDetect(); const binding = autoDetect();
@ -11,6 +15,7 @@ class ConnectionSerial extends Connection {
this._errorListeners = []; this._errorListeners = [];
this._onReceiveListeners = []; this._onReceiveListeners = [];
this._onErrorListener = []; this._onErrorListener = [];
super._type = ConnectionType.Serial;
} }
connectImplementation(path, options, callback) { connectImplementation(path, options, callback) {
@ -115,3 +120,5 @@ class ConnectionSerial extends Connection {
}); });
} }
} }
module.exports = ConnectionSerial;

View file

@ -2,6 +2,10 @@
const net = require('net') const net = require('net')
const { GUI } = require('./../gui');
const { ConnectionType, Connection } = require('./connection')
const i18n = require('./../localization');
const STANDARD_TCP_PORT = 5761; const STANDARD_TCP_PORT = 5761;
class ConnectionTcp extends Connection { class ConnectionTcp extends Connection {
@ -14,6 +18,7 @@ class ConnectionTcp extends Connection {
this.connectionPort = 0; this.connectionPort = 0;
this._onReceiveListeners = []; this._onReceiveListeners = [];
this._onErrorListener = []; this._onErrorListener = [];
super._type = ConnectionType.TCP;
} }
connectImplementation(address, options, callback) { connectImplementation(address, options, callback) {
@ -23,13 +28,13 @@ class ConnectionTcp extends Connection {
this._connectionPort = parseInt(addr[1]) this._connectionPort = parseInt(addr[1])
} else { } else {
this._connectionIP = address[0]; this._connectionIP = address[0];
this._connectionPort = STANDARD_PORT; this._connectionPort = STANDARD_TCP_PORT;
} }
try { try {
this._socket = net.connect({ host: this._connectionIP, port: this._connectionPort }, () => { this._socket = net.connect({ host: this._connectionIP, port: this._connectionPort }, () => {
this._socket.setNoDelay(true); this._socket.setNoDelay(true);
GUI.log(localization.getMessage('connectionConnected', ["tcp://" + this._connectionIP + ":" + this._connectionPort])); GUI.log(i18n.getMessage('connectionConnected', ["tcp://" + this._connectionIP + ":" + this._connectionPort]));
if (callback) { if (callback) {
callback({ callback({
@ -117,3 +122,5 @@ class ConnectionTcp extends Connection {
this._onReceiveErrorListeners = this._onReceiveErrorListeners.filter(listener => listener !== callback); this._onReceiveErrorListeners = this._onReceiveErrorListeners.filter(listener => listener !== callback);
} }
} }
module.exports = ConnectionTcp;

View file

@ -1,8 +1,12 @@
'use strict' 'use strict'
const { ConnectionType, Connection } = require('./connection')
const dgram = require('node:dgram'); const dgram = require('node:dgram');
const socket = dgram.createSocket('udp4'); const socket = dgram.createSocket('udp4');
const { GUI } = require('./../gui');
const i18n = require('./../localization');
const STANDARD_UDP_PORT = 5761; const STANDARD_UDP_PORT = 5761;
class ConnectionUdp extends Connection { class ConnectionUdp extends Connection {
@ -13,6 +17,7 @@ class ConnectionUdp extends Connection {
this._connectionPort = 0; this._connectionPort = 0;
this._onReceiveListeners = []; this._onReceiveListeners = [];
this._onErrorListener = []; this._onErrorListener = [];
super._type = ConnectionType.UDP;
} }
connectImplementation(address, options, callback) { connectImplementation(address, options, callback) {
@ -27,7 +32,7 @@ class ConnectionUdp extends Connection {
try { try {
socket.bind(this._connectionPort, () => { socket.bind(this._connectionPort, () => {
GUI.log(localization.getMessage('connectionConnected', ["udp://" + this._connectionIP + ":" + this._connectionPort])); GUI.log(i18n.getMessage('connectionConnected', ["udp://" + this._connectionIP + ":" + this._connectionPort]));
if (callback) { if (callback) {
callback({ callback({
bitrate: 115200, bitrate: 115200,
@ -116,3 +121,5 @@ class ConnectionUdp extends Connection {
this._onReceiveErrorListeners = this._onReceiveErrorListeners.filter(listener => listener !== callback); this._onReceiveErrorListeners = this._onReceiveErrorListeners.filter(listener => listener !== callback);
} }
} }
module.exports = ConnectionUdp;

View file

@ -10,3 +10,5 @@ var CONFIGURATOR = {
'cliValid': false, 'cliValid': false,
'connection': false 'connection': false
}; };
module.exports = CONFIGURATOR;

View file

@ -1,10 +1,13 @@
/*global mspHelper,$,GUI,MSP,chrome*/ /*global mspHelper,$,GUI,MSP,chrome*/
'use strict'; 'use strict';
var helper = helper || {}; const mspHelper = require('./msp/MSPHelper');
const features = require('./feature_framework');
const { mixer } = require('./model')
var savingDefaultsModal; var savingDefaultsModal;
helper.defaultsDialog = (function () { var defaultsDialog = (function () {
let publicScope = {}, let publicScope = {},
privateScope = {}; privateScope = {};
@ -903,17 +906,17 @@ helper.defaultsDialog = (function () {
privateScope.setFeaturesBits = function (selectedDefaultPreset) { privateScope.setFeaturesBits = function (selectedDefaultPreset) {
if (selectedDefaultPreset.features && selectedDefaultPreset.features.length > 0) { if (selectedDefaultPreset.features && selectedDefaultPreset.features.length > 0) {
helper.features.reset(); features.reset();
for (const feature of selectedDefaultPreset.features) { for (const feature of selectedDefaultPreset.features) {
if (feature.state) { if (feature.state) {
helper.features.set(feature.bit); features.set(feature.bit);
} else { } else {
helper.features.unset(feature.bit); features.unset(feature.bit);
} }
} }
helper.features.execute(function () { features.execute(function () {
privateScope.setSettings(selectedDefaultPreset); privateScope.setSettings(selectedDefaultPreset);
}); });
} else { } else {
@ -924,7 +927,7 @@ helper.defaultsDialog = (function () {
privateScope.finalize = function (selectedDefaultPreset) { privateScope.finalize = function (selectedDefaultPreset) {
mspHelper.saveToEeprom(function () { mspHelper.saveToEeprom(function () {
//noinspection JSUnresolvedVariable //noinspection JSUnresolvedVariable
GUI.log(localization.getMessage('configurationEepromSaved')); GUI.log(i18n.getMessage('configurationEepromSaved'));
if (selectedDefaultPreset.reboot) { if (selectedDefaultPreset.reboot) {
GUI.tab_switch_cleanup(function () { GUI.tab_switch_cleanup(function () {
@ -933,7 +936,7 @@ helper.defaultsDialog = (function () {
if (typeof savingDefaultsModal !== 'undefined') { if (typeof savingDefaultsModal !== 'undefined') {
savingDefaultsModal.close(); savingDefaultsModal.close();
} }
GUI.log(localization.getMessage('deviceRebooting')); GUI.log(i18n.getMessage('deviceRebooting'));
GUI.handleReconnect(); GUI.handleReconnect();
}); });
}); });
@ -992,10 +995,10 @@ helper.defaultsDialog = (function () {
// Set Mixers // Set Mixers
if (selectedDefaultPreset.mixerToApply) { if (selectedDefaultPreset.mixerToApply) {
let currentMixerPreset = helper.mixer.getById(selectedDefaultPreset.mixerToApply); let currentMixerPreset = mixer.getById(selectedDefaultPreset.mixerToApply);
helper.mixer.loadServoRules(currentMixerPreset); mixer.loadServoRules(currentMixerPreset);
helper.mixer.loadMotorRules(currentMixerPreset); mixer.loadMotorRules(currentMixerPreset);
MIXER_CONFIG.platformType = currentMixerPreset.platform; MIXER_CONFIG.platformType = currentMixerPreset.platform;
MIXER_CONFIG.appliedMixerPreset = selectedDefaultPreset.mixerToApply; MIXER_CONFIG.appliedMixerPreset = selectedDefaultPreset.mixerToApply;
@ -1073,7 +1076,7 @@ helper.defaultsDialog = (function () {
} }
$element.find("a").html(preset.title); $element.find("a").html(preset.title);
$element.data("index", i).click(privateScope.onPresetClick) $element.data("index", i).on('click', privateScope.onPresetClick)
$element.appendTo($place); $element.appendTo($place);
} }
} }
@ -1090,3 +1093,5 @@ helper.defaultsDialog = (function () {
return publicScope; return publicScope;
})(); })();
module.exports = defaultsDialog;

View file

@ -1,12 +1,11 @@
'use s'; 'use strict';
var helper = helper || {};
/** /**
* Simple analyzer that returns frequency of events using 5s buffer * Simple analyzer that returns frequency of events using 5s buffer
* Usage: register periodic events with 'put', then call 'get' to get results * Usage: register periodic events with 'put', then call 'get' to get results
*/ */
helper.eventFrequencyAnalyzer = (function () { var eventFrequencyAnalyzer = (function () {
var privateScope = {}, var privateScope = {},
publicScope = {}, publicScope = {},
@ -75,3 +74,5 @@ helper.eventFrequencyAnalyzer = (function () {
return publicScope; return publicScope;
})(); })();
module.exports = eventFrequencyAnalyzer;

296
js/fc.js
View file

@ -1,83 +1,97 @@
'use strict'; 'use strict';
// define all the global variables that are uses to hold FC state const ServoMixerRuleCollection = require('./servoMixerRuleCollection');
var CONFIG, const MotorMixerRuleCollection = require('./motorMixerRuleCollection');
LED_STRIP, const LogicConditionsCollection = require('./logicConditionsCollection');
LED_COLORS, const LogicConditionsStatus = require('./logicConditionsStatus');
LED_MODE_COLORS, const GlobalVariablesStatus = require('./globalVariablesStatus');
PID, const ProgrammingPidCollection = require('./programmingPidCollection');
PID_names, const ProgrammingPidStatus = require('./programmingPidStatus');
PIDs, const WaypointCollection = require('./waypointCollection');
RC_MAP, const OutputMappingCollection = require('./outputMapping');
RC, const SafehomeCollection = require('./safehomeCollection');
RC_tuning, const VTX = require('./vtx');
AUX_CONFIG, const BitHelper = require('./bitHelper');
AUX_CONFIG_IDS,
MODE_RANGES,
ADJUSTMENT_RANGES,
SERVO_CONFIG,
SERVO_RULES,
MOTOR_RULES,
LOGIC_CONDITIONS,
LOGIC_CONDITIONS_STATUS,
GLOBAL_FUNCTIONS,
GLOBAL_VARIABLES_STATUS,
PROGRAMMING_PID,
PROGRAMMING_PID_STATUS,
SERIAL_CONFIG,
SENSOR_DATA,
MOTOR_DATA,
SERVO_DATA,
GPS_DATA,
ADSB_VEHICLES,
MISSION_PLANNER,
ANALOG,
ARMING_CONFIG,
FC_CONFIG,
MISC,
REVERSIBLE_MOTORS,
DATAFLASH,
SDCARD,
BLACKBOX,
RC_deadband,
SENSOR_ALIGNMENT,
RX_CONFIG,
FAILSAFE_CONFIG,
RXFAIL_CONFIG,
VTX_CONFIG,
ADVANCED_CONFIG,
INAV_PID_CONFIG,
PID_ADVANCED,
FILTER_CONFIG,
SENSOR_STATUS,
SENSOR_CONFIG,
NAV_POSHOLD,
CALIBRATION_DATA,
POSITION_ESTIMATOR,
RTH_AND_LAND_CONFIG,
FW_CONFIG,
DEBUG_TRACE,
MIXER_CONFIG,
BATTERY_CONFIG,
OUTPUT_MAPPING,
SETTINGS,
BRAKING_CONFIG,
SAFEHOMES,
BOARD_ALIGNMENT,
CURRENT_METER_CONFIG,
FEATURES,
RATE_DYNAMICS,
EZ_TUNE;
var FC = { var FC = {
// define all the global variables that are uses to hold FC state
CONFIG: null,
LED_STRIP: null,
LED_COLORS: null,
LED_MODE_COLORS: null,
PID: null,
PID_names: null,
PIDs: null,
RC_MAP: null,
RC: null,
RC_tuning: null,
AUX_CONFIG: null,
AUX_CONFIG_IDS: null,
MODE_RANGES: null,
ADJUSTMENT_RANGES: null,
SERVO_CONFIG: null,
SERVO_RULES: null,
MOTOR_RULES: null,
LOGIC_CONDITIONS: null,
LOGIC_CONDITIONS_STATUS: null,
GLOBAL_FUNCTIONS: null,
GLOBAL_VARIABLES_STATUS: null,
PROGRAMMING_PID: null,
PROGRAMMING_PID_STATUS: null,
SERIAL_CONFIG: null,
SENSOR_DATA: null,
MOTOR_DATA: null,
SERVO_DATA: null,
GPS_DATA: null,
ADSB_VEHICLES: null,
MISSION_PLANNER: null,
ANALOG: null,
ARMING_CONFIG: null,
FC_CONFIG: null,
MISC: null,
REVERSIBLE_MOTORS: null,
DATAFLASH: null,
SDCARD: null,
BLACKBOX: null,
RC_deadband: null,
SENSOR_ALIGNMENT: null,
RX_CONFIG: null,
FAILSAFE_CONFIG: null,
RXFAIL_CONFIG: null,
VTX_CONFIG: null,
ADVANCED_CONFIG: null,
INAV_PID_CONFIG: null,
PID_ADVANCED: null,
FILTER_CONFIG: null,
SENSOR_STATUS: null,
SENSOR_CONFIG: null,
NAV_POSHOLD: null,
CALIBRATION_DATA: null,
POSITION_ESTIMATOR: null,
RTH_AND_LAND_CONFIG: null,
FW_CONFIG: null,
DEBUG_TRACE: null,
MIXER_CONFIG: null,
BATTERY_CONFIG: null,
OUTPUT_MAPPING: null,
SETTINGS: null,
BRAKING_CONFIG: null,
SAFEHOMES: null,
BOARD_ALIGNMENT: null,
CURRENT_METER_CONFIG: null,
FEATURES: null,
RATE_DYNAMICS: null,
EZ_TUNE: null,
restartRequired: false, restartRequired: false,
MAX_SERVO_RATE: 125, MAX_SERVO_RATE: 125,
MIN_SERVO_RATE: 0, MIN_SERVO_RATE: 0,
isAirplane: function () { isAirplane: function () {
return (MIXER_CONFIG.platformType == PLATFORM_AIRPLANE); return (this.MIXER_CONFIG.platformType == PLATFORM.AIRPLANE);
}, },
isMultirotor: function () { isMultirotor: function () {
return (MIXER_CONFIG.platformType == PLATFORM_MULTIROTOR || MIXER_CONFIG.platformType == PLATFORM_TRICOPTER); return (this.MIXER_CONFIG.platformType == PLATFORM.MULTIROTOR || MIXER_CONFIG.platformType == PLATFORM.TRICOPTER);
}, },
isRpyFfComponentUsed: function () { isRpyFfComponentUsed: function () {
return true; // Currently all planes have roll, pitch and yaw FF return true; // Currently all planes have roll, pitch and yaw FF
@ -86,7 +100,7 @@ var FC = {
return true; // Currently all platforms use D term return true; // Currently all platforms use D term
}, },
resetState: function () { resetState: function () {
SENSOR_STATUS = { this.SENSOR_STATUS = {
isHardwareHealthy: 0, isHardwareHealthy: 0,
gyroHwStatus: 0, gyroHwStatus: 0,
accHwStatus: 0, accHwStatus: 0,
@ -98,7 +112,7 @@ var FC = {
flowHwStatus: 0 flowHwStatus: 0
}; };
SENSOR_CONFIG = { this.SENSOR_CONFIG = {
accelerometer: 0, accelerometer: 0,
barometer: 0, barometer: 0,
magnetometer: 0, magnetometer: 0,
@ -107,7 +121,7 @@ var FC = {
opflow: 0 opflow: 0
}; };
CONFIG = { this.CONFIG = {
apiVersion: "0.0.0", apiVersion: "0.0.0",
flightControllerIdentifier: '', flightControllerIdentifier: '',
flightControllerVersion: '', flightControllerVersion: '',
@ -129,40 +143,40 @@ var FC = {
name: '' name: ''
}; };
BOARD_ALIGNMENT = { this.BOARD_ALIGNMENT = {
roll: 0, roll: 0,
pitch: 0, pitch: 0,
yaw: 0 yaw: 0
}; };
CURRENT_METER_CONFIG = { this.CURRENT_METER_CONFIG = {
scale: 0, scale: 0,
offset: 0, offset: 0,
type: 0, type: 0,
capacity: 0 capacity: 0
}; };
LED_STRIP = []; this.LED_STRIP = [];
LED_COLORS = []; this.LED_COLORS = [];
LED_MODE_COLORS = []; this.LED_MODE_COLORS = [];
FEATURES = 0; this.FEATURES = 0;
PID = { this.PID = {
}; };
PID_names = []; this.PID_names = [];
PIDs = []; this.PIDs = [];
RC_MAP = []; this.RC_MAP = [];
// defaults // defaults
// roll, pitch, yaw, throttle, aux 1, ... aux n // roll, pitch, yaw, throttle, aux 1, ... aux n
RC = { this.RC = {
active_channels: 0, active_channels: 0,
channels: new Array(32) channels: new Array(32)
}; };
RC_tuning = { this.RC_tuning = {
RC_RATE: 0, RC_RATE: 0,
RC_EXPO: 0, RC_EXPO: 0,
roll_pitch_rate: 0, // pre 1.7 api only roll_pitch_rate: 0, // pre 1.7 api only
@ -181,22 +195,22 @@ var FC = {
manual_yaw_rate: 0, manual_yaw_rate: 0,
}; };
AUX_CONFIG = []; this.AUX_CONFIG = [];
AUX_CONFIG_IDS = []; this.AUX_CONFIG_IDS = [];
MODE_RANGES = []; this.MODE_RANGES = [];
ADJUSTMENT_RANGES = []; this.ADJUSTMENT_RANGES = [];
SERVO_CONFIG = []; this.SERVO_CONFIG = [];
SERVO_RULES = new ServoMixerRuleCollection(); this.SERVO_RULES = new ServoMixerRuleCollection();
MOTOR_RULES = new MotorMixerRuleCollection(); this.MOTOR_RULES = new MotorMixerRuleCollection();
LOGIC_CONDITIONS = new LogicConditionsCollection(); this.LOGIC_CONDITIONS = new LogicConditionsCollection();
LOGIC_CONDITIONS_STATUS = new LogicConditionsStatus(); this.LOGIC_CONDITIONS_STATUS = new LogicConditionsStatus();
GLOBAL_VARIABLES_STATUS = new GlobalVariablesStatus(); this.GLOBAL_VARIABLES_STATUS = new GlobalVariablesStatus();
PROGRAMMING_PID = new ProgrammingPidCollection(); this.PROGRAMMING_PID = new ProgrammingPidCollection();
PROGRAMMING_PID_STATUS = new ProgrammingPidStatus(); this.PROGRAMMING_PID_STATUS = new ProgrammingPidStatus();
MIXER_CONFIG = { this.MIXER_CONFIG = {
yawMotorDirection: 0, yawMotorDirection: 0,
yawJumpPreventionLimit: 0, yawJumpPreventionLimit: 0,
motorStopOnLow: false, motorStopOnLow: false,
@ -207,7 +221,7 @@ var FC = {
numberOfServos: 0 numberOfServos: 0
}, },
SERIAL_CONFIG = { this.SERIAL_CONFIG = {
ports: [], ports: [],
// pre 1.6 settings // pre 1.6 settings
@ -217,7 +231,7 @@ var FC = {
cliBaudRate: 0 cliBaudRate: 0
}; };
SENSOR_DATA = { this.SENSOR_DATA = {
gyroscope: [0, 0, 0], gyroscope: [0, 0, 0],
accelerometer: [0, 0, 0], accelerometer: [0, 0, 0],
magnetometer: [0, 0, 0], magnetometer: [0, 0, 0],
@ -230,10 +244,10 @@ var FC = {
debug: [0, 0, 0, 0] debug: [0, 0, 0, 0]
}; };
MOTOR_DATA = new Array(8); this.MOTOR_DATA = new Array(8);
SERVO_DATA = new Array(16); this.SERVO_DATA = new Array(16);
GPS_DATA = { this.GPS_DATA = {
fix: 0, fix: 0,
numSat: 0, numSat: 0,
lat: 0, lat: 0,
@ -253,15 +267,15 @@ var FC = {
packetCount: 0 packetCount: 0
}; };
ADSB_VEHICLES = { this.ADSB_VEHICLES = {
vehiclesCount: 0, vehiclesCount: 0,
callsignLength: 0, callsignLength: 0,
vehicles: [] vehicles: []
}; };
MISSION_PLANNER = new WaypointCollection(); this.MISSION_PLANNER = new WaypointCollection();
ANALOG = { this.ANALOG = {
voltage: 0, voltage: 0,
mAhdrawn: 0, mAhdrawn: 0,
mWhdrawn: 0, mWhdrawn: 0,
@ -276,16 +290,16 @@ var FC = {
battery_flags: 0 battery_flags: 0
}; };
ARMING_CONFIG = { this.ARMING_CONFIG = {
auto_disarm_delay: 0, auto_disarm_delay: 0,
disarm_kill_switch: 0 disarm_kill_switch: 0
}; };
FC_CONFIG = { this.FC_CONFIG = {
loopTime: 0 loopTime: 0
}; };
MISC = { this.MISC = {
midrc: 0, midrc: 0,
minthrottle: 0, minthrottle: 0,
maxthrottle: 0, maxthrottle: 0,
@ -310,7 +324,7 @@ var FC = {
battery_capacity_unit: 'mAh' battery_capacity_unit: 'mAh'
}; };
BATTERY_CONFIG = { this.BATTERY_CONFIG = {
vbatscale: 0, vbatscale: 0,
vbatdetectcellvoltage: 0, vbatdetectcellvoltage: 0,
vbatmincellvoltage: 0, vbatmincellvoltage: 0,
@ -324,7 +338,7 @@ var FC = {
capacity_unit: 0 capacity_unit: 0
}; };
VTX_CONFIG = { this.VTX_CONFIG = {
device_type: VTX.DEV_UNKNOWN, device_type: VTX.DEV_UNKNOWN,
band: 0, band: 0,
channel: 1, channel: 1,
@ -333,7 +347,7 @@ var FC = {
low_power_disarm: 0, low_power_disarm: 0,
}; };
ADVANCED_CONFIG = { this.ADVANCED_CONFIG = {
gyroSyncDenominator: null, gyroSyncDenominator: null,
pidProcessDenom: null, pidProcessDenom: null,
useUnsyncedPwm: null, useUnsyncedPwm: null,
@ -343,7 +357,7 @@ var FC = {
gyroSync: null gyroSync: null
}; };
FILTER_CONFIG = { this.FILTER_CONFIG = {
gyroSoftLpfHz: null, gyroSoftLpfHz: null,
dtermLpfHz: null, dtermLpfHz: null,
yawLpfHz: null, yawLpfHz: null,
@ -358,7 +372,7 @@ var FC = {
gyroStage2LowpassHz: null gyroStage2LowpassHz: null
}; };
PID_ADVANCED = { this.PID_ADVANCED = {
rollPitchItermIgnoreRate: null, rollPitchItermIgnoreRate: null,
yawItermIgnoreRate: null, yawItermIgnoreRate: null,
yawPLimit: null, yawPLimit: null,
@ -368,7 +382,7 @@ var FC = {
pidSumLimit: null pidSumLimit: null
}; };
INAV_PID_CONFIG = { this.INAV_PID_CONFIG = {
asynchronousMode: null, asynchronousMode: null,
accelerometerTaskFrequency: null, accelerometerTaskFrequency: null,
attitudeTaskFrequency: null, attitudeTaskFrequency: null,
@ -379,7 +393,7 @@ var FC = {
accSoftLpfHz: null accSoftLpfHz: null
}; };
NAV_POSHOLD = { this.NAV_POSHOLD = {
userControlMode: null, userControlMode: null,
maxSpeed: null, maxSpeed: null,
maxClimbRate: null, maxClimbRate: null,
@ -390,7 +404,7 @@ var FC = {
hoverThrottle: null hoverThrottle: null
}; };
CALIBRATION_DATA = { this.CALIBRATION_DATA = {
acc: { acc: {
Pos0: null, Pos0: null,
Pos1: null, Pos1: null,
@ -424,7 +438,7 @@ var FC = {
} }
}; };
RTH_AND_LAND_CONFIG = { this.RTH_AND_LAND_CONFIG = {
minRthDistance: null, minRthDistance: null,
rthClimbFirst: null, rthClimbFirst: null,
rthClimbIgnoreEmergency: null, rthClimbIgnoreEmergency: null,
@ -439,14 +453,14 @@ var FC = {
emergencyDescentRate: null emergencyDescentRate: null
}; };
REVERSIBLE_MOTORS = { this.REVERSIBLE_MOTORS = {
deadband_low: 0, deadband_low: 0,
deadband_high: 0, deadband_high: 0,
neutral: 0, neutral: 0,
deadband_throttle: 0 deadband_throttle: 0
}; };
DATAFLASH = { this.DATAFLASH = {
ready: false, ready: false,
supported: false, supported: false,
sectors: 0, sectors: 0,
@ -454,7 +468,7 @@ var FC = {
usedSize: 0 usedSize: 0
}; };
SDCARD = { this.SDCARD = {
supported: false, supported: false,
state: 0, state: 0,
filesystemLastError: 0, filesystemLastError: 0,
@ -462,27 +476,27 @@ var FC = {
totalSizeKB: 0 totalSizeKB: 0
}; };
BLACKBOX = { this.BLACKBOX = {
supported: false, supported: false,
blackboxDevice: 0, blackboxDevice: 0,
blackboxRateNum: 1, blackboxRateNum: 1,
blackboxRateDenom: 1 blackboxRateDenom: 1
}; };
RC_deadband = { this.RC_deadband = {
deadband: 0, deadband: 0,
yaw_deadband: 0, yaw_deadband: 0,
alt_hold_deadband: 0 alt_hold_deadband: 0
}; };
SENSOR_ALIGNMENT = { this.SENSOR_ALIGNMENT = {
align_gyro: 0, align_gyro: 0,
align_acc: 0, align_acc: 0,
align_mag: 0, align_mag: 0,
align_opflow: 0 align_opflow: 0
}; };
RX_CONFIG = { this.RX_CONFIG = {
receiver_type: 0, receiver_type: 0,
serialrx_provider: 0, serialrx_provider: 0,
maxcheck: 0, maxcheck: 0,
@ -496,7 +510,7 @@ var FC = {
spirx_channel_count: 0, spirx_channel_count: 0,
}; };
POSITION_ESTIMATOR = { this.POSITION_ESTIMATOR = {
w_z_baro_p: null, w_z_baro_p: null,
w_z_gps_p: null, w_z_gps_p: null,
w_z_gps_v: null, w_z_gps_v: null,
@ -506,7 +520,7 @@ var FC = {
use_gps_velned: null use_gps_velned: null
}; };
FAILSAFE_CONFIG = { this.FAILSAFE_CONFIG = {
failsafe_delay: 0, failsafe_delay: 0,
failsafe_off_delay: 0, failsafe_off_delay: 0,
failsafe_throttle: 0, failsafe_throttle: 0,
@ -522,7 +536,7 @@ var FC = {
failsafe_min_distance_procedure: 0 failsafe_min_distance_procedure: 0
}; };
FW_CONFIG = { this.FW_CONFIG = {
cruiseThrottle: null, cruiseThrottle: null,
minThrottle: null, minThrottle: null,
maxThrottle: null, maxThrottle: null,
@ -533,7 +547,7 @@ var FC = {
loiterRadius: null loiterRadius: null
}; };
BRAKING_CONFIG = { this.BRAKING_CONFIG = {
speedThreshold: null, speedThreshold: null,
disengageSpeed: null, disengageSpeed: null,
timeout: null, timeout: null,
@ -544,15 +558,15 @@ var FC = {
bankAngle: null bankAngle: null
} }
RXFAIL_CONFIG = []; this.RXFAIL_CONFIG = [];
OUTPUT_MAPPING = new OutputMappingCollection(); this.OUTPUT_MAPPING = new OutputMappingCollection();
SETTINGS = {}; this.SETTINGS = {};
SAFEHOMES = new SafehomeCollection(); this.SAFEHOMES = new SafehomeCollection();
RATE_DYNAMICS = { this.RATE_DYNAMICS = {
sensitivityCenter: null, sensitivityCenter: null,
sensitivityEnd: null, sensitivityEnd: null,
correctionCenter: null, correctionCenter: null,
@ -561,7 +575,7 @@ var FC = {
weightEnd: null weightEnd: null
}; };
EZ_TUNE = { this.EZ_TUNE = {
enabled: null, enabled: null,
filterHz: null, filterHz: null,
axisRatio: null, axisRatio: null,
@ -613,7 +627,7 @@ var FC = {
features = this.getFeatures(); features = this.getFeatures();
} }
for (var i = 0; i < features.length; i++) { for (var i = 0; i < features.length; i++) {
if (features[i].name == featureName && bit_check(FEATURES, features[i].bit)) { if (features[i].name == featureName && BitHelper.bit_check(this.FEATURES, features[i].bit)) {
return true; return true;
} }
} }
@ -806,7 +820,7 @@ var FC = {
} }
if ((calibrated) && flagNames.hasOwnProperty(13)) { if ((calibrated) && flagNames.hasOwnProperty(13)) {
if (bit_check(CONFIG.armingFlags, 13)) { if (BitHelper.bit_check(CONFIG.armingFlags, 13)) {
calibrated = false; calibrated = false;
} }
} }
@ -918,14 +932,14 @@ var FC = {
return this.getServoMixInputNames()[input]; return this.getServoMixInputNames()[input];
}, },
getModeId: function (name) { getModeId: function (name) {
for (var i = 0; i < AUX_CONFIG.length; i++) { for (var i = 0; i < this.AUX_CONFIG.length; i++) {
if (AUX_CONFIG[i] == name) if (this.AUX_CONFIG[i] == name)
return i; return i;
} }
return -1; return -1;
}, },
isModeBitSet: function (i) { isModeBitSet: function (i) {
return bit_check(CONFIG.mode[Math.trunc(i / 32)], i % 32); return BitHelper.bit_check(this.CONFIG.mode[Math.trunc(i / 32)], i % 32);
}, },
isModeEnabled: function (name) { isModeEnabled: function (name) {
return this.isModeBitSet(this.getModeId(name)); return this.isModeBitSet(this.getModeId(name));
@ -1535,3 +1549,5 @@ var FC = {
return ($.inArray(paramName, this.getControlProfileParameters()) != -1); return ($.inArray(paramName, this.getControlProfileParameters()) != -1);
} }
}; };
module.exports = FC;

View file

@ -1,8 +1,6 @@
/*global mspHelper,FEATURES,bit_clear,bit_set*/ /*global mspHelper,FEATURES,bit_clear,bit_set*/
'use strict'; 'use strict';
var helper = helper || {};
/* /*
Helper to work with FEATURES via MSP Helper to work with FEATURES via MSP
@ -23,7 +21,7 @@ helper.features.execute(function () {
}); });
*/ */
helper.features = (function() { var features = (function() {
let publicScope = {}, let publicScope = {},
privateScope = {}; privateScope = {};
@ -85,3 +83,5 @@ helper.features = (function() {
return publicScope; return publicScope;
})(); })();
module.exports = features;

26
js/globalSettings.js Normal file
View file

@ -0,0 +1,26 @@
const UnitType = {
none: "none",
OSD: "OSD",
imperial: "imperial",
metric: "metric",
}
var globalSettings = {
// Configurator rendering options
// Used to depict how the units are displayed within the UI
unitType: null,
// Used to convert units within the UI
osdUnits: null,
// Map
mapProviderType: null,
mapApiKey: null,
proxyURL: null,
proxyLayer: null,
// Show colours for profiles
showProfileParameters: null,
// tree target for documents
docsTreeLocation: 'master',
cliAutocomplete: true,
};
module.exports = { globalSettings, UnitType };

41
js/globalUpdates.js Normal file
View file

@ -0,0 +1,41 @@
'use strict'
const CONFIGURATOR = require('./data_storage');
const FC = require('./fc');
const { globalSettings } = require('./globalSettings');
const mspHelper = require('./msp/MSPHelper.js');
const i18n = require('./localization');
var update = {
activatedTab: function() {
var activeTab = $('#tabs > ul li.active');
activeTab.removeClass('active');
$('a', activeTab).trigger('click');
},
firmwareVersion: function() {
if (CONFIGURATOR.connectionValid) {
$('#logo .firmware_version').text(FC.CONFIG.flightControllerVersion + " [" + FC.CONFIG.target + "]");
globalSettings.docsTreeLocation = 'https://github.com/iNavFlight/inav/blob/' + FC.CONFIG.flightControllerVersion + '/docs/';
// If this is a master branch firmware, this will find a 404 as there is no tag tree. So default to master for docs.
$.ajax({
url: globalSettings.docsTreeLocation + 'Settings.md',
method: "HEAD",
statusCode: {
404: function () {
globalSettings.docsTreeLocation = 'https://github.com/iNavFlight/inav/blob/master/docs/';
}
}
});
} else {
$('#logo .firmware_version').text(i18n.getMessage('fcNotConnected'));
globalSettings.docsTreeLocation = 'https://github.com/iNavFlight/inav/blob/master/docs/';
}
}
};
module.exports = update;

View file

@ -1,6 +1,6 @@
'use strict'; 'use strict';
let GlobalVariablesStatus = function () { var GlobalVariablesStatus = function () {
let self = {}, let self = {},
data = []; data = [];
@ -51,3 +51,5 @@ let GlobalVariablesStatus = function () {
return self; return self;
}; };
module.exports = GlobalVariablesStatus;

View file

@ -1,6 +1,14 @@
/*global $*/
'use strict'; 'use strict';
const CONFIGURATOR = require('./data_storage');
const Switchery = require('./libraries/switchery/switchery')
const jBox = require('./libraries/jbox/jBox.min.js')
const MSP = require('./msp');
const FC = require('./fc');
const interval = require('./intervals');
const mspBalancedInterval = require('./msp_balanced_interval');
const i18n = require('./localization');
var TABS = {}; // filled by individual tab js file var TABS = {}; // filled by individual tab js file
var GUI_control = function () { var GUI_control = function () {
@ -93,8 +101,8 @@ GUI_control.prototype.log = function (message) {
GUI_control.prototype.tab_switch_cleanup = function (callback) { GUI_control.prototype.tab_switch_cleanup = function (callback) {
MSP.callbacks_cleanup(); // we don't care about any old data that might or might not arrive MSP.callbacks_cleanup(); // we don't care about any old data that might or might not arrive
helper.interval.killAll(['global_data_refresh', 'msp-load-update']); interval.killAll(['global_data_refresh', 'msp-load-update']);
helper.mspBalancedInterval.flush(); mspBalancedInterval.flush();
if (this.active_tab) { if (this.active_tab) {
TABS[this.active_tab].cleanup(callback); TABS[this.active_tab].cleanup(callback);
@ -183,7 +191,7 @@ GUI_control.prototype.content_ready = function (callback) {
const documentationDiv = $('<div>').addClass('cf_doc_version_bt'); const documentationDiv = $('<div>').addClass('cf_doc_version_bt');
$('<a>').attr('href', 'https://github.com/iNavFlight/inav/wiki') $('<a>').attr('href', 'https://github.com/iNavFlight/inav/wiki')
.attr('target', '_blank').attr('id', 'button-documentation') .attr('target', '_blank').attr('id', 'button-documentation')
.html(localization.getMessage('documentation')).appendTo(documentationDiv); .html(i18n.getMessage('documentation')).appendTo(documentationDiv);
documentationDiv.insertAfter(tabTitle); documentationDiv.insertAfter(tabTitle);
// loading tooltip // loading tooltip
@ -249,25 +257,25 @@ GUI_control.prototype.updateStatusBar = function() {
var activeArmFlags = []; var activeArmFlags = [];
for(var i=0;i<32;i++) { for(var i=0;i<32;i++) {
var checkBit = (1 << i); var checkBit = (1 << i);
if(Object.values(armingFlags).includes(checkBit) && (checkBit & CONFIG.armingFlags)) { if(Object.values(armingFlags).includes(checkBit) && (checkBit & FC.CONFIG.armingFlags)) {
activeArmFlags.push(Object.keys(armingFlags)[Object.values(armingFlags).indexOf(checkBit)]); activeArmFlags.push(Object.keys(armingFlags)[Object.values(armingFlags).indexOf(checkBit)]);
} }
} }
$('span.i2c-error').text(CONFIG.i2cError); $('span.i2c-error').text(FC.CONFIG.i2cError);
$('span.cycle-time').text(CONFIG.cycleTime); $('span.cycle-time').text(FC.CONFIG.cycleTime);
$('span.cpu-load').text(localization.getMessage('statusbar_cpu_load', [CONFIG.cpuload])); $('span.cpu-load').text(i18n.getMessage('statusbar_cpu_load', [FC.CONFIG.cpuload]));
$('span.arming-flags').text(activeArmFlags.length ? activeArmFlags.join(', ') : '-'); $('span.arming-flags').text(activeArmFlags.length ? activeArmFlags.join(', ') : '-');
}; };
GUI_control.prototype.updateProfileChange = function(refresh) { GUI_control.prototype.updateProfileChange = function(refresh) {
$('#mixerprofilechange').val(CONFIG.mixer_profile); $('#mixerprofilechange').val(FC.CONFIG.mixer_profile);
$('#profilechange').val(CONFIG.profile); $('#profilechange').val(FC.CONFIG.profile);
$('#batteryprofilechange').val(CONFIG.battery_profile); $('#batteryprofilechange').val(FC.CONFIG.battery_profile);
if (refresh) { if (refresh) {
GUI.log(localization.getMessage('loadedMixerProfile', [CONFIG.mixer_profile + 1])); GUI.log(i18n.getMessage('loadedMixerProfile', [FC.CONFIG.mixer_profile + 1]));
GUI.log(localization.getMessage('pidTuning_LoadedProfile', [CONFIG.profile + 1])); GUI.log(i18n.getMessage('pidTuning_LoadedProfile', [FC.CONFIG.profile + 1]));
GUI.log(localization.getMessage('loadedBatteryProfile', [CONFIG.battery_profile + 1])); GUI.log(i18n.getMessage('loadedBatteryProfile', [FC.CONFIG.battery_profile + 1]));
updateActivatedTab(); updateActivatedTab();
} }
}; };
@ -302,7 +310,7 @@ GUI_control.prototype.simpleBind = function () {
return; return;
} }
$this.change(function () { $this.on('change', function () {
window[toBind[0]][toBind[1]] = $(this).val(); window[toBind[0]][toBind[1]] = $(this).val();
}); });
@ -366,7 +374,7 @@ GUI_control.prototype.renderOperandValue = function ($container, operandMetadata
break; break;
} }
$container.find('.logic_element__operand--value').change(onChange); $container.find('.logic_element__operand--value').on('change', onChange);
}; };
/** /**
@ -399,7 +407,7 @@ GUI_control.prototype.renderLogicConditionSelect = function ($container, logicCo
} }
} }
$select.val(current).change(onChange); $select.val(current).on('change', onChange);
} }
GUI_control.prototype.sliderize = function ($input, value, min, max) { GUI_control.prototype.sliderize = function ($input, value, min, max) {
@ -488,5 +496,50 @@ GUI_control.prototype.sliderize = function ($input, value, min, max) {
$input.trigger('change'); $input.trigger('change');
}; };
GUI_control.prototype.update_dataflash_global = function () {
function formatFilesize(bytes) {
if (bytes < 1024) {
return bytes + "B";
}
var kilobytes = bytes / 1024;
if (kilobytes < 1024) {
return Math.round(kilobytes) + "kB";
}
var megabytes = kilobytes / 1024;
return megabytes.toFixed(1) + "MB";
}
var supportsDataflash = FC.DATAFLASH.totalSize > 0;
if (supportsDataflash){
$(".noflash_global").css({
display: 'none'
});
$(".dataflash-contents_global").css({
display: 'block'
});
$(".dataflash-free_global").css({
width: (100-(FC.DATAFLASH.totalSize - FC.DATAFLASH.usedSize) / FC.DATAFLASH.totalSize * 100) + "%",
display: 'block'
});
$(".dataflash-free_global div").text('Dataflash: free ' + formatFilesize(FC.DATAFLASH.totalSize - FC.DATAFLASH.usedSize));
} else {
$(".noflash_global").css({
display: 'block'
});
$(".dataflash-contents_global").css({
display: 'none'
});
}
};
// initialize object into GUI variable // initialize object into GUI variable
var GUI = new GUI_control(); var GUI = new GUI_control();
module.exports = { GUI, TABS };

View file

@ -2,10 +2,6 @@
'use strict'; 'use strict';
function checkChromeRuntimeError() {
return false;
}
function constrain(input, min, max) { function constrain(input, min, max) {
if (input < min) { if (input < min) {
@ -58,3 +54,5 @@ function scaleRangeInt(x, srcMin, srcMax, destMin, destMax) {
let b = srcMax - srcMin; let b = srcMax - srcMin;
return Math.round((a / b) + destMin); return Math.round((a / b) + destMin);
} }
module.exports = { constrain, zeroPad, generateFilename, scaleRangeInt };

View file

@ -1,8 +1,6 @@
'use strict'; 'use strict';
var helper = helper || {}; var interval = function () {
helper.interval = (function () {
var privateScope = {}, var privateScope = {},
publicScope = {}; publicScope = {};
@ -134,4 +132,6 @@ helper.interval = (function () {
}; };
return publicScope; return publicScope;
})(); }();
module.exports = interval;

View file

@ -1,5 +1,6 @@
( function () { ( function () {
class GLTFLoader extends THREE.Loader { class GLTFLoader extends THREE.Loader {
constructor( manager ) { constructor( manager ) {

View file

@ -1,72 +1,191 @@
'use strict'; 'use strict';
const fs = require('fs') // From Betaflight
window.$ = window.jQuery = require('jquery');
const { app } = require('@electron/remote');
const path = require('path');
const i18next = require('i18next');
const i18nextXHRBackend = require('i18next-xhr-backend');
const Store = require('electron-store');
const store = new Store();
let Localiziation = function(locale) { const availableLanguages = ['en', 'de'];
let self = { };
let messages = null;
let localized = 0
let local = locale;
self.loadMessages = function () { const i18n = {};
const path = require('path');
let fileName = path.join(__dirname, "./locale/" + local + "/messages.json");
if (!fs.existsSync(fileName)) {
fileName = path.join(__dirname, "./../locale/" + local + "/messages.json");
}
console.log(fileName);
try {
var data = fs.readFileSync(fileName, 'utf8',);
messages = JSON.parse(data);
} catch (err) {
console.log("Error while reading language file: " + fileName);
}
}
self.getMessage = function(messageID, substitutions = null) { i18n.init = function (callback) {
try {
if (messages == null) {
self.loadMessages();
}
if (substitutions) { i18next.use(i18nextXHRBackend);
return messages[messageID].message.replace(/\{(\d+)\}/g, (t, i) => { i18next.init({
return substitutions[i] !== void 0 ? substitutions[i] : "{" + (i - substitutions.length) + "}"; lng: store.get('userLanguage', app.getLocale()),
}); getAsync: false,
debug: true,
ns: ['messages'],
defaultNS:['messages'],
fallbackLng: 'en',
backend: {
loadPath: path.join(__dirname, "./../locale/{{lng}}/{{ns}}.json"),
parse: i18n.parseInputFile,
},
}, function(err) {
if (err !== undefined) {
console.error(`Error loading i18n: ${err}`);
} else { } else {
return messages[messageID].message; console.log('i18n system loaded');
} const detectedLanguage = i18n.getMessage(`language_${i18n.getValidLocale("DEFAULT")}`);
} catch { i18next.addResourceBundle('en', 'messages', {"detectedLanguage": detectedLanguage }, true, true);
console.log("Unable to get messageID: " + messageID) i18next.on('languageChanged', function () {
return messageID; i18n.localize(true);
} });
} }
self.translate = function(messageID) { if (callback) {
callback();
}
});
}
i18n.parseInputFile = function (data) {
// Remove the $n interpolate of Chrome $1, $2, ... -> {{1}}, {{2}}, ...
const REGEXP_CHROME = /\$([1-9])/g;
const dataChrome = data.replace(REGEXP_CHROME, '{{$1}}');
// Remove the .message of the nesting $t(xxxxx.message) -> $t(xxxxx)
const REGEXP_NESTING = /\$t\(([^\)]*).message\)/g;
const dataNesting = dataChrome.replace(REGEXP_NESTING, '$t($1)');
// Move the .message of the json object to root xxxxx.message -> xxxxx
const jsonData = JSON.parse(dataNesting);
Object.entries(jsonData).forEach(([key, value]) => {
jsonData[key] = value.message;
});
return jsonData;
}
i18n.getValidLocale = function(userLocale) {
let validUserLocale = userLocale;
if (validUserLocale === 'DEFAULT') {
validUserLocale = app.getLocale();
console.log(`Detected locale ${validUserLocale}`);
}
return validUserLocale;
}
i18n.getMessage = function(messageID, parameters) {
let parametersObject;
if (!i18next.exists(messageID)) {
return false;
}
// Option 1, no parameters or Object as parameters (i18Next type parameters)
if ((parameters === undefined) || ((parameters.constructor !== Array) && (parameters instanceof Object))) {
parametersObject = parameters;
// Option 2: parameters as $1, $2, etc.
// (deprecated, from the old Chrome i18n
} else {
// Convert the input to an array
let parametersArray = parameters;
if (parametersArray.constructor !== Array) {
parametersArray = [parameters];
}
parametersObject = {};
parametersArray.forEach(function(parameter, index) {
parametersObject[index + 1] = parameter;
});
}
return i18next.t(messageID, parametersObject);
};
i18n.getCurrentLanguage = function() {
return i18next.language;
};
i18n.getLanguages = function() {
return availableLanguages;
}
i18n.changeLanguage = function(languageSelected) {
store.set('userLanguage', languageSelected);
i18next.changeLanguage(i18n.getValidLocale(languageSelected));
//i18n.selectedLanguage = languageSelected;
};
i18n.localize = function (reTranslate = false) {
let localized = 0;
const translate = function(messageID) {
localized++; localized++;
return i18n.getMessage(messageID);
if (messages == null) {
self.loadMessages();
}
return self.getMessage(messageID);
}; };
self.localize = function () { if (reTranslate) {
$('[i18n]').each(function() {
const element = $(this);
element.html(translate(element.attr('i18n')));
});
$('[data-i18n]').each(function() {
const element = $(this);
const translated = translate(element.data('i18n'));
element.html(translated);
if (element.attr("title") !== "") {
element.attr("title", translated);
}
});
$('[i18n_title]').each(function() {
const element = $(this);
element.attr('title', translate(element.attr('i18n_title')));
});
$('[data-i18n_title]').each(function() {
const element = $(this);
element.attr('title', translate(element.data('i18n_title')));
});
$('[i18n_label]').each(function() {
const element = $(this);
element.attr('label', translate(element.attr('i18n_label')));
});
$('[data-i18n_label]').each(function() {
const element = $(this);
element.attr('label', translate(element.data('i18n_label')));
});
$('[i18n_value]').each(function() {
const element = $(this);
element.val(translate(element.attr('i18n_value')));
});
$('[i18n_placeholder]').each(function() {
const element = $(this);
element.attr('placeholder', translate(element.attr('i18n_placeholder')));
});
} else {
$('[i18n]:not(.i18n-replaced)').each(function() { $('[i18n]:not(.i18n-replaced)').each(function() {
var element = $(this); const element = $(this);
element.html(self.translate(element.attr('i18n'))); element.html(translate(element.attr('i18n')));
element.addClass('i18n-replaced'); element.addClass('i18n-replaced');
}); });
$('[data-i18n]:not(.i18n-replaced)').each(function() { $('[data-i18n]:not(.i18n-replaced)').each(function() {
var element = $(this); const element = $(this);
const translated = self.translate(element.data('i18n')); const translated = translate(element.data('i18n'));
element.html(translated); element.html(translated);
element.addClass('i18n-replaced'); element.addClass('i18n-replaced');
if (element.attr("title") !== "") { if (element.attr("title") !== "") {
@ -75,50 +194,49 @@ let Localiziation = function(locale) {
}); });
$('[i18n_title]:not(.i18n_title-replaced)').each(function() { $('[i18n_title]:not(.i18n_title-replaced)').each(function() {
var element = $(this); const element = $(this);
element.attr('title', self.translate(element.attr('i18n_title'))); element.attr('title', translate(element.attr('i18n_title')));
element.addClass('i18n_title-replaced'); element.addClass('i18n_title-replaced');
}); });
$('[data-i18n_title]:not(.i18n_title-replaced)').each(function() { $('[data-i18n_title]:not(.i18n_title-replaced)').each(function() {
var element = $(this); const element = $(this);
element.attr('title', self.translate(element.data('i18n_title'))); element.attr('title', translate(element.data('i18n_title')));
element.addClass('i18n_title-replaced'); element.addClass('i18n_title-replaced');
}); });
$('[i18n_label]:not(.i18n_label-replaced)').each(function() { $('[i18n_label]:not(.i18n_label-replaced)').each(function() {
var element = $(this); const element = $(this);
element.attr('label', self.translate(element.attr('i18n_label'))); element.attr('label', translate(element.attr('i18n_label')));
element.addClass('i18n_label-replaced'); element.addClass('i18n_label-replaced');
}); });
$('[data-i18n_label]:not(.i18n_label-replaced)').each(function() { $('[data-i18n_label]:not(.i18n_label-replaced)').each(function() {
var element = $(this); const element = $(this);
element.attr('label', self.translate(element.data('i18n_label'))); element.attr('label', translate(element.data('i18n_label')));
element.addClass('i18n_label-replaced'); element.addClass('i18n_label-replaced');
}); });
$('[i18n_value]:not(.i18n_value-replaced)').each(function() { $('[i18n_value]:not(.i18n_value-replaced)').each(function() {
var element = $(this);"" const element = $(this);""
element.val(self.translate(element.attr('i18n_value'))); element.val(translate(element.attr('i18n_value')));
element.addClass('i18n_value-replaced'); element.addClass('i18n_value-replaced');
}); });
$('[i18n_placeholder]:not(.i18n_placeholder-replaced)').each(function() { $('[i18n_placeholder]:not(.i18n_placeholder-replaced)').each(function() {
var element = $(this); const element = $(this);
element.attr('placeholder', self.translate(element.attr('i18n_placeholder'))); element.attr('placeholder', translate(element.attr('i18n_placeholder')));
element.addClass('i18n_placeholder-replaced'); element.addClass('i18n_placeholder-replaced');
}); });
return localized;
} }
return self; return localized;
} }
module.exports = i18n;

View file

@ -164,7 +164,7 @@ let LogicCondition = function (enabled, activatorId, operation, operandAType, op
/* /*
* Bind events * Bind events
*/ */
$t.change(self.onOperatorTypeChange); $t.on('change', self.onOperatorTypeChange);
} }
} }
@ -306,7 +306,7 @@ let LogicCondition = function (enabled, activatorId, operation, operandAType, op
$t.append('</optgroup>'); $t.append('</optgroup>');
$t.change(self.onOperatorChange); $t.on('change', self.onOperatorChange);
self.renderOperand(0); self.renderOperand(0);
self.renderOperand(1); self.renderOperand(1);

View file

@ -1,6 +1,6 @@
'use strict'; 'use strict';
let LogicConditionsCollection = function () { var LogicConditionsCollection = function () {
let self = {}, let self = {},
data = [], data = [],
@ -68,8 +68,8 @@ let LogicConditionsCollection = function () {
self.init = function ($element) { self.init = function ($element) {
$container = $element; $container = $element;
$container.find('.logic__save').click(self.onSave); $container.find('.logic__save').on('click', self.onSave);
$container.find('.logic__close').click(self.onClose); $container.find('.logic__close').on('click', self.onClose);
}; };
@ -85,3 +85,5 @@ let LogicConditionsCollection = function () {
return self; return self;
}; };
module.exports = LogicConditionsCollection;

View file

@ -23,3 +23,5 @@ let LogicConditionsStatus = function () {
return self; return self;
}; };
module.exports = LogicConditionsStatus;

View file

@ -1,658 +1,169 @@
window.$ = window.jQuery = require('jquery'), const { app, BrowserWindow, ipcMain } = require('electron');
require('jquery-ui-dist/jquery-ui'), const windowStateKeeper = require('electron-window-state');
require('jquery-textcomplete');
const { SerialPort } = require('serialport');
const path = require('path'); const path = require('path');
const { app, dialog } = require('@electron/remote');
const ol = require('openlayers');
const Store = require('electron-store'); const Store = require('electron-store');
const store = new Store(); Store.initRenderer();
var localization;
process.on('uncaughtException', function (error) { require('@electron/remote/main').initialize();
if (process.env.NODE_ENV !== 'development') {
GUI.log(localization.getMessage('unexpectedError', error));
if (GUI.connected_to || GUI.connecting_to) {
GUI.log(localization.getMessage('disconnecting'));
$('a.connect').trigger('click');
}
} else {
throw error;
}
});
// Set how the units render on the configurator only const usbBootloaderIds = [
const UnitType = { { vendorId: 1155, productId: 57105},
none: "none", { vendorId: 11836, productId: 57105}
OSD: "OSD", ];
imperial: "imperial",
metric: "metric",
// Handle creating/removing shortcuts on Windows when installing/uninstalling.
if (require('electron-squirrel-startup')) {
app.quit();
} }
let mainWindow = null;
let bluetoothDeviceChooser = null;
let btDeviceList = null;
let selectBluetoothCallback = null;
let globalSettings = { // In Eletrcon the bluetooth device chooser didn't exist, so we have to buid our own
// Configurator rendering options function createDeviceChooser() {
// Used to depict how the units are displayed within the UI bluetoothDeviceChooser = new BrowserWindow({
unitType: null, parent: mainWindow,
// Used to convert units within the UI width: 400,
osdUnits: null, height: 400,
// Map webPreferences: {
mapProviderType: null, preload: path.join(__dirname, 'js/libraries/bluetooth-device-chooser/preload.js')
mapApiKey: null, }
proxyURL: null, });
proxyLayer: null, bluetoothDeviceChooser.removeMenu();
// Show colours for profiles bluetoothDeviceChooser.loadFile(path.join(__dirname, 'js/libraries/bluetooth-device-chooser/index.html'));
showProfileParameters: null,
// tree target for documents
docsTreeLocation: 'master',
};
$(function() { bluetoothDeviceChooser.on('closed', () => {
localization = new Localiziation("en"); btDeviceList = null;
localization.localize(); if (selectBluetoothCallback) {
selectBluetoothCallback('');
selectBluetoothCallback = null;
}
bluetoothDeviceChooser = null;
});
globalSettings.unitType = store.get('unit_type', UnitType.none); ipcMain.on('deviceSelected', (_event, deviceID) => {
globalSettings.mapProviderType = store.get('map_provider_type', 'osm'); if (selectBluetoothCallback) {
globalSettings.mapApiKey = store.get('map_api_key', ''); selectBluetoothCallback(deviceID);
globalSettings.proxyURL = store.get('proxyurl', 'http://192.168.1.222/mapproxy/service?'); selectBluetoothCallback = null;
globalSettings.proxyLayer = store.get('proxylayer', 'your_proxy_layer_name'); }
globalSettings.showProfileParameters = store.get('show_profile_parameters', 1); });
updateProfilesHighlightColours();
if (store.get('cli_autocomplete', false)) { }
globalSettings.cliAutocomplete = true;
CliAutoComplete.setEnabled(true);
};
// Resets the OSD units used by the unit coversion when the FC is disconnected. app.on('ready', () => {
if (!CONFIGURATOR.connectionValid) {
globalSettings.osdUnits = null; let mainWindowState = windowStateKeeper({
defaultWidth: 800,
defaultHeight: 600
});
mainWindow = new BrowserWindow({
x: mainWindowState.x,
y: mainWindowState.y,
width: mainWindowState.width,
height: mainWindowState.height,
autoHideMenuBar: true,
icon: "images/inav_icon_128.png",
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
webSecurity: false
},
});
mainWindow.webContents.on('select-bluetooth-device', (event, deviceList, callback) => {
event.preventDefault();
selectBluetoothCallback = callback;
const compare = (a, b) => {
if (a.length !== b.length) {
return false;
}
a.every((element, index) => {
if (element.deviceId !== b[index].deviceId) {
return false;
}
})
return true;
} }
// alternative - window.navigator.appVersion.match(/Chrome\/([0-9.]*)/)[1]; if (!btDeviceList || !compare(btDeviceList, deviceList)) {
GUI.log(localization.getMessage('getRunningOS') + GUI.operating_system + '</strong>, ' + btDeviceList = [...deviceList];
'Chrome: <strong>' + process.versions['chrome'] + '</strong>, ' +
localization.getMessage('getConfiguratorVersion') + app.getVersion() + '</strong>');
$('#status-bar .version').text(app.getVersion()); if (!bluetoothDeviceChooser) {
$('#logo .version').text(app.getVersion()); createDeviceChooser();
updateFirmwareVersion();
if (store.get('logopen', false)) {
$("#showlog").trigger('click');
} }
bluetoothDeviceChooser.webContents.send('ble-scan', btDeviceList);
if (store.get('update_notify', true)) {
appUpdater.checkRelease(app.getVersion());
} }
});
// log library versions in console to make version tracking easier
console.log('Libraries: jQuery - ' + $.fn.jquery + ', d3 - ' + d3.version + ', three.js - ' + THREE.REVISION);
// Tabs mainWindow.webContents.session.on('select-usb-device', (event, details, callback) => {
var ui_tabs = $('#tabs > ul'); console.log(details.deviceList)
$('a', ui_tabs).click(function () { let premittedDevice = null;
if (details.deviceList) {
if ($(this).parent().hasClass("tab_help")) { details.deviceList.every((device, idx) => {
if (device.productId == usbBootloaderIds[idx].productId && device.vendorId == usbBootloaderIds[idx].vendorId) {
premittedDevice = device.deviceId;
return; return;
} }
if ($(this).parent().hasClass('active') == false && !GUI.tab_switch_in_progress) { // only initialize when the tab isn't already active
var self = this,
tabClass = $(self).parent().prop('class');
var tabRequiresConnection = $(self).parent().hasClass('mode-connected');
var tab = tabClass.substring(4);
var tabName = $(self).text();
if (tabRequiresConnection && !CONFIGURATOR.connectionValid) {
GUI.log(localization.getMessage('tabSwitchConnectionRequired'));
return;
}
if (GUI.connect_lock) { // tab switching disabled while operation is in progress
GUI.log(localization.getMessage('tabSwitchWaitForOperation'));
return;
}
if (GUI.allowedTabs.indexOf(tab) < 0) {
GUI.log(localization.getMessage('tabSwitchUpgradeRequired', [tabName]));
return;
}
GUI.tab_switch_in_progress = true;
GUI.tab_switch_cleanup(function () {
// disable previously active tab highlight
$('li', ui_tabs).removeClass('active');
// Highlight selected tab
$(self).parent().addClass('active');
// detach listeners and remove element data
var content = $('#content');
content.data('empty', !!content.is(':empty'));
content.empty();
// display loading screen
$('#cache .data-loading').clone().appendTo(content);
function content_ready() {
GUI.tab_switch_in_progress = false;
// Update CSS on to show highlighing or not
updateProfilesHighlightColours();
}
switch (tab) {
case 'landing':
TABS.landing.initialize(content_ready);
break;
case 'firmware_flasher':
TABS.firmware_flasher.initialize(content_ready);
break;
case 'sitl':
TABS.sitl.initialize(content_ready);
break;
case 'auxiliary':
TABS.auxiliary.initialize(content_ready);
break;
case 'adjustments':
TABS.adjustments.initialize(content_ready);
break;
case 'ports':
TABS.ports.initialize(content_ready);
break;
case 'led_strip':
TABS.led_strip.initialize(content_ready);
break;
case 'failsafe':
TABS.failsafe.initialize(content_ready);
break;
case 'setup':
TABS.setup.initialize(content_ready);
break;
case 'calibration':
TABS.calibration.initialize(content_ready);
break;
case 'configuration':
TABS.configuration.initialize(content_ready);
break;
case 'profiles':
TABS.profiles.initialize(content_ready);
break;
case 'pid_tuning':
TABS.pid_tuning.initialize(content_ready);
break;
case 'receiver':
TABS.receiver.initialize(content_ready);
break;
case 'modes':
TABS.modes.initialize(content_ready);
break;
case 'servos':
TABS.servos.initialize(content_ready);
break;
case 'gps':
TABS.gps.initialize(content_ready);
break;
case 'magnetometer':
TABS.magnetometer.initialize(content_ready);
break;
case 'mission_control':
TABS.mission_control.initialize(content_ready);
break;
case 'mixer':
TABS.mixer.initialize(content_ready);
break;
case 'outputs':
TABS.outputs.initialize(content_ready);
break;
case 'osd':
TABS.osd.initialize(content_ready);
break;
case 'sensors':
TABS.sensors.initialize(content_ready);
break;
case 'logging':
TABS.logging.initialize(content_ready);
break;
case 'onboard_logging':
TABS.onboard_logging.initialize(content_ready);
break;
case 'advanced_tuning':
TABS.advanced_tuning.initialize(content_ready);
break;
case 'programming':
TABS.programming.initialize(content_ready);
break;
case 'cli':
TABS.cli.initialize(content_ready);
break;
case 'ez_tune':
TABS.ez_tune.initialize(content_ready);
break;
default:
console.log('Tab not found:' + tab);
}
}); });
} }
});
$('#tabs ul.mode-disconnected li a:first').click(); if (premittedDevice) {
callback(premittedDevice);
// options } else {
$('#options').click(function () { callback();
var el = $(this);
if (!el.hasClass('active')) {
el.addClass('active');
el.after('<div id="options-window"></div>');
$('div#options-window').load('./tabs/options.html', function () {
// translate to user-selected language
localization.localize();
// if notifications are enabled, or wasn't set, check the notifications checkbox
if (store.get('update_notify', true)) {
$('div.notifications input').prop('checked', true);
} }
$('div.notifications input').change(function () {
var check = $(this).is(':checked');
store.set('update_notify', check);
}); });
$('div.statistics input').change(function () { mainWindow.webContents.session.setDevicePermissionHandler((details) => {
var check = $(this).is(':checked'); if (details.deviceType === 'usb' && details.origin === 'file://') {
}); return true;
$('div.show_profile_parameters input').change(function () {
globalSettings.showProfileParameters = $(this).is(':checked');
store.set('show_profile_parameters', globalSettings.showProfileParameters);
// Update CSS on select boxes
updateProfilesHighlightColours();
// Horrible way to reload the tab
const activeTab = $('#tabs li.active');
activeTab.removeClass('active');
activeTab.find('a').click();
});
$('div.cli_autocomplete input').change(function () {
globalSettings.cliAutocomplete = $(this).is(':checked');
store.set('cli_autocomplete', globalSettings.cliAutocomplete);
CliAutoComplete.setEnabled($(this).is(':checked'));
});
$('#ui-unit-type').val(globalSettings.unitType);
$('#map-provider-type').val(globalSettings.mapProviderType);
$('#map-api-key').val(globalSettings.mapApiKey);
$('#proxyurl').val(globalSettings.proxyURL);
$('#proxylayer').val(globalSettings.proxyLayer);
$('#showProfileParameters').prop('checked', globalSettings.showProfileParameters);
$('#cliAutocomplete').prop('checked', globalSettings.cliAutocomplete);
// Set the value of the unit type
// none, OSD, imperial, metric
$('#ui-unit-type').change(function () {
store.set('unit_type', $(this).val());
globalSettings.unitType = $(this).val();
// Update the osd units in global settings
// but only if we need it
if (globalSettings.unitType === UnitType.OSD) {
get_osd_settings();
} }
})
// Horrible way to reload the tab mainWindow.webContents.setWindowOpenHandler(({ url }) => {
const activeTab = $('#tabs li.active'); return {
activeTab.removeClass('active'); action: 'allow',
activeTab.find('a').click(); overrideBrowserWindowOptions: {
}); autoHideMenuBar: true
$('#map-provider-type').change(function () {
store.set('map_provider_type', $(this).val());
globalSettings.mapProviderType = $(this).val();
});
$('#map-api-key').change(function () {
store.set('map_api_key', $(this).val());
globalSettings.mapApiKey = $(this).val();
});
$('#proxyurl').change(function () {
store.set('proxyurl', $(this).val());
globalSettings.proxyURL = $(this).val();
});
$('#proxylayer').change(function () {
store.set('proxylayer', $(this).val());
globalSettings.proxyLayer = $(this).val();
});
$('#demoModeReset').on('click', () => {
SITLProcess.deleteEepromFile('demo.bin');
});
function close_and_cleanup(e) {
if (e.type == 'click' && !$.contains($('div#options-window')[0], e.target) || e.type == 'keyup' && e.keyCode == 27) {
$(document).unbind('click keyup', close_and_cleanup);
$('div#options-window').slideUp(250, function () {
el.removeClass('active');
$(this).empty().remove();
});
}
}
$(document).bind('click keyup', close_and_cleanup);
$(this).slideDown(250);
});
}
});
var $content = $("#content");
// listen to all input change events and adjust the value within limits if necessary
$content.on('focus', 'input[type="number"]', function () {
var element = $(this),
val = element.val();
if (!isNaN(val)) {
element.data('previousValue', parseFloat(val));
}
});
$content.on('keydown', 'input[type="number"]', function (e) {
// whitelist all that we need for numeric control
var whitelist = [
96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, // numpad and standard number keypad
109, 189, // minus on numpad and in standard keyboard
8, 46, 9, // backspace, delete, tab
190, 110, // decimal point
37, 38, 39, 40, 13 // arrows and enter
];
if (whitelist.indexOf(e.keyCode) == -1) {
e.preventDefault();
}
});
$content.on('change', 'input[type="number"]', function () {
var element = $(this),
min = parseFloat(element.prop('min')),
max = parseFloat(element.prop('max')),
step = parseFloat(element.prop('step')),
val = parseFloat(element.val()),
decimal_places;
// only adjust minimal end if bound is set
if (element.prop('min')) {
if (val < min) {
element.val(min);
val = min;
}
}
// only adjust maximal end if bound is set
if (element.prop('max')) {
if (val > max) {
element.val(max);
val = max;
}
}
// if entered value is illegal use previous value instead
if (isNaN(val)) {
element.val(element.data('previousValue'));
val = element.data('previousValue');
}
// if step is not set or step is int and value is float use previous value instead
if (isNaN(step) || step % 1 === 0) {
if (val % 1 !== 0) {
element.val(element.data('previousValue'));
val = element.data('previousValue');
}
}
// if step is set and is float and value is int, convert to float, keep decimal places in float according to step *experimental*
if (!isNaN(step) && step % 1 !== 0) {
decimal_places = String(step).split('.')[1].length;
if (val % 1 === 0) {
element.val(val.toFixed(decimal_places));
} else if (String(val).split('.')[1].length != decimal_places) {
element.val(val.toFixed(decimal_places));
} }
} }
}); });
$("#showlog").on('click', function() { app.commandLine.appendSwitch('disable-features', 'OutOfBlinkCors')
var state = $(this).data('state'),
$log = $("#log");
if (state) { require("@electron/remote/main").enable(mainWindow.webContents);
$log.animate({height: 27}, 200, function() { mainWindow.removeMenu();
var command_log = $('div#log'); mainWindow.setMinimumSize(800, 600);
//noinspection JSValidateTypes
command_log.scrollTop($('div.wrapper', command_log).height());
});
$log.removeClass('active');
$("#content").removeClass('logopen');
$(".tab_container").removeClass('logopen');
$("#scrollicon").removeClass('active');
store.set('logopen', false);
state = false; mainWindow.loadFile('./index.html');
}else{
$log.animate({height: 111}, 200);
$log.addClass('active');
$("#content").addClass('logopen');
$(".tab_container").addClass('logopen');
$("#scrollicon").addClass('active');
store.set('logopen', true);
state = true; mainWindowState.manage(mainWindow);
// Open the DevTools.
if (process.env.NODE_ENV === 'development') {
mainWindow.webContents.openDevTools();
} }
$(this).html(state ? localization.getMessage("mainHideLog") : localization.getMessage("mainShowLog"));
$(this).data('state', state);
});
var mixerprofile_e = $('#mixerprofilechange');
mixerprofile_e.change(function () {
var mixerprofile = parseInt($(this).val());
MSP.send_message(MSPCodes.MSP2_INAV_SELECT_MIXER_PROFILE, [mixerprofile], false, function () {
GUI.log(localization.getMessage('loadedMixerProfile', [mixerprofile + 1]));
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, function () {
GUI.log(localization.getMessage('deviceRebooting'));
GUI.handleReconnect();
});
});
});
var profile_e = $('#profilechange');
profile_e.change(function () {
var profile = parseInt($(this).val());
MSP.send_message(MSPCodes.MSP_SELECT_SETTING, [profile], false, function () {
GUI.log(localization.getMessage('pidTuning_LoadedProfile', [profile + 1]));
});
});
var batteryprofile_e = $('#batteryprofilechange');
batteryprofile_e.change(function () {
var batteryprofile = parseInt($(this).val());
MSP.send_message(MSPCodes.MSP2_INAV_SELECT_BATTERY_PROFILE, [batteryprofile], false, function () {
GUI.log(localization.getMessage('loadedBatteryProfile', [batteryprofile + 1]));
});
});
}); });
app.on('window-all-closed', () => {
function get_osd_settings() { if (process.platform !== 'darwin') {
if (globalSettings.osdUnits !== undefined && globalSettings.osdUnits !== null) { app.quit();
return;
} }
console.log("We're closing...");
});
MSP.promise(MSPCodes.MSP2_INAV_OSD_PREFERENCES).then(function (resp) { app.on('activate', () => {
var prefs = resp.data; // On OS X it's common to re-create a window in the app when the
prefs.readU8(); // dock icon is clicked and there are no other windows open.
prefs.readU8(); if (BrowserWindow.getAllWindows().length === 0) {
prefs.readU8(); createWindow();
prefs.readU8();
prefs.readU8();
prefs.readU8();
prefs.readU8();
globalSettings.osdUnits = prefs.readU8();
});
}
function updateProfilesHighlightColours() {
if (globalSettings.showProfileParameters) {
$('.dropdown-dark #profilechange').addClass('showProfileParams');
$('.dropdown-dark #batteryprofilechange').addClass('showProfileParams');
$('.batteryProfileHighlight').each(function () {
$(this).addClass('batteryProfileHighlightActive');
$(this).removeClass('batteryProfileHighlight');
});
$('.controlProfileHighlight').each(function () {
$(this).addClass('controlProfileHighlightActive');
$(this).removeClass('controlProfileHighlight');
});
} else {
$('.dropdown-dark #profilechange').removeClass('showProfileParams');
$('.dropdown-dark #batteryprofilechange').removeClass('showProfileParams');
$('.batteryProfileHighlightActive').each(function () {
$(this).addClass('batteryProfileHighlight');
$(this).removeClass('batteryProfileHighlightActive');
});
$('.controlProfileHighlightActive').each(function () {
$(this).addClass('controlProfileHighlight');
$(this).removeClass('controlProfileHighlightActive');
});
}
}
function catch_startup_time(startTime) {
var endTime = new Date().getTime(),
timeSpent = endTime - startTime;
}
function millitime() {
return new Date().getTime();
}
function bytesToSize(bytes) {
if (bytes < 1024) {
bytes = bytes + ' Bytes';
} else if (bytes < 1048576) {
bytes = (bytes / 1024).toFixed(3) + ' KB';
} else if (bytes < 1073741824) {
bytes = (bytes / 1048576).toFixed(3) + ' MB';
} else {
bytes = (bytes / 1073741824).toFixed(3) + ' GB';
}
return bytes;
}
Number.prototype.clamp = function (min, max) {
return Math.min(Math.max(this, min), max);
};
/**
* String formatting now supports currying (partial application).
* For a format string with N replacement indices, you can call .format
* with M <= N arguments. The result is going to be a format string
* with N-M replacement indices, properly counting from 0 .. N-M.
* The following Example should explain the usage of partial applied format:
* "{0}:{1}:{2}".format("a","b","c") === "{0}:{1}:{2}".format("a","b").format("c")
* "{0}:{1}:{2}".format("a").format("b").format("c") === "{0}:{1}:{2}".format("a").format("b", "c")
**/
String.prototype.format = function () {
var args = arguments;
return this.replace(/\{(\d+)\}/g, function (t, i) {
return args[i] !== void 0 ? args[i] : "{" + (i - args.length) + "}";
});
};
function padZeros(val, length) {
let str = val.toString();
if (str.length < length) {
if (str.charAt(0) === '-') {
str = "-0" + str.substring(1);
str = padZeros(str, length);
} else {
str = padZeros("0" + str, length);
}
}
return str;
}
function updateActivatedTab() {
var activeTab = $('#tabs > ul li.active');
activeTab.removeClass('active');
$('a', activeTab).trigger('click');
}
function updateFirmwareVersion() {
if (CONFIGURATOR.connectionValid) {
$('#logo .firmware_version').text(CONFIG.flightControllerVersion + " [" + CONFIG.target + "]");
globalSettings.docsTreeLocation = 'https://github.com/iNavFlight/inav/blob/' + CONFIG.flightControllerVersion + '/docs/';
// If this is a master branch firmware, this will find a 404 as there is no tag tree. So default to master for docs.
$.ajax({
url: globalSettings.docsTreeLocation + 'Settings.md',
method: "HEAD",
statusCode: {
404: function () {
globalSettings.docsTreeLocation = 'https://github.com/iNavFlight/inav/blob/master/docs/';
}
}
});
} else {
$('#logo .firmware_version').text(localization.getMessage('fcNotConnected'));
globalSettings.docsTreeLocation = 'https://github.com/iNavFlight/inav/blob/master/docs/';
}
}
function updateEzTuneTabVisibility(loadMixerConfig) {
let useEzTune = true;
if (CONFIGURATOR.connectionValid) {
if (loadMixerConfig) {
mspHelper.loadMixerConfig(function () {
if (MIXER_CONFIG.platformType == PLATFORM_MULTIROTOR || MIXER_CONFIG.platformType == PLATFORM_TRICOPTER) {
$('.tab_ez_tune').removeClass("is-hidden");
} else {
$('.tab_ez_tune').addClass("is-hidden");
useEzTune = false;
}
});
} else {
if (MIXER_CONFIG.platformType == PLATFORM_MULTIROTOR || MIXER_CONFIG.platformType == PLATFORM_TRICOPTER) {
$('.tab_ez_tune').removeClass("is-hidden");
} else {
$('.tab_ez_tune').addClass("is-hidden");
useEzTune = false;
}
}
}
return useEzTune;
} }
});

View file

@ -1,52 +1,63 @@
'use strict'; 'use strict';
const SERVO_GIMBAL_PITCH = 0, const MotorMixRule = require('./motorMixRule');
SERVO_GIMBAL_ROLL = 1, const ServoMixRule = require('./servoMixRule');
SERVO_ELEVATOR = 1,
SERVO_ELEVON_1 = 1,
SERVO_ELEVON_2 = 2,
SERVO_FLAPPERON_1 = 2,
SERVO_FLAPPERON_2 = 3,
SERVO_RUDDER = 4,
SERVO_BICOPTER_LEFT = 4,
SERVO_BICOPTER_RIGHT = 5,
SERVO_DUALCOPTER_LEFT = 4,
SERVO_DUALCOPTER_RIGHT = 5,
SERVO_SINGLECOPTER_1 = 3,
SERVO_SINGLECOPTER_2 = 4,
SERVO_SINGLECOPTER_3 = 5,
SERVO_SINGLECOPTER_4 = 6;
const INPUT_STABILIZED_ROLL = 0, const SERVO = {
INPUT_STABILIZED_PITCH = 1, GIMBAL_PITCH: 0,
INPUT_STABILIZED_YAW = 2, GIMBAL_ROLL: 1,
INPUT_STABILIZED_THROTTLE = 3, ELEVATOR: 1,
INPUT_RC_ROLL = 4, ELEVON_1: 1,
INPUT_RC_PITCH = 5, ELEVON_2: 2,
INPUT_RC_YAW = 6, FLAPPERON_1: 2,
INPUT_RC_THROTTLE = 7, FLAPPERON_2: 3,
INPUT_RC_AUX1 = 8, RUDDER: 4,
INPUT_RC_AUX2 = 9, BICOPTER_LEFT: 4,
INPUT_RC_AUX3 = 10, BICOPTER_RIGHT: 5,
INPUT_RC_AUX4 = 11, DUALCOPTER_LEFT: 4,
INPUT_GIMBAL_PITCH = 12, DUALCOPTER_RIGHT: 5,
INPUT_GIMBAL_ROLL = 13, SINGLECOPTER_1: 3,
INPUT_FEATURE_FLAPS = 14, SINGLECOPTER_2: 4,
STABILIZED_ROLL_POSITIVE = 23, SINGLECOPTER_3: 5,
STABILIZED_ROLL_NEGATIVE = 24, SINGLECOPTER_4: 6
STABILIZED_PITCH_POSITIVE = 25, }
STABILIZED_PITCH_NEGATIVE = 26,
STABILIZED_YAW_POSITIVE = 27,
STABILIZED_YAW_NEGATIVE = 28;
const const INPUT = {
PLATFORM_MULTIROTOR = 0, STABILIZED_DROLL: 0,
PLATFORM_AIRPLANE = 1, STABILIZED_PITCH: 1,
PLATFORM_HELICOPTER = 2, STABILIZED_YAW: 2,
PLATFORM_TRICOPTER = 3, THROTTLE: 3,
PLATFORM_ROVER = 4, RC_ROLL: 4,
PLATFORM_BOAT = 5, RC_PITCH: 5,
PLATFORM_OTHER = 6; RC_YAW: 6,
RC_THROTTLE: 7,
RC_AUX1: 8,
RC_AUX2: 9,
RC_AUX3: 10,
RC_AUX4: 11,
GIMBAL_PITCH: 12,
GIMBAL_ROLL: 13,
FEATURE_FLAPS: 14,
}
const STABILIZED = {
ROLL_POSITIVE: 23,
ROLL_NEGATIVE: 24,
PITCH_POSITIVE: 25,
PITCH_NEGATIVE: 26,
YAW_POSITIVE: 27,
YAW_NEGATIVE: 28
}
const PLATFORM = {
MULTIROTOR: 0,
AIRPLANE: 1,
HELICOPTER: 2,
TRICOPTER: 3,
ROVER: 4,
BOAT: 5,
OTHER: 6
}
// generate mixer // generate mixer
const mixerList = [ const mixerList = [
@ -58,14 +69,14 @@ const mixerList = [
image: 'tri', image: 'tri',
enabled: true, enabled: true,
legacy: true, legacy: true,
platform: PLATFORM_TRICOPTER, platform: PLATFORM.TRICOPTER,
motorMixer: [ motorMixer: [
new MotorMixRule(1.0, 0.0, 1.333333, 0.0), // REAR new MotorMixRule(1.0, 0.0, 1.333333, 0.0), // REAR
new MotorMixRule(1.0, -1.0, -0.666667, 0.0), // RIGHT new MotorMixRule(1.0, -1.0, -0.666667, 0.0), // RIGHT
new MotorMixRule(1.0, 1.0, -0.666667, 0.0), // LEFT new MotorMixRule(1.0, 1.0, -0.666667, 0.0), // LEFT
], ],
servoMixer: [ servoMixer: [
new ServoMixRule(SERVO_RUDDER, INPUT_STABILIZED_YAW, 100, 0), new ServoMixRule(SERVO.RUDDER, INPUT.STABILIZED_YAW, 100, 0),
] ]
}, // 1 }, // 1
{ {
@ -75,7 +86,7 @@ const mixerList = [
image: 'quad_x', image: 'quad_x',
enabled: true, enabled: true,
legacy: true, legacy: true,
platform: PLATFORM_MULTIROTOR, platform: PLATFORM.MULTIROTOR,
motorMixer: [ motorMixer: [
new MotorMixRule(1.0, -1.0, 1.0, -1.0), // REAR_R new MotorMixRule(1.0, -1.0, 1.0, -1.0), // REAR_R
new MotorMixRule(1.0, -1.0, -1.0, 1.0), // FRONT_R new MotorMixRule(1.0, -1.0, -1.0, 1.0), // FRONT_R
@ -91,7 +102,7 @@ const mixerList = [
image: 'quad_p', image: 'quad_p',
enabled: true, enabled: true,
legacy: true, legacy: true,
platform: PLATFORM_MULTIROTOR, platform: PLATFORM.MULTIROTOR,
motorMixer: [ motorMixer: [
new MotorMixRule(1.0, 0.0, 1.0, -1.0), // REAR new MotorMixRule(1.0, 0.0, 1.0, -1.0), // REAR
new MotorMixRule(1.0, -1.0, 0.0, 1.0), // RIGHT new MotorMixRule(1.0, -1.0, 0.0, 1.0), // RIGHT
@ -107,7 +118,7 @@ const mixerList = [
image: 'bicopter', image: 'bicopter',
enabled: false, enabled: false,
legacy: true, legacy: true,
platform: PLATFORM_MULTIROTOR, platform: PLATFORM.MULTIROTOR,
motorMixer: [], motorMixer: [],
servoMixer: [] servoMixer: []
}, // 4 }, // 4
@ -118,7 +129,7 @@ const mixerList = [
image: 'y6', image: 'y6',
enabled: true, enabled: true,
legacy: true, legacy: true,
platform: PLATFORM_MULTIROTOR, platform: PLATFORM.MULTIROTOR,
motorMixer: [ motorMixer: [
new MotorMixRule(1.0, 0.0, 1.333333, 1.0), // REAR new MotorMixRule(1.0, 0.0, 1.333333, 1.0), // REAR
new MotorMixRule(1.0, -1.0, -0.666667, -1.0), // RIGHT new MotorMixRule(1.0, -1.0, -0.666667, -1.0), // RIGHT
@ -136,7 +147,7 @@ const mixerList = [
image: 'hex_p', image: 'hex_p',
enabled: true, enabled: true,
legacy: true, legacy: true,
platform: PLATFORM_MULTIROTOR, platform: PLATFORM.MULTIROTOR,
motorMixer: [ motorMixer: [
new MotorMixRule(1.0, -0.866025, 0.5, 1.0), // REAR_R new MotorMixRule(1.0, -0.866025, 0.5, 1.0), // REAR_R
new MotorMixRule(1.0, -0.866025, -0.5, -1.0), // FRONT_R new MotorMixRule(1.0, -0.866025, -0.5, -1.0), // FRONT_R
@ -154,7 +165,7 @@ const mixerList = [
image: 'y4', image: 'y4',
enabled: true, enabled: true,
legacy: true, legacy: true,
platform: PLATFORM_MULTIROTOR, platform: PLATFORM.MULTIROTOR,
motorMixer: [ motorMixer: [
new MotorMixRule(1.0, 0.0, 1.0, -1.0), // REAR_TOP CW new MotorMixRule(1.0, 0.0, 1.0, -1.0), // REAR_TOP CW
new MotorMixRule(1.0, -1.0, -1.0, 0.0), // FRONT_R CCW new MotorMixRule(1.0, -1.0, -1.0, 0.0), // FRONT_R CCW
@ -170,7 +181,7 @@ const mixerList = [
image: 'hex_x', image: 'hex_x',
enabled: true, enabled: true,
legacy: true, legacy: true,
platform: PLATFORM_MULTIROTOR, platform: PLATFORM.MULTIROTOR,
motorMixer: [ motorMixer: [
new MotorMixRule(1.0, -0.5, 0.866025, 1.0), // REAR_R new MotorMixRule(1.0, -0.5, 0.866025, 1.0), // REAR_R
new MotorMixRule(1.0, -0.5, -0.866025, 1.0), // FRONT_R new MotorMixRule(1.0, -0.5, -0.866025, 1.0), // FRONT_R
@ -188,7 +199,7 @@ const mixerList = [
image: 'octo_x8', image: 'octo_x8',
enabled: true, enabled: true,
legacy: true, legacy: true,
platform: PLATFORM_MULTIROTOR, platform: PLATFORM.MULTIROTOR,
motorMixer: [ motorMixer: [
new MotorMixRule(1.0, -1.0, 1.0, -1.0), // REAR_R new MotorMixRule(1.0, -1.0, 1.0, -1.0), // REAR_R
new MotorMixRule(1.0, -1.0, -1.0, 1.0), // FRONT_R new MotorMixRule(1.0, -1.0, -1.0, 1.0), // FRONT_R
@ -208,7 +219,7 @@ const mixerList = [
image: 'octo_flat_p', image: 'octo_flat_p',
enabled: true, enabled: true,
legacy: true, legacy: true,
platform: PLATFORM_MULTIROTOR, platform: PLATFORM.MULTIROTOR,
motorMixer: [ motorMixer: [
new MotorMixRule(1.0, 0.707107, -0.707107, 1.0), // FRONT_L new MotorMixRule(1.0, 0.707107, -0.707107, 1.0), // FRONT_L
new MotorMixRule(1.0, -0.707107, -0.707107, 1.0), // FRONT_R new MotorMixRule(1.0, -0.707107, -0.707107, 1.0), // FRONT_R
@ -228,7 +239,7 @@ const mixerList = [
image: 'octo_flat_x', image: 'octo_flat_x',
enabled: true, enabled: true,
legacy: true, legacy: true,
platform: PLATFORM_MULTIROTOR, platform: PLATFORM.MULTIROTOR,
motorMixer: [ motorMixer: [
new MotorMixRule(1.0, 1.0, -0.414178, 1.0), // MIDFRONT_L new MotorMixRule(1.0, 1.0, -0.414178, 1.0), // MIDFRONT_L
new MotorMixRule(1.0, -0.414178, -1.0, 1.0), // FRONT_R new MotorMixRule(1.0, -0.414178, -1.0, 1.0), // FRONT_R
@ -248,7 +259,7 @@ const mixerList = [
image: 'vtail_quad', image: 'vtail_quad',
enabled: true, enabled: true,
legacy: true, legacy: true,
platform: PLATFORM_MULTIROTOR, platform: PLATFORM.MULTIROTOR,
motorMixer: [ motorMixer: [
new MotorMixRule(1.0, -0.58, 0.58, 1.0), // REAR_R new MotorMixRule(1.0, -0.58, 0.58, 1.0), // REAR_R
new MotorMixRule(1.0, -0.46, -0.39, -0.5), // FRONT_R new MotorMixRule(1.0, -0.46, -0.39, -0.5), // FRONT_R
@ -264,7 +275,7 @@ const mixerList = [
image: 'custom', image: 'custom',
enabled: true, enabled: true,
legacy: true, legacy: true,
platform: PLATFORM_MULTIROTOR, platform: PLATFORM.MULTIROTOR,
motorMixer: [ motorMixer: [
new MotorMixRule(1.0, -1.0, 1.0, -1.0), // REAR_R new MotorMixRule(1.0, -1.0, 1.0, -1.0), // REAR_R
new MotorMixRule(1.0, -1.0, -1.0, 1.0), // FRONT_R new MotorMixRule(1.0, -1.0, -1.0, 1.0), // FRONT_R
@ -282,7 +293,7 @@ const mixerList = [
image: 'custom', image: 'custom',
enabled: false, enabled: false,
legacy: true, legacy: true,
platform: PLATFORM_MULTIROTOR, platform: PLATFORM.MULTIROTOR,
motorMixer: [], motorMixer: [],
servoMixer: [] servoMixer: []
}, // 20 }, // 20
@ -293,7 +304,7 @@ const mixerList = [
image: 'custom', image: 'custom',
enabled: false, enabled: false,
legacy: true, legacy: true,
platform: PLATFORM_MULTIROTOR, platform: PLATFORM.MULTIROTOR,
motorMixer: [], motorMixer: [],
servoMixer: [] servoMixer: []
}, // 21 }, // 21
@ -304,7 +315,7 @@ const mixerList = [
image: 'atail_quad', image: 'atail_quad',
enabled: true, enabled: true,
legacy: true, legacy: true,
platform: PLATFORM_MULTIROTOR, platform: PLATFORM.MULTIROTOR,
motorMixer: [ motorMixer: [
new MotorMixRule(1.0, 0.0, 1.0, 1.0), // REAR_R new MotorMixRule(1.0, 0.0, 1.0, 1.0), // REAR_R
new MotorMixRule(1.0, -1.0, -1.0, 0.0), // FRONT_R new MotorMixRule(1.0, -1.0, -1.0, 0.0), // FRONT_R
@ -320,7 +331,7 @@ const mixerList = [
image: 'custom', image: 'custom',
enabled: false, enabled: false,
legacy: true, legacy: true,
platform: PLATFORM_MULTIROTOR, platform: PLATFORM.MULTIROTOR,
motorMixer: [], motorMixer: [],
servoMixer: [] servoMixer: []
}, // 23 }, // 23
@ -331,7 +342,7 @@ const mixerList = [
image: 'custom', image: 'custom',
enabled: false, enabled: false,
legacy: true, legacy: true,
platform: PLATFORM_TRICOPTER, platform: PLATFORM.TRICOPTER,
motorMixer: [], motorMixer: [],
servoMixer: [] servoMixer: []
}, // 25 }, // 25
@ -343,22 +354,22 @@ const mixerList = [
model: 'flying_wing', model: 'flying_wing',
image: 'flying_wing', image: 'flying_wing',
imageOutputsNumbers: [ imageOutputsNumbers: [
{input: INPUT_STABILIZED_ROLL, top: 123, left: 18, colour: "#ff0000"}, {input: INPUT.STABILIZED_ROLL, top: 123, left: 18, colour: "#ff0000"},
{input: INPUT_STABILIZED_ROLL, top: 123, left: 134, colour: "#00e000"}, {input: INPUT.STABILIZED_ROLL, top: 123, left: 134, colour: "#00e000"},
{input: INPUT_STABILIZED_THROTTLE, top:93, left:71, colour: "#000000"}, {input: INPUT.STABILIZED_THROTTLE, top:93, left:71, colour: "#000000"},
], ],
enabled: true, enabled: true,
legacy: true, legacy: true,
platform: PLATFORM_AIRPLANE, platform: PLATFORM.AIRPLANE,
motorStopOnLow: true, motorStopOnLow: true,
motorMixer: [ motorMixer: [
new MotorMixRule(1.0, 0.0, 0.0, 0.0), new MotorMixRule(1.0, 0.0, 0.0, 0.0),
], ],
servoMixer: [ servoMixer: [
new ServoMixRule(SERVO_ELEVON_1, INPUT_STABILIZED_ROLL, 50, 0), new ServoMixRule(SERVO.ELEVON_1, INPUT.STABILIZED_ROLL, 50, 0),
new ServoMixRule(SERVO_ELEVON_1, INPUT_STABILIZED_PITCH, 50, 0), new ServoMixRule(SERVO.ELEVON_1, INPUT.STABILIZED_PITCH, 50, 0),
new ServoMixRule(SERVO_ELEVON_2, INPUT_STABILIZED_ROLL, -50, 0), new ServoMixRule(SERVO.ELEVON_2, INPUT.STABILIZED_ROLL, -50, 0),
new ServoMixRule(SERVO_ELEVON_2, INPUT_STABILIZED_PITCH, 50, 0), new ServoMixRule(SERVO.ELEVON_2, INPUT.STABILIZED_PITCH, 50, 0),
] ]
}, // 8 }, // 8
{ {
@ -367,23 +378,23 @@ const mixerList = [
model: 'flying_wing', model: 'flying_wing',
image: 'flying_wing', image: 'flying_wing',
imageOutputsNumbers: [ imageOutputsNumbers: [
{input: INPUT_STABILIZED_ROLL, top: 123, left: 18, colour: "#ff0000"}, {input: INPUT.STABILIZED_ROLL, top: 123, left: 18, colour: "#ff0000"},
{input: INPUT_STABILIZED_ROLL, top: 123, left: 134, colour: "#00e000"}, {input: INPUT.STABILIZED_ROLL, top: 123, left: 134, colour: "#00e000"},
{input: INPUT_STABILIZED_THROTTLE, top:93, left:71, colour: "#000000"}, {input: INPUT.STABILIZED_THROTTLE, top:93, left:71, colour: "#000000"},
], ],
enabled: true, enabled: true,
legacy: false, legacy: false,
platform: PLATFORM_AIRPLANE, platform: PLATFORM.AIRPLANE,
motorStopOnLow: true, motorStopOnLow: true,
motorMixer: [ motorMixer: [
new MotorMixRule(1.0, 0.0, 0.0, 0.1), new MotorMixRule(1.0, 0.0, 0.0, 0.1),
new MotorMixRule(1.0, 0.0, 0.0, -0.1) new MotorMixRule(1.0, 0.0, 0.0, -0.1)
], ],
servoMixer: [ servoMixer: [
new ServoMixRule(SERVO_ELEVON_1, INPUT_STABILIZED_ROLL, 50, 0), new ServoMixRule(SERVO.ELEVON_1, INPUT.STABILIZED_ROLL, 50, 0),
new ServoMixRule(SERVO_ELEVON_1, INPUT_STABILIZED_PITCH, 50, 0), new ServoMixRule(SERVO.ELEVON_1, INPUT.STABILIZED_PITCH, 50, 0),
new ServoMixRule(SERVO_ELEVON_2, INPUT_STABILIZED_ROLL, -50, 0), new ServoMixRule(SERVO.ELEVON_2, INPUT.STABILIZED_ROLL, -50, 0),
new ServoMixRule(SERVO_ELEVON_2, INPUT_STABILIZED_PITCH, 50, 0), new ServoMixRule(SERVO.ELEVON_2, INPUT.STABILIZED_PITCH, 50, 0),
] ]
}, // 27 }, // 27
{ {
@ -392,27 +403,27 @@ const mixerList = [
model: 'twin_plane', model: 'twin_plane',
image: 'airplane', image: 'airplane',
imageOutputsNumbers: [ imageOutputsNumbers: [
{input: INPUT_STABILIZED_PITCH, top: 151, left: 126, colour: "#ff7f00"}, {input: INPUT.STABILIZED_PITCH, top: 151, left: 126, colour: "#ff7f00"},
{input: INPUT_STABILIZED_ROLL, top: 96, left: 18, colour: "#ff0000"}, {input: INPUT.STABILIZED_ROLL, top: 96, left: 18, colour: "#ff0000"},
{input: INPUT_STABILIZED_ROLL, top: 96, left: 134, colour: "#00e000"}, {input: INPUT.STABILIZED_ROLL, top: 96, left: 134, colour: "#00e000"},
{input: INPUT_STABILIZED_YAW, top: 126, left: 52, colour: "#00a6ff"}, {input: INPUT.STABILIZED_YAW, top: 126, left: 52, colour: "#00a6ff"},
{input: INPUT_STABILIZED_THROTTLE, top:5, left:71, colour: "#000000"}, {input: INPUT.STABILIZED_THROTTLE, top:5, left:71, colour: "#000000"},
], ],
enabled: true, enabled: true,
legacy: true, legacy: true,
platform: PLATFORM_AIRPLANE, platform: PLATFORM.AIRPLANE,
motorStopOnLow: true, motorStopOnLow: true,
hasFlaps: true, hasFlaps: true,
motorMixer: [ motorMixer: [
new MotorMixRule(1.0, 0.0, 0.0, 0.0), new MotorMixRule(1.0, 0.0, 0.0, 0.0),
], ],
servoMixer: [ servoMixer: [
new ServoMixRule(SERVO_ELEVATOR, INPUT_STABILIZED_PITCH, 100, 0), new ServoMixRule(SERVO.ELEVATOR, INPUT.STABILIZED_PITCH, 100, 0),
new ServoMixRule(SERVO_FLAPPERON_1, INPUT_STABILIZED_ROLL, 100, 0), new ServoMixRule(SERVO.FLAPPERON_1, INPUT.STABILIZED_ROLL, 100, 0),
/*new ServoMixRule(SERVO_FLAPPERON_1, INPUT_FEATURE_FLAPS, 100, 0),*/ /*new ServoMixRule(SERVO.FLAPPERON_1, INPUT.FEATURE_FLAPS, 100, 0),*/
new ServoMixRule(SERVO_FLAPPERON_2, INPUT_STABILIZED_ROLL, 100, 0), new ServoMixRule(SERVO.FLAPPERON_2, INPUT.STABILIZED_ROLL, 100, 0),
/*new ServoMixRule(SERVO_FLAPPERON_2, INPUT_FEATURE_FLAPS, -100, 0),*/ /*new ServoMixRule(SERVO.FLAPPERON_2, INPUT.FEATURE_FLAPS, -100, 0),*/
new ServoMixRule(SERVO_RUDDER, INPUT_STABILIZED_YAW, 100, 0), new ServoMixRule(SERVO.RUDDER, INPUT.STABILIZED_YAW, 100, 0),
] ]
}, // 14 }, // 14
{ {
@ -421,15 +432,15 @@ const mixerList = [
model: 'twin_plane', model: 'twin_plane',
image: 'airplane', image: 'airplane',
imageOutputsNumbers: [ imageOutputsNumbers: [
{input: INPUT_STABILIZED_PITCH, top: 151, left: 126, colour: "#ff7f00"}, {input: INPUT.STABILIZED_PITCH, top: 151, left: 126, colour: "#ff7f00"},
{input: INPUT_STABILIZED_ROLL, top: 96, left: 18, colour: "#ff0000"}, {input: INPUT.STABILIZED_ROLL, top: 96, left: 18, colour: "#ff0000"},
{input: INPUT_STABILIZED_ROLL, top: 96, left: 134, colour: "#00e000"}, {input: INPUT.STABILIZED_ROLL, top: 96, left: 134, colour: "#00e000"},
{input: INPUT_STABILIZED_YAW, top: 126, left: 52, colour: "#00a6ff"}, {input: INPUT.STABILIZED_YAW, top: 126, left: 52, colour: "#00a6ff"},
{input: INPUT_STABILIZED_THROTTLE, top:5, left:71, colour: "#000000"}, {input: INPUT.STABILIZED_THROTTLE, top:5, left:71, colour: "#000000"},
], ],
enabled: true, enabled: true,
legacy: false, legacy: false,
platform: PLATFORM_AIRPLANE, platform: PLATFORM.AIRPLANE,
motorStopOnLow: true, motorStopOnLow: true,
hasFlaps: true, hasFlaps: true,
motorMixer: [ motorMixer: [
@ -437,12 +448,12 @@ const mixerList = [
new MotorMixRule(1.0, 0.0, 0.0, -0.3) new MotorMixRule(1.0, 0.0, 0.0, -0.3)
], ],
servoMixer: [ servoMixer: [
new ServoMixRule(SERVO_ELEVATOR, INPUT_STABILIZED_PITCH, 100, 0), new ServoMixRule(SERVO.ELEVATOR, INPUT.STABILIZED_PITCH, 100, 0),
new ServoMixRule(SERVO_FLAPPERON_1, INPUT_STABILIZED_ROLL, 100, 0), new ServoMixRule(SERVO.FLAPPERON_1, INPUT.STABILIZED_ROLL, 100, 0),
/*new ServoMixRule(SERVO_FLAPPERON_1, INPUT_FEATURE_FLAPS, 100, 0),*/ /*new ServoMixRule(SERVO.FLAPPERON_1, INPUT.FEATURE_FLAPS, 100, 0),*/
new ServoMixRule(SERVO_FLAPPERON_2, INPUT_STABILIZED_ROLL, 100, 0), new ServoMixRule(SERVO.FLAPPERON_2, INPUT.STABILIZED_ROLL, 100, 0),
/*new ServoMixRule(SERVO_FLAPPERON_2, INPUT_FEATURE_FLAPS, -100, 0),*/ /*new ServoMixRule(SERVO.FLAPPERON_2, INPUT.FEATURE_FLAPS, -100, 0),*/
new ServoMixRule(SERVO_RUDDER, INPUT_STABILIZED_YAW, 100, 0), new ServoMixRule(SERVO.RUDDER, INPUT.STABILIZED_YAW, 100, 0),
] ]
}, // 26 }, // 26
{ {
@ -451,29 +462,29 @@ const mixerList = [
model: 'vtail_plane', model: 'vtail_plane',
image: 'airplane_vtail', image: 'airplane_vtail',
imageOutputsNumbers: [ imageOutputsNumbers: [
{input: INPUT_STABILIZED_ROLL, top: 96, left: 18, colour: "#ff0000"}, {input: INPUT.STABILIZED_ROLL, top: 96, left: 18, colour: "#ff0000"},
{input: INPUT_STABILIZED_ROLL, top: 96, left: 134, colour: "#00e000"}, {input: INPUT.STABILIZED_ROLL, top: 96, left: 134, colour: "#00e000"},
{input: INPUT_STABILIZED_PITCH, top: 154, left: 20, colour: "#ff7f00"}, {input: INPUT.STABILIZED_PITCH, top: 154, left: 20, colour: "#ff7f00"},
{input: INPUT_STABILIZED_PITCH, top: 154, left: 132, colour: "#00a6ff"}, {input: INPUT.STABILIZED_PITCH, top: 154, left: 132, colour: "#00a6ff"},
{input: INPUT_STABILIZED_THROTTLE, top:5, left:71, colour: "#000000"}, {input: INPUT.STABILIZED_THROTTLE, top:5, left:71, colour: "#000000"},
], ],
enabled: true, enabled: true,
legacy: false, legacy: false,
platform: PLATFORM_AIRPLANE, platform: PLATFORM.AIRPLANE,
motorStopOnLow: true, motorStopOnLow: true,
hasFlaps: true, hasFlaps: true,
motorMixer: [ motorMixer: [
new MotorMixRule(1.0, 0.0, 0.0, 0.0), new MotorMixRule(1.0, 0.0, 0.0, 0.0),
], ],
servoMixer: [ servoMixer: [
new ServoMixRule(1, INPUT_STABILIZED_ROLL, 100, 0), new ServoMixRule(1, INPUT.STABILIZED_ROLL, 100, 0),
/*new ServoMixRule(1, INPUT_FEATURE_FLAPS, 100, 0),*/ /*new ServoMixRule(1, INPUT.FEATURE_FLAPS, 100, 0),*/
new ServoMixRule(2, INPUT_STABILIZED_ROLL, 100, 0), new ServoMixRule(2, INPUT.STABILIZED_ROLL, 100, 0),
/*new ServoMixRule(2, INPUT_FEATURE_FLAPS, 100, 0),*/ /*new ServoMixRule(2, INPUT.FEATURE_FLAPS, 100, 0),*/
new ServoMixRule(3, INPUT_STABILIZED_PITCH, 50, 0), new ServoMixRule(3, INPUT.STABILIZED_PITCH, 50, 0),
new ServoMixRule(3, INPUT_STABILIZED_YAW, -50, 0), new ServoMixRule(3, INPUT.STABILIZED_YAW, -50, 0),
new ServoMixRule(4, INPUT_STABILIZED_PITCH, -50, 0), new ServoMixRule(4, INPUT.STABILIZED_PITCH, -50, 0),
new ServoMixRule(4, INPUT_STABILIZED_YAW, -50, 0) new ServoMixRule(4, INPUT.STABILIZED_YAW, -50, 0)
] ]
}, // 28 }, // 28
{ {
@ -482,15 +493,15 @@ const mixerList = [
model: 'vtail_plane', model: 'vtail_plane',
image: 'airplane_vtail', image: 'airplane_vtail',
imageOutputsNumbers: [ imageOutputsNumbers: [
{input: INPUT_STABILIZED_ROLL, top: 96, left: 18, colour: "#ff0000"}, {input: INPUT.STABILIZED_ROLL, top: 96, left: 18, colour: "#ff0000"},
{input: INPUT_STABILIZED_ROLL, top: 96, left: 134, colour: "#00e000"}, {input: INPUT.STABILIZED_ROLL, top: 96, left: 134, colour: "#00e000"},
{input: INPUT_STABILIZED_PITCH, top: 154, left: 20, colour: "#ff7f00"}, {input: INPUT.STABILIZED_PITCH, top: 154, left: 20, colour: "#ff7f00"},
{input: INPUT_STABILIZED_PITCH, top: 154, left: 132, colour: "#00a6ff"}, {input: INPUT.STABILIZED_PITCH, top: 154, left: 132, colour: "#00a6ff"},
{input: INPUT_STABILIZED_THROTTLE, top:5, left:71, colour: "#000000"}, {input: INPUT.STABILIZED_THROTTLE, top:5, left:71, colour: "#000000"},
], ],
enabled: true, enabled: true,
legacy: false, legacy: false,
platform: PLATFORM_AIRPLANE, platform: PLATFORM.AIRPLANE,
motorStopOnLow: true, motorStopOnLow: true,
hasFlaps: true, hasFlaps: true,
motorMixer: [ motorMixer: [
@ -498,14 +509,14 @@ const mixerList = [
new MotorMixRule(1.0, 0.0, 0.0, -0.3) new MotorMixRule(1.0, 0.0, 0.0, -0.3)
], ],
servoMixer: [ servoMixer: [
new ServoMixRule(1, INPUT_STABILIZED_ROLL, 100, 0), new ServoMixRule(1, INPUT.STABILIZED_ROLL, 100, 0),
/*new ServoMixRule(1, INPUT_FEATURE_FLAPS, 100, 0),*/ /*new ServoMixRule(1, INPUT.FEATURE_FLAPS, 100, 0),*/
new ServoMixRule(2, INPUT_STABILIZED_ROLL, 100, 0), new ServoMixRule(2, INPUT.STABILIZED_ROLL, 100, 0),
/*new ServoMixRule(2, INPUT_FEATURE_FLAPS, 100, 0),*/ /*new ServoMixRule(2, INPUT.FEATURE_FLAPS, 100, 0),*/
new ServoMixRule(3, INPUT_STABILIZED_PITCH, 50, 0), new ServoMixRule(3, INPUT.STABILIZED_PITCH, 50, 0),
new ServoMixRule(3, INPUT_STABILIZED_YAW, -50, 0), new ServoMixRule(3, INPUT.STABILIZED_YAW, -50, 0),
new ServoMixRule(4, INPUT_STABILIZED_PITCH, -50, 0), new ServoMixRule(4, INPUT.STABILIZED_PITCH, -50, 0),
new ServoMixRule(4, INPUT_STABILIZED_YAW, -50, 0) new ServoMixRule(4, INPUT.STABILIZED_YAW, -50, 0)
] ]
}, // 34 }, // 34
{ {
@ -514,24 +525,24 @@ const mixerList = [
model: 'vtail_single_servo_plane', model: 'vtail_single_servo_plane',
image: 'airplane_vtail_single', image: 'airplane_vtail_single',
imageOutputsNumbers: [ imageOutputsNumbers: [
{input: INPUT_STABILIZED_ROLL, top: 96, left: 18, colour: "#ff7f00"}, {input: INPUT.STABILIZED_ROLL, top: 96, left: 18, colour: "#ff7f00"},
{input: INPUT_STABILIZED_PITCH, top: 154, left: 20, colour: "#ff0000"}, {input: INPUT.STABILIZED_PITCH, top: 154, left: 20, colour: "#ff0000"},
{input: INPUT_STABILIZED_PITCH, top: 154, left: 132, colour: "#00e000"}, {input: INPUT.STABILIZED_PITCH, top: 154, left: 132, colour: "#00e000"},
{input: INPUT_STABILIZED_THROTTLE, top:5, left:71, colour: "#000000"}, {input: INPUT.STABILIZED_THROTTLE, top:5, left:71, colour: "#000000"},
], ],
enabled: true, enabled: true,
legacy: false, legacy: false,
platform: PLATFORM_AIRPLANE, platform: PLATFORM.AIRPLANE,
motorStopOnLow: true, motorStopOnLow: true,
motorMixer: [ motorMixer: [
new MotorMixRule(1.0, 0.0, 0.0, 0.0), new MotorMixRule(1.0, 0.0, 0.0, 0.0),
], ],
servoMixer: [ servoMixer: [
new ServoMixRule(1, INPUT_STABILIZED_ROLL, 100, 0), new ServoMixRule(1, INPUT.STABILIZED_ROLL, 100, 0),
new ServoMixRule(2, INPUT_STABILIZED_PITCH, 50, 0), new ServoMixRule(2, INPUT.STABILIZED_PITCH, 50, 0),
new ServoMixRule(2, INPUT_STABILIZED_YAW, -50, 0), new ServoMixRule(2, INPUT.STABILIZED_YAW, -50, 0),
new ServoMixRule(3, INPUT_STABILIZED_PITCH, -50, 0), new ServoMixRule(3, INPUT.STABILIZED_PITCH, -50, 0),
new ServoMixRule(3, INPUT_STABILIZED_YAW, -50, 0), new ServoMixRule(3, INPUT.STABILIZED_YAW, -50, 0),
] ]
}, //29 }, //29
{ {
@ -540,25 +551,25 @@ const mixerList = [
model: 'rudderless_plane', model: 'rudderless_plane',
image: 'airplane_norudder', image: 'airplane_norudder',
imageOutputsNumbers: [ imageOutputsNumbers: [
{input: INPUT_STABILIZED_PITCH, top: 151, left: 126, colour: "#ff7f00"}, {input: INPUT.STABILIZED_PITCH, top: 151, left: 126, colour: "#ff7f00"},
{input: INPUT_STABILIZED_ROLL, top: 96, left: 18, colour: "#ff0000"}, {input: INPUT.STABILIZED_ROLL, top: 96, left: 18, colour: "#ff0000"},
{input: INPUT_STABILIZED_ROLL, top: 96, left: 134, colour: "#00e000"}, {input: INPUT.STABILIZED_ROLL, top: 96, left: 134, colour: "#00e000"},
{input: INPUT_STABILIZED_THROTTLE, top:5, left:71, colour: "#000000"}, {input: INPUT.STABILIZED_THROTTLE, top:5, left:71, colour: "#000000"},
], ],
enabled: true, enabled: true,
legacy: false, legacy: false,
platform: PLATFORM_AIRPLANE, platform: PLATFORM.AIRPLANE,
hasFlaps: true, hasFlaps: true,
motorStopOnLow: true, motorStopOnLow: true,
motorMixer: [ motorMixer: [
new MotorMixRule(1.0, 0.0, 0.0, 0.0), new MotorMixRule(1.0, 0.0, 0.0, 0.0),
], ],
servoMixer: [ servoMixer: [
new ServoMixRule(SERVO_ELEVATOR, INPUT_STABILIZED_PITCH, 100, 0), new ServoMixRule(SERVO.ELEVATOR, INPUT.STABILIZED_PITCH, 100, 0),
new ServoMixRule(SERVO_FLAPPERON_1, INPUT_STABILIZED_ROLL, 100, 0), new ServoMixRule(SERVO.FLAPPERON_1, INPUT.STABILIZED_ROLL, 100, 0),
/*new ServoMixRule(SERVO_FLAPPERON_1, INPUT_FEATURE_FLAPS, 100, 0),*/ /*new ServoMixRule(SERVO.FLAPPERON_1, INPUT.FEATURE_FLAPS, 100, 0),*/
new ServoMixRule(SERVO_FLAPPERON_2, INPUT_STABILIZED_ROLL, 100, 0), new ServoMixRule(SERVO.FLAPPERON_2, INPUT.STABILIZED_ROLL, 100, 0),
/*new ServoMixRule(SERVO_FLAPPERON_2, INPUT_FEATURE_FLAPS, 100, 0),*/ /*new ServoMixRule(SERVO.FLAPPERON_2, INPUT.FEATURE_FLAPS, 100, 0),*/
] ]
}, // 30 }, // 30
{ {
@ -567,15 +578,15 @@ const mixerList = [
model: 'twin_plane', model: 'twin_plane',
image: 'airplane', image: 'airplane',
imageOutputsNumbers: [ imageOutputsNumbers: [
{input: INPUT_STABILIZED_PITCH, top: 151, left: 126, colour: "#ff7f00"}, {input: INPUT.STABILIZED_PITCH, top: 151, left: 126, colour: "#ff7f00"},
{input: INPUT_STABILIZED_ROLL, top: 96, left: 18, colour: "#ff0000"}, {input: INPUT.STABILIZED_ROLL, top: 96, left: 18, colour: "#ff0000"},
{input: INPUT_STABILIZED_ROLL, top: 96, left: 134, colour: "#00e000"}, {input: INPUT.STABILIZED_ROLL, top: 96, left: 134, colour: "#00e000"},
{input: INPUT_STABILIZED_YAW, top: 126, left: 52, colour: "#00a6ff"}, {input: INPUT.STABILIZED_YAW, top: 126, left: 52, colour: "#00a6ff"},
{input: INPUT_STABILIZED_THROTTLE, top:5, left:71, colour: "#000000"}, {input: INPUT.STABILIZED_THROTTLE, top:5, left:71, colour: "#000000"},
], ],
enabled: false, enabled: false,
legacy: true, legacy: true,
platform: PLATFORM_AIRPLANE, platform: PLATFORM.AIRPLANE,
motorStopOnLow: true, motorStopOnLow: true,
motorMixer: [], motorMixer: [],
servoMixer: [] servoMixer: []
@ -589,7 +600,7 @@ const mixerList = [
image: 'custom', image: 'custom',
enabled: false, enabled: false,
legacy: true, legacy: true,
platform: PLATFORM_HELICOPTER, platform: PLATFORM.HELICOPTER,
motorMixer: [], motorMixer: [],
servoMixer: [] servoMixer: []
}, // 15 }, // 15
@ -600,7 +611,7 @@ const mixerList = [
image: 'custom', image: 'custom',
enabled: false, enabled: false,
legacy: true, legacy: true,
platform: PLATFORM_HELICOPTER, platform: PLATFORM.HELICOPTER,
motorMixer: [], motorMixer: [],
servoMixer: [] servoMixer: []
}, // 16 }, // 16
@ -613,12 +624,12 @@ const mixerList = [
image: 'custom', image: 'custom',
enabled: true, enabled: true,
legacy: false, legacy: false,
platform: PLATFORM_ROVER, platform: PLATFORM.ROVER,
motorMixer: [ motorMixer: [
new MotorMixRule(1.0, 0.0, 0.0, 0.0), new MotorMixRule(1.0, 0.0, 0.0, 0.0),
], ],
servoMixer: [ servoMixer: [
new ServoMixRule(3, INPUT_STABILIZED_YAW, 100, 0), new ServoMixRule(3, INPUT.STABILIZED_YAW, 100, 0),
] ]
}, },
{ {
@ -628,12 +639,12 @@ const mixerList = [
image: 'custom', image: 'custom',
enabled: true, enabled: true,
legacy: false, legacy: false,
platform: PLATFORM_BOAT, platform: PLATFORM.BOAT,
motorMixer: [ motorMixer: [
new MotorMixRule(1.0, 0.0, 0.0, 0.0), new MotorMixRule(1.0, 0.0, 0.0, 0.0),
], ],
servoMixer: [ servoMixer: [
new ServoMixRule(3, INPUT_STABILIZED_YAW, 100, 0), new ServoMixRule(3, INPUT.STABILIZED_YAW, 100, 0),
] ]
}, },
// ** Misc ** // ** Misc **
@ -644,12 +655,12 @@ const mixerList = [
image: 'custom', image: 'custom',
enabled: true, enabled: true,
legacy: false, legacy: false,
platform: PLATFORM_OTHER, platform: PLATFORM.OTHER,
motorMixer: [ motorMixer: [
new MotorMixRule(1.0, 0.0, 0.0, 0.0), new MotorMixRule(1.0, 0.0, 0.0, 0.0),
], ],
servoMixer: [ servoMixer: [
new ServoMixRule(3, INPUT_STABILIZED_YAW, 100, 0), new ServoMixRule(3, INPUT.STABILIZED_YAW, 100, 0),
] ]
}, },
{ {
@ -659,7 +670,7 @@ const mixerList = [
image: 'custom', image: 'custom',
enabled: false, enabled: false,
legacy: true, legacy: true,
platform: PLATFORM_OTHER, platform: PLATFORM.OTHER,
motorMixer: [], motorMixer: [],
servoMixer: [] servoMixer: []
}, // 5 }, // 5
@ -670,7 +681,7 @@ const mixerList = [
image: 'custom', image: 'custom',
enabled: false, enabled: false,
legacy: true, legacy: true,
platform: PLATFORM_OTHER, platform: PLATFORM.OTHER,
motorMixer: [], motorMixer: [],
servoMixer: [] servoMixer: []
}, // 19 }, // 19
@ -721,9 +732,7 @@ const platformList = [
} }
]; ];
var helper = helper || {}; var mixer = (function (mixerList) {
helper.mixer = (function (mixerList) {
let publicScope = {}, let publicScope = {},
privateScope = {}; privateScope = {};
@ -833,7 +842,7 @@ helper.mixer = (function (mixerList) {
return publicScope; return publicScope;
})(mixerList); })(mixerList);
helper.platform = (function (platforms) { var platform = (function (platforms) {
let publicScope = {}, let publicScope = {},
privateScope = {}; privateScope = {};
@ -864,3 +873,5 @@ helper.platform = (function (platforms) {
return publicScope; return publicScope;
})(platformList); })(platformList);
module.exports = { mixer, platform, PLATFORM, SERVO, INPUT, STABILIZED };

View file

@ -66,3 +66,5 @@ var MotorMixRule = function (throttle, roll, pitch, yaw) {
return self; return self;
}; };
module.exports = MotorMixRule;

View file

@ -72,3 +72,5 @@ var MotorMixerRuleCollection = function () {
return self; return self;
}; };
module.exports = MotorMixerRuleCollection;

View file

@ -1,5 +1,8 @@
'use strict'; 'use strict';
const MSPCodes = require('./msp/MSPCodes')
const mspQueue = require('./serial_queue');
/** /**
* *
* @constructor * @constructor
@ -20,10 +23,13 @@ var MspMessageClass = function () {
return publicScope; return publicScope;
}; };
/**
* @typedef {{state: number, message_direction: number, code: number, message_length_expected: number, message_length_received: number, message_buffer: null, message_buffer_uint8_view: null, message_checksum: number, callbacks: Array, packet_error: number, unsupported: number, ledDirectionLetters: [*], ledFunctionLetters: [*], ledBaseFunctionLetters: [*], ledOverlayLetters: [*], last_received_timestamp: null, analog_last_received_timestamp: number, read: MSP.read, send_message: MSP.send_message, promise: MSP.promise, callbacks_cleanup: MSP.callbacks_cleanup, disconnect_cleanup: MSP.disconnect_cleanup}} MSP
*/
var MSP = { var MSP = {
SDCARD_STATE_NOT_PRESENT: 0,
SDCARD_STATE_FATAL: 1,
SDCARD_STATE_CARD_INIT: 2,
SDCARD_STATE_FS_INIT: 3,
SDCARD_STATE_READY: 4,
symbols: { symbols: {
BEGIN: '$'.charCodeAt(0), BEGIN: '$'.charCodeAt(0),
PROTO_V1: 'M'.charCodeAt(0), PROTO_V1: 'M'.charCodeAt(0),
@ -78,7 +84,18 @@ var MSP = {
last_received_timestamp: null, last_received_timestamp: null,
analog_last_received_timestamp: null, analog_last_received_timestamp: null,
read: function (readInfo) { processData: null,
init() {
mspQueue.setPutCallback(this.putCallback);
mspQueue.setremoveCallback(this.removeCallback);
},
setProcessData(cb) {
this.processData = cb;
},
read(readInfo) {
var data = new Uint8Array(readInfo.data); var data = new Uint8Array(readInfo.data);
for (var i = 0; i < data.length; i++) { for (var i = 0; i < data.length; i++) {
@ -220,22 +237,22 @@ var MSP = {
/* /*
* Free port * Free port
*/ */
helper.mspQueue.freeHardLock(); mspQueue.freeHardLock();
console.log('Unknown state detected: ' + this.state); console.log('Unknown state detected: ' + this.state);
} }
} }
this.last_received_timestamp = Date.now(); this.last_received_timestamp = Date.now();
}, },
_initialize_read_buffer: function() { _initialize_read_buffer() {
this.message_buffer = new ArrayBuffer(this.message_length_expected); this.message_buffer = new ArrayBuffer(this.message_length_expected);
this.message_buffer_uint8_view = new Uint8Array(this.message_buffer); this.message_buffer_uint8_view = new Uint8Array(this.message_buffer);
}, },
_dispatch_message: function(expected_checksum) { _dispatch_message(expected_checksum) {
if (this.message_checksum == expected_checksum) { if (this.message_checksum == expected_checksum) {
// message received, process // message received, process
mspHelper.processData(this); this.processData(this);
} else { } else {
console.log('code: ' + this.code + ' - crc failed'); console.log('code: ' + this.code + ' - crc failed');
this.packet_error++; this.packet_error++;
@ -245,7 +262,7 @@ var MSP = {
/* /*
* Free port * Free port
*/ */
helper.mspQueue.freeHardLock(); mspQueue.freeHardLock();
// Reset variables // Reset variables
this.message_length_received = 0; this.message_length_received = 0;
@ -256,24 +273,24 @@ var MSP = {
* *
* @param {MSP} mspData * @param {MSP} mspData
*/ */
putCallback: function (mspData) { putCallback(mspData) {
MSP.callbacks.push(mspData); MSP.callbacks.push(mspData);
}, },
/** /**
* @param {number} code * @param {number} code
*/ */
removeCallback: function (code) { removeCallback(code) {
for (var i in this.callbacks) { for (var i in this.callbacks) {
if (this.callbacks.hasOwnProperty(i) && this.callbacks[i].code == code) { if (MSP.callbacks.hasOwnProperty(i) && this.callbacks[i].code == code) {
clearTimeout(this.callbacks[i].timer); clearTimeout(this.callbacks[i].timer);
this.callbacks.splice(i, 1); MSP.callbacks.splice(i, 1);
} }
} }
}, },
send_message: function (code, data, callback_sent, callback_msp, protocolVersion) { send_message(code, data, callback_sent, callback_msp, protocolVersion) {
var payloadLength = data && data.length ? data.length : 0; var payloadLength = data && data.length ? data.length : 0;
var length; var length;
var buffer; var buffer;
@ -343,11 +360,11 @@ var MSP = {
message.retryCounter = 10; message.retryCounter = 10;
} }
helper.mspQueue.put(message); mspQueue.put(message);
return true; return true;
}, },
_crc8_dvb_s2: function(crc, ch) { _crc8_dvb_s2(crc, ch) {
crc ^= ch; crc ^= ch;
for (var ii = 0; ii < 8; ++ii) { for (var ii = 0; ii < 8; ++ii) {
if (crc & 0x80) { if (crc & 0x80) {
@ -358,7 +375,7 @@ var MSP = {
} }
return crc; return crc;
}, },
promise: function(code, data, protocolVersion) { promise(code, data, protocolVersion) {
var self = this; var self = this;
return new Promise(function(resolve) { return new Promise(function(resolve) {
self.send_message(code, data, false, function(data) { self.send_message(code, data, false, function(data) {
@ -366,14 +383,14 @@ var MSP = {
}, protocolVersion); }, protocolVersion);
}); });
}, },
callbacks_cleanup: function () { callbacks_cleanup() {
for (var i = 0; i < this.callbacks.length; i++) { for (var i = 0; i < this.callbacks.length; i++) {
clearInterval(this.callbacks[i].timer); clearInterval(this.callbacks[i].timer);
} }
this.callbacks = []; this.callbacks = [];
}, },
disconnect_cleanup: function () { disconnect_cleanup() {
this.state = 0; // reset packet state for "clean" initial entry (this is only required if user hot-disconnects) this.state = 0; // reset packet state for "clean" initial entry (this is only required if user hot-disconnects)
this.packet_error = 0; // reset CRC packet error counter for next session this.packet_error = 0; // reset CRC packet error counter for next session
@ -381,8 +398,4 @@ var MSP = {
} }
}; };
MSP.SDCARD_STATE_NOT_PRESENT = 0; module.exports = MSP;
MSP.SDCARD_STATE_FATAL = 1;
MSP.SDCARD_STATE_CARD_INIT = 2;
MSP.SDCARD_STATE_FS_INIT = 3;
MSP.SDCARD_STATE_READY = 4;

View file

@ -249,3 +249,5 @@ var MSPCodes = {
MSP2_ADSB_VEHICLE_LIST: 0x2090, MSP2_ADSB_VEHICLE_LIST: 0x2090,
}; };
module.exports = MSPCodes;

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,4 @@
/*global $*/
'use strict'; 'use strict';
var MSPChainerClass = function () { var MSPChainerClass = function () {
@ -33,3 +33,5 @@ var MSPChainerClass = function () {
return self; return self;
}; };
module.exports = MSPChainerClass;

View file

@ -1,8 +1,9 @@
'use strict'; 'use strict';
var helper = helper || {}; const mspQueue = require('./serial_queue');
const interval = require('./intervals');
helper.mspBalancedInterval = (function (mspQueue, intervalHandler) { var mspBalancedInterval = (function (mspQueue, intervalHandler) {
var publicScope = {}, var publicScope = {},
privateScope = {}; privateScope = {};
@ -59,7 +60,7 @@ helper.mspBalancedInterval = (function (mspQueue, intervalHandler) {
}; };
/** /**
* Real interval cleaning happens win helper.interval.killAll method * Real interval cleaning happens win interval.killAll method
* both methods have to be executed * both methods have to be executed
*/ */
publicScope.flush = function () { publicScope.flush = function () {
@ -69,4 +70,6 @@ helper.mspBalancedInterval = (function (mspQueue, intervalHandler) {
setInterval(publicScope.balancer, Math.round(1000 / privateScope.balancingFrequency)); setInterval(publicScope.balancer, Math.round(1000 / privateScope.balancingFrequency));
return publicScope; return publicScope;
})(helper.mspQueue, helper.interval); })(mspQueue, interval);
module.exports = mspBalancedInterval;

View file

@ -1,7 +1,7 @@
/*global bit_check*/ /*global bit_check*/
'use strict'; 'use strict';
let OutputMappingCollection = function () { var OutputMappingCollection = function () {
let self = {}, let self = {},
data = [], data = [],
timerOverrides = {}; timerOverrides = {};
@ -177,3 +177,5 @@ let OutputMappingCollection = function () {
return self; return self;
} }
module.exports = OutputMappingCollection;

View file

@ -1,8 +1,13 @@
'use strict'; 'use strict';
var helper = helper || {}; const { GUI } = require('./gui');
const FC = require('./fc');
const CONFIGURATOR = require('./data_storage');
const MSP = require('./msp');
const MSPCodes = require('./msp/MSPCodes');
const mspQueue = require('./serial_queue');
helper.periodicStatusUpdater = (function () { var periodicStatusUpdater = (function () {
var publicScope = {}, var publicScope = {},
privateScope = {}; privateScope = {};
@ -50,16 +55,16 @@ helper.periodicStatusUpdater = (function () {
'background-image': 'url("./images/icons/cf_icon_failsafe_grey.svg")' 'background-image': 'url("./images/icons/cf_icon_failsafe_grey.svg")'
}); });
if (ANALOG != undefined) { if (FC.ANALOG != undefined) {
var nbCells; var nbCells;
nbCells = ANALOG.cell_count; nbCells = FC.ANALOG.cell_count;
var min = MISC.vbatmincellvoltage * nbCells; var min = FC.MISC.vbatmincellvoltage * nbCells;
var max = MISC.vbatmaxcellvoltage * nbCells; var max = FC.MISC.vbatmaxcellvoltage * nbCells;
var warn = MISC.vbatwarningcellvoltage * nbCells; var warn = FC.MISC.vbatwarningcellvoltage * nbCells;
$(".battery-status").css({ $(".battery-status").css({
width: ANALOG.battery_percentage + "%", width: FC.ANALOG.battery_percentage + "%",
display: 'inline-block' display: 'inline-block'
}); });
@ -73,13 +78,13 @@ helper.periodicStatusUpdater = (function () {
}); });
} }
if (((ANALOG.use_capacity_thresholds && ANALOG.battery_remaining_capacity <= MISC.battery_capacity_warning - MISC.battery_capacity_critical) || (!ANALOG.use_capacity_thresholds && ANALOG.voltage < warn)) || ANALOG.voltage < min) { if (((FC.ANALOG.use_capacity_thresholds && FC.ANALOG.battery_remaining_capacity <= FC.MISC.battery_capacity_warning - FC.MISC.battery_capacity_critical) || (!FC.ANALOG.use_capacity_thresholds && FC.ANALOG.voltage < warn)) || FC.ANALOG.voltage < min) {
$(".battery-status").css('background-color', '#D42133'); $(".battery-status").css('background-color', '#D42133');
} else { } else {
$(".battery-status").css('background-color', '#59AA29'); $(".battery-status").css('background-color', '#59AA29');
} }
$(".battery-legend").text(ANALOG.voltage + " V"); $(".battery-legend").text(FC.ANALOG.voltage + " V");
} }
$('#quad-status_wrapper').show(); $('#quad-status_wrapper').show();
@ -97,7 +102,7 @@ helper.periodicStatusUpdater = (function () {
if (GUI.active_tab != 'cli') { if (GUI.active_tab != 'cli') {
if (helper.mspQueue.shouldDropStatus()) { if (mspQueue.shouldDropStatus()) {
return; return;
} }
@ -112,3 +117,5 @@ helper.periodicStatusUpdater = (function () {
return publicScope; return publicScope;
})(); })();
module.exports = periodicStatusUpdater;

View file

@ -35,3 +35,5 @@ function adjustBoxNameIfPeripheralWithModeID(modeId, defaultName) {
return defaultName; return defaultName;
} }
module.exports = { isPeripheralSelected, adjustBoxNameIfPeripheralWithModeID };

View file

@ -1,8 +1,7 @@
'use strict'; 'use strict';
var classes = classes || {};
classes.PidController = function () { var PidController = function () {
var self = {}, var self = {},
privateScope = {}; privateScope = {};
@ -127,3 +126,5 @@ classes.PidController = function () {
return self; return self;
}; };
module.exports = PidController;

View file

@ -1,6 +1,10 @@
'use strict'; 'use strict';
const { ipcRenderer } = require('electron'); const Store = require('electron-store');
const store = new Store();
const { GUI } = require('./../js/gui');
const ConnectionSerial = require('./connection/connectionSerial');
var usbDevices = [ var usbDevices = [
{ 'vendorId': 1155, 'productId': 57105}, { 'vendorId': 1155, 'productId': 57105},
@ -50,7 +54,7 @@ PortHandler.check = function () {
if (GUI.connected_to) { if (GUI.connected_to) {
for (var i = 0; i < removed_ports.length; i++) { for (var i = 0; i < removed_ports.length; i++) {
if (removed_ports[i] == GUI.connected_to) { if (removed_ports[i] == GUI.connected_to) {
$('div#port-picker a.connect').click(); $('div#port-picker a.connect').trigger( "click" );
} }
} }
} }
@ -99,7 +103,7 @@ PortHandler.check = function () {
} }
if (store.get('wireless_mode_enabled', false)) { if (store.get('wireless_mode_enabled', false)) {
$('#wireless-mode').prop('checked', true).change(); $('#wireless-mode').prop('checked', true).trigger('change');
} }
} }
@ -292,3 +296,5 @@ PortHandler.flush_callbacks = function () {
return killed; return killed;
}; };
module.exports = { usbDevices, PortHandler };

View file

@ -140,16 +140,16 @@ let ProgrammingPid = function (enabled, setpointType, setpointValue, measurement
self.renderOperand(1); self.renderOperand(1);
$row.find(".pid_cell__p").html('<input type="number" class="pid_cell__p-gain" step="1" min="0" max="32767" value="0">'); $row.find(".pid_cell__p").html('<input type="number" class="pid_cell__p-gain" step="1" min="0" max="32767" value="0">');
$row.find(".pid_cell__p-gain").val(self.getGainP()).change(self.onGainPChange); $row.find(".pid_cell__p-gain").val(self.getGainP()).on('change', self.onGainPChange);
$row.find(".pid_cell__i").html('<input type="number" class="pid_cell__i-gain" step="1" min="0" max="32767" value="0">'); $row.find(".pid_cell__i").html('<input type="number" class="pid_cell__i-gain" step="1" min="0" max="32767" value="0">');
$row.find(".pid_cell__i-gain").val(self.getGainI()).change(self.onGainIChange); $row.find(".pid_cell__i-gain").val(self.getGainI()).on('change', self.onGainIChange);
$row.find(".pid_cell__d").html('<input type="number" class="pid_cell__d-gain" step="1" min="0" max="32767" value="0">'); $row.find(".pid_cell__d").html('<input type="number" class="pid_cell__d-gain" step="1" min="0" max="32767" value="0">');
$row.find(".pid_cell__d-gain").val(self.getGainD()).change(self.onGainDChange); $row.find(".pid_cell__d-gain").val(self.getGainD()).on('change', self.onGainDChange);
$row.find(".pid_cell__ff").html('<input type="number" class="pid_cell__ff-gain" step="1" min="0" max="32767" value="0">'); $row.find(".pid_cell__ff").html('<input type="number" class="pid_cell__ff-gain" step="1" min="0" max="32767" value="0">');
$row.find(".pid_cell__ff-gain").val(self.getGainFF()).change(self.onGainFFChange); $row.find(".pid_cell__ff-gain").val(self.getGainFF()).on('change', self.onGainFFChange);
} }
@ -208,7 +208,7 @@ let ProgrammingPid = function (enabled, setpointType, setpointValue, measurement
/* /*
* Bind events * Bind events
*/ */
$t.change(self.onOperatorTypeChange); $t.on('change', self.onOperatorTypeChange);
} }
@ -222,3 +222,5 @@ let ProgrammingPid = function (enabled, setpointType, setpointValue, measurement
return self; return self;
}; };
module.exports = ProgrammingPid;

View file

@ -1,6 +1,6 @@
'use strict'; 'use strict';
let ProgrammingPidCollection = function () { var ProgrammingPidCollection = function () {
let self = {}, let self = {},
data = [], data = [],
@ -56,3 +56,5 @@ let ProgrammingPidCollection = function () {
return self; return self;
}; };
module.exports = ProgrammingPidCollection;

View file

@ -1,6 +1,6 @@
'use strict'; 'use strict';
let ProgrammingPidStatus = function () { var ProgrammingPidStatus = function () {
let self = {}, let self = {},
data = []; data = [];
@ -31,3 +31,5 @@ let ProgrammingPidStatus = function () {
return self; return self;
}; };
module.exports = ProgrammingPidStatus;

View file

@ -7,6 +7,12 @@
*/ */
'use strict'; 'use strict';
const CONFIGURATOR = require('./../data_storage');
const { GUI } = require('./../gui');
const interval = require('./../intervals');
const { usbDevices, PortHandler } = require('./../port_handler');
const ConnectionSerial = require('./../connection/connectionSerial');
var STM32_protocol = function () { var STM32_protocol = function () {
this.baud; this.baud;
this.options = {}; this.options = {};
@ -81,7 +87,7 @@ STM32_protocol.prototype.connect = function (port, baud, hex, options, callback)
self.initialize(); self.initialize();
} else { } else {
GUI.log(localization.getMessage('failedToOpenSerialPort')); GUI.log(i18n.getMessage('failedToOpenSerialPort'));
} }
}); });
} else { } else {
@ -108,7 +114,7 @@ STM32_protocol.prototype.connect = function (port, baud, hex, options, callback)
retries++; retries++;
if (retries > maxRetries) { if (retries > maxRetries) {
clearInterval(interval); clearInterval(interval);
GUI.log(localization.getMessage('failedToFlash') + port); GUI.log(i18n.getMessage('failedToFlash') + port);
} }
} }
// Check for DFU devices // Check for DFU devices
@ -145,7 +151,7 @@ STM32_protocol.prototype.connect = function (port, baud, hex, options, callback)
}); });
}); });
} else { } else {
GUI.log(localization.getMessage('failedToOpenSerialPort')); GUI.log(i18n.getMessage('failedToOpenSerialPort'));
} }
}); });
} }
@ -170,11 +176,11 @@ STM32_protocol.prototype.initialize = function () {
// lock some UI elements TODO needs rework // lock some UI elements TODO needs rework
$('select[name="release"]').prop('disabled', true); $('select[name="release"]').prop('disabled', true);
CONFIGURATOR.connection.onReceive.addListener(function (info) { CONFIGURATOR.connection.addOnReceiveCallback(function (info) {
self.read(info); self.read(info);
}); });
helper.interval.add('STM32_timeout', function () { interval.add('STM32_timeout', function () {
if (self.upload_process_alive) { // process is running if (self.upload_process_alive) { // process is running
self.upload_process_alive = false; self.upload_process_alive = false;
} else { } else {
@ -185,7 +191,7 @@ STM32_protocol.prototype.initialize = function () {
// protocol got stuck, clear timer and disconnect // protocol got stuck, clear timer and disconnect
helper.interval.remove('STM32_timeout'); interval.remove('STM32_timeout');
// exit // exit
self.upload_procedure(99); self.upload_procedure(99);
@ -380,10 +386,10 @@ STM32_protocol.prototype.upload_procedure = function (step) {
$('span.progressLabel').text('Contacting bootloader ...'); $('span.progressLabel').text('Contacting bootloader ...');
var send_counter = 0; var send_counter = 0;
helper.interval.add('stm32_initialize_mcu', function () { // 200 ms interval (just in case mcu was already initialized), we need to break the 2 bytes command requirement interval.add('stm32_initialize_mcu', function () { // 200 ms interval (just in case mcu was already initialized), we need to break the 2 bytes command requirement
self.send([0x7F], 1, function (reply) { self.send([0x7F], 1, function (reply) {
if (reply[0] == 0x7F || reply[0] == self.status.ACK || reply[0] == self.status.NACK) { if (reply[0] == 0x7F || reply[0] == self.status.ACK || reply[0] == self.status.NACK) {
helper.interval.remove('stm32_initialize_mcu'); interval.remove('stm32_initialize_mcu');
console.log('STM32 - Serial interface initialized on the MCU side'); console.log('STM32 - Serial interface initialized on the MCU side');
// proceed to next step // proceed to next step
@ -392,7 +398,7 @@ STM32_protocol.prototype.upload_procedure = function (step) {
$('span.progressLabel').text('Communication with bootloader failed'); $('span.progressLabel').text('Communication with bootloader failed');
self.progress_bar_e.addClass('invalid'); self.progress_bar_e.addClass('invalid');
helper.interval.remove('stm32_initialize_mcu'); interval.remove('stm32_initialize_mcu');
// disconnect // disconnect
self.upload_procedure(99); self.upload_procedure(99);
@ -406,8 +412,8 @@ STM32_protocol.prototype.upload_procedure = function (step) {
$('span.progressLabel').text('No response from the bootloader, programming: FAILED'); $('span.progressLabel').text('No response from the bootloader, programming: FAILED');
self.progress_bar_e.addClass('invalid'); self.progress_bar_e.addClass('invalid');
helper.interval.remove('stm32_initialize_mcu'); interval.remove('stm32_initialize_mcu');
helper.interval.remove('STM32_timeout'); interval.remove('STM32_timeout');
// exit // exit
self.upload_procedure(99); self.upload_procedure(99);
@ -766,7 +772,7 @@ STM32_protocol.prototype.upload_procedure = function (step) {
break; break;
case 99: case 99:
// disconnect // disconnect
helper.interval.remove('STM32_timeout'); // stop STM32 timeout timer (everything is finished now) interval.remove('STM32_timeout'); // stop STM32 timeout timer (everything is finished now)
// close connection // close connection
CONFIGURATOR.connection.disconnect(function (result) { CONFIGURATOR.connection.disconnect(function (result) {
@ -790,3 +796,5 @@ STM32_protocol.prototype.upload_procedure = function (step) {
// initialize object // initialize object
var STM32 = new STM32_protocol(); var STM32 = new STM32_protocol();
module.exports = STM32;

View file

@ -12,6 +12,9 @@
*/ */
'use strict'; 'use strict';
const { GUI, TABS } = require('./../gui');
const i18n = require('./../localization');
var STM32DFU_protocol = function () { var STM32DFU_protocol = function () {
this.callback = null; this.callback = null;
this.hex = null; this.hex = null;
@ -106,7 +109,7 @@ STM32DFU_protocol.prototype.connect = function (usbDevices, hex, options, callba
self.openDevice(); self.openDevice();
} else { } else {
console.log('USB DFU not found'); console.log('USB DFU not found');
GUI.log(localization.getMessage('stm32UsbDfuNotFound')); GUI.log(i18n.getMessage('stm32UsbDfuNotFound'));
} }
}); });
@ -116,14 +119,14 @@ STM32DFU_protocol.prototype.openDevice = function () {
var self = this; var self = this;
self.usbDevice.open().then( () => { self.usbDevice.open().then( () => {
GUI.log(localization.getMessage('usbDeviceOpened')); GUI.log(i18n.getMessage('usbDeviceOpened'));
console.log('USB-Device opened'); console.log('USB-Device opened');
self.claimInterface(0); self.claimInterface(0);
}).catch(error => { }).catch(error => {
console.log('Failed to open USB device: ' + error); console.log('Failed to open USB device: ' + error);
GUI.log(localization.getMessage('usbDeviceOpenFail')); GUI.log(i18n.getMessage('usbDeviceOpenFail'));
if(GUI.operating_system === 'Linux') { if(GUI.operating_system === 'Linux') {
GUI.log(localization.getMessage('usbDeviceUdevNotice')); GUI.log(i18n.getMessage('usbDeviceUdevNotice'));
} }
}); });
}; };
@ -132,11 +135,11 @@ STM32DFU_protocol.prototype.closeDevice = function () {
var self = this; var self = this;
self.usbDevice.close().then(() => { self.usbDevice.close().then(() => {
GUI.log(localization.getMessage('usbDeviceClosed')); GUI.log(i18n.getMessage('usbDeviceClosed'));
console.log('USB-Device closed'); console.log('USB-Device closed');
}).catch(error => { }).catch(error => {
console.log('Failed to close USB device!'); console.log('Failed to close USB device!');
GUI.log(localization.getMessage('usbDeviceCloseFail')); GUI.log(i18n.getMessage('usbDeviceCloseFail'));
}); });
self.usbDevice = null; self.usbDevice = null;
@ -556,10 +559,10 @@ STM32DFU_protocol.prototype.upload_procedure = function (step) {
self.flash_layout = chipInfo.internal_flash; self.flash_layout = chipInfo.internal_flash;
self.available_flash_size = self.flash_layout.total_size - (self.hex.start_linear_address - self.flash_layout.start_address); self.available_flash_size = self.flash_layout.total_size - (self.hex.start_linear_address - self.flash_layout.start_address);
GUI.log(localization.getMessage('dfu_device_flash_info', (self.flash_layout.total_size / 1024).toString())); GUI.log(i18n.getMessage('dfu_device_flash_info', (self.flash_layout.total_size / 1024).toString()));
if (self.hex.bytes_total > self.available_flash_size) { if (self.hex.bytes_total > self.available_flash_size) {
GUI.log(localization.getMessage('dfu_error_image_size', GUI.log(i18n.getMessage('dfu_error_image_size',
[(self.hex.bytes_total / 1024.0).toFixed(1), [(self.hex.bytes_total / 1024.0).toFixed(1),
(self.available_flash_size / 1024.0).toFixed(1)])); (self.available_flash_size / 1024.0).toFixed(1)]));
self.cleanup(); self.cleanup();
@ -583,10 +586,10 @@ STM32DFU_protocol.prototype.upload_procedure = function (step) {
self.available_flash_size = firmware_partition_size; self.available_flash_size = firmware_partition_size;
GUI.log(localization.getMessage('dfu_device_flash_info', (self.flash_layout.total_size / 1024).toString())); GUI.log(i18n.getMessage('dfu_device_flash_info', (self.flash_layout.total_size / 1024).toString()));
if (self.hex.bytes_total > self.available_flash_size) { if (self.hex.bytes_total > self.available_flash_size) {
GUI.log(localization.getMessage('dfu_error_image_size', GUI.log(i18n.getMessage('dfu_error_image_size',
[(self.hex.bytes_total / 1024.0).toFixed(1), [(self.hex.bytes_total / 1024.0).toFixed(1),
(self.available_flash_size / 1024.0).toFixed(1)])); (self.available_flash_size / 1024.0).toFixed(1)]));
self.cleanup(); self.cleanup();
@ -619,7 +622,7 @@ STM32DFU_protocol.prototype.upload_procedure = function (step) {
var unprotect = function() { var unprotect = function() {
console.log('Initiate read unprotect'); console.log('Initiate read unprotect');
let messageReadProtected = localization.getMessage('stm32ReadProtected'); let messageReadProtected = i18n.getMessage('stm32ReadProtected');
GUI.log(messageReadProtected); GUI.log(messageReadProtected);
TABS.firmware_flasher.flashingMessage(messageReadProtected, TABS.firmware_flasher.FLASH_MESSAGE_TYPES.ACTION); TABS.firmware_flasher.flashingMessage(messageReadProtected, TABS.firmware_flasher.FLASH_MESSAGE_TYPES.ACTION);
@ -642,9 +645,9 @@ STM32DFU_protocol.prototype.upload_procedure = function (step) {
self.controlTransfer('in', self.request.GETSTATUS, 0, 0, 6, 0, function (data, error) { // should stall/disconnect self.controlTransfer('in', self.request.GETSTATUS, 0, 0, 6, 0, function (data, error) { // should stall/disconnect
if(error) { // we encounter an error, but this is expected. should be a stall. if(error) { // we encounter an error, but this is expected. should be a stall.
console.log('Unprotect memory command ran successfully. Unplug flight controller. Connect again in DFU mode and try flashing again.'); console.log('Unprotect memory command ran successfully. Unplug flight controller. Connect again in DFU mode and try flashing again.');
GUI.log(localization.getMessage('stm32UnprotectSuccessful')); GUI.log(i18n.getMessage('stm32UnprotectSuccessful'));
let messageUnprotectUnplug = localization.getMessage('stm32UnprotectUnplug'); let messageUnprotectUnplug = i18n.getMessage('stm32UnprotectUnplug');
GUI.log(messageUnprotectUnplug); GUI.log(messageUnprotectUnplug);
TABS.firmware_flasher.flashingMessage(messageUnprotectUnplug, TABS.firmware_flasher.FLASH_MESSAGE_TYPES.ACTION) TABS.firmware_flasher.flashingMessage(messageUnprotectUnplug, TABS.firmware_flasher.FLASH_MESSAGE_TYPES.ACTION)
@ -653,8 +656,8 @@ STM32DFU_protocol.prototype.upload_procedure = function (step) {
} else { // unprotecting the flight controller did not work. It did not reboot. } else { // unprotecting the flight controller did not work. It did not reboot.
console.log('Failed to execute unprotect memory command'); console.log('Failed to execute unprotect memory command');
GUI.log(localization.getMessage('stm32UnprotectFailed')); GUI.log(i18n.getMessage('stm32UnprotectFailed'));
TABS.firmware_flasher.flashingMessage(localization.getMessage('stm32UnprotectFailed'), TABS.firmware_flasher.FLASH_MESSAGE_TYPES.INVALID); TABS.firmware_flasher.flashingMessage(i18n.getMessage('stm32UnprotectFailed'), TABS.firmware_flasher.FLASH_MESSAGE_TYPES.INVALID);
console.log(data); console.log(data);
self.cleanup(); self.cleanup();
} }
@ -662,7 +665,7 @@ STM32DFU_protocol.prototype.upload_procedure = function (step) {
}, incr); }, incr);
} else { } else {
console.log('Failed to initiate unprotect memory command'); console.log('Failed to initiate unprotect memory command');
let messageUnprotectInitFailed = localization.getMessage('stm32UnprotectInitFailed'); let messageUnprotectInitFailed = i18n.getMessage('stm32UnprotectInitFailed');
GUI.log(messageUnprotectInitFailed); GUI.log(messageUnprotectInitFailed);
TABS.firmware_flasher.flashingMessage(messageUnprotectInitFailed, TABS.firmware_flasher.FLASH_MESSAGE_TYPES.INVALID); TABS.firmware_flasher.flashingMessage(messageUnprotectInitFailed, TABS.firmware_flasher.FLASH_MESSAGE_TYPES.INVALID);
self.cleanup(); self.cleanup();
@ -683,7 +686,7 @@ STM32DFU_protocol.prototype.upload_procedure = function (step) {
if (data[4] == self.state.dfuUPLOAD_IDLE && ob_data.length == self.chipInfo.option_bytes.total_size) { if (data[4] == self.state.dfuUPLOAD_IDLE && ob_data.length == self.chipInfo.option_bytes.total_size) {
console.log('Option bytes read successfully'); console.log('Option bytes read successfully');
console.log('Chip does not appear read protected'); console.log('Chip does not appear read protected');
GUI.log(localization.getMessage('stm32NotReadProtected')); GUI.log(i18n.getMessage('stm32NotReadProtected'));
// it is pretty safe to continue to erase flash // it is pretty safe to continue to erase flash
self.clearStatus(function() { self.clearStatus(function() {
self.upload_procedure(2); self.upload_procedure(2);
@ -732,14 +735,14 @@ STM32DFU_protocol.prototype.upload_procedure = function (step) {
// if address load fails with this specific error though, it is very likely bc of read protection // if address load fails with this specific error though, it is very likely bc of read protection
if(loadAddressResponse[4] == self.state.dfuERROR && loadAddressResponse[0] == self.status.errVENDOR) { if(loadAddressResponse[4] == self.state.dfuERROR && loadAddressResponse[0] == self.status.errVENDOR) {
// read protected // read protected
GUI.log(localization.getMessage('stm32AddressLoadFailed')); GUI.log(i18n.getMessage('stm32AddressLoadFailed'));
self.clearStatus(unprotect); self.clearStatus(unprotect);
return; return;
} else if(loadAddressResponse[4] == self.state.dfuDNLOAD_IDLE) { } else if(loadAddressResponse[4] == self.state.dfuDNLOAD_IDLE) {
console.log('Address load for option bytes sector succeeded.'); console.log('Address load for option bytes sector succeeded.');
self.clearStatus(tryReadOB); self.clearStatus(tryReadOB);
} else { } else {
GUI.log(localization.getMessage('stm32AddressLoadUnknown')); GUI.log(i18n.getMessage('stm32AddressLoadUnknown'));
self.cleanup(); self.cleanup();
} }
}; };
@ -781,13 +784,13 @@ STM32DFU_protocol.prototype.upload_procedure = function (step) {
if (erase_pages.length === 0) { if (erase_pages.length === 0) {
console.log('Aborting, No flash pages to erase'); console.log('Aborting, No flash pages to erase');
TABS.firmware_flasher.flashingMessage(localization.getMessage('stm32InvalidHex'), TABS.firmware_flasher.FLASH_MESSAGE_TYPES.INVALID); TABS.firmware_flasher.flashingMessage(i18n.getMessage('stm32InvalidHex'), TABS.firmware_flasher.FLASH_MESSAGE_TYPES.INVALID);
self.cleanup(); self.cleanup();
break; break;
} }
TABS.firmware_flasher.flashingMessage(localization.getMessage('stm32Erase'), TABS.firmware_flasher.FLASH_MESSAGE_TYPES.NEUTRAL); TABS.firmware_flasher.flashingMessage(i18n.getMessage('stm32Erase'), TABS.firmware_flasher.FLASH_MESSAGE_TYPES.NEUTRAL);
console.log('Executing local chip erase', erase_pages); console.log('Executing local chip erase', erase_pages);
var page = 0; var page = 0;
@ -799,7 +802,7 @@ STM32DFU_protocol.prototype.upload_procedure = function (step) {
if(page == erase_pages.length) { if(page == erase_pages.length) {
console.log("Erase: complete"); console.log("Erase: complete");
GUI.log(localization.getMessage('dfu_erased_kilobytes', (total_erased / 1024).toString())); GUI.log(i18n.getMessage('dfu_erased_kilobytes', (total_erased / 1024).toString()));
self.upload_procedure(4); self.upload_procedure(4);
} else { } else {
erase_page(); erase_page();
@ -869,7 +872,7 @@ STM32DFU_protocol.prototype.upload_procedure = function (step) {
// upload // upload
// we dont need to clear the state as we are already using DFU_DNLOAD // we dont need to clear the state as we are already using DFU_DNLOAD
console.log('Writing data ...'); console.log('Writing data ...');
TABS.firmware_flasher.flashingMessage(localization.getMessage('stm32Flashing'), TABS.firmware_flasher.FLASH_MESSAGE_TYPES.NEUTRAL); TABS.firmware_flasher.flashingMessage(i18n.getMessage('stm32Flashing'), TABS.firmware_flasher.FLASH_MESSAGE_TYPES.NEUTRAL);
var blocks = self.hex.data.length - 1; var blocks = self.hex.data.length - 1;
var flashing_block = 0; var flashing_block = 0;
@ -941,7 +944,7 @@ STM32DFU_protocol.prototype.upload_procedure = function (step) {
case 5: case 5:
// verify // verify
console.log('Verifying data ...'); console.log('Verifying data ...');
TABS.firmware_flasher.flashingMessage(localization.getMessage('stm32Verifying'), TABS.firmware_flasher.FLASH_MESSAGE_TYPES.NEUTRAL); TABS.firmware_flasher.flashingMessage(i18n.getMessage('stm32Verifying'), TABS.firmware_flasher.FLASH_MESSAGE_TYPES.NEUTRAL);
var blocks = self.hex.data.length - 1; var blocks = self.hex.data.length - 1;
var reading_block = 0; var reading_block = 0;
@ -1009,14 +1012,14 @@ STM32DFU_protocol.prototype.upload_procedure = function (step) {
if (verify) { if (verify) {
console.log('Programming: SUCCESSFUL'); console.log('Programming: SUCCESSFUL');
// update progress bar // update progress bar
TABS.firmware_flasher.flashingMessage(localization.getMessage('stm32ProgrammingSuccessful'), TABS.firmware_flasher.FLASH_MESSAGE_TYPES.VALID); TABS.firmware_flasher.flashingMessage(i18n.getMessage('stm32ProgrammingSuccessful'), TABS.firmware_flasher.FLASH_MESSAGE_TYPES.VALID);
// proceed to next step // proceed to next step
self.leave(); self.leave();
} else { } else {
console.log('Programming: FAILED'); console.log('Programming: FAILED');
// update progress bar // update progress bar
TABS.firmware_flasher.flashingMessage(localization.getMessage('stm32ProgrammingFailed'), TABS.firmware_flasher.FLASH_MESSAGE_TYPES.INVALID); TABS.firmware_flasher.flashingMessage(i18n.getMessage('stm32ProgrammingFailed'), TABS.firmware_flasher.FLASH_MESSAGE_TYPES.INVALID);
// disconnect // disconnect
self.cleanup(); self.cleanup();
@ -1071,3 +1074,4 @@ STM32DFU_protocol.prototype.cleanup = function () {
// initialize object // initialize object
var STM32DFU = new STM32DFU_protocol(); var STM32DFU = new STM32DFU_protocol();
module.exports = STM32DFU;

View file

@ -1,8 +1,7 @@
/*global $*/ /*global $*/
'use strict'; 'use strict';
var Safehome = function (number, enabled, lat, lon) {
let Safehome = function (number, enabled, lat, lon) {
var self = {}; var self = {};
@ -59,3 +58,5 @@ let Safehome = function (number, enabled, lat, lon) {
return self; return self;
}; };
module.exports = Safehome;

View file

@ -1,6 +1,6 @@
'use strict'; 'use strict';
let SafehomeCollection = function () { var SafehomeCollection = function () {
let self = {}, let self = {},
data = [], data = [],
@ -128,3 +128,5 @@ let SafehomeCollection = function () {
return self; return self;
}; };
module.exports = SafehomeCollection;

View file

@ -1,23 +1,53 @@
/*global chrome*/
'use strict'; 'use strict';
$(document).ready(function () { const semver = require('semver');
const Store = require('electron-store');
const store = new Store();
var $port = $('#port'), const { GUI, TABS } = require('./gui');
$baud = $('#baud'), const MSP = require('./msp');
$portOverride = $('#port-override'), const FC = require('./fc');
isDemoRunning = false; const MSPCodes = require('./msp/MSPCodes');
const mspHelper = require('./msp/MSPHelper');
const { ConnectionType, Connection } = require('./connection/connection');
const connectionFactory = require('./connection/connectionFactory');
const CONFIGURATOR = require('./data_storage');
const { PortHandler } = require('./port_handler');
const i18n = require('./../js/localization');
const interval = require('./intervals');
const periodicStatusUpdater = require('./periodicStatusUpdater');
const mspQueue = require('./serial_queue');
const timeout = require('./timeouts');
const mspBalancedInterval = require('./msp_balanced_interval');
const defaultsDialog = require('./defaults_dialog');
const { SITLProcess } = require('./sitl');
const update = require('./globalUpdates.js');
const BitHelper = require('./bitHelper.js');
var SerialBackend = (function () {
var publicScope = {},
privateScope = {};
privateScope.isDemoRunning = false;
/* /*
* Handle "Wireless" mode with strict queueing of messages * Handle "Wireless" mode with strict queueing of messages
*/ */
$('#wireless-mode').change(function () { publicScope.init = function() {
privateScope.$port = $('#port'),
privateScope.$baud = $('#baud'),
publicScope.$portOverride = $('#port-override'),
mspHelper.setSensorStatusEx(privateScope.sensor_status_ex);
$('#wireless-mode').on('change', function () {
var $this = $(this); var $this = $(this);
if ($this.is(':checked')) { if ($this.is(':checked')) {
helper.mspQueue.setLockMethod('hard'); mspQueue.setLockMethod('hard');
} else { } else {
helper.mspQueue.setLockMethod('soft'); mspQueue.setLockMethod('soft');
} }
}); });
@ -25,7 +55,7 @@ $(document).ready(function () {
let modal; let modal;
if (BOARD.hasVcp(CONFIG.boardIdentifier)) { // VCP-based flight controls may crash old drivers, we catch and reconnect if (BOARD.hasVcp(FC.CONFIG.boardIdentifier)) { // VCP-based flight controls may crash old drivers, we catch and reconnect
modal = new jBox('Modal', { modal = new jBox('Modal', {
width: 400, width: 400,
@ -40,7 +70,7 @@ $(document).ready(function () {
Disconnect Disconnect
*/ */
setTimeout(function () { setTimeout(function () {
$('a.connect').click(); $('a.connect').trigger( "click" );
}, 100); }, 100);
/* /*
@ -48,24 +78,24 @@ $(document).ready(function () {
*/ */
setTimeout(function start_connection() { setTimeout(function start_connection() {
modal.close(); modal.close();
$('a.connect').click(); $('a.connect').trigger( "click" );
/* /*
Open configuration tab Open configuration tab
*/ */
if ($tabElement != null) { if ($tabElement != null) {
setTimeout(function () { setTimeout(function () {
$tabElement.click(); $tabElement.trigger( "click" );
}, 500); }, 500);
} }
}, 7000); }, 7000);
} else { } else {
helper.timeout.add('waiting_for_bootup', function waiting_for_bootup() { timeout.add('waiting_for_bootup', function waiting_for_bootup() {
MSP.send_message(MSPCodes.MSPV2_INAV_STATUS, false, false, function () { MSP.send_message(MSPCodes.MSPV2_INAV_STATUS, false, false, function () {
//noinspection JSUnresolvedVariable //noinspection JSUnresolvedVariable
GUI.log(localization.getMessage('deviceReady')); GUI.log(i18n.getMessage('deviceReady'));
//noinspection JSValidateTypes //noinspection JSValidateTypes
TABS.configuration.initialize(false, $('#content').scrollTop()); TABS.configuration.initialize(false, $('#content').scrollTop());
}); });
@ -76,7 +106,7 @@ $(document).ready(function () {
GUI.updateManualPortVisibility = function(){ GUI.updateManualPortVisibility = function(){
var selected_port = $port.find('option:selected'); var selected_port = privateScope.$port.find('option:selected');
if (selected_port.data().isManual || selected_port.data().isTcp || selected_port.data().isUdp) { if (selected_port.data().isManual || selected_port.data().isTcp || selected_port.data().isUdp) {
$('#port-override-option').show(); $('#port-override-option').show();
} }
@ -91,10 +121,10 @@ $(document).ready(function () {
} }
if (selected_port.data().isDFU || selected_port.data().isBle || selected_port.data().isTcp || selected_port.data().isUdp || selected_port.data().isSitl) { if (selected_port.data().isDFU || selected_port.data().isBle || selected_port.data().isTcp || selected_port.data().isUdp || selected_port.data().isSitl) {
$baud.hide(); privateScope.$baud.hide();
} }
else { else {
$baud.show(); privateScope.$baud.show();
} }
if (selected_port.data().isBle || selected_port.data().isTcp || selected_port.data().isUdp || selected_port.data().isSitl) { if (selected_port.data().isBle || selected_port.data().isTcp || selected_port.data().isUdp || selected_port.data().isSitl) {
@ -110,34 +140,34 @@ $(document).ready(function () {
} else if (selected_port.data().isUdp) { } else if (selected_port.data().isUdp) {
type = ConnectionType.UDP; type = ConnectionType.UDP;
} }
CONFIGURATOR.connection = Connection.create(type); CONFIGURATOR.connection = connectionFactory(type, CONFIGURATOR.connection);
}; };
GUI.updateManualPortVisibility(); GUI.updateManualPortVisibility();
$portOverride.change(function () { publicScope.$portOverride.on('change', function () {
store.set('portOverride', $portOverride.val()); store.set('portOverride', privateScope.$portOverride.val());
}); });
$portOverride.val(store.get('portOverride', '')); publicScope.$portOverride.val(store.get('portOverride', ''));
$port.change(function (target) { privateScope.$port.on('change', function (target) {
GUI.updateManualPortVisibility(); GUI.updateManualPortVisibility();
}); });
$('div.connect_controls a.connect').click(function () { $('div.connect_controls a.connect').on('click', function () {
if (GUI.connect_lock != true) { // GUI control overrides the user control if (GUI.connect_lock != true) { // GUI control overrides the user control
var clicks = $(this).data('clicks'); var clicks = $(this).data('clicks');
var selected_baud = parseInt($baud.val()); var selected_baud = parseInt(privateScope.$baud.val());
var selected_port = $port.find('option:selected').data().isManual ? var selected_port = privateScope.$port.find('option:selected').data().isManual ?
$portOverride.val() : publicScope.$portOverride.val() :
String($port.val()); String(privateScope.$port.val());
if (selected_port === 'DFU') { if (selected_port === 'DFU') {
GUI.log(localization.getMessage('dfu_connect_message')); GUI.log(i18n.getMessage('dfu_connect_message'));
} }
else if (selected_port != '0') { else if (selected_port != '0') {
if (!clicks) { if (!clicks) {
@ -146,21 +176,25 @@ $(document).ready(function () {
// lock port select & baud while we are connecting / connected // lock port select & baud while we are connecting / connected
$('#port, #baud, #delay').prop('disabled', true); $('#port, #baud, #delay').prop('disabled', true);
$('div.connect_controls a.connect_state').text(localization.getMessage('connecting')); $('div.connect_controls a.connect_state').text(i18n.getMessage('connecting'));
if (selected_port == 'tcp' || selected_port == 'udp') { if (selected_port == 'tcp' || selected_port == 'udp') {
CONFIGURATOR.connection.connect($portOverride.val(), {}, onOpen); CONFIGURATOR.connection.connect(publicScope.$portOverride.val(), {}, privateScope.onOpen);
} else if (selected_port == 'sitl') { } else if (selected_port == 'sitl') {
CONFIGURATOR.connection.connect("127.0.0.1:5760", {}, onOpen); CONFIGURATOR.connection.connect("127.0.0.1:5760", {}, privateScope.onOpen);
} else if (selected_port == 'sitl-demo') { } else if (selected_port == 'sitl-demo') {
if (SITLProcess.isRunning) { if (SITLProcess.isRunning) {
SITLProcess.stop(); SITLProcess.stop();
} }
SITLProcess.start("demo.bin"); SITLProcess.start("demo.bin"), 1000;
this.isDemoRunning = true; this.isDemoRunning = true;
CONFIGURATOR.connection.connect("127.0.0.1:5760", {}, onOpen);
// Wait 1 sec until SITL is ready
setTimeout(() => {
CONFIGURATOR.connection.connect("127.0.0.1:5760", {}, privateScope.onOpen);
}, 1000);
} else { } else {
CONFIGURATOR.connection.connect(selected_port, {bitrate: selected_baud}, onOpen); CONFIGURATOR.connection.connect(selected_port, {bitrate: selected_baud}, privateScope.onOpen);
} }
} else { } else {
if (this.isDemoRunning) { if (this.isDemoRunning) {
@ -170,9 +204,9 @@ $(document).ready(function () {
var wasConnected = CONFIGURATOR.connectionValid; var wasConnected = CONFIGURATOR.connectionValid;
helper.timeout.killAll(); timeout.killAll();
helper.interval.killAll(['global_data_refresh', 'msp-load-update']); interval.killAll(['global_data_refresh', 'msp-load-update']);
helper.mspBalancedInterval.flush(); mspBalancedInterval.flush();
if (CONFIGURATOR.cliActive) { if (CONFIGURATOR.cliActive) {
GUI.tab_switch_cleanup(finishDisconnect); GUI.tab_switch_cleanup(finishDisconnect);
@ -191,11 +225,11 @@ $(document).ready(function () {
/* /*
* Flush * Flush
*/ */
helper.mspQueue.flush(); mspQueue.flush();
helper.mspQueue.freeHardLock(); mspQueue.freeHardLock();
helper.mspQueue.freeSoftLock(); mspQueue.freeSoftLock();
CONFIGURATOR.connection.disconnect(onClosed); CONFIGURATOR.connection.disconnect(privateScope.onClosed);
MSP.disconnect_cleanup(); MSP.disconnect_cleanup();
// Reset various UI elements // Reset various UI elements
@ -204,22 +238,22 @@ $(document).ready(function () {
$('span.cpu-load').text(''); $('span.cpu-load').text('');
// unlock port select & baud // unlock port select & baud
$port.prop('disabled', false); privateScope.$port.prop('disabled', false);
$baud.prop('disabled', false); privateScope.$baud.prop('disabled', false);
// reset connect / disconnect button // reset connect / disconnect button
$('div.connect_controls a.connect').removeClass('active'); $('div.connect_controls a.connect').removeClass('active');
$('div.connect_controls a.connect_state').text(localization.getMessage('connect')); $('div.connect_controls a.connect_state').text(i18n.getMessage('connect'));
// reset active sensor indicators // reset active sensor indicators
sensor_status(0); privateScope.sensor_status(0);
if (wasConnected) { if (wasConnected) {
// detach listeners and remove element data // detach listeners and remove element data
$('#content').empty(); $('#content').empty();
} }
$('#tabs .tab_landing a').click(); $('#tabs .tab_landing a').trigger( "click" );
} }
} }
@ -229,67 +263,67 @@ $(document).ready(function () {
}); });
PortHandler.initialize(); PortHandler.initialize();
}); }
function onValidFirmware() privateScope.onValidFirmware = function ()
{ {
MSP.send_message(MSPCodes.MSP_BUILD_INFO, false, false, function () { MSP.send_message(MSPCodes.MSP_BUILD_INFO, false, false, function () {
GUI.log(localization.getMessage('buildInfoReceived', [CONFIG.buildInfo])); GUI.log(i18n.getMessage('buildInfoReceived', [FC.CONFIG.buildInfo]));
MSP.send_message(MSPCodes.MSP_BOARD_INFO, false, false, function () { MSP.send_message(MSPCodes.MSP_BOARD_INFO, false, false, function () {
GUI.log(localization.getMessage('boardInfoReceived', [CONFIG.boardIdentifier, CONFIG.boardVersion])); GUI.log(i18n.getMessage('boardInfoReceived', [FC.CONFIG.boardIdentifier, FC.CONFIG.boardVersion]));
MSP.send_message(MSPCodes.MSP_UID, false, false, function () { MSP.send_message(MSPCodes.MSP_UID, false, false, function () {
GUI.log(localization.getMessage('uniqueDeviceIdReceived', [CONFIG.uid[0].toString(16) + CONFIG.uid[1].toString(16) + CONFIG.uid[2].toString(16)])); GUI.log(i18n.getMessage('uniqueDeviceIdReceived', [FC.CONFIG.uid[0].toString(16) + FC.CONFIG.uid[1].toString(16) + FC.CONFIG.uid[2].toString(16)]));
// continue as usually // continue as usually
CONFIGURATOR.connectionValid = true; CONFIGURATOR.connectionValid = true;
GUI.allowedTabs = GUI.defaultAllowedTabsWhenConnected.slice(); GUI.allowedTabs = GUI.defaultAllowedTabsWhenConnected.slice();
onConnect(); privateScope.onConnect();
helper.defaultsDialog.init(); defaultsDialog.init();
$('#tabs ul.mode-connected .tab_setup a').click(); $('#tabs ul.mode-connected .tab_setup a').trigger( "click" );
updateEzTuneTabVisibility(true); GUI.updateEzTuneTabVisibility(true);
updateFirmwareVersion(); update.firmwareVersion();
}); });
}); });
}); });
} }
function onInvalidFirmwareVariant() privateScope.onInvalidFirmwareVariant = function ()
{ {
GUI.log(localization.getMessage('firmwareVariantNotSupported')); GUI.log(i18n.getMessage('firmwareVariantNotSupported'));
CONFIGURATOR.connectionValid = true; // making it possible to open the CLI tab CONFIGURATOR.connectionValid = true; // making it possible to open the CLI tab
GUI.allowedTabs = ['cli']; GUI.allowedTabs = ['cli'];
onConnect(); privateScope.onConnect();
$('#tabs .tab_cli a').click(); $('#tabs .tab_cli a').trigger( "click" );
} }
function onInvalidFirmwareVersion() privateScope.onInvalidFirmwareVersion = function ()
{ {
GUI.log(localization.getMessage('firmwareVersionNotSupported', [CONFIGURATOR.minfirmwareVersionAccepted, CONFIGURATOR.maxFirmwareVersionAccepted])); GUI.log(i18n.getMessage('firmwareVersionNotSupported', [CONFIGURATOR.minfirmwareVersionAccepted, CONFIGURATOR.maxFirmwareVersionAccepted]));
CONFIGURATOR.connectionValid = true; // making it possible to open the CLI tab CONFIGURATOR.connectionValid = true; // making it possible to open the CLI tab
GUI.allowedTabs = ['cli']; GUI.allowedTabs = ['cli'];
onConnect(); privateScope.onConnect();
$('#tabs .tab_cli a').click(); $('#tabs .tab_cli a').trigger( "click" );
} }
function onBleNotSupported() { privateScope.onBleNotSupported = function () {
GUI.log(localization.getMessage('connectionBleNotSupported')); GUI.log(i18n.getMessage('connectionBleNotSupported'));
CONFIGURATOR.connection.abort(); CONFIGURATOR.connection.abort();
} }
function onOpen(openInfo) { privateScope.onOpen = function (openInfo) {
if (FC.restartRequired) { if (FC.restartRequired) {
GUI_control.prototype.log("<span style='color: red; font-weight: bolder'><strong>" + localization.getMessage("illegalStateRestartRequired") + "</strong></span>"); GUI_control.prototype.log("<span style='color: red; font-weight: bolder'><strong>" + i18n.getMessage("illegalStateRestartRequired") + "</strong></span>");
$('div.connect_controls a').click(); // disconnect $('div.connect_controls a').trigger( "click" ); // disconnect
return; return;
} }
@ -300,7 +334,7 @@ function onOpen(openInfo) {
// reset connecting_to // reset connecting_to
GUI.connecting_to = false; GUI.connecting_to = false;
GUI.log(localization.getMessage('serialPortOpened', [openInfo.connectionId])); GUI.log(i18n.getMessage('serialPortOpened', [openInfo.connectionId]));
// save selected port if the port differs // save selected port if the port differs
var last_used_port = store.get('last_used_port', false); var last_used_port = store.get('last_used_port', false);
@ -318,20 +352,20 @@ function onOpen(openInfo) {
store.set('last_used_bps', CONFIGURATOR.connection.bitrate); store.set('last_used_bps', CONFIGURATOR.connection.bitrate);
store.set('wireless_mode_enabled', $('#wireless-mode').is(":checked")); store.set('wireless_mode_enabled', $('#wireless-mode').is(":checked"));
CONFIGURATOR.connection.addOnReceiveListener(read_serial); CONFIGURATOR.connection.addOnReceiveListener(publicScope.read_serial);
/* /*
// disconnect after 10 seconds with error if we don't get IDENT data // disconnect after 10 seconds with error if we don't get IDENT data
helper.timeout.add('connecting', function () { timeout.add('connecting', function () {
if (!CONFIGURATOR.connectionValid) { if (!CONFIGURATOR.connectionValid) {
GUI.log(localization.getMessage('noConfigurationReceived')); GUI.log(i18n.getMessage('noConfigurationReceived'));
helper.mspQueue.flush(); mspQueue.flush();
helper.mspQueue.freeHardLock(); mspQueue.freeHardLock();
helper.mspQueue.freeSoftLock(); mspQueue.freeSoftLock();
CONFIGURATOR.connection.emptyOutputBuffer(); CONFIGURATOR.connection.emptyOutputBuffer();
$('div.connect_controls a').click(); // disconnect $('div.connect_controls a').trigger( "click" ); // disconnect
} }
}, 10000); }, 10000);
*/ */
@ -343,46 +377,46 @@ function onOpen(openInfo) {
MSP.protocolVersion = MSP.constants.PROTOCOL_V2; MSP.protocolVersion = MSP.constants.PROTOCOL_V2;
MSP.send_message(MSPCodes.MSP_API_VERSION, false, false, function () { MSP.send_message(MSPCodes.MSP_API_VERSION, false, false, function () {
if (CONFIG.apiVersion === "0.0.0") { if (FC.CONFIG.apiVersion === "0.0.0") {
GUI_control.prototype.log("<span style='color: red; font-weight: bolder'><strong>" + localization.getMessage("illegalStateRestartRequired") + "</strong></span>"); GUI_control.prototype.log("<span style='color: red; font-weight: bolder'><strong>" + i18n.getMessage("illegalStateRestartRequired") + "</strong></span>");
FC.restartRequired = true; FC.restartRequired = true;
return; return;
} }
GUI.log(localization.getMessage('apiVersionReceived', [CONFIG.apiVersion])); GUI.log(i18n.getMessage('apiVersionReceived', [FC.CONFIG.apiVersion]));
MSP.send_message(MSPCodes.MSP_FC_VARIANT, false, false, function () { MSP.send_message(MSPCodes.MSP_FC_VARIANT, false, false, function () {
if (CONFIG.flightControllerIdentifier == 'INAV') { if (FC.CONFIG.flightControllerIdentifier == 'INAV') {
MSP.send_message(MSPCodes.MSP_FC_VERSION, false, false, function () { MSP.send_message(MSPCodes.MSP_FC_VERSION, false, false, function () {
GUI.log(localization.getMessage('fcInfoReceived', [CONFIG.flightControllerIdentifier, CONFIG.flightControllerVersion])); GUI.log(i18n.getMessage('fcInfoReceived', [FC.CONFIG.flightControllerIdentifier, FC.CONFIG.flightControllerVersion]));
if (semver.gte(CONFIG.flightControllerVersion, CONFIGURATOR.minfirmwareVersionAccepted) && semver.lt(CONFIG.flightControllerVersion, CONFIGURATOR.maxFirmwareVersionAccepted)) { if (semver.gte(FC.CONFIG.flightControllerVersion, CONFIGURATOR.minfirmwareVersionAccepted) && semver.lt(FC.CONFIG.flightControllerVersion, CONFIGURATOR.maxFirmwareVersionAccepted)) {
if (CONFIGURATOR.connection.type == ConnectionType.BLE && semver.lt(CONFIG.flightControllerVersion, "5.0.0")) { if (CONFIGURATOR.connection.type == ConnectionType.BLE && semver.lt(FC.CONFIG.flightControllerVersion, "5.0.0")) {
onBleNotSupported(); privateScope.onBleNotSupported();
} else { } else {
mspHelper.getCraftName(function(name) { mspHelper.getCraftName(function(name) {
if (name) { if (name) {
CONFIG.name = name; FC.CONFIG.name = name;
} }
onValidFirmware(); privateScope.onValidFirmware();
}); });
} }
} else { } else {
onInvalidFirmwareVersion(); privateScope.onInvalidFirmwareVersion();
} }
}); });
} else { } else {
onInvalidFirmwareVariant(); privateScope.onInvalidFirmwareVariant();
} }
}); });
}); });
} else { } else {
console.log('Failed to open serial port'); console.log('Failed to open serial port');
GUI.log(localization.getMessage('serialPortOpenFail')); GUI.log(i18n.getMessage('serialPortOpenFail'));
var $connectButton = $('#connectbutton'); var $connectButton = $('#connectbutton');
$connectButton.find('.connect_state').text(localization.getMessage('connect')); $connectButton.find('.connect_state').text(i18n.getMessage('connect'));
$connectButton.find('.connect').removeClass('active'); $connectButton.find('.connect').removeClass('active');
// unlock port select & baud // unlock port select & baud
@ -391,11 +425,11 @@ function onOpen(openInfo) {
// reset data // reset data
$connectButton.find('.connect').data("clicks", false); $connectButton.find('.connect').data("clicks", false);
} }
} }
function onConnect() { privateScope.onConnect = function () {
helper.timeout.remove('connecting'); // kill connecting timer timeout.remove('connecting'); // kill connecting timer
$('#connectbutton a.connect_state').text(localization.getMessage('disconnect')).addClass('active'); $('#connectbutton a.connect_state').text(i18n.getMessage('disconnect')).addClass('active');
$('#connectbutton a.connect').addClass('active'); $('#connectbutton a.connect').addClass('active');
$('.mode-disconnected').hide(); $('.mode-disconnected').hide();
$('.mode-connected').show(); $('.mode-connected').show();
@ -417,25 +451,25 @@ function onConnect() {
let pidCount = 11; let pidCount = 11;
for (let i = 0; i < pidCount; i++) { for (let i = 0; i < pidCount; i++) {
PIDs.push(new Array(4)); FC.PIDs.push(new Array(4));
} }
helper.interval.add('msp-load-update', function () { interval.add('msp-load-update', function () {
$('#msp-version').text("MSP version: " + MSP.protocolVersion.toFixed(0)); $('#msp-version').text("MSP version: " + MSP.protocolVersion.toFixed(0));
$('#msp-load').text("MSP load: " + helper.mspQueue.getLoad().toFixed(1)); $('#msp-load').text("MSP load: " + mspQueue.getLoad().toFixed(1));
$('#msp-roundtrip').text("MSP round trip: " + helper.mspQueue.getRoundtrip().toFixed(0)); $('#msp-roundtrip').text("MSP round trip: " + mspQueue.getRoundtrip().toFixed(0));
$('#hardware-roundtrip').text("HW round trip: " + helper.mspQueue.getHardwareRoundtrip().toFixed(0)); $('#hardware-roundtrip').text("HW round trip: " + mspQueue.getHardwareRoundtrip().toFixed(0));
$('#drop-rate').text("Drop ratio: " + helper.mspQueue.getDropRatio().toFixed(0) + "%"); $('#drop-rate').text("Drop ratio: " + mspQueue.getDropRatio().toFixed(0) + "%");
}, 100); }, 100);
helper.interval.add('global_data_refresh', helper.periodicStatusUpdater.run, helper.periodicStatusUpdater.getUpdateInterval(CONFIGURATOR.connection.bitrate), false); interval.add('global_data_refresh', periodicStatusUpdater.run, periodicStatusUpdater.getUpdateInterval(CONFIGURATOR.connection.bitrate), false);
} }
function onClosed(result) { privateScope.onClosed = function (result) {
if (result) { // All went as expected if (result) { // All went as expected
GUI.log(localization.getMessage('serialPortClosedOk')); GUI.log(i18n.getMessage('serialPortClosedOk'));
} else { // Something went wrong } else { // Something went wrong
GUI.log(localization.getMessage('serialPortClosedFail')); GUI.log(i18n.getMessage('serialPortClosedFail'));
} }
$('.mode-connected').hide(); $('.mode-connected').hide();
@ -447,42 +481,42 @@ function onClosed(result) {
$('#quad-status_wrapper').hide(); $('#quad-status_wrapper').hide();
updateFirmwareVersion(); updateFirmwareVersion();
} }
function read_serial(info) { publicScope.read_serial = function (info) {
if (!CONFIGURATOR.cliActive) { if (!CONFIGURATOR.cliActive) {
MSP.read(info); MSP.read(info);
} else if (CONFIGURATOR.cliActive) { } else if (CONFIGURATOR.cliActive) {
TABS.cli.read(info); TABS.cli.read(info);
} }
} }
/** /**
* Sensor handler used in INAV >= 1.5 * Sensor handler used in INAV >= 1.5
* @param hw_status * @param hw_status
*/ */
function sensor_status_ex(hw_status) privateScope.sensor_status_ex = function (hw_status)
{ {
var statusHash = sensor_status_hash(hw_status); var statusHash = privateScope.sensor_status_hash(hw_status);
if (sensor_status_ex.previousHash == statusHash) { if (privateScope.sensor_status_ex.previousHash == statusHash) {
return; return;
} }
sensor_status_ex.previousHash = statusHash; privateScope.sensor_status_ex.previousHash = statusHash;
sensor_status_update_icon('.gyro', '.gyroicon', hw_status.gyroHwStatus); privateScope.sensor_status_update_icon('.gyro', '.gyroicon', hw_status.gyroHwStatus);
sensor_status_update_icon('.accel', '.accicon', hw_status.accHwStatus); privateScope.sensor_status_update_icon('.accel', '.accicon', hw_status.accHwStatus);
sensor_status_update_icon('.mag', '.magicon', hw_status.magHwStatus); privateScope.sensor_status_update_icon('.mag', '.magicon', hw_status.magHwStatus);
sensor_status_update_icon('.baro', '.baroicon', hw_status.baroHwStatus); privateScope.sensor_status_update_icon('.baro', '.baroicon', hw_status.baroHwStatus);
sensor_status_update_icon('.gps', '.gpsicon', hw_status.gpsHwStatus); privateScope.sensor_status_update_icon('.gps', '.gpsicon', hw_status.gpsHwStatus);
sensor_status_update_icon('.sonar', '.sonaricon', hw_status.rangeHwStatus); privateScope.sensor_status_update_icon('.sonar', '.sonaricon', hw_status.rangeHwStatus);
sensor_status_update_icon('.airspeed', '.airspeedicon', hw_status.speedHwStatus); privateScope.sensor_status_update_icon('.airspeed', '.airspeedicon', hw_status.speedHwStatus);
sensor_status_update_icon('.opflow', '.opflowicon', hw_status.flowHwStatus); privateScope.sensor_status_update_icon('.opflow', '.opflowicon', hw_status.flowHwStatus);
} }
function sensor_status_update_icon(sensId, sensIconId, status) privateScope.sensor_status_update_icon = function (sensId, sensIconId, status)
{ {
var e_sensor_status = $('#sensor-status'); var e_sensor_status = $('#sensor-status');
if (status == 0) { if (status == 0) {
@ -500,10 +534,10 @@ function sensor_status_update_icon(sensId, sensIconId, status)
$(sensIconId, e_sensor_status).removeClass('active'); $(sensIconId, e_sensor_status).removeClass('active');
$(sensIconId, e_sensor_status).addClass('error'); $(sensIconId, e_sensor_status).addClass('error');
} }
} }
function sensor_status_hash(hw_status) privateScope.sensor_status_hash = function (hw_status)
{ {
return "S" + return "S" +
hw_status.isHardwareHealthy + hw_status.isHardwareHealthy +
hw_status.gyroHwStatus + hw_status.gyroHwStatus +
@ -514,115 +548,55 @@ function sensor_status_hash(hw_status)
hw_status.rangeHwStatus + hw_status.rangeHwStatus +
hw_status.speedHwStatus + hw_status.speedHwStatus +
hw_status.flowHwStatus; hw_status.flowHwStatus;
} }
/** /**
* Legacy sensor handler used in INAV < 1.5 versions * Legacy sensor handler used in INAV < 1.5 versions
* @param sensors_detected * @param sensors_detected
* @deprecated * @deprecated
*/ */
function sensor_status(sensors_detected) { privateScope.sensor_status = function (sensors_detected) {
if (typeof SENSOR_STATUS === 'undefined') { if (typeof SENSOR_STATUS === 'undefined') {
return; return;
} }
SENSOR_STATUS.isHardwareHealthy = 1; SENSOR_STATUS.isHardwareHealthy = 1;
SENSOR_STATUS.gyroHwStatus = have_sensor(sensors_detected, 'gyro') ? 1 : 0; SENSOR_STATUS.gyroHwStatus = publicScope.have_sensor(sensors_detected, 'gyro') ? 1 : 0;
SENSOR_STATUS.accHwStatus = have_sensor(sensors_detected, 'acc') ? 1 : 0; SENSOR_STATUS.accHwStatus = publicScope.have_sensor(sensors_detected, 'acc') ? 1 : 0;
SENSOR_STATUS.magHwStatus = have_sensor(sensors_detected, 'mag') ? 1 : 0; SENSOR_STATUS.magHwStatus = publicScope.have_sensor(sensors_detected, 'mag') ? 1 : 0;
SENSOR_STATUS.baroHwStatus = have_sensor(sensors_detected, 'baro') ? 1 : 0; SENSOR_STATUS.baroHwStatus = publicScope.have_sensor(sensors_detected, 'baro') ? 1 : 0;
SENSOR_STATUS.gpsHwStatus = have_sensor(sensors_detected, 'gps') ? 1 : 0; SENSOR_STATUS.gpsHwStatus = publicScope.have_sensor(sensors_detected, 'gps') ? 1 : 0;
SENSOR_STATUS.rangeHwStatus = have_sensor(sensors_detected, 'sonar') ? 1 : 0; SENSOR_STATUS.rangeHwStatus = publicScope.have_sensor(sensors_detected, 'sonar') ? 1 : 0;
SENSOR_STATUS.speedHwStatus = have_sensor(sensors_detected, 'airspeed') ? 1 : 0; SENSOR_STATUS.speedHwStatus = publicScope.have_sensor(sensors_detected, 'airspeed') ? 1 : 0;
SENSOR_STATUS.flowHwStatus = have_sensor(sensors_detected, 'opflow') ? 1 : 0; SENSOR_STATUS.flowHwStatus = publicScope.have_sensor(sensors_detected, 'opflow') ? 1 : 0;
sensor_status_ex(SENSOR_STATUS); privateScope.sensor_status_ex(SENSOR_STATUS);
} }
function have_sensor(sensors_detected, sensor_code) { publicScope.have_sensor = function (sensors_detected, sensor_code) {
switch(sensor_code) { switch(sensor_code) {
case 'acc': case 'acc':
case 'gyro': case 'gyro':
return bit_check(sensors_detected, 0); return BitHelper.check(sensors_detected, 0);
case 'baro': case 'baro':
return bit_check(sensors_detected, 1); return BitHelper.bit_check(sensors_detected, 1);
case 'mag': case 'mag':
return bit_check(sensors_detected, 2); return BitHelper.bit_check(sensors_detected, 2);
case 'gps': case 'gps':
return bit_check(sensors_detected, 3); return BitHelper.bit_check(sensors_detected, 3);
case 'sonar': case 'sonar':
return bit_check(sensors_detected, 4); return BitHelper.bit_check(sensors_detected, 4);
case 'opflow': case 'opflow':
return bit_check(sensors_detected, 5); return BitHelper.bit_check(sensors_detected, 5);
case 'airspeed': case 'airspeed':
return bit_check(sensors_detected, 6); return BitHelper.bit_check(sensors_detected, 6);
} }
return false; return false;
}
function highByte(num) {
return num >> 8;
}
function lowByte(num) {
return 0x00FF & num;
}
function specificByte(num, pos) {
return 0x000000FF & (num >> (8 * pos));
}
function bit_check(num, bit) {
return ((num >> bit) % 2 != 0);
}
function bit_set(num, bit) {
return num | 1 << bit;
}
function bit_clear(num, bit) {
return num & ~(1 << bit);
}
function update_dataflash_global() {
function formatFilesize(bytes) {
if (bytes < 1024) {
return bytes + "B";
}
var kilobytes = bytes / 1024;
if (kilobytes < 1024) {
return Math.round(kilobytes) + "kB";
} }
var megabytes = kilobytes / 1024;
return megabytes.toFixed(1) + "MB"; return publicScope;
}
var supportsDataflash = DATAFLASH.totalSize > 0; })();
if (supportsDataflash){ module.exports = SerialBackend;
$(".noflash_global").css({
display: 'none'
});
$(".dataflash-contents_global").css({
display: 'block'
});
$(".dataflash-free_global").css({
width: (100-(DATAFLASH.totalSize - DATAFLASH.usedSize) / DATAFLASH.totalSize * 100) + "%",
display: 'block'
});
$(".dataflash-free_global div").text('Dataflash: free ' + formatFilesize(DATAFLASH.totalSize - DATAFLASH.usedSize));
} else {
$(".noflash_global").css({
display: 'block'
});
$(".dataflash-contents_global").css({
display: 'none'
});
}
}

View file

@ -1,8 +1,12 @@
'use strict'; 'use strict';
var helper = helper || {}; const CONFIGURATOR = require('./data_storage');
const MSPCodes = require('./msp/MSPCodes');
const SimpleSmoothFilter = require('./simple_smooth_filter');
const PidController = require('./pid_controller');
const eventFrequencyAnalyzer = require('./eventFrequencyAnalyzer');
helper.mspQueue = (function (MSP) { var mspQueue = function () {
var publicScope = {}, var publicScope = {},
privateScope = {}; privateScope = {};
@ -10,9 +14,9 @@ helper.mspQueue = (function (MSP) {
privateScope.handlerFrequency = 100; privateScope.handlerFrequency = 100;
privateScope.balancerFrequency = 20; privateScope.balancerFrequency = 20;
privateScope.loadFilter = new classes.SimpleSmoothFilter(1, 0.85); privateScope.loadFilter = new SimpleSmoothFilter(1, 0.85);
privateScope.roundtripFilter = new classes.SimpleSmoothFilter(20, 0.95); privateScope.roundtripFilter = new SimpleSmoothFilter(20, 0.95);
privateScope.hardwareRoundtripFilter = new classes.SimpleSmoothFilter(10, 0.95); privateScope.hardwareRoundtripFilter = new SimpleSmoothFilter(10, 0.95);
/** /**
* Target load for MSP queue. When load is above target, throttling might start to appear * Target load for MSP queue. When load is above target, throttling might start to appear
@ -25,9 +29,9 @@ helper.mspQueue = (function (MSP) {
/** /**
* PID controller used to perform throttling * PID controller used to perform throttling
* @type {classes.PidController} * @type {PidController}
*/ */
privateScope.loadPidController = new classes.PidController(); privateScope.loadPidController = new PidController();
privateScope.loadPidController.setTarget(privateScope.targetLoad); privateScope.loadPidController.setTarget(privateScope.targetLoad);
privateScope.loadPidController.setOutput(0, 99, 0); privateScope.loadPidController.setOutput(0, 99, 0);
privateScope.loadPidController.setGains(5, 6, 3); privateScope.loadPidController.setGains(5, 6, 3);
@ -35,6 +39,9 @@ helper.mspQueue = (function (MSP) {
privateScope.dropRatio = 0; privateScope.dropRatio = 0;
privateScope.removeCallback = null;
privateScope.putCallback = null;
publicScope.computeDropRatio = function () { publicScope.computeDropRatio = function () {
privateScope.dropRatio = privateScope.loadPidController.run(publicScope.getLoad()); privateScope.dropRatio = privateScope.loadPidController.run(publicScope.getLoad());
}; };
@ -52,6 +59,14 @@ helper.mspQueue = (function (MSP) {
privateScope.queueLocked = false; privateScope.queueLocked = false;
publicScope.setremoveCallback = function(cb) {
privateScope.removeCallback = cb;
}
publicScope.setPutCallback = function(cb) {
privateScope.putCallback = cb;
}
/** /**
* Method locks queue * Method locks queue
* All future put requests will be rejected * All future put requests will be rejected
@ -121,7 +136,7 @@ helper.mspQueue = (function (MSP) {
/* /*
* Debug * Debug
*/ */
helper.eventFrequencyAnalyzer.put("execute"); eventFrequencyAnalyzer.put("execute");
privateScope.loadFilter.apply(privateScope.queue.length); privateScope.loadFilter.apply(privateScope.queue.length);
@ -129,7 +144,7 @@ helper.mspQueue = (function (MSP) {
* if port is blocked or there is no connection, do not process the queue * if port is blocked or there is no connection, do not process the queue
*/ */
if (publicScope.isLocked() || CONFIGURATOR.connection === false) { if (publicScope.isLocked() || CONFIGURATOR.connection === false) {
helper.eventFrequencyAnalyzer.put("port in use"); eventFrequencyAnalyzer.put("port in use");
return false; return false;
} }
@ -148,7 +163,8 @@ helper.mspQueue = (function (MSP) {
/* /*
* Remove current callback * Remove current callback
*/ */
MSP.removeCallback(request.code);
privateScope.removeCallback(request.code);
/* /*
* To prevent infinite retry situation, allow retry only while counter is positive * To prevent infinite retry situation, allow retry only while counter is positive
@ -171,9 +187,9 @@ helper.mspQueue = (function (MSP) {
/* /*
* Set receive callback here * Set receive callback here
*/ */
MSP.putCallback(request); privateScope.putCallback(request);
helper.eventFrequencyAnalyzer.put('message sent'); eventFrequencyAnalyzer.put('message sent');
/* /*
* Send data to serial port * Send data to serial port
@ -253,7 +269,7 @@ helper.mspQueue = (function (MSP) {
publicScope.balancer = function () { publicScope.balancer = function () {
privateScope.currentLoad = privateScope.loadFilter.get(); privateScope.currentLoad = privateScope.loadFilter.get();
helper.mspQueue.computeDropRatio(); publicScope.computeDropRatio();
/* /*
* Also, check if port lock if hanging. Free is so * Also, check if port lock if hanging. Free is so
@ -267,11 +283,11 @@ helper.mspQueue = (function (MSP) {
if (privateScope.softLock !== false && currentTimestamp - privateScope.softLock > threshold) { if (privateScope.softLock !== false && currentTimestamp - privateScope.softLock > threshold) {
privateScope.softLock = false; privateScope.softLock = false;
helper.eventFrequencyAnalyzer.put('force free soft lock'); eventFrequencyAnalyzer.put('force free soft lock');
} }
if (privateScope.hardLock !== false && currentTimestamp - privateScope.hardLock > threshold) { if (privateScope.hardLock !== false && currentTimestamp - privateScope.hardLock > threshold) {
privateScope.hardLock = false; privateScope.hardLock = false;
helper.eventFrequencyAnalyzer.put('force free hard lock'); eventFrequencyAnalyzer.put('force free hard lock');
} }
}; };
@ -305,4 +321,6 @@ helper.mspQueue = (function (MSP) {
setInterval(publicScope.balancer, Math.round(1000 / privateScope.balancerFrequency)); setInterval(publicScope.balancer, Math.round(1000 / privateScope.balancerFrequency));
return publicScope; return publicScope;
})(MSP); }();
module.exports = mspQueue;

View file

@ -1,7 +1,7 @@
/*global $*/ /*global $*/
'use strict'; 'use strict';
let ServoMixRule = function (target, input, rate, speed, condition) { var ServoMixRule = function (target, input, rate, speed, condition) {
var self = {}; var self = {};
@ -51,3 +51,5 @@ let ServoMixRule = function (target, input, rate, speed, condition) {
return self; return self;
}; };
module.exports = ServoMixRule;

View file

@ -1,7 +1,7 @@
/*global ServoMixRule*/ /*global ServoMixRule*/
'use strict'; 'use strict';
let ServoMixerRuleCollection = function () { var ServoMixerRuleCollection = function () {
let self = {}, let self = {},
data = [], data = [],
@ -156,3 +156,5 @@ let ServoMixerRuleCollection = function () {
return self; return self;
}; };
module.exports = ServoMixerRuleCollection;

View file

@ -1,12 +1,27 @@
'use strict'; 'use strict';
function padZeros(val, length) {
let str = val.toString();
if (str.length < length) {
if (str.charAt(0) === '-') {
str = "-0" + str.substring(1);
str = padZeros(str, length);
} else {
str = padZeros("0" + str, length);
}
}
return str;
}
var Settings = (function () { var Settings = (function () {
let self = {}; let self = {};
self.fillSelectOption = function(s, ii) { self.fillSelectOption = function(s, ii) {
var name = (s.setting.table ? s.setting.table.values[ii] : null); var name = (s.setting.table ? s.setting.table.values[ii] : null);
if (name) { if (name) {
var localizedName = localization.getMessage(name); var localizedName = i18n.getMessage(name);
if (localizedName) { if (localizedName) {
name = localizedName; name = localizedName;
} }
@ -123,7 +138,7 @@ var Settings = (function () {
input.data('setting-info', s.setting); input.data('setting-info', s.setting);
if (input.data('live')) { if (input.data('live')) {
input.change(function() { input.on('change', function () {
self.saveInput(input); self.saveInput(input);
}); });
} }

View file

@ -1,8 +1,7 @@
'use strict'; 'use strict';
var classes = classes || {};
classes.SimpleSmoothFilter = function (initialValue, smoothingFactor) { var SimpleSmoothFilter = function (initialValue, smoothingFactor) {
var self = {}; var self = {};
@ -29,3 +28,5 @@ classes.SimpleSmoothFilter = function (initialValue, smoothingFactor) {
return self; return self;
}; };
module.exports = SimpleSmoothFilter;

View file

@ -1,9 +1,12 @@
'use strict' 'use strict'
const path = require('path');
const { app } = require('@electron/remote');
const { SerialPort } = require('serialport');
const { spawn } = require('node:child_process'); const { spawn } = require('node:child_process');
const pathMod = require('path');
const { chmod, rm } = require('node:fs'); const { chmod, rm } = require('node:fs');
const { GUI } = require('./gui');
const serialRXProtocolls = [ const serialRXProtocolls = [
{ {
name : "SBus", name : "SBus",
@ -55,9 +58,9 @@ var Ser2TCP = {
var path; var path;
if (GUI.operating_system == 'Windows') { if (GUI.operating_system == 'Windows') {
path = './resources/sitl/windows/Ser2TCP.exe' path = './../resources/sitl/windows/Ser2TCP.exe'
} else if (GUI.operating_system == 'Linux') { } else if (GUI.operating_system == 'Linux') {
path = './resources/sitl/linux/Ser2TCP' path = './../resources/sitl/linux/Ser2TCP'
chmod(path, 0o755, (err) => { chmod(path, 0o755, (err) => {
if (err) if (err)
console.log(err); console.log(err);
@ -191,7 +194,7 @@ var SITLProcess = {
process: null, process: null,
deleteEepromFile(filename) { deleteEepromFile(filename) {
rm(`${nw.App.dataPath}/${filename}`, error => { rm(`${app.getPath('userData')}/${filename}`, error => {
if (error) { if (error) {
GUI.log(`Unable to reset Demo mode: ${error.message}`); GUI.log(`Unable to reset Demo mode: ${error.message}`);
} }
@ -205,11 +208,11 @@ var SITLProcess = {
var sitlExePath, eepromPath; var sitlExePath, eepromPath;
if (GUI.operating_system == 'Windows') { if (GUI.operating_system == 'Windows') {
sitlExePath = './resources/sitl/windows/inav_SITL.exe' sitlExePath = path.join(__dirname, './../resources/sitl/windows/inav_SITL.exe');
eepromPath = `${nw.App.dataPath}\\${eepromFileName}` eepromPath = `${app.getPath('userData')}\\${eepromFileName}`
} else if (GUI.operating_system == 'Linux') { } else if (GUI.operating_system == 'Linux') {
sitlExePath = './resources/sitl/linux/inav_SITL'; sitlExePath = './../resources/sitl/linux/inav_SITL';
eepromPath = `${nw.App.dataPath}/${eepromFileName}` eepromPath = `${app.getPath('userData')}/${eepromFileName}`
chmod(sitlExePath, 0o755, err => { chmod(sitlExePath, 0o755, err => {
if (err) if (err)
console.log(err); console.log(err);
@ -271,3 +274,5 @@ var SITLProcess = {
} }
} }
}; };
module.exports = { Ser2TCP, SITLProcess };

View file

@ -1,8 +1,6 @@
'use strict'; 'use strict';
var helper = helper || {}; var tabs = (function () {
helper.tabs = (function () {
let self = {}, let self = {},
$container; $container;
@ -19,9 +17,11 @@ helper.tabs = (function () {
self.init = function ($dom) { self.init = function ($dom) {
$container = $dom; $container = $dom;
$container.find(".subtab__header_label").click(onHeaderClick); $container.find(".subtab__header_label").on('click',(onHeaderClick);
}; };
return self; return self;
})(); })();
module.exports = tabs;

View file

@ -1,8 +1,6 @@
'use strict'; 'use strict';
var helper = helper || {}; var timeout = (function () {
helper.timeout = (function () {
var privateScope = {}, var privateScope = {},
publicScope = {}; publicScope = {};
@ -64,3 +62,5 @@ helper.timeout = (function () {
return publicScope; return publicScope;
})(); })();
module.exports = timeout;

View file

@ -37,3 +37,5 @@ var VTX = (function() {
return self; return self;
})(); })();
module.exports = VTX;

View file

@ -1,8 +1,6 @@
'use strict'; 'use strict';
var classes = classes || {}; var WalkingAverageFilter = function (maxLength) {
classes.WalkingAverageFilter = function (maxLength) {
var table = [], var table = [],
self = {}; self = {};
@ -31,3 +29,4 @@ classes.WalkingAverageFilter = function (maxLength) {
return self; return self;
}; };
module.exports = WalkingAverageFilter;

View file

@ -1,7 +1,7 @@
/*global $*/ /*global $*/
'use strict'; 'use strict';
let Waypoint = function (number, action, lat, lon, alt=0, p1=0, p2=0, p3=0, endMission=0, isUsed=true, isAttached=false, attachedId="") { var Waypoint = function (number, action, lat, lon, alt=0, p1=0, p2=0, p3=0, endMission=0, isUsed=true, isAttached=false, attachedId="") {
var self = {}; var self = {};
let layerNumber = "undefined"; let layerNumber = "undefined";
@ -157,3 +157,5 @@ let Waypoint = function (number, action, lat, lon, alt=0, p1=0, p2=0, p3=0, endM
return self; return self;
}; };
module.exports = Waypoint;

View file

@ -480,3 +480,6 @@ let WaypointCollection = function () {
return self; return self;
}; };
module.exports = WaypointCollection;

5495
locale/de/messages.json Normal file

File diff suppressed because it is too large Load diff

View file

@ -2,6 +2,17 @@
"translation_version": { "translation_version": {
"message": "0" "message": "0"
}, },
"language_de": {
"message": "Deutsch",
"comment": "Don't translate!"
},
"language_en": {
"message": "English",
"_comment": "Don't translate!"
},
"language": {
"message": "Language"
},
"options_title": { "options_title": {
"message": "Application Options" "message": "Application Options"
}, },
@ -24,7 +35,7 @@
"message": "Configurator rendering options" "message": "Configurator rendering options"
}, },
"unexpectedError" : { "unexpectedError" : {
"message": "Unexpected error: {0}" "message": "Unexpected error: $1"
}, },
"disconnecting": { "disconnecting": {
"message": "Disconnecting..." "message": "Disconnecting..."
@ -69,13 +80,13 @@
}, },
"configMigrationFrom": { "configMigrationFrom": {
"message": "Migrating configuration file generated by configurator: {0}" "message": "Migrating configuration file generated by configurator: $1"
}, },
"configMigratedTo": { "configMigratedTo": {
"message": "Migrated configuration to configurator: {0}" "message": "Migrated configuration to configurator: $1"
}, },
"configMigrationSuccessful": { "configMigrationSuccessful": {
"message": "Configuration migration complete, migrations applied: {0}" "message": "Configuration migration complete, migrations applied: $1"
}, },
"documentation": { "documentation": {
"message": "Documentation" "message": "Documentation"
@ -273,7 +284,7 @@
"message": "ACRO" "message": "ACRO"
}, },
"serialPortOpened": { "serialPortOpened": {
"message": "MSP connection <span style=\"color: #37a8db\">successfully</span> opened with ID: {0}" "message": "MSP connection <span style=\"color: #37a8db\">successfully</span> opened with ID: $1"
}, },
"serialPortOpenFail": { "serialPortOpenFail": {
"message": "<span style=\"color: red\">Failed</span> to open MSP connection" "message": "<span style=\"color: red\">Failed</span> to open MSP connection"
@ -288,10 +299,10 @@
"message": "Unrecoverable <span style=\"color: red\">failure</span> of serial connection, disconnecting...'" "message": "Unrecoverable <span style=\"color: red\">failure</span> of serial connection, disconnecting...'"
}, },
"connectionConnected": { "connectionConnected": {
"message": "Connected to: {0}" "message": "Connected to: $1"
}, },
"connectionBleType": { "connectionBleType": {
"message": "BLE device type: {0}" "message": "BLE device type: $1"
}, },
"connectionBleNotSupported": { "connectionBleNotSupported": {
"message": "<span style=\"color: red\">Connection error:</span> Firmware doesn't support BLE connections. Abort." "message": "<span style=\"color: red\">Connection error:</span> Firmware doesn't support BLE connections. Abort."
@ -300,7 +311,7 @@
"message": "The connection was unexpectedly interrupted." "message": "The connection was unexpectedly interrupted."
}, },
"connectionBleError": { "connectionBleError": {
"message": "Error while opening BLE device: {0}" "message": "Error while opening BLE device: $1"
}, },
"connectionBleCliEnter": { "connectionBleCliEnter": {
"message": "Connection over BLE active, output might be slower than usual." "message": "Connection over BLE active, output might be slower than usual."
@ -336,7 +347,7 @@
"message": "STM32 - timed out, programming: FAILED" "message": "STM32 - timed out, programming: FAILED"
}, },
"stm32WrongResponse": { "stm32WrongResponse": {
"message": "STM32 Communication failed, wrong response, expected: {0} (0x{1}) received: {2} (0x{3})" "message": "STM32 Communication failed, wrong response, expected: $1 (0x$2) received: $3 (0x$4)"
}, },
"stm32ContactingBootloader": { "stm32ContactingBootloader": {
"message": "Contacting bootloader ..." "message": "Contacting bootloader ..."
@ -409,7 +420,7 @@
"message": "No configuration received within <span style=\"color: red\">10 seconds</span>, communication <span style=\"color: red\">failed</span>" "message": "No configuration received within <span style=\"color: red\">10 seconds</span>, communication <span style=\"color: red\">failed</span>"
}, },
"firmwareVersionNotSupported": { "firmwareVersionNotSupported": {
"message": "This firmware version is <span style=\"color: red\">not supported</span>. This version of Configurator supports firmware from {0} to {1} (excluded)" "message": "This firmware version is <span style=\"color: red\">not supported</span>. This version of Configurator supports firmware from $1 to $2 (excluded)"
}, },
"firmwareVariantNotSupported": { "firmwareVariantNotSupported": {
"message": "This firmware variant is <span style=\"color: red\">not supported</span>. Please upgrade to INAV firmware. Use CLI for backup before flashing. CLI backup/restore procedure is in the documention." "message": "This firmware variant is <span style=\"color: red\">not supported</span>. Please upgrade to INAV firmware. Use CLI for backup before flashing. CLI backup/restore procedure is in the documention."
@ -423,29 +434,29 @@
}, },
"tabSwitchUpgradeRequired": { "tabSwitchUpgradeRequired": {
"message": "You need to <strong>upgrade</strong> your firmware before you can use the {0} tab." "message": "You need to <strong>upgrade</strong> your firmware before you can use the $1 tab."
}, },
"firmwareVersion": { "firmwareVersion": {
"message": "Firmware Version: <strong>{0}</strong>" "message": "Firmware Version: <strong>$1</strong>"
}, },
"apiVersionReceived": { "apiVersionReceived": {
"message": "MultiWii API version <span style=\"color: #37a8db\">received</span> - <strong>{0}</strong>" "message": "MultiWii API version <span style=\"color: #37a8db\">received</span> - <strong>$1</strong>"
}, },
"uniqueDeviceIdReceived": { "uniqueDeviceIdReceived": {
"message": "Unique device ID <span style=\"color: #37a8db\">received</span> - <strong>0x{0}</strong>" "message": "Unique device ID <span style=\"color: #37a8db\">received</span> - <strong>0x$1</strong>"
}, },
"boardInfoReceived": { "boardInfoReceived": {
"message": "Board: <strong>{0}</strong>, version: <strong>{1}</strong>" "message": "Board: <strong>$1</strong>, version: <strong>$2</strong>"
}, },
"buildInfoReceived": { "buildInfoReceived": {
"message": "Running firmware released on: <strong>{0}</strong>" "message": "Running firmware released on: <strong>$1</strong>"
}, },
"fcInfoReceived": { "fcInfoReceived": {
"message": "Flight controller info, identifier: <strong>{0}</strong>, version: <strong>{1}</strong>" "message": "Flight controller info, identifier: <strong>$1</strong>, version: <strong>$2</strong>"
}, },
"notifications_app_just_updated_to_version": { "notifications_app_just_updated_to_version": {
"message": "Application just updated to version: {0}" "message": "Application just updated to version: $1"
}, },
"notifications_click_here_to_start_app": { "notifications_click_here_to_start_app": {
"message": "Click here to start the application" "message": "Click here to start the application"
@ -455,10 +466,10 @@
"message": "Port utilization:" "message": "Port utilization:"
}, },
"statusbar_usage_download": { "statusbar_usage_download": {
"message": "D: {0}%" "message": "D: $1%"
}, },
"statusbar_usage_upload": { "statusbar_usage_upload": {
"message": "U: {0}%" "message": "U: $1%"
}, },
"statusbar_packet_error": { "statusbar_packet_error": {
"message": "Packet error:" "message": "Packet error:"
@ -470,7 +481,7 @@
"message": "Cycle Time:" "message": "Cycle Time:"
}, },
"statusbar_cpu_load": { "statusbar_cpu_load": {
"message": "CPU Load: {0}%" "message": "CPU Load: $1%"
}, },
"statusbar_arming_flags": { "statusbar_arming_flags": {
"message": "Arming Flags:" "message": "Arming Flags:"
@ -480,13 +491,13 @@
"message": "Please use the Firmware Flasher to access DFU devices" "message": "Please use the Firmware Flasher to access DFU devices"
}, },
"dfu_erased_kilobytes": { "dfu_erased_kilobytes": {
"message": "Erased {0} kB of flash <span style=\"color: #37a8db\">successfully</span>" "message": "Erased $1 kB of flash <span style=\"color: #37a8db\">successfully</span>"
}, },
"dfu_device_flash_info": { "dfu_device_flash_info": {
"message": "Detected device with total flash size {0} kiB" "message": "Detected device with total flash size $1 kiB"
}, },
"dfu_error_image_size": { "dfu_error_image_size": {
"message": "<span style=\"color: red; font-weight: bold\">Error</span>: Supplied image is larger then flash available on the chip! Image: {0} kiB, limit = {1} kiB" "message": "<span style=\"color: red; font-weight: bold\">Error</span>: Supplied image is larger then flash available on the chip! Image: $1 kiB, limit = $2 kiB"
}, },
"eeprom_saved_ok": { "eeprom_saved_ok": {
@ -545,7 +556,7 @@
"message": "Facebook Group" "message": "Facebook Group"
}, },
"initialSetupBackupAndRestoreApiVersion": { "initialSetupBackupAndRestoreApiVersion": {
"message": "<span style=\"color: red\">Backup and restore functionality disabled.</span> You have firmware with API version <span style=\"color: red\">{0}</span>, backup and restore requires <span style=\"color: #37a8db\">{1}</span>. Please backup your settings via the CLI, see INAV documentation for procedure." "message": "<span style=\"color: red\">Backup and restore functionality disabled.</span> You have firmware with API version <span style=\"color: red\">$1</span>, backup and restore requires <span style=\"color: #37a8db\">$2</span>. Please backup your settings via the CLI, see INAV documentation for procedure."
}, },
"initialSetupButtonCalibrateAccel": { "initialSetupButtonCalibrateAccel": {
"message": "Calibrate Accelerometer" "message": "Calibrate Accelerometer"
@ -584,7 +595,7 @@
"message": "Reset Z axis, offset: 0 deg" "message": "Reset Z axis, offset: 0 deg"
}, },
"initialSetupButtonResetZaxisValue": { "initialSetupButtonResetZaxisValue": {
"message": "Reset Z axis, offset: {0} deg" "message": "Reset Z axis, offset: $1 deg"
}, },
"initialSetupMixerHead": { "initialSetupMixerHead": {
"message": "Mixer Type" "message": "Mixer Type"
@ -641,40 +652,40 @@
"message": "Battery detected cell count:" "message": "Battery detected cell count:"
}, },
"initialSetupBatteryDetectedCellsValue": { "initialSetupBatteryDetectedCellsValue": {
"message": "{0}" "message": "$1"
}, },
"initialSetupBatteryPercentage": { "initialSetupBatteryPercentage": {
"message": "Battery left:" "message": "Battery left:"
}, },
"initialSetupBatteryPercentageValue": { "initialSetupBatteryPercentageValue": {
"message": "{0} %" "message": "$1 %"
}, },
"initialSetupBatteryRemainingCapacity": { "initialSetupBatteryRemainingCapacity": {
"message": "Battery remaining capacity" "message": "Battery remaining capacity"
}, },
"initialSetupBatteryRemainingCapacityValue": { "initialSetupBatteryRemainingCapacityValue": {
"message": "{0} {1}" "message": "$1 $2"
}, },
"initialSetupBatteryFull": { "initialSetupBatteryFull": {
"message": "Battery full when plugged in" "message": "Battery full when plugged in"
}, },
"initialSetupBatteryFullValue": { "initialSetupBatteryFullValue": {
"message": "{0}" "message": "$1"
}, },
"initialSetupBatteryThresholds": { "initialSetupBatteryThresholds": {
"message": "Battery use cap thresholds" "message": "Battery use cap thresholds"
}, },
"initialSetupBatteryThresholdsValue": { "initialSetupBatteryThresholdsValue": {
"message": "{0}" "message": "$1"
}, },
"initialSetup_Wh_drawn": { "initialSetup_Wh_drawn": {
"message": "Capacity drawn:" "message": "Capacity drawn:"
}, },
"initialSetup_Wh_drawnValue": { "initialSetup_Wh_drawnValue": {
"message": "{0} Wh" "message": "$1 Wh"
}, },
"initialSetupBatteryVoltageValue": { "initialSetupBatteryVoltageValue": {
"message": "{0} V" "message": "$1 V"
}, },
"initialSetupDrawn": { "initialSetupDrawn": {
"message": "Capacity drawn:" "message": "Capacity drawn:"
@ -686,19 +697,19 @@
"message": "Power draw:" "message": "Power draw:"
}, },
"initialSetupPowerDrawValue": { "initialSetupPowerDrawValue": {
"message": "{0} W" "message": "$1 W"
}, },
"initialSetupBatteryMahValue": { "initialSetupBatteryMahValue": {
"message": "{0} mAh" "message": "$1 mAh"
}, },
"initialSetupCurrentDrawValue": { "initialSetupCurrentDrawValue": {
"message": "{0} A" "message": "$1 A"
}, },
"initialSetupRSSI": { "initialSetupRSSI": {
"message": "RSSI:" "message": "RSSI:"
}, },
"initialSetupRSSIValue": { "initialSetupRSSIValue": {
"message": "{0} %" "message": "$1 %"
}, },
"initialSetupGPSHead": { "initialSetupGPSHead": {
"message": "GPS" "message": "GPS"
@ -710,10 +721,10 @@
"message": "Save" "message": "Save"
}, },
"initialSetupModel": { "initialSetupModel": {
"message": "Model: {0}" "message": "Model: $1"
}, },
"initialSetupAttitude": { "initialSetupAttitude": {
"message": "{0} deg" "message": "$1 deg"
}, },
"initialSetupAccelCalibStarted": { "initialSetupAccelCalibStarted": {
"message": "Accelerometer calibration started" "message": "Accelerometer calibration started"
@ -1492,7 +1503,7 @@
"message": "I-term mechanics" "message": "I-term mechanics"
}, },
"pidTuning_itermRelaxCutoff": { "pidTuning_itermRelaxCutoff": {
"message": "Iterm Relax Cutoff Frequency" "message": "I-term Relax Cutoff Frequency"
}, },
"pidTuning_itermRelaxCutoffHelp": { "pidTuning_itermRelaxCutoffHelp": {
"message": "Lower values open a longer time window for Iterm Relax to work on and stronger Iterm suppression. Higher values shortens the time windows and reduces suppression." "message": "Lower values open a longer time window for Iterm Relax to work on and stronger Iterm suppression. Higher values shortens the time windows and reduces suppression."
@ -1573,7 +1584,7 @@
"message": "Profile" "message": "Profile"
}, },
"pidTuning_LoadedProfile": { "pidTuning_LoadedProfile": {
"message": "Loaded Profile: <strong style=\"color: #37a8db\">{0}</strong>" "message": "Loaded Profile: <strong style=\"color: #37a8db\">$1</strong>"
}, },
"pidTuning_gyro_use_dyn_lpf": { "pidTuning_gyro_use_dyn_lpf": {
"message": "Dynamic gyro LPF" "message": "Dynamic gyro LPF"
@ -1597,10 +1608,10 @@
"message": "Defines the gyro LPF cutoff frequency at maximum throttle. When throttle is decreased, LPF cutoff frequency is decreased as well, down to the minimum cutoff frequency." "message": "Defines the gyro LPF cutoff frequency at maximum throttle. When throttle is decreased, LPF cutoff frequency is decreased as well, down to the minimum cutoff frequency."
}, },
"loadedMixerProfile": { "loadedMixerProfile": {
"message": "Loaded Mixer Profile: <strong style=\"color: #37a8db\">{0}</strong>, Check modes tab: MIXER PROFILE 2 if you don't see the changes" "message": "Loaded Mixer Profile: <strong style=\"color: #37a8db\">$1</strong>, Check modes tab: MIXER PROFILE 2 if you don't see the changes"
}, },
"loadedBatteryProfile": { "loadedBatteryProfile": {
"message": "Loaded Battery Profile: <strong style=\"color: #37a8db\">{0}</strong>" "message": "Loaded Battery Profile: <strong style=\"color: #37a8db\">$1</strong>"
}, },
"pidTuningDataRefreshed": { "pidTuningDataRefreshed": {
"message": "PID data <strong>refreshed</strong>" "message": "PID data <strong>refreshed</strong>"
@ -2223,7 +2234,7 @@
"message": "Please select at least one property to log" "message": "Please select at least one property to log"
}, },
"loggingAutomaticallyRetained": { "loggingAutomaticallyRetained": {
"message": "Automatically loaded previous log file: <strong>{0}</strong>" "message": "Automatically loaded previous log file: <strong>$1</strong>"
}, },
"blackboxNotSupported": { "blackboxNotSupported": {
"message": "Your flight controller's firmware does not support Blackbox logging or Blackbox feature is not enabled" "message": "Your flight controller's firmware does not support Blackbox logging or Blackbox feature is not enabled"
@ -3519,7 +3530,7 @@
"message": "Default Layout" "message": "Default Layout"
}, },
"osdLayoutAlternative": { "osdLayoutAlternative": {
"message": "Alternative Layout #{0}" "message": "Alternative Layout #$1"
}, },
"osdUnitImperial": { "osdUnitImperial": {
"message": "Imperial" "message": "Imperial"
@ -4209,7 +4220,7 @@
"message": "Uploading..." "message": "Uploading..."
}, },
"uploadedCharacters": { "uploadedCharacters": {
"message": "Uploaded {0} characters" "message": "Uploaded $1 characters"
}, },
"portsIdentifier": { "portsIdentifier": {
"message": "Identifier" "message": "Identifier"

168
main.js
View file

@ -1,168 +0,0 @@
const { app, BrowserWindow, ipcMain } = require('electron');
const windowStateKeeper = require('electron-window-state');
const path = require('path');
const Store = require('electron-store');
Store.initRenderer();
require('@electron/remote/main').initialize();
const usbBootloaderIds = [
{ vendorId: 1155, productId: 57105},
{ vendorId: 11836, productId: 57105}
];
// Handle creating/removing shortcuts on Windows when installing/uninstalling.
if (require('electron-squirrel-startup')) {
app.quit();
}
let mainWindow = null;
let bluetoothDeviceChooser = null;
let btDeviceList = null;
let selectBluetoothCallback = null;
// In Eletrcon the bluetooth device chooser didn't exist, so we have to buid our own
function createDeviceChooser() {
bluetoothDeviceChooser = new BrowserWindow({
parent: mainWindow,
width: 400,
height: 400,
webPreferences: {
preload: path.join(__dirname, 'js/libraries/bluetooth-device-chooser/preload.js')
}
});
bluetoothDeviceChooser.removeMenu();
bluetoothDeviceChooser.loadFile(path.join(__dirname, 'js/libraries/bluetooth-device-chooser/index.html'));
bluetoothDeviceChooser.on('closed', () => {
btDeviceList = null;
if (selectBluetoothCallback) {
selectBluetoothCallback('');
selectBluetoothCallback = null;
}
bluetoothDeviceChooser = null;
});
ipcMain.on('deviceSelected', (_event, deviceID) => {
if (selectBluetoothCallback) {
selectBluetoothCallback(deviceID);
selectBluetoothCallback = null;
}
});
}
app.on('ready', () => {
let mainWindowState = windowStateKeeper({
defaultWidth: 800,
defaultHeight: 600
});
mainWindow = new BrowserWindow({
x: mainWindowState.x,
y: mainWindowState.y,
width: mainWindowState.width,
height: mainWindowState.height,
autoHideMenuBar: true,
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
webSecurity: false
},
});
mainWindow.webContents.on('select-bluetooth-device', (event, deviceList, callback) => {
event.preventDefault();
selectBluetoothCallback = callback;
const compare = (a, b) => {
if (a.length !== b.length) {
return false;
}
a.every((element, index) => {
if (element.deviceId !== b[index].deviceId) {
return false;
}
})
return true;
}
if (!btDeviceList || !compare(btDeviceList, deviceList)) {
btDeviceList = [...deviceList];
if (!bluetoothDeviceChooser) {
createDeviceChooser();
}
bluetoothDeviceChooser.webContents.send('ble-scan', btDeviceList);
}
});
mainWindow.webContents.session.on('select-usb-device', (event, details, callback) => {
console.log(details.deviceList)
let premittedDevice = null;
if (details.deviceList) {
details.deviceList.every((device, idx) => {
if (device.productId == usbBootloaderIds[idx].productId && device.vendorId == usbBootloaderIds[idx].vendorId) {
premittedDevice = device.deviceId;
return;
}
});
}
if (premittedDevice) {
callback(premittedDevice);
} else {
callback();
}
});
mainWindow.webContents.session.setDevicePermissionHandler((details) => {
if (details.deviceType === 'usb' && details.origin === 'file://') {
return true;
}
})
mainWindow.webContents.setWindowOpenHandler(({ url }) => {
return {
action: 'allow',
overrideBrowserWindowOptions: {
autoHideMenuBar: true
}
}
});
app.commandLine.appendSwitch('disable-features', 'OutOfBlinkCors')
require("@electron/remote/main").enable(mainWindow.webContents);
mainWindow.removeMenu();
mainWindow.setMinimumSize(800, 600);
mainWindow.loadFile('index.html');
mainWindowState.manage(mainWindow);
// Open the DevTools.
if (process.env.NODE_ENV === 'development') {
mainWindow.webContents.openDevTools();
}
});
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
console.log("We're closing...");
});
app.on('activate', () => {
// On OS X it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
}
});

373
package-lock.json generated
View file

@ -14,6 +14,8 @@
"electron-store": "^8.1.0", "electron-store": "^8.1.0",
"electron-window-state": "^5.0.3", "electron-window-state": "^5.0.3",
"fs": "0.0.1-security", "fs": "0.0.1-security",
"i18next": "^23.8.3",
"i18next-xhr-backend": "^3.2.2",
"inflection": "1.12.0", "inflection": "1.12.0",
"jquery": "3.7.1", "jquery": "3.7.1",
"jquery-textcomplete": "^1.8.5", "jquery-textcomplete": "^1.8.5",
@ -23,8 +25,10 @@
"openlayers": "^4.6.5", "openlayers": "^4.6.5",
"plotly": "^1.0.6", "plotly": "^1.0.6",
"promise-map-series": "^0.3.0", "promise-map-series": "^0.3.0",
"semver": "^7.6.0",
"serialport": "^12.0.0", "serialport": "^12.0.0",
"temp": "^0.8.3", "temp": "^0.8.3",
"three": "0.139.0",
"usb": "^2.11.0", "usb": "^2.11.0",
"xml2js": "^0.4.19" "xml2js": "^0.4.19"
}, },
@ -34,14 +38,24 @@
"@electron-forge/maker-rpm": "^7.2.0", "@electron-forge/maker-rpm": "^7.2.0",
"@electron-forge/maker-squirrel": "^7.2.0", "@electron-forge/maker-squirrel": "^7.2.0",
"@electron-forge/maker-zip": "^7.2.0", "@electron-forge/maker-zip": "^7.2.0",
"@electron-forge/plugin-auto-unpack-natives": "^7.2.0",
"electron": "28.1.4" "electron": "28.1.4"
} }
}, },
"node_modules/@babel/runtime": {
"version": "7.23.9",
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.23.9.tgz",
"integrity": "sha512-0CX6F+BI2s9dkUqr08KFrAIZgNFj75rdBU/DjCyYLIaV/quFjkk6T+EJ2LkZHyZTbEV4L5p97mNkUsHl2wLFAw==",
"dependencies": {
"regenerator-runtime": "^0.14.0"
},
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@electron-forge/cli": { "node_modules/@electron-forge/cli": {
"version": "7.2.0", "version": "7.3.0",
"resolved": "https://registry.npmjs.org/@electron-forge/cli/-/cli-7.2.0.tgz", "resolved": "https://registry.npmjs.org/@electron-forge/cli/-/cli-7.3.0.tgz",
"integrity": "sha512-FJ8XzT4w6bTC3trvHHWL67W1zp7g2xmCC5riNa1rjk8Gd2C1j8wf0ul4ch9kbcaEAFaXuXwv98QKXxhCn4aLtQ==", "integrity": "sha512-tIzNYTvCEjJbma7zLWpa03phLKX/pd9f+vG+0HlIpmESMFGWhyLDzunZn0YOOXPRKpCTVg5RpC+BVte1Da4VjQ==",
"dev": true, "dev": true,
"funding": [ "funding": [
{ {
@ -54,8 +68,8 @@
} }
], ],
"dependencies": { "dependencies": {
"@electron-forge/core": "7.2.0", "@electron-forge/core": "7.3.0",
"@electron-forge/shared-types": "7.2.0", "@electron-forge/shared-types": "7.3.0",
"@electron/get": "^3.0.0", "@electron/get": "^3.0.0",
"chalk": "^4.0.0", "chalk": "^4.0.0",
"commander": "^4.1.1", "commander": "^4.1.1",
@ -74,9 +88,9 @@
} }
}, },
"node_modules/@electron-forge/core": { "node_modules/@electron-forge/core": {
"version": "7.2.0", "version": "7.3.0",
"resolved": "https://registry.npmjs.org/@electron-forge/core/-/core-7.2.0.tgz", "resolved": "https://registry.npmjs.org/@electron-forge/core/-/core-7.3.0.tgz",
"integrity": "sha512-7Sh0KW79Z/y9MStU3sWTBbTkM4SvV6rL557/ndlfAbZrxcGMnmWHrzn/odAZW1eyfhKguBb7C1Ijw0YTpsdVsw==", "integrity": "sha512-Z0wvs/YutUzo5xbCBjhoWSnlO1y5DbM4LMa5Di4Dxaf8v/xi7PQ/ncjAiOJKFYI8mG23Nn8Ae13weG0tiXISbA==",
"dev": true, "dev": true,
"funding": [ "funding": [
{ {
@ -89,19 +103,19 @@
} }
], ],
"dependencies": { "dependencies": {
"@electron-forge/core-utils": "7.2.0", "@electron-forge/core-utils": "7.3.0",
"@electron-forge/maker-base": "7.2.0", "@electron-forge/maker-base": "7.3.0",
"@electron-forge/plugin-base": "7.2.0", "@electron-forge/plugin-base": "7.3.0",
"@electron-forge/publisher-base": "7.2.0", "@electron-forge/publisher-base": "7.3.0",
"@electron-forge/shared-types": "7.2.0", "@electron-forge/shared-types": "7.3.0",
"@electron-forge/template-base": "7.2.0", "@electron-forge/template-base": "7.3.0",
"@electron-forge/template-vite": "7.2.0", "@electron-forge/template-vite": "7.3.0",
"@electron-forge/template-vite-typescript": "7.2.0", "@electron-forge/template-vite-typescript": "7.3.0",
"@electron-forge/template-webpack": "7.2.0", "@electron-forge/template-webpack": "7.3.0",
"@electron-forge/template-webpack-typescript": "7.2.0", "@electron-forge/template-webpack-typescript": "7.3.0",
"@electron-forge/tracer": "7.2.0", "@electron-forge/tracer": "7.3.0",
"@electron/get": "^3.0.0", "@electron/get": "^3.0.0",
"@electron/packager": "^18.0.0", "@electron/packager": "^18.1.2",
"@electron/rebuild": "^3.2.10", "@electron/rebuild": "^3.2.10",
"@malept/cross-spawn-promise": "^2.0.0", "@malept/cross-spawn-promise": "^2.0.0",
"chalk": "^4.0.0", "chalk": "^4.0.0",
@ -130,12 +144,12 @@
} }
}, },
"node_modules/@electron-forge/core-utils": { "node_modules/@electron-forge/core-utils": {
"version": "7.2.0", "version": "7.3.0",
"resolved": "https://registry.npmjs.org/@electron-forge/core-utils/-/core-utils-7.2.0.tgz", "resolved": "https://registry.npmjs.org/@electron-forge/core-utils/-/core-utils-7.3.0.tgz",
"integrity": "sha512-PI1wETlF/+Cxm1m/IgURQ9S3LzHU70/S4CHmkw4xJg4wYVRTfiKpH2XRE9VqEJU854hEnsCGynAIn7/Z2h6SIA==", "integrity": "sha512-cKeWuC8zYcp2n9caRWvCQgwIFtDqaUlwQVeg2VBpgJTGYHNKEDQHadR2xtIXTcfNgPUbQEAXiaS2xuxuhPQLfw==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@electron-forge/shared-types": "7.2.0", "@electron-forge/shared-types": "7.3.0",
"@electron/rebuild": "^3.2.10", "@electron/rebuild": "^3.2.10",
"@malept/cross-spawn-promise": "^2.0.0", "@malept/cross-spawn-promise": "^2.0.0",
"chalk": "^4.0.0", "chalk": "^4.0.0",
@ -151,12 +165,12 @@
} }
}, },
"node_modules/@electron-forge/maker-base": { "node_modules/@electron-forge/maker-base": {
"version": "7.2.0", "version": "7.3.0",
"resolved": "https://registry.npmjs.org/@electron-forge/maker-base/-/maker-base-7.2.0.tgz", "resolved": "https://registry.npmjs.org/@electron-forge/maker-base/-/maker-base-7.3.0.tgz",
"integrity": "sha512-5dCFiVo4WhSlLf/T9MP+jnMqP3qfmwvjCSiTRE08USeotNWhycztcFox94NbxMJkRt329tNeG2RRs7RzdCz21w==", "integrity": "sha512-1o0YT1QBCf9oAfQNJmWQehn+DQp8mqaUbwaivNtIgTKRlzAVfD7UoAS7izuUqEW6M6NOvFXfCQjp7IgGckVVBg==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@electron-forge/shared-types": "7.2.0", "@electron-forge/shared-types": "7.3.0",
"fs-extra": "^10.0.0", "fs-extra": "^10.0.0",
"which": "^2.0.2" "which": "^2.0.2"
}, },
@ -165,13 +179,13 @@
} }
}, },
"node_modules/@electron-forge/maker-deb": { "node_modules/@electron-forge/maker-deb": {
"version": "7.2.0", "version": "7.3.0",
"resolved": "https://registry.npmjs.org/@electron-forge/maker-deb/-/maker-deb-7.2.0.tgz", "resolved": "https://registry.npmjs.org/@electron-forge/maker-deb/-/maker-deb-7.3.0.tgz",
"integrity": "sha512-UYulMZpof+PIcapUFxQ5pVoSqa2FsS8crY8WGbVm1ALuknJUn4C2I37S8AujQH0l7oJRGnH95Y7Bcryyhe08yw==", "integrity": "sha512-rlTYjF18p1rVVzInr9kJPSwELvu2ycLp7qGi/Nrj91N2cS92D3z8l6UkQE6wvhsBMhhL0sOX+NyDhvzKoRsWNQ==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@electron-forge/maker-base": "7.2.0", "@electron-forge/maker-base": "7.3.0",
"@electron-forge/shared-types": "7.2.0" "@electron-forge/shared-types": "7.3.0"
}, },
"engines": { "engines": {
"node": ">= 16.4.0" "node": ">= 16.4.0"
@ -181,13 +195,13 @@
} }
}, },
"node_modules/@electron-forge/maker-rpm": { "node_modules/@electron-forge/maker-rpm": {
"version": "7.2.0", "version": "7.3.0",
"resolved": "https://registry.npmjs.org/@electron-forge/maker-rpm/-/maker-rpm-7.2.0.tgz", "resolved": "https://registry.npmjs.org/@electron-forge/maker-rpm/-/maker-rpm-7.3.0.tgz",
"integrity": "sha512-XKWK8Db44O9L7Njx0jEYLPfkf5eJ/i+XqT1Tejke+t0b74uCqFMKcbWLFp1LZj0hVM3kACy1LqtTCuOlti3INA==", "integrity": "sha512-EzfkRcnWeLYHUvGmtP2KcGU8I93izAaGfYze1xQqG6BQ0FXjEm7xcESy2gZThX/2vEtQUdjCdIbfVf4yveZKFQ==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@electron-forge/maker-base": "7.2.0", "@electron-forge/maker-base": "7.3.0",
"@electron-forge/shared-types": "7.2.0" "@electron-forge/shared-types": "7.3.0"
}, },
"engines": { "engines": {
"node": ">= 16.4.0" "node": ">= 16.4.0"
@ -197,13 +211,13 @@
} }
}, },
"node_modules/@electron-forge/maker-squirrel": { "node_modules/@electron-forge/maker-squirrel": {
"version": "7.2.0", "version": "7.3.0",
"resolved": "https://registry.npmjs.org/@electron-forge/maker-squirrel/-/maker-squirrel-7.2.0.tgz", "resolved": "https://registry.npmjs.org/@electron-forge/maker-squirrel/-/maker-squirrel-7.3.0.tgz",
"integrity": "sha512-SyPeFgJoMUcOPDM8+1AUPuseOqnl5YqnnjgKX9+YUIrsGKIsSz1cTtSOEu5R/l2yWNWFTmLnOlcuqIe7NayHBg==", "integrity": "sha512-JXKKwztnIDiMjzwUwROphZyIAtUivw7YOsWhskuxj/KhxtHpksNboBbwhvbvX8stfzVl2M95IgqATyPJXClQ9w==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@electron-forge/maker-base": "7.2.0", "@electron-forge/maker-base": "7.3.0",
"@electron-forge/shared-types": "7.2.0", "@electron-forge/shared-types": "7.3.0",
"fs-extra": "^10.0.0" "fs-extra": "^10.0.0"
}, },
"engines": { "engines": {
@ -214,13 +228,13 @@
} }
}, },
"node_modules/@electron-forge/maker-zip": { "node_modules/@electron-forge/maker-zip": {
"version": "7.2.0", "version": "7.3.0",
"resolved": "https://registry.npmjs.org/@electron-forge/maker-zip/-/maker-zip-7.2.0.tgz", "resolved": "https://registry.npmjs.org/@electron-forge/maker-zip/-/maker-zip-7.3.0.tgz",
"integrity": "sha512-U6FSSMcHogHDv+7SmF037lJ9m0stwwqyerw7Q6mD3jKQHX9GBxFApEzA5HSURGPAEBhPgPppYOSMGRB6LV5F2g==", "integrity": "sha512-VYYLScDpibVIiMRK7JWeCS9G8VYvPXa1X6p6fNYQoFOWommG9zC7OOnFfNnLBrH1+0ginZRJeLD1zo+cM12JuQ==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@electron-forge/maker-base": "7.2.0", "@electron-forge/maker-base": "7.3.0",
"@electron-forge/shared-types": "7.2.0", "@electron-forge/shared-types": "7.3.0",
"cross-zip": "^4.0.0", "cross-zip": "^4.0.0",
"fs-extra": "^10.0.0", "fs-extra": "^10.0.0",
"got": "^11.8.5" "got": "^11.8.5"
@ -229,51 +243,38 @@
"node": ">= 16.4.0" "node": ">= 16.4.0"
} }
}, },
"node_modules/@electron-forge/plugin-auto-unpack-natives": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/@electron-forge/plugin-auto-unpack-natives/-/plugin-auto-unpack-natives-7.2.0.tgz",
"integrity": "sha512-5BI2t/Qt9wP188PHoS1qv/0CqIhByyacWRVeAgQ9kP6iMsPyyc4kn3kWGDQF2MyFqMmusRzcdM+SljDGR9aIeg==",
"dev": true,
"dependencies": {
"@electron-forge/plugin-base": "7.2.0",
"@electron-forge/shared-types": "7.2.0"
},
"engines": {
"node": ">= 16.4.0"
}
},
"node_modules/@electron-forge/plugin-base": { "node_modules/@electron-forge/plugin-base": {
"version": "7.2.0", "version": "7.3.0",
"resolved": "https://registry.npmjs.org/@electron-forge/plugin-base/-/plugin-base-7.2.0.tgz", "resolved": "https://registry.npmjs.org/@electron-forge/plugin-base/-/plugin-base-7.3.0.tgz",
"integrity": "sha512-c/pQK36BMBMKiemO68g1ZQOCXBA93x/aeX3lIXwK5bKVuaGt16Unfmby5Q7iIvY+/KsBuLYGkAder8HDN+4Nbw==", "integrity": "sha512-cS0dqi9yTMgKzy1RhJ21YheRjWSbUh0bOKuByYAWevdqMZfqO2KyhXIsmH5QizL+bub8uWOUsknXVrOp73NLfw==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@electron-forge/shared-types": "7.2.0" "@electron-forge/shared-types": "7.3.0"
}, },
"engines": { "engines": {
"node": ">= 16.4.0" "node": ">= 16.4.0"
} }
}, },
"node_modules/@electron-forge/publisher-base": { "node_modules/@electron-forge/publisher-base": {
"version": "7.2.0", "version": "7.3.0",
"resolved": "https://registry.npmjs.org/@electron-forge/publisher-base/-/publisher-base-7.2.0.tgz", "resolved": "https://registry.npmjs.org/@electron-forge/publisher-base/-/publisher-base-7.3.0.tgz",
"integrity": "sha512-c0pwcQeMZi0S4iLlgA3pqm6ZdW2u7Ea4Ynat04Gw7su5GLtbrKRgYSL36ZRhzz7sgm4372niI0k91KaH5KToHg==", "integrity": "sha512-iO8QuM0zTLcEA0/7adEUOzMrhu/h6Qk9UiWNUllBctZXZ+FO0CbAY7eGzOgjOKqH5akbEKHwCSRnjrFt91QpQg==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@electron-forge/shared-types": "7.2.0" "@electron-forge/shared-types": "7.3.0"
}, },
"engines": { "engines": {
"node": ">= 16.4.0" "node": ">= 16.4.0"
} }
}, },
"node_modules/@electron-forge/shared-types": { "node_modules/@electron-forge/shared-types": {
"version": "7.2.0", "version": "7.3.0",
"resolved": "https://registry.npmjs.org/@electron-forge/shared-types/-/shared-types-7.2.0.tgz", "resolved": "https://registry.npmjs.org/@electron-forge/shared-types/-/shared-types-7.3.0.tgz",
"integrity": "sha512-d8i+pwPwBnlmFTRkq7QfaoRS9LywfyjDdHqQZuArFbL6NLAEbZ52irFiAE3NSLf4STew/BA6IK9sTPz3KRmvQw==", "integrity": "sha512-+YGOTGUGVrcaRm9zO3xsWSj2GS9iVY6E1WTG0vD2OxZtdEGcdy3hZryV72f5gH+qeZZvujYSR2s7VvZjhFEHaQ==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@electron-forge/tracer": "7.2.0", "@electron-forge/tracer": "7.3.0",
"@electron/packager": "^18.0.0", "@electron/packager": "^18.1.2",
"@electron/rebuild": "^3.2.10", "@electron/rebuild": "^3.2.10",
"listr2": "^5.0.3" "listr2": "^5.0.3"
}, },
@ -282,12 +283,12 @@
} }
}, },
"node_modules/@electron-forge/template-base": { "node_modules/@electron-forge/template-base": {
"version": "7.2.0", "version": "7.3.0",
"resolved": "https://registry.npmjs.org/@electron-forge/template-base/-/template-base-7.2.0.tgz", "resolved": "https://registry.npmjs.org/@electron-forge/template-base/-/template-base-7.3.0.tgz",
"integrity": "sha512-X7JrgQctgN0saFih/kKWVJ3KxiI1BpzdrkW58vs5H0kXXmA6UObE16/dWuKYfB06j0yIsfMbZ32Md1yAkgdCfg==", "integrity": "sha512-Lf0fupMzuO9XuBOaWoQ5QljjQ89B7TYU40+eEUvxnIMNAfnU3n+cfhC4xGLldmh+LYRuotB1jJitX79BwRqzIA==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@electron-forge/shared-types": "7.2.0", "@electron-forge/shared-types": "7.3.0",
"@malept/cross-spawn-promise": "^2.0.0", "@malept/cross-spawn-promise": "^2.0.0",
"debug": "^4.3.1", "debug": "^4.3.1",
"fs-extra": "^10.0.0", "fs-extra": "^10.0.0",
@ -298,13 +299,13 @@
} }
}, },
"node_modules/@electron-forge/template-vite": { "node_modules/@electron-forge/template-vite": {
"version": "7.2.0", "version": "7.3.0",
"resolved": "https://registry.npmjs.org/@electron-forge/template-vite/-/template-vite-7.2.0.tgz", "resolved": "https://registry.npmjs.org/@electron-forge/template-vite/-/template-vite-7.3.0.tgz",
"integrity": "sha512-Q5FSD+NVNMJKuAo/htQXpk3Q/eo116Xhx0zTzhSldAqpsgfxdAIJhl8TFmdVvCJIig1vEcLG2n/PgudxnuDuEQ==", "integrity": "sha512-4vdOLmd0/rThA9lO/Tf16oCoDBPWGLRZZF+XM+ECPDfaL0CbFNoEa/NLrr6T/2D6IlV5+GnmVjz29LlVOFUB7w==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@electron-forge/shared-types": "7.2.0", "@electron-forge/shared-types": "7.3.0",
"@electron-forge/template-base": "7.2.0", "@electron-forge/template-base": "7.3.0",
"fs-extra": "^10.0.0" "fs-extra": "^10.0.0"
}, },
"engines": { "engines": {
@ -312,13 +313,13 @@
} }
}, },
"node_modules/@electron-forge/template-vite-typescript": { "node_modules/@electron-forge/template-vite-typescript": {
"version": "7.2.0", "version": "7.3.0",
"resolved": "https://registry.npmjs.org/@electron-forge/template-vite-typescript/-/template-vite-typescript-7.2.0.tgz", "resolved": "https://registry.npmjs.org/@electron-forge/template-vite-typescript/-/template-vite-typescript-7.3.0.tgz",
"integrity": "sha512-knN3lxJY6UyXa2u5957K4ZyItCoCw22wrUhQARvdHOcgXvMFAcwvfEDT8zOQy6ki6A9W3cMHhSTys7dC8/ChVw==", "integrity": "sha512-4gVlJihXLM+r6GBOCeO6mSv5vZImew9Vp/xFfxMrf3nDThMCnA6HYLIGA361ZTbn4z3ARquXPo6Vsm7/s4ykbw==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@electron-forge/shared-types": "7.2.0", "@electron-forge/shared-types": "7.3.0",
"@electron-forge/template-base": "7.2.0", "@electron-forge/template-base": "7.3.0",
"fs-extra": "^10.0.0" "fs-extra": "^10.0.0"
}, },
"engines": { "engines": {
@ -326,13 +327,13 @@
} }
}, },
"node_modules/@electron-forge/template-webpack": { "node_modules/@electron-forge/template-webpack": {
"version": "7.2.0", "version": "7.3.0",
"resolved": "https://registry.npmjs.org/@electron-forge/template-webpack/-/template-webpack-7.2.0.tgz", "resolved": "https://registry.npmjs.org/@electron-forge/template-webpack/-/template-webpack-7.3.0.tgz",
"integrity": "sha512-h2LQ3vAzIraRqLUM5fKOLXknp7n5hrQXudRjO/vEEbm1a0jbl4yjp6liKk3yx8MFFO4eAHVDrXwRSsLR3a2Wew==", "integrity": "sha512-5Cv0g+AHdEI2R4hPI38PzWTnqUwqpM36jpQgkXV1RnL3V9FvNuza/w9RLMj5bhGzB0j5M4bVbcnglMX0pDvVBQ==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@electron-forge/shared-types": "7.2.0", "@electron-forge/shared-types": "7.3.0",
"@electron-forge/template-base": "7.2.0", "@electron-forge/template-base": "7.3.0",
"fs-extra": "^10.0.0" "fs-extra": "^10.0.0"
}, },
"engines": { "engines": {
@ -340,13 +341,13 @@
} }
}, },
"node_modules/@electron-forge/template-webpack-typescript": { "node_modules/@electron-forge/template-webpack-typescript": {
"version": "7.2.0", "version": "7.3.0",
"resolved": "https://registry.npmjs.org/@electron-forge/template-webpack-typescript/-/template-webpack-typescript-7.2.0.tgz", "resolved": "https://registry.npmjs.org/@electron-forge/template-webpack-typescript/-/template-webpack-typescript-7.3.0.tgz",
"integrity": "sha512-eshvPcYXUgmpB+ts9/xRPvQexY46unfe0mGmLDaj8s/5fqCANgyUO5jusvMXlJdf3qwJ/rfi3jS0NuqnjsqskQ==", "integrity": "sha512-eiBhsY/LUaV1vIy/PZqnmkxWyjEyN/PsXyq79lr1nuOKrqkVgZUe/IdvtNxr8wvPoKSScORNLHjiD/C2Jp74HA==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"@electron-forge/shared-types": "7.2.0", "@electron-forge/shared-types": "7.3.0",
"@electron-forge/template-base": "7.2.0", "@electron-forge/template-base": "7.3.0",
"fs-extra": "^10.0.0" "fs-extra": "^10.0.0"
}, },
"engines": { "engines": {
@ -354,9 +355,9 @@
} }
}, },
"node_modules/@electron-forge/tracer": { "node_modules/@electron-forge/tracer": {
"version": "7.2.0", "version": "7.3.0",
"resolved": "https://registry.npmjs.org/@electron-forge/tracer/-/tracer-7.2.0.tgz", "resolved": "https://registry.npmjs.org/@electron-forge/tracer/-/tracer-7.3.0.tgz",
"integrity": "sha512-EoJ07nptEuuY2fcs/bUWzIf11RQRx6Ch/dZ6A9WIRcFYe9cFrslQwvyUf0siY3jcqVvxETCz69JGuBxKGwak7A==", "integrity": "sha512-FS7ABTm52BMP2BlR/pDmUIKtH9NI1i+BBJuKke58KguToBRuvAX1cLt0Hhkq4HlqYR9fNjRoCo1vrK4OBb0Bew==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"chrome-trace-event": "^1.0.3" "chrome-trace-event": "^1.0.3"
@ -445,9 +446,9 @@
} }
}, },
"node_modules/@electron/notarize": { "node_modules/@electron/notarize": {
"version": "2.2.1", "version": "2.3.0",
"resolved": "https://registry.npmjs.org/@electron/notarize/-/notarize-2.2.1.tgz", "resolved": "https://registry.npmjs.org/@electron/notarize/-/notarize-2.3.0.tgz",
"integrity": "sha512-aL+bFMIkpR0cmmj5Zgy0LMKEpgy43/hw5zadEArgmAMWWlKc5buwFvFT9G/o/YJkvXAJm5q3iuTuLaiaXW39sg==", "integrity": "sha512-EiTBU0BwE7HZZjAG1fFWQaiQpCuPrVGn7jPss1kUjD6eTTdXXd29RiZqEqkgN7xqt/Pgn4g3I7Saqovanrfj3w==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"debug": "^4.1.1", "debug": "^4.1.1",
@ -1093,9 +1094,9 @@
"optional": true "optional": true
}, },
"node_modules/@types/node": { "node_modules/@types/node": {
"version": "18.19.15", "version": "18.19.18",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.15.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.18.tgz",
"integrity": "sha512-AMZ2UWx+woHNfM11PyAEQmfSxi05jm9OlkxczuHeEqmvwPkYj6MWv44gbzDPefYOLysTOFyI3ziiy2ONmUZfpA==", "integrity": "sha512-80CP7B8y4PzZF0GWx15/gVWRrB5y/bIjNI84NK3cmQJu0WZwvmj2WMA5LcofQFVfLqqCSp545+U2LsrVzX36Zg==",
"dependencies": { "dependencies": {
"undici-types": "~5.26.4" "undici-types": "~5.26.4"
} }
@ -1753,14 +1754,15 @@
} }
}, },
"node_modules/call-bind": { "node_modules/call-bind": {
"version": "1.0.6", "version": "1.0.7",
"resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.6.tgz", "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.7.tgz",
"integrity": "sha512-Mj50FLHtlsoVfRfnHaZvyrooHcrlceNZdL/QBvJJVd9Ta55qCQK0gs4ss2oZDeV9zFCs6ewzYgVE5yfVmfFpVg==", "integrity": "sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w==",
"dependencies": { "dependencies": {
"es-define-property": "^1.0.0",
"es-errors": "^1.3.0", "es-errors": "^1.3.0",
"function-bind": "^1.1.2", "function-bind": "^1.1.2",
"get-intrinsic": "^1.2.3", "get-intrinsic": "^1.2.4",
"set-function-length": "^1.2.0" "set-function-length": "^1.2.1"
}, },
"engines": { "engines": {
"node": ">= 0.4" "node": ">= 0.4"
@ -2406,9 +2408,9 @@
} }
}, },
"node_modules/cross-zip": { "node_modules/cross-zip": {
"version": "4.0.0", "version": "4.0.1",
"resolved": "https://registry.npmjs.org/cross-zip/-/cross-zip-4.0.0.tgz", "resolved": "https://registry.npmjs.org/cross-zip/-/cross-zip-4.0.1.tgz",
"integrity": "sha512-MEzGfZo0rqE10O/B+AEcCSJLZsrWuRUvmqJTqHNqBtALhaJc3E3ixLGLJNTRzEA2K34wbmOHC4fwYs9sVsdcCA==", "integrity": "sha512-n63i0lZ0rvQ6FXiGQ+/JFCKAUyPFhLQYJIqKaa+tSJtfKeULF/IDNDAbdnSIxgS4NTuw2b0+lj8LzfITuq+ZxQ==",
"dev": true, "dev": true,
"funding": [ "funding": [
{ {
@ -2596,17 +2598,19 @@
} }
}, },
"node_modules/define-data-property": { "node_modules/define-data-property": {
"version": "1.1.2", "version": "1.1.4",
"resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.2.tgz", "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz",
"integrity": "sha512-SRtsSqsDbgpJBbW3pABMCOt6rQyeM8s8RiyeSN8jYG8sYmt/kGJejbydttUsnDs1tadr19tvhT4ShwMyoqAm4g==", "integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==",
"dependencies": { "dependencies": {
"es-define-property": "^1.0.0",
"es-errors": "^1.3.0", "es-errors": "^1.3.0",
"get-intrinsic": "^1.2.2", "gopd": "^1.0.1"
"gopd": "^1.0.1",
"has-property-descriptors": "^1.0.1"
}, },
"engines": { "engines": {
"node": ">= 0.4" "node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
} }
}, },
"node_modules/define-properties": { "node_modules/define-properties": {
@ -2700,6 +2704,11 @@
"safer-buffer": "^2.1.0" "safer-buffer": "^2.1.0"
} }
}, },
"node_modules/ecc-jsbn/node_modules/jsbn": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz",
"integrity": "sha512-UVU9dibq2JcFWxQPA6KCqj5O42VOmAY3zQUfEKxU0KpTGXwNoCjkX1e13eHNvw/xPynt6pU0rZ1htjWTNTSXsg=="
},
"node_modules/ee-first": { "node_modules/ee-first": {
"version": "1.1.1", "version": "1.1.1",
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
@ -3330,6 +3339,17 @@
"is-arrayish": "^0.2.1" "is-arrayish": "^0.2.1"
} }
}, },
"node_modules/es-define-property": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.0.tgz",
"integrity": "sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ==",
"dependencies": {
"get-intrinsic": "^1.2.4"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/es-errors": { "node_modules/es-errors": {
"version": "1.3.0", "version": "1.3.0",
"resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz",
@ -3743,6 +3763,7 @@
"version": "1.0.4", "version": "1.0.4",
"resolved": "https://registry.npmjs.org/gar/-/gar-1.0.4.tgz", "resolved": "https://registry.npmjs.org/gar/-/gar-1.0.4.tgz",
"integrity": "sha512-w4n9cPWyP7aHxKxYHFQMegj7WIAsL/YX/C4Bs5Rr8s1H9M1rNtRWRsw+ovYMkXDQ5S4ZbYHsHAPmevPjPgw44w==", "integrity": "sha512-w4n9cPWyP7aHxKxYHFQMegj7WIAsL/YX/C4Bs5Rr8s1H9M1rNtRWRsw+ovYMkXDQ5S4ZbYHsHAPmevPjPgw44w==",
"deprecated": "Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.",
"dev": true, "dev": true,
"optional": true "optional": true
}, },
@ -4229,20 +4250,20 @@
} }
}, },
"node_modules/has-property-descriptors": { "node_modules/has-property-descriptors": {
"version": "1.0.1", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.1.tgz", "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz",
"integrity": "sha512-VsX8eaIewvas0xnvinAe9bw4WfIeODpGYikiWYLH+dma0Jw6KHYqWiWfhQlgOVK8D6PvjubK5Uc4P0iIhIcNVg==", "integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==",
"dependencies": { "dependencies": {
"get-intrinsic": "^1.2.2" "es-define-property": "^1.0.0"
}, },
"funding": { "funding": {
"url": "https://github.com/sponsors/ljharb" "url": "https://github.com/sponsors/ljharb"
} }
}, },
"node_modules/has-proto": { "node_modules/has-proto": {
"version": "1.0.1", "version": "1.0.3",
"resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.0.1.tgz", "resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.0.3.tgz",
"integrity": "sha512-7qE+iP+O+bgF9clE5+UoBFzE65mlBiVj3tKCrlNQ0Ogwm0BjpT/gK4SlLYDMybDh5I3TCTKnPPa0oMG7JDYrhg==", "integrity": "sha512-SJ1amZAJUiZS+PhsVLf5tGydlaVB8EdFpaSO4gmiUKUOxk8qzn5AIy4ZeJUmh22znIdk/uMAUT2pl3FxzVUH+Q==",
"engines": { "engines": {
"node": ">= 0.4" "node": ">= 0.4"
}, },
@ -4413,6 +4434,37 @@
"ms": "^2.0.0" "ms": "^2.0.0"
} }
}, },
"node_modules/i18next": {
"version": "23.10.0",
"resolved": "https://registry.npmjs.org/i18next/-/i18next-23.10.0.tgz",
"integrity": "sha512-/TgHOqsa7/9abUKJjdPeydoyDc0oTi/7u9F8lMSj6ufg4cbC1Oj3f/Jja7zj7WRIhEQKB7Q4eN6y68I9RDxxGQ==",
"funding": [
{
"type": "individual",
"url": "https://locize.com"
},
{
"type": "individual",
"url": "https://locize.com/i18next.html"
},
{
"type": "individual",
"url": "https://www.i18next.com/how-to/faq#i18next-is-awesome.-how-can-i-support-the-project"
}
],
"dependencies": {
"@babel/runtime": "^7.23.2"
}
},
"node_modules/i18next-xhr-backend": {
"version": "3.2.2",
"resolved": "https://registry.npmjs.org/i18next-xhr-backend/-/i18next-xhr-backend-3.2.2.tgz",
"integrity": "sha512-OtRf2Vo3IqAxsttQbpjYnmMML12IMB5e0fc5B7qKJFLScitYaXa1OhMX0n0X/3vrfFlpHL9Ro/H+ps4Ej2j7QQ==",
"deprecated": "replaced by i18next-http-backend",
"dependencies": {
"@babel/runtime": "^7.5.5"
}
},
"node_modules/iconv-lite": { "node_modules/iconv-lite": {
"version": "0.6.3", "version": "0.6.3",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz",
@ -4511,11 +4563,18 @@
"node": ">=10.13.0" "node": ">=10.13.0"
} }
}, },
"node_modules/ip": { "node_modules/ip-address": {
"version": "2.0.0", "version": "9.0.5",
"resolved": "https://registry.npmjs.org/ip/-/ip-2.0.0.tgz", "resolved": "https://registry.npmjs.org/ip-address/-/ip-address-9.0.5.tgz",
"integrity": "sha512-WKa+XuLG1A1R0UWhl2+1XQSi+fZWMsYKffMZTTYsiZaUD8k2yDAj5atimTUD2TZkyCkNEeYE5NhFZmupOGtjYQ==", "integrity": "sha512-zHtQzGojZXTwZTHQqra+ETKd4Sn3vgi7uBmlPoXVWZqYvuKmtI0l/VZTjqGmJY9x88GGOaZ9+G9ES8hC4T4X8g==",
"dev": true "dev": true,
"dependencies": {
"jsbn": "1.1.0",
"sprintf-js": "^1.1.3"
},
"engines": {
"node": ">= 12"
}
}, },
"node_modules/is-arrayish": { "node_modules/is-arrayish": {
"version": "0.2.1", "version": "0.2.1",
@ -4720,9 +4779,10 @@
} }
}, },
"node_modules/jsbn": { "node_modules/jsbn": {
"version": "0.1.1", "version": "1.1.0",
"resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-1.1.0.tgz",
"integrity": "sha512-UVU9dibq2JcFWxQPA6KCqj5O42VOmAY3zQUfEKxU0KpTGXwNoCjkX1e13eHNvw/xPynt6pU0rZ1htjWTNTSXsg==" "integrity": "sha512-4bYVV3aAMtDTTu4+xsDYa6sy9GyJ69/amsu9sYF2zqjiEoZA5xJi3BrfX3uY+/IekIu7MwdObdbDWpoZdBv3/A==",
"dev": true
}, },
"node_modules/jsdoc": { "node_modules/jsdoc": {
"version": "3.5.5", "version": "3.5.5",
@ -5399,9 +5459,9 @@
"dev": true "dev": true
}, },
"node_modules/node-abi": { "node_modules/node-abi": {
"version": "3.54.0", "version": "3.56.0",
"resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.54.0.tgz", "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.56.0.tgz",
"integrity": "sha512-p7eGEiQil0YUV3ItH4/tBb781L5impVmmx2E9FRKF7d18XXzp4PGT2tdYMFY6wQqgxD0IwNZOiSJ0/K0fSi/OA==", "integrity": "sha512-fZjdhDOeRcaS+rcpve7XuwHBmktS1nS1gzgghwKUQQ8nTy2FdSDr6ZT8k6YhvlJeHmmQMYiT/IH9hfco5zeW2Q==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"semver": "^7.3.5" "semver": "^7.3.5"
@ -6479,6 +6539,11 @@
"node": ">= 10.13.0" "node": ">= 10.13.0"
} }
}, },
"node_modules/regenerator-runtime": {
"version": "0.14.1",
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.14.1.tgz",
"integrity": "sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw=="
},
"node_modules/repeat-string": { "node_modules/repeat-string": {
"version": "1.6.1", "version": "1.6.1",
"resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz",
@ -7131,16 +7196,16 @@
"integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A=="
}, },
"node_modules/socks": { "node_modules/socks": {
"version": "2.7.1", "version": "2.8.1",
"resolved": "https://registry.npmjs.org/socks/-/socks-2.7.1.tgz", "resolved": "https://registry.npmjs.org/socks/-/socks-2.8.1.tgz",
"integrity": "sha512-7maUZy1N7uo6+WVEX6psASxtNlKaNVMlGQKkG/63nEDdLOWNbiUMoLK7X4uYoLhQstau72mLgfEWcXcwsaHbYQ==", "integrity": "sha512-B6w7tkwNid7ToxjZ08rQMT8M9BJAf8DKx8Ft4NivzH0zBUfd6jldGcisJn/RLgxcX3FPNDdNQCUEMMT79b+oCQ==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"ip": "^2.0.0", "ip-address": "^9.0.5",
"smart-buffer": "^4.2.0" "smart-buffer": "^4.2.0"
}, },
"engines": { "engines": {
"node": ">= 10.13.0", "node": ">= 10.0.0",
"npm": ">= 3.0.0" "npm": ">= 3.0.0"
} }
}, },
@ -7199,9 +7264,9 @@
} }
}, },
"node_modules/spdx-exceptions": { "node_modules/spdx-exceptions": {
"version": "2.4.0", "version": "2.5.0",
"resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.4.0.tgz", "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.5.0.tgz",
"integrity": "sha512-hcjppoJ68fhxA/cjbN4T8N6uCUejN8yFw69ttpqtBeCbF3u13n7mb31NB9jKwGTTWWnt9IbRA/mf1FprYS8wfw==", "integrity": "sha512-PiU42r+xO4UbUS1buo3LPJkjlO7430Xn5SVAhdpzzsPHsjbYVflnnFdATgabnLude+Cqu25p6N+g2lw/PFsa4w==",
"dev": true "dev": true
}, },
"node_modules/spdx-expression-parse": { "node_modules/spdx-expression-parse": {
@ -7224,7 +7289,7 @@
"version": "1.1.3", "version": "1.1.3",
"resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.3.tgz", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.3.tgz",
"integrity": "sha512-Oo+0REFV59/rz3gfJNKQiBlwfHaSESl1pcGyABQsnnIfWOFt6JNj5gCog2U6MLZ//IGYD+nA8nI+mTShREReaA==", "integrity": "sha512-Oo+0REFV59/rz3gfJNKQiBlwfHaSESl1pcGyABQsnnIfWOFt6JNj5gCog2U6MLZ//IGYD+nA8nI+mTShREReaA==",
"optional": true "devOptional": true
}, },
"node_modules/sshpk": { "node_modules/sshpk": {
"version": "1.18.0", "version": "1.18.0",
@ -7258,6 +7323,11 @@
"node": ">=0.8" "node": ">=0.8"
} }
}, },
"node_modules/sshpk/node_modules/jsbn": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz",
"integrity": "sha512-UVU9dibq2JcFWxQPA6KCqj5O42VOmAY3zQUfEKxU0KpTGXwNoCjkX1e13eHNvw/xPynt6pU0rZ1htjWTNTSXsg=="
},
"node_modules/ssri": { "node_modules/ssri": {
"version": "9.0.1", "version": "9.0.1",
"resolved": "https://registry.npmjs.org/ssri/-/ssri-9.0.1.tgz", "resolved": "https://registry.npmjs.org/ssri/-/ssri-9.0.1.tgz",
@ -7468,6 +7538,11 @@
"rimraf": "bin.js" "rimraf": "bin.js"
} }
}, },
"node_modules/three": {
"version": "0.139.0",
"resolved": "https://registry.npmjs.org/three/-/three-0.139.0.tgz",
"integrity": "sha512-hZ4LkCjgoEM82WLaOVptDKGpB3SkEyuJP2OHe36AFO8hS2I6CrEiNanXj7wwR3wIPT7V5wi5Y5pFnncS5SVHgQ=="
},
"node_modules/throttleit": { "node_modules/throttleit": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/throttleit/-/throttleit-1.0.1.tgz", "resolved": "https://registry.npmjs.org/throttleit/-/throttleit-1.0.1.tgz",

View file

@ -1,9 +1,9 @@
{ {
"name": "inav-configurator", "name": "inav-configurator",
"description": "INAV Configurator", "productName": "INAV Configurator",
"description": "Configurator for the open source flight controller software INAV.",
"version": "8.0.0", "version": "8.0.0",
"main": "main.js", "main": "js/main.js",
"default_locale": "en",
"scripts": { "scripts": {
"start": "electron-forge start", "start": "electron-forge start",
"package": "electron-forge package", "package": "electron-forge package",
@ -11,18 +11,11 @@
"publish": "electron-forge publish", "publish": "electron-forge publish",
"lint": "echo \"No linting configured\"" "lint": "echo \"No linting configured\""
}, },
"window": {
"title": "INAV Configurator",
"icon": "images/inav_icon_128.png",
"toolbar": true,
"width": 1024,
"height": 800
},
"repository": { "repository": {
"type": "git", "type": "git",
"url": "github.com/iNavFlight/inav-configurator" "url": "github.com/iNavFlight/inav-configurator"
}, },
"author": "iNavFlight", "author": "The INAV open source project",
"license": "GPL-3.0", "license": "GPL-3.0",
"dependencies": { "dependencies": {
"electron-squirrel-startup": "^1.0.0", "electron-squirrel-startup": "^1.0.0",
@ -32,6 +25,8 @@
"usb": "^2.11.0", "usb": "^2.11.0",
"promise-map-series": "^0.3.0", "promise-map-series": "^0.3.0",
"serialport": "^12.0.0", "serialport": "^12.0.0",
"semver": "^7.6.0",
"three": "0.139.0",
"inflection": "1.12.0", "inflection": "1.12.0",
"fs": "0.0.1-security", "fs": "0.0.1-security",
"jquery": "3.7.1", "jquery": "3.7.1",
@ -42,7 +37,9 @@
"openlayers": "^4.6.5", "openlayers": "^4.6.5",
"plotly": "^1.0.6", "plotly": "^1.0.6",
"temp": "^0.8.3", "temp": "^0.8.3",
"xml2js": "^0.4.19" "xml2js": "^0.4.19",
"i18next": "^23.8.3",
"i18next-xhr-backend": "^3.2.2"
}, },
"devDependencies": { "devDependencies": {
"@electron-forge/cli": "^7.2.0", "@electron-forge/cli": "^7.2.0",
@ -50,7 +47,6 @@
"@electron-forge/maker-rpm": "^7.2.0", "@electron-forge/maker-rpm": "^7.2.0",
"@electron-forge/maker-squirrel": "^7.2.0", "@electron-forge/maker-squirrel": "^7.2.0",
"@electron-forge/maker-zip": "^7.2.0", "@electron-forge/maker-zip": "^7.2.0",
"@electron-forge/plugin-auto-unpack-natives": "^7.2.0",
"electron": "28.1.4" "electron": "28.1.4"
} }
} }

View file

@ -132,7 +132,7 @@ TABS.adjustments.initialize = function (callback) {
var enableElement = $(newAdjustment).find('.enable'); var enableElement = $(newAdjustment).find('.enable');
$(enableElement).data('adjustmentElement', newAdjustment); $(enableElement).data('adjustmentElement', newAdjustment);
$(enableElement).change(function() { $(enableElement).on('change', function () {
var adjustmentElement = $(this).data('adjustmentElement'); var adjustmentElement = $(this).data('adjustmentElement');
if ($(this).prop("checked")) { if ($(this).prop("checked")) {
$(adjustmentElement).find(':input').prop("disabled", false); $(adjustmentElement).find(':input').prop("disabled", false);
@ -153,7 +153,7 @@ TABS.adjustments.initialize = function (callback) {
}); });
var isEnabled = (adjustmentRange.range.start != adjustmentRange.range.end); var isEnabled = (adjustmentRange.range.start != adjustmentRange.range.end);
$(enableElement).prop("checked", isEnabled).change(); $(enableElement).prop("checked", isEnabled).trigger('change');
return newAdjustment; return newAdjustment;
} }
@ -169,10 +169,10 @@ TABS.adjustments.initialize = function (callback) {
} }
// translate to user-selected language // translate to user-selected language
localization.localize();; i18n.localize();;
// UI Hooks // UI Hooks
$('a.save').click(function () { $('a.save').on('click', function () {
// update internal data structures based on current UI elements // update internal data structures based on current UI elements
var requiredAdjustmentRangeCount = ADJUSTMENT_RANGES.length; var requiredAdjustmentRangeCount = ADJUSTMENT_RANGES.length;
@ -222,7 +222,7 @@ TABS.adjustments.initialize = function (callback) {
function save_to_eeprom() { function save_to_eeprom() {
MSP.send_message(MSPCodes.MSP_EEPROM_WRITE, false, false, function () { MSP.send_message(MSPCodes.MSP_EEPROM_WRITE, false, false, function () {
GUI.log(localization.getMessage('adjustmentsEepromSaved')); GUI.log(i18n.getMessage('adjustmentsEepromSaved'));
}); });
} }

View file

@ -35,7 +35,7 @@ TABS.advanced_tuning.initialize = function (callback) {
GUI.simpleBind(); GUI.simpleBind();
localization.localize();; i18n.localize();;
// Set up required field warnings // Set up required field warnings
$('#launchIdleThr').keyup(function() { $('#launchIdleThr').keyup(function() {
@ -50,7 +50,7 @@ TABS.advanced_tuning.initialize = function (callback) {
TABS.advanced_tuning.checkRequirements_LinearDescent(); TABS.advanced_tuning.checkRequirements_LinearDescent();
}); });
$('#rthUseLinearDescent').change(function() { $('#rthUseLinearDescent').on('change', function () {
TABS.advanced_tuning.checkRequirements_LinearDescent(); TABS.advanced_tuning.checkRequirements_LinearDescent();
}); });
@ -58,7 +58,7 @@ TABS.advanced_tuning.initialize = function (callback) {
TABS.advanced_tuning.checkRequirements_IdleThrottle(); TABS.advanced_tuning.checkRequirements_IdleThrottle();
TABS.advanced_tuning.checkRequirements_LinearDescent(); TABS.advanced_tuning.checkRequirements_LinearDescent();
$('a.save').click(function () { $('a.save').on('click', function () {
Settings.saveInputs().then(function () { Settings.saveInputs().then(function () {
var self = this; var self = this;
MSP.promise(MSPCodes.MSP_EEPROM_WRITE); MSP.promise(MSPCodes.MSP_EEPROM_WRITE);
@ -77,7 +77,7 @@ TABS.advanced_tuning.initialize = function (callback) {
function reboot() { function reboot() {
//noinspection JSUnresolvedVariable //noinspection JSUnresolvedVariable
GUI.log(localization.getMessage('configurationEepromSaved')); GUI.log(i18n.getMessage('configurationEepromSaved'));
GUI.tab_switch_cleanup(function () { GUI.tab_switch_cleanup(function () {
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, reinitialize); MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, reinitialize);
}); });
@ -85,7 +85,7 @@ TABS.advanced_tuning.initialize = function (callback) {
function reinitialize() { function reinitialize() {
//noinspection JSUnresolvedVariable //noinspection JSUnresolvedVariable
GUI.log(localization.getMessage('deviceRebooting')); GUI.log(i18n.getMessage('deviceRebooting'));
GUI.handleReconnect($('.tab_advanced_tuning a')); GUI.handleReconnect($('.tab_advanced_tuning a'));
} }
}; };

View file

@ -138,7 +138,7 @@ TABS.auxiliary.initialize = function (callback) {
//add value to autodetect channel //add value to autodetect channel
let channelOption = channelOptionTemplate.clone(); let channelOption = channelOptionTemplate.clone();
channelOption.text(localization.getMessage('auxiliaryAutoChannelSelect')); channelOption.text(i18n.getMessage('auxiliaryAutoChannelSelect'));
channelOption.val(-1); channelOption.val(-1);
channelList.append(channelOption); channelList.append(channelOption);
@ -195,7 +195,7 @@ TABS.auxiliary.initialize = function (callback) {
$(rangeElement).find('.deleteRange').data('rangeElement', rangeElement); $(rangeElement).find('.deleteRange').data('rangeElement', rangeElement);
$(rangeElement).find('a.deleteRange').click(function () { $(rangeElement).find('a.deleteRange').on('click', function () {
var rangeElement = $(this).data('rangeElement'); var rangeElement = $(this).data('rangeElement');
modeElement.removeClass('inRange'); modeElement.removeClass('inRange');
rangeElement.remove(); rangeElement.remove();
@ -268,7 +268,7 @@ TABS.auxiliary.initialize = function (callback) {
return auxChannelIndexCandidates[0]; return auxChannelIndexCandidates[0];
} }
$('a.addRange').click(function () { $('a.addRange').on('click', function () {
var modeElement = $(this).data('modeElement'); var modeElement = $(this).data('modeElement');
var firstUnusedChannel = findFirstUnusedChannel(modeElement); var firstUnusedChannel = findFirstUnusedChannel(modeElement);
@ -277,10 +277,10 @@ TABS.auxiliary.initialize = function (callback) {
}); });
// translate to user-selected language // translate to user-selected language
localization.localize();; i18n.localize();;
// UI Hooks // UI Hooks
$('a.save').click(function () { $('a.save').on('click', function () {
// update internal data structures based on current UI elements // update internal data structures based on current UI elements
@ -330,7 +330,7 @@ TABS.auxiliary.initialize = function (callback) {
function save_to_eeprom() { function save_to_eeprom() {
MSP.send_message(MSPCodes.MSP_EEPROM_WRITE, false, false, function () { MSP.send_message(MSPCodes.MSP_EEPROM_WRITE, false, false, function () {
GUI.log(localization.getMessage('auxiliaryEepromSaved')); GUI.log(i18n.getMessage('auxiliaryEepromSaved'));
}); });
} }
}); });
@ -487,13 +487,13 @@ TABS.auxiliary.initialize = function (callback) {
let hideUnusedModes = false; let hideUnusedModes = false;
let hideUnusedModesStore = store.get('hideUnusedModes', false); let hideUnusedModesStore = store.get('hideUnusedModes', false);
$("input#switch-toggle-unused") $("input#switch-toggle-unused")
.change(function() { .on('change', function () {
hideUnusedModes = $(this).prop("checked"); hideUnusedModes = $(this).prop("checked");
store.set('hideUnusedModes', hideUnusedModes); store.set('hideUnusedModes', hideUnusedModes);
update_ui(); update_ui();
}) })
.prop("checked", !!hideUnusedModesStore) .prop("checked", !!hideUnusedModesStore)
.change(); .trigger('change');
// update ui instantly on first load // update ui instantly on first load
update_ui(); update_ui();

View file

@ -67,7 +67,7 @@ TABS.calibration.initialize = function (callback) {
function reboot() { function reboot() {
//noinspection JSUnresolvedVariable //noinspection JSUnresolvedVariable
GUI.log(localization.getMessage('configurationEepromSaved')); GUI.log(i18n.getMessage('configurationEepromSaved'));
GUI.tab_switch_cleanup(function() { GUI.tab_switch_cleanup(function() {
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, reinitialize); MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, reinitialize);
@ -76,7 +76,7 @@ TABS.calibration.initialize = function (callback) {
function reinitialize() { function reinitialize() {
//noinspection JSUnresolvedVariable //noinspection JSUnresolvedVariable
GUI.log(localization.getMessage('deviceRebooting')); GUI.log(i18n.getMessage('deviceRebooting'));
GUI.handleReconnect($('.tab_calibration a')); GUI.handleReconnect($('.tab_calibration a'));
} }
@ -161,7 +161,7 @@ TABS.calibration.initialize = function (callback) {
}).open(); }).open();
MSP.send_message(MSPCodes.MSP_ACC_CALIBRATION, false, false, function () { MSP.send_message(MSPCodes.MSP_ACC_CALIBRATION, false, false, function () {
GUI.log(localization.getMessage('initialSetupAccelCalibStarted')); GUI.log(i18n.getMessage('initialSetupAccelCalibStarted'));
}); });
helper.timeout.add('acc_calibration_timeout', function () { helper.timeout.add('acc_calibration_timeout', function () {
@ -169,20 +169,20 @@ TABS.calibration.initialize = function (callback) {
modalProcessing.close(); modalProcessing.close();
MSP.send_message(MSPCodes.MSP_CALIBRATION_DATA, false, false, checkFinishAccCalibrate); MSP.send_message(MSPCodes.MSP_CALIBRATION_DATA, false, false, checkFinishAccCalibrate);
GUI.log(localization.getMessage('initialSetupAccelCalibEnded')); GUI.log(i18n.getMessage('initialSetupAccelCalibEnded'));
}, 2000); }, 2000);
} }
} }
function setupCalibrationButton(callback) { function setupCalibrationButton(callback) {
if (FC.getAccelerometerCalibrated()) { if (FC.getAccelerometerCalibrated()) {
$('#calibrate-start-button').html(localization.getMessage("AccResetBtn")); $('#calibrate-start-button').html(i18n.getMessage("AccResetBtn"));
$('#calibrate-start-button').prop("title", localization.getMessage("AccResetBtn")); $('#calibrate-start-button').prop("title", i18n.getMessage("AccResetBtn"));
$('#calibrate-start-button').removeClass("calibrate"); $('#calibrate-start-button').removeClass("calibrate");
$('#calibrate-start-button').addClass("resetCalibration"); $('#calibrate-start-button').addClass("resetCalibration");
} else { } else {
$('#calibrate-start-button').html(localization.getMessage("AccBtn")); $('#calibrate-start-button').html(i18n.getMessage("AccBtn"));
$('#calibrate-start-button').prop("title", localization.getMessage("AccBtn")); $('#calibrate-start-button').prop("title", i18n.getMessage("AccBtn"));
$('#calibrate-start-button').addClass("calibrate"); $('#calibrate-start-button').addClass("calibrate");
$('#calibrate-start-button').removeClass("resetCalibration"); $('#calibrate-start-button').removeClass("resetCalibration");
} }
@ -228,7 +228,7 @@ TABS.calibration.initialize = function (callback) {
$('#mag_btn').on('click', function () { $('#mag_btn').on('click', function () {
MSP.send_message(MSPCodes.MSP_MAG_CALIBRATION, false, false, function () { MSP.send_message(MSPCodes.MSP_MAG_CALIBRATION, false, false, function () {
GUI.log(localization.getMessage('initialSetupMagCalibStarted')); GUI.log(i18n.getMessage('initialSetupMagCalibStarted'));
}); });
var button = $(this); var button = $(this);
@ -252,7 +252,7 @@ TABS.calibration.initialize = function (callback) {
$(button).removeClass('disabled'); $(button).removeClass('disabled');
modalProcessing.close(); modalProcessing.close();
GUI.log(localization.getMessage('initialSetupMagCalibEnded')); GUI.log(i18n.getMessage('initialSetupMagCalibEnded'));
MSP.send_message(MSPCodes.MSP_CALIBRATION_DATA, false, false, updateSensorData); MSP.send_message(MSPCodes.MSP_CALIBRATION_DATA, false, false, updateSensorData);
helper.interval.remove('compass_calibration_interval'); helper.interval.remove('compass_calibration_interval');
@ -270,7 +270,7 @@ TABS.calibration.initialize = function (callback) {
$('#opflow_btn').on('click', function () { $('#opflow_btn').on('click', function () {
MSP.send_message(MSPCodes.MSP2_INAV_OPFLOW_CALIBRATION, false, false, function () { MSP.send_message(MSPCodes.MSP2_INAV_OPFLOW_CALIBRATION, false, false, function () {
GUI.log(localization.getMessage('initialSetupOpflowCalibStarted')); GUI.log(i18n.getMessage('initialSetupOpflowCalibStarted'));
}); });
var button = $(this); var button = $(this);
@ -294,24 +294,24 @@ TABS.calibration.initialize = function (callback) {
$(button).removeClass('disabled'); $(button).removeClass('disabled');
modalProcessing.close(); modalProcessing.close();
GUI.log(localization.getMessage('initialSetupOpflowCalibEnded')); GUI.log(i18n.getMessage('initialSetupOpflowCalibEnded'));
MSP.send_message(MSPCodes.MSP_CALIBRATION_DATA, false, false, updateSensorData); MSP.send_message(MSPCodes.MSP_CALIBRATION_DATA, false, false, updateSensorData);
helper.interval.remove('opflow_calibration_interval'); helper.interval.remove('opflow_calibration_interval');
} }
}, 1000); }, 1000);
}); });
$('#modal-start-button').click(function () { $('#modal-start-button').on('click', function () {
modalStart.close(); modalStart.close();
TABS.calibration.model.next(); TABS.calibration.model.next();
}); });
$('#modal-stop-button').click(function () { $('#modal-stop-button').on('click', function () {
modalStop.close(); modalStop.close();
}); });
// translate to user-selected language // translate to user-selected language
localization.localize();; i18n.localize();;
setupCalibrationButton(); setupCalibrationButton();
$('#calibrate-start-button').on('click', actionCalibrateButton); $('#calibrate-start-button').on('click', actionCalibrateButton);

View file

@ -51,7 +51,7 @@ function copyToClipboard(text) {
const button = $('.tab-cli .copy'); const button = $('.tab-cli .copy');
const origText = button.text(); const origText = button.text();
const origWidth = button.css("width"); const origWidth = button.css("width");
button.text(localization.getMessage("cliCopySuccessful")); button.text(i18n.getMessage("cliCopySuccessful"));
button.css({ button.css({
width: origWidth, width: origWidth,
textAlign: "center", textAlign: "center",
@ -123,7 +123,7 @@ TABS.cli.initialize = function (callback) {
GUI.load(path.join(__dirname, "tabs/cli.html"), function () { GUI.load(path.join(__dirname, "tabs/cli.html"), function () {
// translate to user-selected language // translate to user-selected language
localization.localize(); i18n.localize();
$('.cliDocsBtn').attr('href', globalSettings.docsTreeLocation + 'Settings.md'); $('.cliDocsBtn').attr('href', globalSettings.docsTreeLocation + 'Settings.md');
@ -134,17 +134,17 @@ TABS.cli.initialize = function (callback) {
$(CliAutoComplete).on('build:start', function() { $(CliAutoComplete).on('build:start', function() {
textarea textarea
.val('') .val('')
.attr('placeholder', localization.getMessage('cliInputPlaceholderBuilding')) .attr('placeholder', i18n.getMessage('cliInputPlaceholderBuilding'))
.prop('disabled', true); .prop('disabled', true);
}); });
$(CliAutoComplete).on('build:stop', function() { $(CliAutoComplete).on('build:stop', function() {
textarea textarea
.attr('placeholder', localization.getMessage('cliInputPlaceholder')) .attr('placeholder', i18n.getMessage('cliInputPlaceholder'))
.prop('disabled', false) .prop('disabled', false)
.focus(); .focus();
}); });
$('.tab-cli .save').click(function() { $('.tab-cli .save').on('click', function () {
var options = { var options = {
filters: [ filters: [
@ -154,17 +154,17 @@ TABS.cli.initialize = function (callback) {
}; };
dialog.showSaveDialog(options).then(result => { dialog.showSaveDialog(options).then(result => {
if (result.canceled) { if (result.canceled) {
GUI.log(localization.getMessage('cliSaveToFileAborted')); GUI.log(i18n.getMessage('cliSaveToFileAborted'));
return; return;
} }
const fs = require('fs'); const fs = require('fs');
fs.writeFile(result.filePath, self.outputHistory, (err) => { fs.writeFile(result.filePath, self.outputHistory, (err) => {
if (err) { if (err) {
GUI.log(localization.getMessage('ErrorWritingFile')); GUI.log(i18n.getMessage('ErrorWritingFile'));
return console.error(err); return console.error(err);
} }
GUI.log(localization.getMessage('FileSaved')); GUI.log(i18n.getMessage('FileSaved'));
}); });
}).catch (err => { }).catch (err => {
@ -172,38 +172,38 @@ TABS.cli.initialize = function (callback) {
}); });
}); });
$('.tab-cli .exit').click(function() { $('.tab-cli .exit').on('click', function () {
self.send(getCliCommand('exit\n', TABS.cli.cliBuffer)); self.send(getCliCommand('exit\n', TABS.cli.cliBuffer));
}); });
$('.tab-cli .savecmd').click(function() { $('.tab-cli .savecmd').on('click', function () {
self.send(getCliCommand('save\n', TABS.cli.cliBuffer)); self.send(getCliCommand('save\n', TABS.cli.cliBuffer));
}); });
$('.tab-cli .msc').click(function() { $('.tab-cli .msc').on('click', function () {
self.send(getCliCommand('msc\n', TABS.cli.cliBuffer)); self.send(getCliCommand('msc\n', TABS.cli.cliBuffer));
}); });
$('.tab-cli .diffall').click(function() { $('.tab-cli .diffall').on('click', function () {
self.outputHistory = ""; self.outputHistory = "";
$('.tab-cli .window .wrapper').empty(); $('.tab-cli .window .wrapper').empty();
self.send(getCliCommand('diff all\n', TABS.cli.cliBuffer)); self.send(getCliCommand('diff all\n', TABS.cli.cliBuffer));
}); });
$('.tab-cli .clear').click(function() { $('.tab-cli .clear').on('click', function () {
self.outputHistory = ""; self.outputHistory = "";
$('.tab-cli .window .wrapper').empty(); $('.tab-cli .window .wrapper').empty();
}); });
if (clipboardCopySupport) { if (clipboardCopySupport) {
$('.tab-cli .copy').click(function() { $('.tab-cli .copy').on('click', function () {
copyToClipboard(self.outputHistory); copyToClipboard(self.outputHistory);
}); });
} else { } else {
$('.tab-cli .copy').hide(); $('.tab-cli .copy').hide();
} }
$('.tab-cli .load').on('click', () => { $('.tab-cli .load').on('click', function () {
var options = { var options = {
filters: [ filters: [
{ name: 'CLI/TXT', extensions: ['cli', 'txt'] }, { name: 'CLI/TXT', extensions: ['cli', 'txt'] },
@ -233,9 +233,9 @@ TABS.cli.initialize = function (callback) {
closeButton: 'title', closeButton: 'title',
animation: false, animation: false,
isolateScroll: false, isolateScroll: false,
title: localization.getMessage("cliConfirmSnippetDialogTitle"), title: i18n.getMessage("cliConfirmSnippetDialogTitle"),
content: $('#snippetpreviewcontent'), content: $('#snippetpreviewcontent'),
onCreated: () => $("#snippetpreviewcontent a.confirm").click(() => executeSnippet()), onCreated: () => $("#snippetpreviewcontent a.confirm").on('click', function () executeSnippet()),
}); });
} }
previewArea.val(result); previewArea.val(result);
@ -246,7 +246,7 @@ TABS.cli.initialize = function (callback) {
const fs = require('fs'); const fs = require('fs');
fs.readFile(result.filePaths[0], (err, data) => { fs.readFile(result.filePaths[0], (err, data) => {
if (err) { if (err) {
GUI.log(localization.getMessage('ErrorReadingFile')); GUI.log(i18n.getMessage('ErrorReadingFile'));
return console.error(err); return console.error(err);
} }
@ -343,7 +343,7 @@ TABS.cli.initialize = function (callback) {
if (delay > 0) { if (delay > 0) {
helper.timeout.add('cli_delay', () => { helper.timeout.add('cli_delay', () => {
self.send(getCliCommand("cli_delay " + delay + '\n', TABS.cli.cliBuffer)); self.send(getCliCommand("cli_delay " + delay + '\n', TABS.cli.cliBuffer));
self.send(getCliCommand('# ' + localization.getMessage('connectionBleCliEnter') + '\n', TABS.cli.cliBuffer)); self.send(getCliCommand('# ' + i18n.getMessage('connectionBleCliEnter') + '\n', TABS.cli.cliBuffer));
}, 400); }, 400);
} }
} }
@ -469,15 +469,15 @@ TABS.cli.read = function (readInfo) {
if (this.cliBuffer == 'Rebooting') { if (this.cliBuffer == 'Rebooting') {
CONFIGURATOR.cliActive = false; CONFIGURATOR.cliActive = false;
CONFIGURATOR.cliValid = false; CONFIGURATOR.cliValid = false;
GUI.log(localization.getMessage('cliReboot')); GUI.log(i18n.getMessage('cliReboot'));
GUI.log(localization.getMessage('deviceRebooting')); GUI.log(i18n.getMessage('deviceRebooting'));
GUI.handleReconnect(); GUI.handleReconnect();
} }
} }
if (!CONFIGURATOR.cliValid && validateText.indexOf('CLI') !== -1) { if (!CONFIGURATOR.cliValid && validateText.indexOf('CLI') !== -1) {
GUI.log(localization.getMessage('cliEnter')); GUI.log(i18n.getMessage('cliEnter'));
CONFIGURATOR.cliValid = true; CONFIGURATOR.cliValid = true;
if (CliAutoComplete.isEnabled() && !CliAutoComplete.isBuilding()) { if (CliAutoComplete.isEnabled() && !CliAutoComplete.isBuilding()) {

View file

@ -49,7 +49,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
function reboot() { function reboot() {
//noinspection JSUnresolvedVariable //noinspection JSUnresolvedVariable
GUI.log(localization.getMessage('configurationEepromSaved')); GUI.log(i18n.getMessage('configurationEepromSaved'));
GUI.tab_switch_cleanup(function () { GUI.tab_switch_cleanup(function () {
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, reinitialize); MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, reinitialize);
@ -58,7 +58,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
function reinitialize() { function reinitialize() {
//noinspection JSUnresolvedVariable //noinspection JSUnresolvedVariable
GUI.log(localization.getMessage('deviceRebooting')); GUI.log(i18n.getMessage('deviceRebooting'));
GUI.handleReconnect($('.tab_configuration a')); GUI.handleReconnect($('.tab_configuration a'));
} }
@ -80,11 +80,11 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
feature_tip_html = ''; feature_tip_html = '';
if (features[i].showNameInTip) { if (features[i].showNameInTip) {
tips.push(localization.getMessage("manualEnablingTemplate").replace("{name}", features[i].name)); tips.push(i18n.getMessage("manualEnablingTemplate").replace("{name}", features[i].name));
} }
if (features[i].haveTip) { if (features[i].haveTip) {
tips.push(localization.getMessage("feature" + features[i].name + "Tip")); tips.push(i18n.getMessage("feature" + features[i].name + "Tip"));
} }
if (tips.length > 0) { if (tips.length > 0) {
@ -111,7 +111,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
helper.features.updateUI($('.tab-configuration'), FEATURES); helper.features.updateUI($('.tab-configuration'), FEATURES);
// translate to user-selected language // translate to user-selected language
localization.localize();; i18n.localize();;
// VTX // VTX
var config_vtx = $('.config-vtx'); var config_vtx = $('.config-vtx');
@ -121,7 +121,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
vtx_band.empty(); vtx_band.empty();
var vtx_no_band_note = $('#vtx_no_band'); var vtx_no_band_note = $('#vtx_no_band');
if (VTX_CONFIG.band < VTX.BAND_MIN || VTX_CONFIG.band > VTX.BAND_MAX) { if (VTX_CONFIG.band < VTX.BAND_MIN || VTX_CONFIG.band > VTX.BAND_MAX) {
var noBandName = localization.getMessage("configurationNoBand"); var noBandName = i18n.getMessage("configurationNoBand");
$('<option value="0">' + noBandName + '</option>').appendTo(vtx_band); $('<option value="0">' + noBandName + '</option>').appendTo(vtx_band);
vtx_no_band_note.show(); vtx_no_band_note.show();
} else { } else {
@ -135,7 +135,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
} }
option.appendTo(vtx_band); option.appendTo(vtx_band);
} }
vtx_band.change(function () { vtx_band.on('change', function () {
VTX_CONFIG.band = parseInt($(this).val()); VTX_CONFIG.band = parseInt($(this).val());
}); });
@ -148,7 +148,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
} }
option.appendTo(vtx_channel); option.appendTo(vtx_channel);
} }
vtx_channel.change(function () { vtx_channel.on('change', function () {
VTX_CONFIG.channel = parseInt($(this).val()); VTX_CONFIG.channel = parseInt($(this).val());
}); });
@ -163,14 +163,14 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
} }
option.appendTo(vtx_power); option.appendTo(vtx_power);
} }
vtx_power.change(function () { vtx_power.on('change', function () {
VTX_CONFIG.power = parseInt($(this).val()); VTX_CONFIG.power = parseInt($(this).val());
}); });
var vtx_low_power_disarm = $('#vtx_low_power_disarm'); var vtx_low_power_disarm = $('#vtx_low_power_disarm');
vtx_low_power_disarm.empty(); vtx_low_power_disarm.empty();
for (var ii = VTX.LOW_POWER_DISARM_MIN; ii <= VTX.LOW_POWER_DISARM_MAX; ii++) { for (var ii = VTX.LOW_POWER_DISARM_MIN; ii <= VTX.LOW_POWER_DISARM_MAX; ii++) {
var name = localization.getMessage("configurationVTXLowPowerDisarmValue_" + ii); var name = i18n.getMessage("configurationVTXLowPowerDisarmValue_" + ii);
if (!name) { if (!name) {
name = ii; name = ii;
} }
@ -180,7 +180,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
} }
option.appendTo(vtx_low_power_disarm); option.appendTo(vtx_low_power_disarm);
} }
vtx_low_power_disarm.change(function () { vtx_low_power_disarm.on('change', function () {
VTX_CONFIG.low_power_disarm = parseInt($(this).val()); VTX_CONFIG.low_power_disarm = parseInt($(this).val());
}); });
@ -226,7 +226,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
let $i2cSpeed = $('#i2c_speed'), let $i2cSpeed = $('#i2c_speed'),
$i2cSpeedInfo = $('#i2c_speed-info'); $i2cSpeedInfo = $('#i2c_speed-info');
$i2cSpeed.change(function () { $i2cSpeed.on('change', function () {
let $this = $(this), let $this = $(this),
value = $this.children("option:selected").text(); value = $this.children("option:selected").text();
@ -236,7 +236,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
$i2cSpeedInfo.addClass('info-box'); $i2cSpeedInfo.addClass('info-box');
$i2cSpeedInfo.removeClass('warning-box'); $i2cSpeedInfo.removeClass('warning-box');
$i2cSpeedInfo.html(localization.getMessage('i2cSpeedSuggested800khz')); $i2cSpeedInfo.html(i18n.getMessage('i2cSpeedSuggested800khz'));
$i2cSpeedInfo.show(); $i2cSpeedInfo.show();
} else if (value == "800KHZ") { } else if (value == "800KHZ") {
@ -248,15 +248,15 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
$i2cSpeedInfo.removeClass('ok-box'); $i2cSpeedInfo.removeClass('ok-box');
$i2cSpeedInfo.removeClass('info-box'); $i2cSpeedInfo.removeClass('info-box');
$i2cSpeedInfo.addClass('warning-box'); $i2cSpeedInfo.addClass('warning-box');
$i2cSpeedInfo.html(localization.getMessage('i2cSpeedTooLow')); $i2cSpeedInfo.html(i18n.getMessage('i2cSpeedTooLow'));
$i2cSpeedInfo.show(); $i2cSpeedInfo.show();
} }
}); });
$i2cSpeed.change(); $i2cSpeed.trigger('change');
$('a.save').click(function () { $('a.save').on('click', function () {
//UPDATE: moved to GPS tab and hidden //UPDATE: moved to GPS tab and hidden
//MISC.mag_declination = parseFloat($('#mag_declination').val()); //MISC.mag_declination = parseFloat($('#mag_declination').val());

View file

@ -34,14 +34,14 @@ TABS.ez_tune.initialize = function (callback) {
function reboot() { function reboot() {
//noinspection JSUnresolvedVariable //noinspection JSUnresolvedVariable
GUI.log(localization.getMessage('configurationEepromSaved')); GUI.log(i18n.getMessage('configurationEepromSaved'));
GUI.tab_switch_cleanup(function () { GUI.tab_switch_cleanup(function () {
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, reinitialize); MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, reinitialize);
}); });
} }
function reinitialize() { function reinitialize() {
GUI.log(localization.getMessage('deviceRebooting')); GUI.log(i18n.getMessage('deviceRebooting'));
GUI.handleReconnect($('.tab_ez_tune a')); GUI.handleReconnect($('.tab_ez_tune a'));
} }
@ -101,7 +101,7 @@ TABS.ez_tune.initialize = function (callback) {
} }
function process_html() { function process_html() {
localization.localize();; i18n.localize();;
helper.tabs.init($('.tab-ez_tune')); helper.tabs.init($('.tab-ez_tune'));
helper.features.updateUI($('.tab-ez_tune'), FEATURES); helper.features.updateUI($('.tab-ez_tune'), FEATURES);

View file

@ -18,7 +18,7 @@ TABS.failsafe.initialize = function (callback, scrollPosition) {
GUI.simpleBind(); GUI.simpleBind();
// translate to user-selected language // translate to user-selected language
localization.localize();; i18n.localize();;
// for some odd reason chrome 38+ changes scroll according to the touched select element // for some odd reason chrome 38+ changes scroll according to the touched select element
// i am guessing this is a bug, since this wasn't happening on 37 // i am guessing this is a bug, since this wasn't happening on 37
@ -26,7 +26,7 @@ TABS.failsafe.initialize = function (callback, scrollPosition) {
$('#content').scrollTop((scrollPosition) ? scrollPosition : 0); $('#content').scrollTop((scrollPosition) ? scrollPosition : 0);
// set stage 2 failsafe procedure // set stage 2 failsafe procedure
$('input[type="radio"].procedure').change(function () { $('input[type="radio"].procedure').on('change', function () {
var element = $(this), var element = $(this),
checked = element.is(':checked'), checked = element.is(':checked'),
id = element.attr('id'); id = element.attr('id');
@ -53,27 +53,27 @@ TABS.failsafe.initialize = function (callback, scrollPosition) {
case 0: case 0:
let element = $('input[id="land"]'); let element = $('input[id="land"]');
element.prop('checked', true); element.prop('checked', true);
element.change(); element.trigger('change');
break; break;
case 1: case 1:
element = $('input[id="drop"]'); element = $('input[id="drop"]');
element.prop('checked', true); element.prop('checked', true);
element.change(); element.trigger('change');
break; break;
case 2: case 2:
element = $('input[id="rth"]'); element = $('input[id="rth"]');
element.prop('checked', true); element.prop('checked', true);
element.change(); element.trigger('change');
break; break;
case 3: case 3:
element = $('input[id="nothing"]'); element = $('input[id="nothing"]');
element.prop('checked', true); element.prop('checked', true);
element.change(); element.trigger('change');
break; break;
} }
// Adjust Minimum Distance values when checkbox is checked/unchecked // Adjust Minimum Distance values when checkbox is checked/unchecked
$('#failsafe_use_minimum_distance').change(function() { $('#failsafe_use_minimum_distance').on('change', function () {
if ($(this).is(':checked')) { if ($(this).is(':checked')) {
// No default distance added due to conversions // No default distance added due to conversions
$('#failsafe_min_distance_elements').show(); $('#failsafe_min_distance_elements').show();
@ -97,7 +97,7 @@ TABS.failsafe.initialize = function (callback, scrollPosition) {
$('#failsafe_min_distance_procedure_elements').hide(); $('#failsafe_min_distance_procedure_elements').hide();
} }
$('a.save').click(function () { $('a.save').on('click', function () {
if ($('input[id="land"]').is(':checked')) { if ($('input[id="land"]').is(':checked')) {
FAILSAFE_CONFIG.failsafe_procedure = 0; FAILSAFE_CONFIG.failsafe_procedure = 0;
} else if ($('input[id="drop"]').is(':checked')) { } else if ($('input[id="drop"]').is(':checked')) {
@ -130,7 +130,7 @@ TABS.failsafe.initialize = function (callback, scrollPosition) {
function reboot() { function reboot() {
//noinspection JSUnresolvedVariable //noinspection JSUnresolvedVariable
GUI.log(localization.getMessage('configurationEepromSaved')); GUI.log(i18n.getMessage('configurationEepromSaved'));
GUI.tab_switch_cleanup(function () { GUI.tab_switch_cleanup(function () {
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, reinitialize); MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, reinitialize);
}); });
@ -138,7 +138,7 @@ TABS.failsafe.initialize = function (callback, scrollPosition) {
function reinitialize() { function reinitialize() {
//noinspection JSUnresolvedVariable //noinspection JSUnresolvedVariable
GUI.log(localization.getMessage('deviceRebooting')); GUI.log(i18n.getMessage('deviceRebooting'));
GUI.handleReconnect($('.tab_failsafe a')); GUI.handleReconnect($('.tab_failsafe a'));
} }
}; };

View file

@ -1,7 +1,27 @@
/*global $*/
'use strict'; 'use strict';
const { marked } = require('marked'); const { marked } = require('marked');
const path = require('path');
const semver = require('semver');
const { dialog } = require('@electron/remote');
const Store = require('electron-store');
const store = new Store();
const i18n = require('./../js/localization');
const { GUI, TABS } = require('./../js/gui');
const MSP = require('./../js/msp');
const MSPCodes = require('./../js/msp/MSPCodes')
const FC = require('./../js/fc');
const { usbDevices, PortHandler } = require('./../js/port_handler');
const CONFIGURATOR = require('./../js/data_storage');
const SerialBackend = require('./../js/serial_backend');
const timeout = require('./../js/timeouts');
const interval = require('./../js/intervals');
const mspBalancedInterval = require('./../js/msp_balanced_interval');
const mspQueue = require('./../js/serial_queue');
const mspHelper = require('./../js/msp/MSPHelper');
const STM32 = require('./../js/protocols/stm32');
const STM32DFU = require('./../js/protocols/stm32usbdfu');
TABS.firmware_flasher = {}; TABS.firmware_flasher = {};
TABS.firmware_flasher.initialize = function (callback) { TABS.firmware_flasher.initialize = function (callback) {
@ -10,16 +30,15 @@ TABS.firmware_flasher.initialize = function (callback) {
GUI.active_tab = 'firmware_flasher'; GUI.active_tab = 'firmware_flasher';
} }
var intel_hex = false, // standard intel hex in string format var intel_hex = false, // standard intel hex in string format
parsed_hex = false; // parsed raw hex in array format parsed_hex = false; // parsed raw hex in array format
GUI.load(path.join(__dirname, "tabs/firmware_flasher.html"), function () { GUI.load(path.join(__dirname, "firmware_flasher.html"), function () {
// translate to user-selected language // translate to user-selected language
localization.localize(); i18n.localize();
function enable_load_online_button() { function enable_load_online_button() {
$(".load_remote_file").text(localization.getMessage('firmwareFlasherButtonLoadOnline')).removeClass('disabled'); $(".load_remote_file").text(i18n.getMessage('firmwareFlasherButtonLoadOnline')).removeClass('disabled');
} }
function parse_hex(str, callback) { function parse_hex(str, callback) {
@ -51,16 +70,16 @@ TABS.firmware_flasher.initialize = function (callback) {
}; };
} }
$('input.show_development_releases').click(function() { $('input.show_development_releases').on('click', function () {
let selectedTarget = String($('select[name="board"]').val()); let selectedTarget = String($('select[name="board"]').val());
GUI.log(localization.getMessage('selectedTarget') + selectedTarget); GUI.log(i18n.getMessage('selectedTarget') + selectedTarget);
buildBoardOptions(); buildBoardOptions();
GUI.log(localization.getMessage('toggledRCs')); GUI.log(i18n.getMessage('toggledRCs'));
if (selectedTarget === "0") { if (selectedTarget === "0") {
TABS.firmware_flasher.getTarget(); TABS.firmware_flasher.getTarget();
} else { } else {
$('select[name="board"] option[value=' + selectedTarget + ']').attr("selected", "selected"); $('select[name="board"] option[value=' + selectedTarget + ']').attr("selected", "selected");
$('select[name="board"]').change(); $('select[name="board"]').trigger('change');
} }
}); });
@ -87,8 +106,8 @@ TABS.firmware_flasher.initialize = function (callback) {
var versions_e = $('select[name="firmware_version"]').empty(); var versions_e = $('select[name="firmware_version"]').empty();
var showDevReleases = ($('input.show_development_releases').is(':checked')); var showDevReleases = ($('input.show_development_releases').is(':checked'));
boards_e.append($("<option value='0'>{0}</option>".format(localization.getMessage('firmwareFlasherOptionLabelSelectBoard')))); boards_e.append($("<option value='0'>{0}</option>".format(i18n.getMessage('firmwareFlasherOptionLabelSelectBoard'))));
versions_e.append($("<option value='0'>{0}</option>".format(localization.getMessage('firmwareFlasherOptionLabelSelectFirmwareVersion')))); versions_e.append($("<option value='0'>{0}</option>".format(i18n.getMessage('firmwareFlasherOptionLabelSelectFirmwareVersion'))));
var releases = {}; var releases = {};
var sortedTargets = []; var sortedTargets = [];
@ -177,23 +196,23 @@ TABS.firmware_flasher.initialize = function (callback) {
buildBoardOptions(); buildBoardOptions();
// bind events // bind events
$('select[name="board"]').change(function() { $('select[name="board"]').on('change', function () {
$("a.load_remote_file").addClass('disabled'); $("a.load_remote_file").addClass('disabled');
var target = $(this).children("option:selected").text(); var target = $(this).children("option:selected").text();
if (!GUI.connect_lock) { if (!GUI.connect_lock) {
$('.progress').val(0).removeClass('valid invalid'); $('.progress').val(0).removeClass('valid invalid');
$('span.progressLabel').text(localization.getMessage('firmwareFlasherLoadFirmwareFile')); $('span.progressLabel').text(i18n.getMessage('firmwareFlasherLoadFirmwareFile'));
$('div.git_info').slideUp(); $('div.git_info').slideUp();
$('div.release_info').slideUp(); $('div.release_info').slideUp();
$('a.flash_firmware').addClass('disabled'); $('a.flash_firmware').addClass('disabled');
var versions_e = $('select[name="firmware_version"]').empty(); var versions_e = $('select[name="firmware_version"]').empty();
if(target == 0) { if(target == 0) {
versions_e.append($("<option value='0'>{0}</option>".format(localization.getMessage('firmwareFlasherOptionLabelSelectFirmwareVersion')))); versions_e.append($("<option value='0'>{0}</option>".format(i18n.getMessage('firmwareFlasherOptionLabelSelectFirmwareVersion'))));
} else { } else {
versions_e.append($("<option value='0'>{0} {1}</option>".format(localization.getMessage('firmwareFlasherOptionLabelSelectFirmwareVersionFor'), target))); versions_e.append($("<option value='0'>{0} {1}</option>".format(i18n.getMessage('firmwareFlasherOptionLabelSelectFirmwareVersionFor'), target)));
} }
TABS.firmware_flasher.releases[target].forEach(function(descriptor) { TABS.firmware_flasher.releases[target].forEach(function(descriptor) {
@ -259,7 +278,7 @@ TABS.firmware_flasher.initialize = function (callback) {
$('span.progressLabel').text('Loaded Local Firmware: (' + parsed_hex.bytes_total + ' bytes)'); $('span.progressLabel').text('Loaded Local Firmware: (' + parsed_hex.bytes_total + ' bytes)');
} else { } else {
$('span.progressLabel').text(localization.getMessage('firmwareFlasherHexCorrupted')); $('span.progressLabel').text(i18n.getMessage('firmwareFlasherHexCorrupted'));
} }
}); });
}); });
@ -271,7 +290,7 @@ TABS.firmware_flasher.initialize = function (callback) {
/** /**
* Lock / Unlock the firmware download button according to the firmware selection dropdown. * Lock / Unlock the firmware download button according to the firmware selection dropdown.
*/ */
$('select[name="firmware_version"]').change(function(evt){ $('select[name="firmware_version"]').on('change', function(evt){
$('div.release_info').slideUp(); $('div.release_info').slideUp();
$('a.flash_firmware').addClass('disabled'); $('a.flash_firmware').addClass('disabled');
if (evt.target.value=="0") { if (evt.target.value=="0") {
@ -282,10 +301,10 @@ TABS.firmware_flasher.initialize = function (callback) {
} }
}); });
$('a.load_remote_file').click(function (evt) { $('a.load_remote_file').on('click', function () {
if ($('select[name="firmware_version"]').val() == "0") { if ($('select[name="firmware_version"]').val() == "0") {
GUI.log(localization.getMessage('noFirmwareSelectedToLoad')); GUI.log(i18n.getMessage('noFirmwareSelectedToLoad'));
return; return;
} }
@ -327,7 +346,7 @@ TABS.firmware_flasher.initialize = function (callback) {
var status_e = $('div.release_info .status'); var status_e = $('div.release_info .status');
if (summary.status == 'release-candidate') { if (summary.status == 'release-candidate') {
$('div.release_info .status').html(localization.getMessage('firmwareFlasherReleaseStatusReleaseCandidate')).show(); $('div.release_info .status').html(i18n.getMessage('firmwareFlasherReleaseStatusReleaseCandidate')).show();
} else { } else {
status_e.hide(); status_e.hide();
} }
@ -347,30 +366,30 @@ TABS.firmware_flasher.initialize = function (callback) {
$('div.release_info').slideDown(); $('div.release_info').slideDown();
} else { } else {
$('span.progressLabel').text(localization.getMessage('firmwareFlasherHexCorrupted')); $('span.progressLabel').text(i18n.getMessage('firmwareFlasherHexCorrupted'));
} }
}); });
} }
function failed_to_load() { function failed_to_load() {
$('span.progressLabel').text(localization.getMessage('firmwareFlasherFailedToLoadOnlineFirmware')); $('span.progressLabel').text(i18n.getMessage('firmwareFlasherFailedToLoadOnlineFirmware'));
$('a.flash_firmware').addClass('disabled'); $('a.flash_firmware').addClass('disabled');
enable_load_online_button(); enable_load_online_button();
} }
var summary = $('select[name="firmware_version"] option:selected').data('summary'); var summary = $('select[name="firmware_version"] option:selected').data('summary');
if (summary) { // undefined while list is loading or while running offline if (summary) { // undefined while list is loading or while running offline
$(".load_remote_file").text(localization.getMessage('firmwareFlasherButtonLoading')).addClass('disabled'); $(".load_remote_file").text(i18n.getMessage('firmwareFlasherButtonLoading')).addClass('disabled');
$.get(summary.url, function (data) { $.get(summary.url, function (data) {
enable_load_online_button(); enable_load_online_button();
process_hex(data, summary); process_hex(data, summary);
}).fail(failed_to_load); }).fail(failed_to_load);
} else { } else {
$('span.progressLabel').text(localization.getMessage('firmwareFlasherFailedToLoadOnlineFirmware')); $('span.progressLabel').text(i18n.getMessage('firmwareFlasherFailedToLoadOnlineFirmware'));
} }
}); });
$('a.flash_firmware').click(function () { $('a.flash_firmware').on('click', function () {
if (!$(this).hasClass('disabled')) { if (!$(this).hasClass('disabled')) {
if (!GUI.connect_lock) { // button disabled while flashing is in progress if (!GUI.connect_lock) { // button disabled while flashing is in progress
if (parsed_hex != false) { if (parsed_hex != false) {
@ -412,13 +431,13 @@ TABS.firmware_flasher.initialize = function (callback) {
STM32.connect(port, baud, parsed_hex, options); STM32.connect(port, baud, parsed_hex, options);
} else { } else {
console.log('Please select valid serial port'); console.log('Please select valid serial port');
GUI.log(localization.getMessage('selectValidSerialPort')); GUI.log(i18n.getMessage('selectValidSerialPort'));
} }
} else { } else {
STM32DFU.connect(usbDevices, parsed_hex, options); STM32DFU.connect(usbDevices, parsed_hex, options);
} }
} else { } else {
$('span.progressLabel').text(localization.getMessage('firmwareFlasherFirmwareNotLoaded')); $('span.progressLabel').text(i18n.getMessage('firmwareFlasherFirmwareNotLoaded'));
} }
} }
} }
@ -462,7 +481,7 @@ TABS.firmware_flasher.initialize = function (callback) {
}); });
} else { } else {
console.log('You don\'t have write permissions for this file, sorry.'); console.log('You don\'t have write permissions for this file, sorry.');
GUI.log(localization.getMessage('writePermissionsForFile')); GUI.log(i18n.getMessage('writePermissionsForFile'));
} }
}); });
}); });
@ -478,20 +497,20 @@ TABS.firmware_flasher.initialize = function (callback) {
} }
// bind UI hook so the status is saved on change // bind UI hook so the status is saved on change
$('input.updating').change(function() { $('input.updating').on('change', function () {
var status = $(this).is(':checked'); var status = $(this).is(':checked');
if (status) { if (status) {
$('.flash_on_connect_wrapper').show(); $('.flash_on_connect_wrapper').show();
} else { } else {
$('input.flash_on_connect').prop('checked', false).change(); $('input.flash_on_connect').prop('checked', false).trigger('change');
$('.flash_on_connect_wrapper').hide(); $('.flash_on_connect_wrapper').hide();
} }
store.set('no_reboot_sequence', status); store.set('no_reboot_sequence', status);
}); });
$('input.updating').change(); $('input.updating').trigger('change');
store.get('flash_manual_baud', function (result) { store.get('flash_manual_baud', function (result) {
@ -502,24 +521,24 @@ TABS.firmware_flasher.initialize = function (callback) {
} }
// bind UI hook so the status is saved on change // bind UI hook so the status is saved on change
$('input.flash_manual_baud').change(function() { $('input.flash_manual_baud').on('change', function () {
var status = $(this).is(':checked'); var status = $(this).is(':checked');
store.set('flash_manual_baud', status); store.set('flash_manual_baud', status);
}); });
$('input.flash_manual_baud').change(); $('input.flash_manual_baud').trigger('change');
}); });
var flash_manual_baud_rate = store.get('flash_manual_baud_rate', ''); var flash_manual_baud_rate = store.get('flash_manual_baud_rate', '');
$('#flash_manual_baud_rate').val(flash_manual_baud_rate); $('#flash_manual_baud_rate').val(flash_manual_baud_rate);
// bind UI hook so the status is saved on change // bind UI hook so the status is saved on change
$('#flash_manual_baud_rate').change(function() { $('#flash_manual_baud_rate').on('change', function () {
var baud = parseInt($('#flash_manual_baud_rate').val()); var baud = parseInt($('#flash_manual_baud_rate').val());
store.set('flash_manual_baud_rate', baud); store.set('flash_manual_baud_rate', baud);
}); });
$('input.flash_manual_baud_rate').change(); $('input.flash_manual_baud_rate').trigger('change');
if (store.get('flash_on_connect', false)) { if (store.get('flash_on_connect', false)) {
@ -528,7 +547,7 @@ TABS.firmware_flasher.initialize = function (callback) {
$('input.flash_on_connect').prop('checked', false); $('input.flash_on_connect').prop('checked', false);
} }
$('input.flash_on_connect').change(function () { $('input.flash_on_connect').on('change', function () {
var status = $(this).is(':checked'); var status = $(this).is(':checked');
if (status) { if (status) {
@ -541,8 +560,8 @@ TABS.firmware_flasher.initialize = function (callback) {
console.log('Detected: ' + port + ' - triggering flash on connect'); console.log('Detected: ' + port + ' - triggering flash on connect');
// Trigger regular Flashing sequence // Trigger regular Flashing sequence
helper.timeout.add('initialization_timeout', function () { timeout.add('initialization_timeout', function () {
$('a.flash_firmware').click(); $('a.flash_firmware').trigger( "click" );
}, 100); // timeout so bus have time to initialize after being detected by the system }, 100); // timeout so bus have time to initialize after being detected by the system
} else { } else {
GUI.log('Detected <strong>' + port + '</strong> - previous device still flashing, please replug to try again'); GUI.log('Detected <strong>' + port + '</strong> - previous device still flashing, please replug to try again');
@ -559,7 +578,7 @@ TABS.firmware_flasher.initialize = function (callback) {
} }
store.set('flash_on_connect', status); store.set('flash_on_connect', status);
}).change(); }).trigger('change');
@ -570,22 +589,22 @@ TABS.firmware_flasher.initialize = function (callback) {
} }
// bind UI hook so the status is saved on change // bind UI hook so the status is saved on change
$('input.erase_chip').change(function () { $('input.erase_chip').on('change', function () {
store.set('erase_chip', $(this).is(':checked')); store.set('erase_chip', $(this).is(':checked'));
}); });
$('input.erase_chip').change(); $('input.erase_chip').trigger('change');
$(document).keypress(function (e) { $(document).keypress(function (e) {
if (e.which == 13) { // enter if (e.which == 13) { // enter
// Trigger regular Flashing sequence // Trigger regular Flashing sequence
$('a.flash_firmware').click(); $('a.flash_firmware').trigger( "click" );
} }
}); });
$('a.auto_select_target').click(function () { $('a.auto_select_target').on('click', function () {
TABS.firmware_flasher.getTarget(); TABS.firmware_flasher.getTarget();
}); });
@ -644,14 +663,14 @@ TABS.firmware_flasher.cleanup = function (callback) {
}; };
TABS.firmware_flasher.getTarget = function() { TABS.firmware_flasher.getTarget = function() {
GUI.log(localization.getMessage('automaticTargetSelect')); GUI.log(i18n.getMessage('automaticTargetSelect'));
var selected_baud = parseInt($('#baud').val()); var selected_baud = parseInt($('#baud').val());
var selected_port = $('#port').find('option:selected').data().isManual ? $('#port-override').val() : String($('#port').val()); var selected_port = $('#port').find('option:selected').data().isManual ? $('#port-override').val() : String($('#port').val());
if (selected_port !== 'DFU') { if (selected_port !== 'DFU') {
if (!selected_port || selected_port == '0') { if (!selected_port || selected_port == '0') {
GUI.log(localization.getMessage('targetPrefetchFailNoPort')); GUI.log(i18n.getMessage('targetPrefetchFailNoPort'));
} else { } else {
console.log('Connecting to: ' + selected_port); console.log('Connecting to: ' + selected_port);
GUI.connecting_to = selected_port; GUI.connecting_to = selected_port;
@ -663,7 +682,7 @@ TABS.firmware_flasher.getTarget = function() {
} }
} }
} else { } else {
GUI.log(localization.getMessage('targetPrefetchFailDFU')); GUI.log(i18n.getMessage('targetPrefetchFailDFU'));
} }
}; };
@ -690,12 +709,12 @@ TABS.firmware_flasher.onOpen = function(openInfo) {
store.set('last_used_bps', CONFIGURATOR.connection.bitrate); store.set('last_used_bps', CONFIGURATOR.connection.bitrate);
store.set('wireless_mode_enabled', $('#wireless-mode').is(":checked")); store.set('wireless_mode_enabled', $('#wireless-mode').is(":checked"));
CONFIGURATOR.connection.addOnReceiveListener(read_serial); CONFIGURATOR.connection.addOnReceiveListener(SerialBackend.read_serial);
// disconnect after 10 seconds with error if we don't get IDENT data // disconnect after 10 seconds with error if we don't get IDENT data
helper.timeout.add('connecting', function () { timeout.add('connecting', function () {
if (!CONFIGURATOR.connectionValid) { if (!CONFIGURATOR.connectionValid) {
GUI.log(localization.getMessage('targetPrefetchFail') + localization.getMessage('noConfigurationReceived')); GUI.log(i18n.getMessage('targetPrefetchFail') + i18n.getMessage('noConfigurationReceived'));
TABS.firmware_flasher.closeTempConnection(); TABS.firmware_flasher.closeTempConnection();
} }
@ -708,35 +727,35 @@ TABS.firmware_flasher.onOpen = function(openInfo) {
MSP.protocolVersion = MSP.constants.PROTOCOL_V2; MSP.protocolVersion = MSP.constants.PROTOCOL_V2;
MSP.send_message(MSPCodes.MSP_API_VERSION, false, false, function () { MSP.send_message(MSPCodes.MSP_API_VERSION, false, false, function () {
if (CONFIG.apiVersion === "0.0.0") { if (FC.CONFIG.apiVersion === "0.0.0") {
GUI_control.prototype.log("Cannot prefetch target: <span style='color: red; font-weight: bolder'><strong>" + localization.getMessage("illegalStateRestartRequired") + "</strong></span>"); GUI_control.prototype.log("Cannot prefetch target: <span style='color: red; font-weight: bolder'><strong>" + i18n.getMessage("illegalStateRestartRequired") + "</strong></span>");
FC.restartRequired = true; FC.restartRequired = true;
return; return;
} }
MSP.send_message(MSPCodes.MSP_FC_VARIANT, false, false, function () { MSP.send_message(MSPCodes.MSP_FC_VARIANT, false, false, function () {
if (CONFIG.flightControllerIdentifier == 'INAV') { if (FC.CONFIG.flightControllerIdentifier == 'INAV') {
MSP.send_message(MSPCodes.MSP_FC_VERSION, false, false, function () { MSP.send_message(MSPCodes.MSP_FC_VERSION, false, false, function () {
if (semver.lt(CONFIG.flightControllerVersion, "5.0.0")) { if (semver.lt(FC.CONFIG.flightControllerVersion, "5.0.0")) {
GUI.log(localization.getMessage('targetPrefetchFailOld')); GUI.log(i18n.getMessage('targetPrefetchFailOld'));
TABS.firmware_flasher.closeTempConnection(); TABS.firmware_flasher.closeTempConnection();
} else { } else {
mspHelper.getCraftName(function(name) { mspHelper.getCraftName(function(name) {
if (name) { if (name) {
CONFIG.name = name; FC.CONFIG.name = name;
} }
TABS.firmware_flasher.onValidFirmware(); TABS.firmware_flasher.onValidFirmware();
}); });
} }
}); });
} else { } else {
GUI.log(localization.getMessage('targetPrefetchFailNonINAV')); GUI.log(i18n.getMessage('targetPrefetchFailNonINAV'));
TABS.firmware_flasher.closeTempConnection(); TABS.firmware_flasher.closeTempConnection();
} }
}); });
}); });
} else { } else {
GUI.log(localization.getMessage('targetPrefetchFail') + localization.getMessage('serialPortOpenFail')); GUI.log(i18n.getMessage('targetPrefetchFail') + i18n.getMessage('serialPortOpenFail'));
return; return;
} }
}; };
@ -744,28 +763,28 @@ TABS.firmware_flasher.onOpen = function(openInfo) {
TABS.firmware_flasher.onValidFirmware = function() { TABS.firmware_flasher.onValidFirmware = function() {
MSP.send_message(MSPCodes.MSP_BUILD_INFO, false, false, function () { MSP.send_message(MSPCodes.MSP_BUILD_INFO, false, false, function () {
MSP.send_message(MSPCodes.MSP_BOARD_INFO, false, false, function () { MSP.send_message(MSPCodes.MSP_BOARD_INFO, false, false, function () {
$('select[name="board"] option[value=' + CONFIG.target + ']').attr("selected", "selected"); $('select[name="board"] option[value=' + FC.CONFIG.target + ']').attr("selected", "selected");
GUI.log(localization.getMessage('targetPrefetchsuccessful') + CONFIG.target); GUI.log(i18n.getMessage('targetPrefetchsuccessful') + FC.CONFIG.target);
TABS.firmware_flasher.closeTempConnection(); TABS.firmware_flasher.closeTempConnection();
$('select[name="board"]').change(); $('select[name="board"]').trigger('change');
}); });
}); });
}; };
TABS.firmware_flasher.closeTempConnection = function() { TABS.firmware_flasher.closeTempConnection = function() {
helper.timeout.killAll(); timeout.killAll();
helper.interval.killAll(['global_data_refresh', 'msp-load-update']); interval.killAll(['global_data_refresh', 'msp-load-update']);
helper.mspBalancedInterval.flush(); mspBalancedInterval.flush();
helper.mspQueue.flush(); mspQueue.flush();
helper.mspQueue.freeHardLock(); mspQueue.freeHardLock();
helper.mspQueue.freeSoftLock(); mspQueue.freeSoftLock();
CONFIGURATOR.connection.emptyOutputBuffer(); CONFIGURATOR.connection.emptyOutputBuffer();
CONFIGURATOR.connectionValid = false; CONFIGURATOR.connectionValid = false;
GUI.connected_to = false; GUI.connected_to = false;
CONFIGURATOR.connection.disconnect(onClosed); CONFIGURATOR.connection.disconnect();
MSP.disconnect_cleanup(); MSP.disconnect_cleanup();
}; };

View file

@ -60,12 +60,12 @@ TABS.gps.initialize = function (callback) {
function reboot() { function reboot() {
//noinspection JSUnresolvedVariable //noinspection JSUnresolvedVariable
GUI.log(localization.getMessage('configurationEepromSaved')); GUI.log(i18n.getMessage('configurationEepromSaved'));
GUI.tab_switch_cleanup(function () { GUI.tab_switch_cleanup(function () {
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, function () { MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, function () {
//noinspection JSUnresolvedVariable //noinspection JSUnresolvedVariable
GUI.log(localization.getMessage('deviceRebooting')); GUI.log(i18n.getMessage('deviceRebooting'));
GUI.handleReconnect($('.tab_gps a')); GUI.handleReconnect($('.tab_gps a'));
}); });
}); });
@ -85,7 +85,7 @@ TABS.gps.initialize = function (callback) {
let vehiclesCursorInitialized = false; let vehiclesCursorInitialized = false;
function process_html() { function process_html() {
localization.localize();; i18n.localize();;
var features = FC.getFeatures(); var features = FC.getFeatures();
@ -100,19 +100,19 @@ TABS.gps.initialize = function (callback) {
gps_protocol_e.append('<option value="' + i + '">' + gpsProtocols[i] + '</option>'); gps_protocol_e.append('<option value="' + i + '">' + gpsProtocols[i] + '</option>');
} }
gps_protocol_e.change(function () { gps_protocol_e.on('change', function () {
MISC.gps_type = parseInt($(this).val()); MISC.gps_type = parseInt($(this).val());
}); });
gps_protocol_e.val(MISC.gps_type); gps_protocol_e.val(MISC.gps_type);
gps_protocol_e.change(); gps_protocol_e.trigger('change');
var gps_ubx_sbas_e = $('#gps_ubx_sbas'); var gps_ubx_sbas_e = $('#gps_ubx_sbas');
for (let i = 0; i < gpsSbas.length; i++) { for (let i = 0; i < gpsSbas.length; i++) {
gps_ubx_sbas_e.append('<option value="' + i + '">' + gpsSbas[i] + '</option>'); gps_ubx_sbas_e.append('<option value="' + i + '">' + gpsSbas[i] + '</option>');
} }
gps_ubx_sbas_e.change(function () { gps_ubx_sbas_e.on('change', function () {
MISC.gps_ubx_sbas = parseInt($(this).val()); MISC.gps_ubx_sbas = parseInt($(this).val());
}); });
@ -140,7 +140,7 @@ TABS.gps.initialize = function (callback) {
mapLayer = new ol.source.OSM(); mapLayer = new ol.source.OSM();
} }
$("#center_button").click(function () { $("#center_button").on('click', function () {
let lat = GPS_DATA.lat / 10000000; let lat = GPS_DATA.lat / 10000000;
let lon = GPS_DATA.lon / 10000000; let lon = GPS_DATA.lon / 10000000;
let center = ol.proj.fromLonLat([lon, lat]); let center = ol.proj.fromLonLat([lon, lat]);
@ -208,11 +208,11 @@ TABS.gps.initialize = function (callback) {
let lat = GPS_DATA.lat / 10000000; let lat = GPS_DATA.lat / 10000000;
let lon = GPS_DATA.lon / 10000000; let lon = GPS_DATA.lon / 10000000;
let gpsFixType = localization.getMessage('gpsFixNone'); let gpsFixType = i18n.getMessage('gpsFixNone');
if (GPS_DATA.fix >= 2) { if (GPS_DATA.fix >= 2) {
gpsFixType = localization.getMessage('gpsFix3D'); gpsFixType = i18n.getMessage('gpsFix3D');
} else if (GPS_DATA.fix >= 1) { } else if (GPS_DATA.fix >= 1) {
gpsFixType = localization.getMessage('gpsFix2D'); gpsFixType = i18n.getMessage('gpsFix2D');
} }
$('.GPS_info td.fix').html(gpsFixType); $('.GPS_info td.fix').html(gpsFixType);

View file

@ -1,25 +1,32 @@
'use strict'; 'use strict';
/*global $,TABS,GUI*/ const path = require('path');
const { GUI, TABS } = require('./../js/gui');
const i18n = require('./../js/localization');
TABS.landing = {}; const landing = {};
TABS.landing.initialize = function (callback) { landing.initialize = function (callback) {
if (GUI.active_tab != 'landing') { if (GUI.active_tab != 'landing') {
GUI.active_tab = 'landing'; GUI.active_tab = 'landing';
} }
GUI.load(path.join(__dirname, "tabs/landing.html"), function () { GUI.load(path.join(__dirname, "landing.html"), function () {
localization.localize(); i18n.localize();
$('.tab-landing a').click(function () { /*
// googleAnalytics.sendEvent('ExternalUrls', 'Click', $(this).prop('href')); $('.tab-landing a').on('click', function () {
googleAnalytics.sendEvent('ExternalUrls', 'Click', $(this).prop('href'));
}); });
*/
GUI.content_ready(callback); GUI.content_ready(callback);
}); });
}; };
TABS.landing.cleanup = function (callback) { landing.cleanup = function (callback) {
if (callback) callback(); if (callback) callback();
}; };
TABS.landing = landing;
module.exports = landing;

View file

@ -54,7 +54,7 @@ TABS.led_strip.initialize = function (callback, scrollPosition) {
function process_html() { function process_html() {
localization.localize();; i18n.localize();;
// Build Grid // Build Grid
var theHTML = []; var theHTML = [];
@ -64,12 +64,12 @@ TABS.led_strip.initialize = function (callback, scrollPosition) {
} }
$('.mainGrid').html(theHTML.join('')); $('.mainGrid').html(theHTML.join(''));
$('.tempOutput').click(function() { $('.tempOutput').on('click', function () {
$(this).select(); $(this).select();
}); });
// Clear button // Clear button
$('.funcClear').click(function() { $('.funcClear').on('click', function () {
$('.gPoint').each(function() { $('.gPoint').each(function() {
if ($(this).is('.ui-selected')) { if ($(this).is('.ui-selected')) {
removeFunctionsAndDirections(this); removeFunctionsAndDirections(this);
@ -82,7 +82,7 @@ TABS.led_strip.initialize = function (callback, scrollPosition) {
}); });
// Clear All button // Clear All button
$('.funcClearAll').click(function() { $('.funcClearAll').on('click', function () {
$('.gPoint').each(function() { $('.gPoint').each(function() {
removeFunctionsAndDirections(this); removeFunctionsAndDirections(this);
}); });
@ -244,13 +244,13 @@ TABS.led_strip.initialize = function (callback, scrollPosition) {
} }
}); });
$('.funcWire').click(function() { $('.funcWire').on('click', function () {
$(this).toggleClass('btnOn'); $(this).toggleClass('btnOn');
TABS.led_strip.wireMode = $(this).hasClass('btnOn'); TABS.led_strip.wireMode = $(this).hasClass('btnOn');
$('.mainGrid').toggleClass('gridWire'); $('.mainGrid').toggleClass('gridWire');
}); });
$('.funcWireClearSelect').click(function() { $('.funcWireClearSelect').on('click', function () {
$('.ui-selected').each(function() { $('.ui-selected').each(function() {
var thisWire = $(this).find('.wire'); var thisWire = $(this).find('.wire');
if (thisWire.html() != '') { if (thisWire.html() != '') {
@ -260,7 +260,7 @@ TABS.led_strip.initialize = function (callback, scrollPosition) {
}); });
}); });
$('.funcWireClear').click(function() { $('.funcWireClear').on('click', function () {
$('.gPoint .wire').html(''); $('.gPoint .wire').html('');
updateBulkCmd(); updateBulkCmd();
}); });
@ -353,7 +353,7 @@ TABS.led_strip.initialize = function (callback, scrollPosition) {
if (feature_o.is(':checked') != newVal) { if (feature_o.is(':checked') != newVal) {
feature_o.prop('checked', newVal); feature_o.prop('checked', newVal);
feature_o.change(); feature_o.trigger('change');
} }
}); });
@ -450,7 +450,7 @@ TABS.led_strip.initialize = function (callback, scrollPosition) {
} }
// UI: check-box toggle // UI: check-box toggle
$('.checkbox').change(function(e) { $('.checkbox').on('change', function(e) {
if (e.originalEvent) { if (e.originalEvent) {
// user-triggered event // user-triggered event
var that = $(this).find('input'); var that = $(this).find('input');
@ -466,11 +466,11 @@ TABS.led_strip.initialize = function (callback, scrollPosition) {
if (ret) { if (ret) {
if (letter == 'b' && cbn.is(':checked')) { if (letter == 'b' && cbn.is(':checked')) {
cbn.prop('checked', false); cbn.prop('checked', false);
cbn.change(); cbn.trigger('change');
toggleSwitch(cbn, 'n'); toggleSwitch(cbn, 'n');
} else if (letter == 'n' && cbb.is(':checked')) { } else if (letter == 'n' && cbb.is(':checked')) {
cbb.prop('checked', false); cbb.prop('checked', false);
cbb.change(); cbb.trigger('change');
toggleSwitch(cbb, 'b'); toggleSwitch(cbb, 'b');
} }
} }
@ -524,7 +524,7 @@ TABS.led_strip.initialize = function (callback, scrollPosition) {
}); });
$('a.save').click(function () { $('a.save').on('click', function () {
mspHelper.sendLedStripConfig(send_led_strip_colors); mspHelper.sendLedStripConfig(send_led_strip_colors);
@ -538,7 +538,7 @@ TABS.led_strip.initialize = function (callback, scrollPosition) {
function save_to_eeprom() { function save_to_eeprom() {
MSP.send_message(MSPCodes.MSP_EEPROM_WRITE, false, false, function() { MSP.send_message(MSPCodes.MSP_EEPROM_WRITE, false, false, function() {
GUI.log(localization.getMessage('ledStripEepromSaved')); GUI.log(i18n.getMessage('ledStripEepromSaved'));
}); });
} }
@ -861,7 +861,7 @@ TABS.led_strip.initialize = function (callback, scrollPosition) {
function unselectOverlay(func, overlay) { function unselectOverlay(func, overlay) {
$('input.function-' + overlay).prop('checked', false); $('input.function-' + overlay).prop('checked', false);
$('input.function-' + overlay).change(); $('input.function-' + overlay).trigger('change');
$('.ui-selected').each(function() { $('.ui-selected').each(function() {
if (func == '' || $(this).is('.function-' + func)) { if (func == '' || $(this).is('.function-' + func)) {
$(this).removeClass('function-' + overlay); $(this).removeClass('function-' + overlay);

View file

@ -30,12 +30,12 @@ TABS.logging.initialize = function (callback) {
function process_html() { function process_html() {
// translate to user-selected language // translate to user-selected language
localization.localize();; i18n.localize();;
// UI hooks // UI hooks
$('a.log_file').click(prepare_file); $('a.log_file').on('click', prepare_file);
$('a.logging').click(function () { $('a.logging').on('click', function () {
if (GUI.connected_to) { if (GUI.connected_to) {
if (readyToWrite) { if (readyToWrite) {
var clicks = $(this).data('clicks'); var clicks = $(this).data('clicks');
@ -83,24 +83,24 @@ TABS.logging.initialize = function (callback) {
}, 1000); }, 1000);
$('.speed').prop('disabled', true); $('.speed').prop('disabled', true);
$(this).text(localization.getMessage('loggingStop')); $(this).text(i18n.getMessage('loggingStop'));
$(this).data("clicks", !clicks); $(this).data("clicks", !clicks);
} else { } else {
GUI.log(localization.getMessage('loggingErrorOneProperty')); GUI.log(i18n.getMessage('loggingErrorOneProperty'));
} }
} else { } else {
helper.interval.killAll(['global_data_refresh', 'msp-load-update']); helper.interval.killAll(['global_data_refresh', 'msp-load-update']);
helper.mspBalancedInterval.flush(); helper.mspBalancedInterval.flush();
$('.speed').prop('disabled', false); $('.speed').prop('disabled', false);
$(this).text(localization.getMessage('loggingStart')); $(this).text(i18n.getMessage('loggingStart'));
$(this).data("clicks", !clicks); $(this).data("clicks", !clicks);
} }
} else { } else {
GUI.log(localization.getMessage('loggingErrorLogFile')); GUI.log(i18n.getMessage('loggingErrorLogFile'));
} }
} else { } else {
GUI.log(localization.getMessage('loggingErrorNotConnected')); GUI.log(i18n.getMessage('loggingErrorNotConnected'));
} }
}); });
@ -242,6 +242,10 @@ TABS.logging.initialize = function (callback) {
}); });
} }
function millitime() {
return new Date().getTime();
}
}; };
TABS.logging.cleanup = function (callback) { TABS.logging.cleanup = function (callback) {

View file

@ -125,7 +125,7 @@ TABS.magnetometer.initialize = function (callback) {
function reboot() { function reboot() {
//noinspection JSUnresolvedVariable //noinspection JSUnresolvedVariable
GUI.log(localization.getMessage('configurationEepromSaved')); GUI.log(i18n.getMessage('configurationEepromSaved'));
GUI.tab_switch_cleanup(function () { GUI.tab_switch_cleanup(function () {
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, reinitialize); MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, reinitialize);
@ -133,7 +133,7 @@ TABS.magnetometer.initialize = function (callback) {
} }
function reinitialize() { function reinitialize() {
GUI.log(localization.getMessage('deviceRebooting')); GUI.log(i18n.getMessage('deviceRebooting'));
GUI.handleReconnect($('.tab_magnetometer a')); GUI.handleReconnect($('.tab_magnetometer a'));
} }
@ -291,7 +291,7 @@ TABS.magnetometer.initialize = function (callback) {
function process_html() { function process_html() {
localization.localize();; i18n.localize();;
// initialize 3D // initialize 3D
self.initialize3D(); self.initialize3D();
@ -336,15 +336,15 @@ TABS.magnetometer.initialize = function (callback) {
} }
self.pageElements.orientation_board_roll.change(function () { self.pageElements.orientation_board_roll.on('change', function () {
updateBoardRollAxis(clamp(this, -180, 360)); updateBoardRollAxis(clamp(this, -180, 360));
}); });
self.pageElements.orientation_board_pitch.change(function () { self.pageElements.orientation_board_pitch.on('change', function () {
updateBoardPitchAxis(clamp(this, -180, 360)); updateBoardPitchAxis(clamp(this, -180, 360));
}); });
self.pageElements.orientation_board_yaw.change(function () { self.pageElements.orientation_board_yaw.on('change', function () {
updateBoardYawAxis(clamp(this, -180, 360)); updateBoardYawAxis(clamp(this, -180, 360));
}); });
@ -405,7 +405,7 @@ TABS.magnetometer.initialize = function (callback) {
}); });
const elementToShow = $("#element_to_show"); const elementToShow = $("#element_to_show");
elementToShow.change(function () { elementToShow.on('change', function () {
const value = parseInt($(this).val()); const value = parseInt($(this).val());
self.showMagnetometer = (value == 0); self.showMagnetometer = (value == 0);
self.render3D(); self.render3D();
@ -415,7 +415,7 @@ TABS.magnetometer.initialize = function (callback) {
return Math.min(Math.max(parseInt($(input).val()), min), max); return Math.min(Math.max(parseInt($(input).val()), min), max);
} }
self.pageElements.orientation_mag_e.change(function () { self.pageElements.orientation_mag_e.on('change', function () {
SENSOR_ALIGNMENT.align_mag = parseInt($(this).val()); SENSOR_ALIGNMENT.align_mag = parseInt($(this).val());
const degrees = getAxisDegreeWithPresetAndBoardOrientation(SENSOR_ALIGNMENT.align_mag); const degrees = getAxisDegreeWithPresetAndBoardOrientation(SENSOR_ALIGNMENT.align_mag);
presetUpdated(degrees); presetUpdated(degrees);
@ -426,22 +426,22 @@ TABS.magnetometer.initialize = function (callback) {
presetUpdated(degrees); presetUpdated(degrees);
}); });
self.pageElements.orientation_mag_roll.change(function () { self.pageElements.orientation_mag_roll.on('change', function () {
disableSavePreset(); disableSavePreset();
updateRollAxis(clamp(this, -180, 360)); updateRollAxis(clamp(this, -180, 360));
}); });
self.pageElements.orientation_mag_pitch.change(function () { self.pageElements.orientation_mag_pitch.on('change', function () {
disableSavePreset(); disableSavePreset();
updatePitchAxis(clamp(this, -180, 360)); updatePitchAxis(clamp(this, -180, 360));
}); });
self.pageElements.orientation_mag_yaw.change(function () { self.pageElements.orientation_mag_yaw.on('change', function () {
disableSavePreset(); disableSavePreset();
updateYawAxis(clamp(this, -180, 360)); updateYawAxis(clamp(this, -180, 360));
}); });
$('a.save').click(function () { $('a.save').on('click', function () {
saveChainer.execute() saveChainer.execute()
}); });
@ -517,9 +517,9 @@ TABS.magnetometer.initialize = function (callback) {
} }
MSP.send_message(MSPCodes.MSP_ATTITUDE, false, false, function () { MSP.send_message(MSPCodes.MSP_ATTITUDE, false, false, function () {
self.roll_e.text(localization.getMessage('initialSetupAttitude', [SENSOR_DATA.kinematics[0]])); self.roll_e.text(i18n.getMessage('initialSetupAttitude', [SENSOR_DATA.kinematics[0]]));
self.pitch_e.text(localization.getMessage('initialSetupAttitude', [SENSOR_DATA.kinematics[1]])); self.pitch_e.text(i18n.getMessage('initialSetupAttitude', [SENSOR_DATA.kinematics[1]]));
self.heading_e.text(localization.getMessage('initialSetupAttitude', [SENSOR_DATA.kinematics[2]])); self.heading_e.text(i18n.getMessage('initialSetupAttitude', [SENSOR_DATA.kinematics[2]]));
self.render3D(); self.render3D();
}); });
} }
@ -572,7 +572,7 @@ TABS.magnetometer.initialize3D = function () {
if (useWebGlRenderer) { if (useWebGlRenderer) {
if (MIXER_CONFIG.appliedMixerPreset === -1) { if (MIXER_CONFIG.appliedMixerPreset === -1) {
model_file = 'custom'; model_file = 'custom';
GUI_control.prototype.log("<span style='color: red; font-weight: bolder'><strong>" + localization.getMessage("mixerNotConfigured") + "</strong></span>"); GUI_control.prototype.log("<span style='color: red; font-weight: bolder'><strong>" + i18n.getMessage("mixerNotConfigured") + "</strong></span>");
} }
else { else {
model_file = helper.mixer.getById(MIXER_CONFIG.appliedMixerPreset).model; model_file = helper.mixer.getById(MIXER_CONFIG.appliedMixerPreset).model;

View file

@ -133,7 +133,7 @@ TABS.mission_control.initialize = function (callback) {
$('#missionMap, #missionControls').hide(); $('#missionMap, #missionControls').hide();
$('#notLoadMap').show(); $('#notLoadMap').show();
} }
localization.localize(); i18n.localize();
function get_raw_gps_data() { function get_raw_gps_data() {
MSP.send_message(MSPCodes.MSP_RAW_GPS, false, false, get_comp_gps_data); MSP.send_message(MSPCodes.MSP_RAW_GPS, false, false, get_comp_gps_data);
@ -488,21 +488,21 @@ TABS.mission_control.initialize = function (callback) {
$row.find(".safehome-number").text(safehome.getNumber()+1); $row.find(".safehome-number").text(safehome.getNumber()+1);
$row.find(".safehome-enabled-value").prop('checked',safehome.isUsed()).change(function () { $row.find(".safehome-enabled-value").prop('checked',safehome.isUsed()).on('change', function () {
safehome.setEnabled((($(this).prop('checked')) ? 1 : 0)); safehome.setEnabled((($(this).prop('checked')) ? 1 : 0));
SAFEHOMES.updateSafehome(safehome); SAFEHOMES.updateSafehome(safehome);
cleanSafehomeLayers(); cleanSafehomeLayers();
renderSafehomesOnMap(); renderSafehomesOnMap();
}); });
$row.find(".safehome-lon").val(safehome.getLonMap()).change(function () { $row.find(".safehome-lon").val(safehome.getLonMap()).on('change', function () {
safehome.setLon(Math.round(Number($(this).val()) * 10000000)); safehome.setLon(Math.round(Number($(this).val()) * 10000000));
SAFEHOMES.updateSafehome(safehome); SAFEHOMES.updateSafehome(safehome);
cleanSafehomeLayers(); cleanSafehomeLayers();
renderSafehomesOnMap(); renderSafehomesOnMap();
}); });
$row.find(".safehome-lat").val(safehome.getLatMap()).change(function () { $row.find(".safehome-lat").val(safehome.getLatMap()).on('change', function () {
safehome.setLat(Math.round(Number($(this).val()) * 10000000)); safehome.setLat(Math.round(Number($(this).val()) * 10000000));
SAFEHOMES.updateSafehome(safehome); SAFEHOMES.updateSafehome(safehome);
cleanSafehomeLayers(); cleanSafehomeLayers();
@ -513,7 +513,7 @@ TABS.mission_control.initialize = function (callback) {
} }
} }
GUI.switchery(); GUI.switchery();
localization.localize();; i18n.localize();;
} }
@ -649,13 +649,13 @@ TABS.mission_control.initialize = function (callback) {
* Process home table UI * Process home table UI
*/ */
$(".home-lat").val(HOME.getLatMap()).change(function () { $(".home-lat").val(HOME.getLatMap()).on('change', function () {
HOME.setLat(Math.round(Number($(this).val()) * 10000000)); HOME.setLat(Math.round(Number($(this).val()) * 10000000));
cleanHomeLayers(); cleanHomeLayers();
renderHomeOnMap(); renderHomeOnMap();
}); });
$(".home-lon").val(HOME.getLonMap()).change(function () { $(".home-lon").val(HOME.getLonMap()).on('change', function () {
HOME.setLon(Math.round(Number($(this).val()) * 10000000)); HOME.setLon(Math.round(Number($(this).val()) * 10000000));
cleanHomeLayers(); cleanHomeLayers();
renderHomeOnMap(); renderHomeOnMap();
@ -908,7 +908,7 @@ TABS.mission_control.initialize = function (callback) {
MMCount ++; MMCount ++;
} }
}); });
$('#multimissionOptionList').val(MMCount).change(); $('#multimissionOptionList').val(MMCount).trigger('change');
} }
function deleteMultimission() { function deleteMultimission() {
@ -951,7 +951,7 @@ TABS.mission_control.initialize = function (callback) {
function fileLoadMultiMissionCheck() { function fileLoadMultiMissionCheck() {
if (singleMissionActive()) { if (singleMissionActive()) {
return true; return true;
} else if (confirm(localization.getMessage('confirm_overwrite_multimission_file_load_option'))) { } else if (confirm(i18n.getMessage('confirm_overwrite_multimission_file_load_option'))) {
var options = { var options = {
filters: [ { name: "Mission file", extensions: ['mission'] } ] filters: [ { name: "Mission file", extensions: ['mission'] } ]
}; };
@ -1296,7 +1296,7 @@ TABS.mission_control.initialize = function (callback) {
GUI.fillSelect($row.find(".waypointOptions-action"), waypointOptions, waypointOptions.indexOf(MWNP.WPTYPE.REV[element.getAction()])); GUI.fillSelect($row.find(".waypointOptions-action"), waypointOptions, waypointOptions.indexOf(MWNP.WPTYPE.REV[element.getAction()]));
$row.find(".waypointOptions-action").val(waypointOptions.indexOf(MWNP.WPTYPE.REV[element.getAction()])).change(function () { $row.find(".waypointOptions-action").val(waypointOptions.indexOf(MWNP.WPTYPE.REV[element.getAction()])).on('change', function () {
element.setAction(MWNP.WPTYPE[waypointOptions[$(this).val()]]); element.setAction(MWNP.WPTYPE[waypointOptions[$(this).val()]]);
for (var i = 1; i <= 3; i++) { for (var i = 1; i <= 3; i++) {
if (dictOfLabelParameterPoint[element.getAction()]['parameter'+String(i)] != '') { if (dictOfLabelParameterPoint[element.getAction()]['parameter'+String(i)] != '') {
@ -1315,31 +1315,31 @@ TABS.mission_control.initialize = function (callback) {
$row.find(".waypointOptions-number").text(element.getAttachedNumber()+1); $row.find(".waypointOptions-number").text(element.getAttachedNumber()+1);
$row.find(".waypointOptions-p1").val((MWNP.WPTYPE.REV[element.getAction()] == "JUMP" ? element.getP1()+1 : element.getP1())).change(function () { $row.find(".waypointOptions-p1").val((MWNP.WPTYPE.REV[element.getAction()] == "JUMP" ? element.getP1()+1 : element.getP1())).on('change', function () {
if (MWNP.WPTYPE.REV[element.getAction()] == "SET_HEAD") { if (MWNP.WPTYPE.REV[element.getAction()] == "SET_HEAD") {
if ($(this).val() >= 360 || ($(this).val() < 0 && $(this).val() != -1)) if ($(this).val() >= 360 || ($(this).val() < 0 && $(this).val() != -1))
{ {
$(this).val(-1); $(this).val(-1);
alert(localization.getMessage('MissionPlannerHeadSettingsCheck')); alert(i18n.getMessage('MissionPlannerHeadSettingsCheck'));
} }
} }
else if (MWNP.WPTYPE.REV[element.getAction()] == "RTH") { else if (MWNP.WPTYPE.REV[element.getAction()] == "RTH") {
if ($(this).val() != 0 && $(this).val() != 1) if ($(this).val() != 0 && $(this).val() != 1)
{ {
$(this).val(0); $(this).val(0);
alert(localization.getMessage('MissionPlannerRTHSettingsCheck')); alert(i18n.getMessage('MissionPlannerRTHSettingsCheck'));
} }
} }
else if (MWNP.WPTYPE.REV[element.getAction()] == "JUMP") { else if (MWNP.WPTYPE.REV[element.getAction()] == "JUMP") {
if ($(this).val() > mission.getNonAttachedList().length || $(this).val() < 1) if ($(this).val() > mission.getNonAttachedList().length || $(this).val() < 1)
{ {
$(this).val(1); $(this).val(1);
alert(localization.getMessage('MissionPlannerJumpSettingsCheck')); alert(i18n.getMessage('MissionPlannerJumpSettingsCheck'));
} }
else if (mission.getPoiList().length != 0 && mission.getPoiList()) { else if (mission.getPoiList().length != 0 && mission.getPoiList()) {
if (mission.getPoiList().includes(mission.convertJumpNumberToWaypoint(Number($(this).val())-1))) { if (mission.getPoiList().includes(mission.convertJumpNumberToWaypoint(Number($(this).val())-1))) {
$(this).val(1); $(this).val(1);
alert(localization.getMessage('MissionPlannerJump3SettingsCheck')); alert(i18n.getMessage('MissionPlannerJump3SettingsCheck'));
} }
} }
} }
@ -1349,12 +1349,12 @@ TABS.mission_control.initialize = function (callback) {
redrawLayer(); redrawLayer();
}); });
$row.find(".waypointOptions-p2").val(element.getP2()).change(function () { $row.find(".waypointOptions-p2").val(element.getP2()).on('change', function () {
if (MWNP.WPTYPE.REV[element.getAction()] == "JUMP") { if (MWNP.WPTYPE.REV[element.getAction()] == "JUMP") {
if ($(this).val() > 10 || ($(this).val() < 0 && $(this).val() != -1)) if ($(this).val() > 10 || ($(this).val() < 0 && $(this).val() != -1))
{ {
$(this).val(0); $(this).val(0);
alert(localization.getMessage('MissionPlannerJump2SettingsCheck')); alert(i18n.getMessage('MissionPlannerJump2SettingsCheck'));
} }
} }
element.setP2(Number($(this).val())); element.setP2(Number($(this).val()));
@ -1367,7 +1367,7 @@ TABS.mission_control.initialize = function (callback) {
}); });
GUI.switchery(); GUI.switchery();
localization.localize();; i18n.localize();;
return waypoint; return waypoint;
} }
@ -1802,7 +1802,7 @@ TABS.mission_control.initialize = function (callback) {
clearEditForm(); clearEditForm();
} catch (e) { } catch (e) {
console.log(e); console.log(e);
GUI.log(localization.getMessage('notAWAYPOINT')); GUI.log(i18n.getMessage('notAWAYPOINT'));
} }
} }
selectedFeature = map.forEachFeatureAtPixel(evt.pixel, selectedFeature = map.forEachFeatureAtPixel(evt.pixel,
@ -2042,7 +2042,7 @@ TABS.mission_control.initialize = function (callback) {
///////////////////////////////////////////// /////////////////////////////////////////////
// Callback for Waypoint edition // Callback for Waypoint edition
///////////////////////////////////////////// /////////////////////////////////////////////
$('#pointType').change(function () { $('#pointType').on('change', function () {
if (selectedMarker) { if (selectedMarker) {
selectedMarker.setAction(Number($('#pointType').val())); selectedMarker.setAction(Number($('#pointType').val()));
if ([MWNP.WPTYPE.SET_POI,MWNP.WPTYPE.POSHOLD_TIME,MWNP.WPTYPE.LAND].includes(selectedMarker.getAction())) { if ([MWNP.WPTYPE.SET_POI,MWNP.WPTYPE.POSHOLD_TIME,MWNP.WPTYPE.LAND].includes(selectedMarker.getAction())) {
@ -2237,7 +2237,7 @@ TABS.mission_control.initialize = function (callback) {
} }
}); });
$("[data-role='waypointOptions-add']").click(function () { $("[data-role='waypointOptions-add']").on('click', function () {
if (selectedMarker) { if (selectedMarker) {
mission.addAttachedFromWaypoint(selectedMarker); mission.addAttachedFromWaypoint(selectedMarker);
renderWaypointOptionsTable(selectedMarker); renderWaypointOptionsTable(selectedMarker);
@ -2272,13 +2272,13 @@ TABS.mission_control.initialize = function (callback) {
$('#loadEepromSafehomeButton').on('click', function () { $('#loadEepromSafehomeButton').on('click', function () {
$(this).addClass('disabled'); $(this).addClass('disabled');
GUI.log(localization.getMessage('startGettingSafehomePoints')); GUI.log(i18n.getMessage('startGettingSafehomePoints'));
mspHelper.loadSafehomes(); mspHelper.loadSafehomes();
setTimeout(function(){ setTimeout(function(){
renderSafehomesTable(); renderSafehomesTable();
cleanSafehomeLayers(); cleanSafehomeLayers();
renderSafehomesOnMap(); renderSafehomesOnMap();
GUI.log(localization.getMessage('endGettingSafehomePoints')); GUI.log(i18n.getMessage('endGettingSafehomePoints'));
$('#loadEepromSafehomeButton').removeClass('disabled'); $('#loadEepromSafehomeButton').removeClass('disabled');
}, 500); }, 500);
@ -2286,11 +2286,11 @@ TABS.mission_control.initialize = function (callback) {
$('#saveEepromSafehomeButton').on('click', function() { $('#saveEepromSafehomeButton').on('click', function() {
$(this).addClass('disabled'); $(this).addClass('disabled');
GUI.log(localization.getMessage('startSendingSafehomePoints')); GUI.log(i18n.getMessage('startSendingSafehomePoints'));
mspHelper.saveSafehomes(); mspHelper.saveSafehomes();
setTimeout(function(){ setTimeout(function(){
mspHelper.saveToEeprom(); mspHelper.saveToEeprom();
GUI.log(localization.getMessage('endSendingSafehomePoints')); GUI.log(i18n.getMessage('endSendingSafehomePoints'));
$('#saveEepromSafehomeButton').removeClass('disabled'); $('#saveEepromSafehomeButton').removeClass('disabled');
}, 500); }, 500);
}); });
@ -2366,7 +2366,7 @@ TABS.mission_control.initialize = function (callback) {
}); });
$('#updateMultimissionButton').on('click', function () { $('#updateMultimissionButton').on('click', function () {
$('#multimissionOptionList').val('0').change(); $('#multimissionOptionList').val('0').trigger('change');
}); });
$('#cancelMultimission').on('click', function () { $('#cancelMultimission').on('click', function () {
@ -2381,7 +2381,7 @@ TABS.mission_control.initialize = function (callback) {
// Callback for Remove buttons // Callback for Remove buttons
///////////////////////////////////////////// /////////////////////////////////////////////
$('#removeAllPoints').on('click', function () { $('#removeAllPoints').on('click', function () {
if (markers.length && confirm(localization.getMessage('confirm_delete_all_points'))) { if (markers.length && confirm(i18n.getMessage('confirm_delete_all_points'))) {
if (removeAllMultiMissionCheck()) { if (removeAllMultiMissionCheck()) {
removeAllWaypoints(); removeAllWaypoints();
updateMultimissionState(); updateMultimissionState();
@ -2394,10 +2394,10 @@ TABS.mission_control.initialize = function (callback) {
$('#removePoint').on('click', function () { $('#removePoint').on('click', function () {
if (selectedMarker) { if (selectedMarker) {
if (mission.isJumpTargetAttached(selectedMarker)) { if (mission.isJumpTargetAttached(selectedMarker)) {
alert(localization.getMessage('MissionPlannerJumpTargetRemoval')); alert(i18n.getMessage('MissionPlannerJumpTargetRemoval'));
} }
else if (mission.getAttachedFromWaypoint(selectedMarker) && mission.getAttachedFromWaypoint(selectedMarker).length != 0) { else if (mission.getAttachedFromWaypoint(selectedMarker) && mission.getAttachedFromWaypoint(selectedMarker).length != 0) {
if (confirm(localization.getMessage('confirm_delete_point_with_options'))) { if (confirm(i18n.getMessage('confirm_delete_point_with_options'))) {
mission.getAttachedFromWaypoint(selectedMarker).forEach(function (element) { mission.getAttachedFromWaypoint(selectedMarker).forEach(function (element) {
mission.dropWaypoint(element); mission.dropWaypoint(element);
mission.update(singleMissionActive()); mission.update(singleMissionActive());
@ -2428,7 +2428,7 @@ TABS.mission_control.initialize = function (callback) {
$('#loadFileMissionButton').on('click', function () { $('#loadFileMissionButton').on('click', function () {
if (!fileLoadMultiMissionCheck()) return; if (!fileLoadMultiMissionCheck()) return;
if (markers.length && !confirm(localization.getMessage('confirm_delete_all_points'))) return; if (markers.length && !confirm(i18n.getMessage('confirm_delete_all_points'))) return;
var options = { var options = {
filters: [ { name: "Mission file", extensions: ['mission'] } ] filters: [ { name: "Mission file", extensions: ['mission'] } ]
}; };
@ -2457,39 +2457,39 @@ TABS.mission_control.initialize = function (callback) {
$('#loadMissionButton').on('click', function () { $('#loadMissionButton').on('click', function () {
let message = multimissionCount ? 'confirm_overwrite_multimission_file_load_option' : 'confirm_delete_all_points'; let message = multimissionCount ? 'confirm_overwrite_multimission_file_load_option' : 'confirm_delete_all_points';
if ((markers.length || multimissionCount) && !confirm(localization.getMessage(message))) return; if ((markers.length || multimissionCount) && !confirm(i18n.getMessage(message))) return;
removeAllWaypoints(); removeAllWaypoints();
$(this).addClass('disabled'); $(this).addClass('disabled');
GUI.log(localization.getMessage('startGetPoint')); GUI.log(i18n.getMessage('startGetPoint'));
getWaypointsFromFC(false); getWaypointsFromFC(false);
}); });
$('#saveMissionButton').on('click', function () { $('#saveMissionButton').on('click', function () {
if (mission.isEmpty()) { if (mission.isEmpty()) {
alert(localization.getMessage('no_waypoints_to_save')); alert(i18n.getMessage('no_waypoints_to_save'));
return; return;
} }
$(this).addClass('disabled'); $(this).addClass('disabled');
GUI.log(localization.getMessage('startSendPoint')); GUI.log(i18n.getMessage('startSendPoint'));
sendWaypointsToFC(false); sendWaypointsToFC(false);
}); });
$('#loadEepromMissionButton').on('click', function () { $('#loadEepromMissionButton').on('click', function () {
let message = multimissionCount ? 'confirm_overwrite_multimission_file_load_option' : 'confirm_delete_all_points'; let message = multimissionCount ? 'confirm_overwrite_multimission_file_load_option' : 'confirm_delete_all_points';
if ((markers.length || multimissionCount) && !confirm(localization.getMessage(message))) return; if ((markers.length || multimissionCount) && !confirm(i18n.getMessage(message))) return;
removeAllWaypoints(); removeAllWaypoints();
$(this).addClass('disabled'); $(this).addClass('disabled');
GUI.log(localization.getMessage('startGetPoint')); GUI.log(i18n.getMessage('startGetPoint'));
getWaypointsFromFC(true); getWaypointsFromFC(true);
}); });
$('#saveEepromMissionButton').on('click', function () { $('#saveEepromMissionButton').on('click', function () {
if (mission.isEmpty()) { if (mission.isEmpty()) {
alert(localization.getMessage('no_waypoints_to_save')); alert(i18n.getMessage('no_waypoints_to_save'));
return; return;
} }
$(this).addClass('disabled'); $(this).addClass('disabled');
GUI.log(localization.getMessage('startSendPoint')); GUI.log(i18n.getMessage('startSendPoint'));
sendWaypointsToFC(true); sendWaypointsToFC(true);
}); });
@ -2529,17 +2529,17 @@ TABS.mission_control.initialize = function (callback) {
///////////////////////////////////////////// /////////////////////////////////////////////
function loadMissionFile(filename) { function loadMissionFile(filename) {
const fs = require('fs'); const fs = require('fs');
if (!window.xml2js) return GUI.log(localization.getMessage('errorReadingFileXml2jsNotFound')); if (!window.xml2js) return GUI.log(i18n.getMessage('errorReadingFileXml2jsNotFound'));
fs.readFile(filename, (err, data) => { fs.readFile(filename, (err, data) => {
if (err) { if (err) {
GUI.log(localization.getMessage('errorReadingFile')); GUI.log(i18n.getMessage('errorReadingFile'));
return console.error(err); return console.error(err);
} }
window.xml2js.Parser({ 'explicitChildren': true, 'preserveChildrenOrder': true }).parseString(data, (err, result) => { window.xml2js.Parser({ 'explicitChildren': true, 'preserveChildrenOrder': true }).parseString(data, (err, result) => {
if (err) { if (err) {
GUI.log(localization.getMessage('errorParsingFile')); GUI.log(i18n.getMessage('errorParsingFile'));
return console.error(err); return console.error(err);
} }
@ -2627,7 +2627,7 @@ TABS.mission_control.initialize = function (callback) {
} }
if (missionEndFlagCount > 1) { if (missionEndFlagCount > 1) {
if (multimissionCount && !confirm(localization.getMessage('confirm_multimission_file_load'))) { if (multimissionCount && !confirm(i18n.getMessage('confirm_multimission_file_load'))) {
mission.flush(); mission.flush();
return; return;
} else { } else {
@ -2671,7 +2671,7 @@ TABS.mission_control.initialize = function (callback) {
} }
updateTotalInfo(); updateTotalInfo();
let sFilename = String(filename.split('\\').pop().split('/').pop()); let sFilename = String(filename.split('\\').pop().split('/').pop());
GUI.log(sFilename + localization.getMessage('loadedSuccessfully')); GUI.log(sFilename + i18n.getMessage('loadedSuccessfully'));
updateFilename(sFilename); updateFilename(sFilename);
}); });
}); });
@ -2679,7 +2679,7 @@ TABS.mission_control.initialize = function (callback) {
function saveMissionFile(filename) { function saveMissionFile(filename) {
const fs = require('fs'); const fs = require('fs');
if (!window.xml2js) return GUI.log(localization.getMessage('errorWritingFileXml2jsNotFound')); if (!window.xml2js) return GUI.log(i18n.getMessage('errorWritingFileXml2jsNotFound'));
var center = ol.proj.toLonLat(map.getView().getCenter()); var center = ol.proj.toLonLat(map.getView().getCenter());
var zoom = map.getView().getZoom(); var zoom = map.getView().getZoom();
@ -2728,11 +2728,11 @@ TABS.mission_control.initialize = function (callback) {
xml = xml.replace(/missionitem mission/g, 'meta mission'); xml = xml.replace(/missionitem mission/g, 'meta mission');
fs.writeFile(filename, xml, (err) => { fs.writeFile(filename, xml, (err) => {
if (err) { if (err) {
GUI.log(localization.getMessage('ErrorWritingFile')); GUI.log(i18n.getMessage('ErrorWritingFile'));
return console.error(err); return console.error(err);
} }
let sFilename = String(filename.split('\\').pop().split('/').pop()); let sFilename = String(filename.split('\\').pop().split('/').pop());
GUI.log(sFilename + localization.getMessage('savedSuccessfully')); GUI.log(sFilename + i18n.getMessage('savedSuccessfully'));
updateFilename(sFilename); updateFilename(sFilename);
}); });
} }
@ -2750,15 +2750,15 @@ TABS.mission_control.initialize = function (callback) {
function getWaypointData() { function getWaypointData() {
mspHelper.loadWaypoints(function() { mspHelper.loadWaypoints(function() {
GUI.log(localization.getMessage('endGetPoint')); GUI.log(i18n.getMessage('endGetPoint'));
if (loadEeprom) { if (loadEeprom) {
GUI.log(localization.getMessage('eeprom_load_ok')); GUI.log(i18n.getMessage('eeprom_load_ok'));
$('#loadEepromMissionButton').removeClass('disabled'); $('#loadEepromMissionButton').removeClass('disabled');
} else { } else {
$('#loadMissionButton').removeClass('disabled'); $('#loadMissionButton').removeClass('disabled');
} }
if (!MISSION_PLANNER.getCountBusyPoints()) { if (!MISSION_PLANNER.getCountBusyPoints()) {
alert(localization.getMessage('no_waypoints_to_load')); alert(i18n.getMessage('no_waypoints_to_load'));
return; return;
} }
mission.reinit(); mission.reinit();
@ -2792,10 +2792,10 @@ TABS.mission_control.initialize = function (callback) {
MISSION_PLANNER.copy(mission); MISSION_PLANNER.copy(mission);
MISSION_PLANNER.update(false, true, true); MISSION_PLANNER.update(false, true, true);
mspHelper.saveWaypoints(function() { mspHelper.saveWaypoints(function() {
GUI.log(localization.getMessage('endSendPoint')); GUI.log(i18n.getMessage('endSendPoint'));
if (saveEeprom) { if (saveEeprom) {
$('#saveEepromMissionButton').removeClass('disabled'); $('#saveEepromMissionButton').removeClass('disabled');
GUI.log(localization.getMessage('eeprom_saved_ok')); GUI.log(i18n.getMessage('eeprom_saved_ok'));
MSP.send_message(MSPCodes.MSP_WP_MISSION_SAVE, [0], false, setMissionIndex); MSP.send_message(MSPCodes.MSP_WP_MISSION_SAVE, [0], false, setMissionIndex);
} else { } else {
$('#saveMissionButton').removeClass('disabled'); $('#saveMissionButton').removeClass('disabled');
@ -2815,7 +2815,7 @@ TABS.mission_control.initialize = function (callback) {
let activeIndex = singleMissionActive() ? 1 : $('#activeNissionIndex').text(); let activeIndex = singleMissionActive() ? 1 : $('#activeNissionIndex').text();
mspHelper.setSetting("nav_wp_multi_mission_index", activeIndex, function () { mspHelper.setSetting("nav_wp_multi_mission_index", activeIndex, function () {
MSP.send_message(MSPCodes.MSP_EEPROM_WRITE, false, false, function () { MSP.send_message(MSPCodes.MSP_EEPROM_WRITE, false, false, function () {
GUI.log(localization.getMessage('multimission_active_index_saved_eeprom')); GUI.log(i18n.getMessage('multimission_active_index_saved_eeprom'));
}); });
}); });
} }
@ -2828,7 +2828,7 @@ TABS.mission_control.initialize = function (callback) {
availableWPs = availableWPs - multimission.get().length; availableWPs = availableWPs - multimission.get().length;
} }
$('#availablePoints').text(availableWPs + '/' + mission.getMaxWaypoints()); $('#availablePoints').text(availableWPs + '/' + mission.getMaxWaypoints());
$('#missionValid').html(mission.getValidMission() ? localization.getMessage('armingCheckPass') : localization.getMessage('armingCheckFail')); $('#missionValid').html(mission.getValidMission() ? i18n.getMessage('armingCheckPass') : i18n.getMessage('armingCheckFail'));
} }
} }
@ -2854,7 +2854,7 @@ TABS.mission_control.initialize = function (callback) {
if (AbsAltCheck) { if (AbsAltCheck) {
if (checkAltitude < 100 * elevation) { if (checkAltitude < 100 * elevation) {
if (resetAltitude) { if (resetAltitude) {
alert(localization.getMessage('MissionPlannerAltitudeChangeReset')); alert(i18n.getMessage('MissionPlannerAltitudeChangeReset'));
altitude = selectedMarker.getAlt(); altitude = selectedMarker.getAlt();
} else { } else {
altitude = settings.alt + 100 * elevation; altitude = settings.alt + 100 * elevation;
@ -2865,7 +2865,7 @@ TABS.mission_control.initialize = function (callback) {
let elevationAtHome = HOME.getAlt(); let elevationAtHome = HOME.getAlt();
if ((checkAltitude / 100 + elevationAtHome) < elevation) { if ((checkAltitude / 100 + elevationAtHome) < elevation) {
if (resetAltitude) { if (resetAltitude) {
alert(localization.getMessage('MissionPlannerAltitudeChangeReset')); alert(i18n.getMessage('MissionPlannerAltitudeChangeReset'));
altitude = selectedMarker.getAlt(); altitude = selectedMarker.getAlt();
} else { } else {
let currentGroundClearance = 100 * Number($('#groundClearanceValueAtWP').text()); let currentGroundClearance = 100 * Number($('#groundClearanceValueAtWP').text());

View file

@ -50,7 +50,7 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
function reboot() { function reboot() {
//noinspection JSUnresolvedVariable //noinspection JSUnresolvedVariable
GUI.log(localization.getMessage('configurationEepromSaved')); GUI.log(i18n.getMessage('configurationEepromSaved'));
GUI.tab_switch_cleanup(function() { GUI.tab_switch_cleanup(function() {
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, reinitialize); MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, reinitialize);
@ -59,7 +59,7 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
function reinitialize() { function reinitialize() {
//noinspection JSUnresolvedVariable //noinspection JSUnresolvedVariable
GUI.log(localization.getMessage('deviceRebooting')); GUI.log(i18n.getMessage('deviceRebooting'));
GUI.handleReconnect($('.tab_mixer a')); GUI.handleReconnect($('.tab_mixer a'));
} }
@ -128,7 +128,7 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
function renderOutputMapping() { function renderOutputMapping() {
let outputMap = OUTPUT_MAPPING.getOutputTable( let outputMap = OUTPUT_MAPPING.getOutputTable(
MIXER_CONFIG.platformType == PLATFORM_MULTIROTOR || MIXER_CONFIG.platformType == PLATFORM_TRICOPTER, MIXER_CONFIG.platformType == PLATFORM.MULTIROTOR || MIXER_CONFIG.platformType == PLATFORM.TRICOPTER,
MOTOR_RULES.getNumberOfConfiguredMotors(), MOTOR_RULES.getNumberOfConfiguredMotors(),
SERVO_RULES.getUsedServoIndexes() SERVO_RULES.getUsedServoIndexes()
); );
@ -150,15 +150,15 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
$(this).css("color", ""); $(this).css("color", "");
}); });
if (MIXER_CONFIG.platformType == PLATFORM_AIRPLANE) { if (MIXER_CONFIG.platformType == PLATFORM.AIRPLANE) {
if (outputMap != null && currentMixerPreset.hasOwnProperty('imageOutputsNumbers')) { if (outputMap != null && currentMixerPreset.hasOwnProperty('imageOutputsNumbers')) {
let outputPad = 1; let outputPad = 1;
let outputArea = null; let outputArea = null;
let inputBoxes = null; let inputBoxes = null;
let surfaces = { let surfaces = {
aileronSet: helper.mixer.countSurfaceType(currentMixerPreset, INPUT_STABILIZED_ROLL), aileronSet: helper.mixer.countSurfaceType(currentMixerPreset, INPUT.STABILIZED_ROLL),
elevatorSet: helper.mixer.countSurfaceType(currentMixerPreset, INPUT_STABILIZED_PITCH), elevatorSet: helper.mixer.countSurfaceType(currentMixerPreset, INPUT.STABILIZED_PITCH),
rudderSet: helper.mixer.countSurfaceType(currentMixerPreset, INPUT_STABILIZED_YAW), rudderSet: helper.mixer.countSurfaceType(currentMixerPreset, INPUT.STABILIZED_YAW),
}; };
let motors = []; let motors = [];
let servoRules = SERVO_RULES; let servoRules = SERVO_RULES;
@ -174,11 +174,11 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
let divID = "servoPreview" + omIndex[1]; let divID = "servoPreview" + omIndex[1];
switch (parseInt(servo.getInput())) { switch (parseInt(servo.getInput())) {
case INPUT_STABILIZED_PITCH: case INPUT.STABILIZED_PITCH:
case STABILIZED_PITCH_POSITIVE: case STABILIZED.PITCH_POSITIVE:
case STABILIZED_PITCH_NEGATIVE: case STABILIZED.PITCH_NEGATIVE:
case INPUT_RC_PITCH: case INPUT.RC_PITCH:
outputArea = getOutputImageArea(currentMixerPreset.imageOutputsNumbers, INPUT_STABILIZED_PITCH, surfaces.elevatorSet); outputArea = getOutputImageArea(currentMixerPreset.imageOutputsNumbers, INPUT.STABILIZED_PITCH, surfaces.elevatorSet);
if (outputArea != null) { if (outputArea != null) {
mixerPreview.append('<div id="' + divID + '" class="outputImageNumber">S' + outputPad + '</div>'); mixerPreview.append('<div id="' + divID + '" class="outputImageNumber">S' + outputPad + '</div>');
@ -198,11 +198,11 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
surfaces.elevatorSet--; surfaces.elevatorSet--;
} }
break; break;
case INPUT_STABILIZED_ROLL: case INPUT.STABILIZED_ROLL:
case STABILIZED_ROLL_POSITIVE: case STABILIZED.ROLL_POSITIVE:
case STABILIZED_ROLL_NEGATIVE: case STABILIZED.ROLL_NEGATIVE:
case INPUT_RC_ROLL: case INPUT.RC_ROLL:
outputArea = getOutputImageArea(currentMixerPreset.imageOutputsNumbers, INPUT_STABILIZED_ROLL, surfaces.aileronSet); outputArea = getOutputImageArea(currentMixerPreset.imageOutputsNumbers, INPUT.STABILIZED_ROLL, surfaces.aileronSet);
if (outputArea != null) { if (outputArea != null) {
mixerPreview.append('<div id="' + divID + '" class="outputImageNumber">S' + outputPad + '</div>'); mixerPreview.append('<div id="' + divID + '" class="outputImageNumber">S' + outputPad + '</div>');
@ -222,11 +222,11 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
surfaces.aileronSet--; surfaces.aileronSet--;
} }
break; break;
case INPUT_STABILIZED_YAW: case INPUT.STABILIZED_YAW:
case STABILIZED_YAW_POSITIVE: case STABILIZED.YAW_POSITIVE:
case STABILIZED_YAW_NEGATIVE: case STABILIZED.YAW_NEGATIVE:
case INPUT_RC_YAW: case INPUT.RC_YAW:
outputArea = getOutputImageArea(currentMixerPreset.imageOutputsNumbers, INPUT_STABILIZED_YAW, surfaces.rudderSet); outputArea = getOutputImageArea(currentMixerPreset.imageOutputsNumbers, INPUT.STABILIZED_YAW, surfaces.rudderSet);
if (outputArea != null) { if (outputArea != null) {
mixerPreview.append('<div id="' + divID + '" class="outputImageNumber">S' + outputPad + '</div>'); mixerPreview.append('<div id="' + divID + '" class="outputImageNumber">S' + outputPad + '</div>');
@ -256,7 +256,7 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
if (motors.length > 0) { if (motors.length > 0) {
mixerPreview.append('<div id="motorsPreview" class="outputImageNumber isMotor">S' + motors.join('/') + '</div>'); mixerPreview.append('<div id="motorsPreview" class="outputImageNumber isMotor">S' + motors.join('/') + '</div>');
outputArea = getOutputImageArea(currentMixerPreset.imageOutputsNumbers, INPUT_STABILIZED_THROTTLE, 0); outputArea = getOutputImageArea(currentMixerPreset.imageOutputsNumbers, INPUT.STABILIZED_THROTTLE, 0);
if (outputArea != null) { if (outputArea != null) {
$("#motorsPreview").css("top", outputArea.top + "px"); $("#motorsPreview").css("top", outputArea.top + "px");
$("#motorsPreview").css("left", outputArea.left + "px"); $("#motorsPreview").css("left", outputArea.left + "px");
@ -276,21 +276,21 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
for (let area of outputImageAreas) { for (let area of outputImageAreas) {
if (area.input == input) { if (area.input == input) {
if ( input === INPUT_STABILIZED_THROTTLE if ( input === INPUT.STABILIZED_THROTTLE
|| (surfacesSet > 0 && || (surfacesSet > 0 &&
((input === INPUT_STABILIZED_YAW && surfacesSet !== lastYaw) ((input === INPUT.STABILIZED_YAW && surfacesSet !== lastYaw)
|| (input === INPUT_STABILIZED_ROLL && surfacesSet !== lastRoll) || (input === INPUT.STABILIZED_ROLL && surfacesSet !== lastRoll)
|| (input === INPUT_STABILIZED_PITCH && surfacesSet !== lastPitch)) || (input === INPUT.STABILIZED_PITCH && surfacesSet !== lastPitch))
) )
) { ) {
returnArea = area; returnArea = area;
} }
if (input === INPUT_STABILIZED_ROLL) { if (input === INPUT.STABILIZED_ROLL) {
lastRoll = surfacesSet-1; lastRoll = surfacesSet-1;
} else if (input === INPUT_STABILIZED_PITCH) { } else if (input === INPUT.STABILIZED_PITCH) {
lastPitch = surfacesSet-1; lastPitch = surfacesSet-1;
} else if (input === INPUT_STABILIZED_YAW) { } else if (input === INPUT.STABILIZED_YAW) {
lastYaw = surfacesSet-1; lastYaw = surfacesSet-1;
} }
@ -356,25 +356,25 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
$row.find(".mix-rule-input").children('option[value="14"]').remove(); $row.find(".mix-rule-input").children('option[value="14"]').remove();
} }
$row.find(".mix-rule-input").val(servoRule.getInput()).change(function () { $row.find(".mix-rule-input").val(servoRule.getInput()).on('change', function () {
servoRule.setInput($(this).val()); servoRule.setInput($(this).val());
updateFixedValueVisibility($row, $(this)); updateFixedValueVisibility($row, $(this));
renderOutputMapping(); renderOutputMapping();
}); });
$row.find(".mix-rule-servo").val(servoRule.getTarget()).change(function () { $row.find(".mix-rule-servo").val(servoRule.getTarget()).on('change', function () {
servoRule.setTarget($(this).val()); servoRule.setTarget($(this).val());
}); });
$row.find(".mix-rule-rate").val(servoRule.getRate()).change(function () { $row.find(".mix-rule-rate").val(servoRule.getRate()).on('change', function () {
servoRule.setRate($(this).val()); servoRule.setRate($(this).val());
$row.find(".mix-rule-fixed-value").val(mapServoWeightToFixedValue($(this).val())); $row.find(".mix-rule-fixed-value").val(mapServoWeightToFixedValue($(this).val()));
}); });
$row.find(".mix-rule-fixed-value").val(mapServoWeightToFixedValue($row.find(".mix-rule-rate").val())); $row.find(".mix-rule-fixed-value").val(mapServoWeightToFixedValue($row.find(".mix-rule-rate").val()));
$row.find(".mix-rule-speed").val(servoRule.getSpeed()).change(function () { $row.find(".mix-rule-speed").val(servoRule.getSpeed()).on('change', function () {
servoRule.setSpeed($(this).val()); servoRule.setSpeed($(this).val());
}); });
@ -388,7 +388,7 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
rate_inputs.attr("min", -1000); rate_inputs.attr("min", -1000);
rate_inputs.attr("max", 1000); rate_inputs.attr("max", 1000);
localization.localize();; i18n.localize();;
} }
function updateFixedValueVisibility(row, $mixRuleInput) { function updateFixedValueVisibility(row, $mixRuleInput) {
@ -506,15 +506,15 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
} }
} }
updateThrottle(); updateThrottle();
$throttleInput.change(updateThrottle); $throttleInput.on('change', updateThrottle);
$row.find('.mix-rule-roll').val(rule.getRoll()).change(function () { $row.find('.mix-rule-roll').val(rule.getRoll()).on('change', function () {
rule.setRoll($(this).val()); rule.setRoll($(this).val());
}); });
$row.find('.mix-rule-pitch').val(rule.getPitch()).change(function () { $row.find('.mix-rule-pitch').val(rule.getPitch()).on('change', function () {
rule.setPitch($(this).val()); rule.setPitch($(this).val());
}); });
$row.find('.mix-rule-yaw').val(rule.getYaw()).change(function () { $row.find('.mix-rule-yaw').val(rule.getYaw()).on('change', function () {
rule.setYaw($(this).val()); rule.setYaw($(this).val());
}); });
$row.find("[data-role='role-motor-delete']").attr("data-index", i); $row.find("[data-role='role-motor-delete']").attr("data-index", i);
@ -522,7 +522,7 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
} }
labelMotorNumbers(); labelMotorNumbers();
localization.localize();; i18n.localize();;
} }
function saveAndReboot() { function saveAndReboot() {
@ -569,7 +569,7 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
closeButton: 'title', closeButton: 'title',
animation: false, animation: false,
attach: $wizardButton, attach: $wizardButton,
title: localization.getMessage("mixerWizardModalTitle"), title: i18n.getMessage("mixerWizardModalTitle"),
content: $('#mixerWizardContent') content: $('#mixerWizardContent')
}); });
@ -591,9 +591,9 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
return (errorCount == 0); return (errorCount == 0);
} }
$(".wizard-motor-select").change(validateMixerWizard); $(".wizard-motor-select").on('change', validateMixerWizard);
$("#wizard-execute-button").click(function () { $("#wizard-execute-button").on('click', function () {
// Validate mixer settings // Validate mixer settings
if (!validateMixerWizard()) { if (!validateMixerWizard()) {
@ -633,24 +633,24 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
const updateMotorDirection = function () { const updateMotorDirection = function () {
let motorDirectionCheckbox = $("#motor_direction_inverted"); let motorDirectionCheckbox = $("#motor_direction_inverted");
const isReversed = motorDirectionCheckbox.is(":checked") && (MIXER_CONFIG.platformType == PLATFORM_MULTIROTOR || MIXER_CONFIG.platformType == PLATFORM_TRICOPTER); const isReversed = motorDirectionCheckbox.is(":checked") && (MIXER_CONFIG.platformType == PLATFORM.MULTIROTOR || MIXER_CONFIG.platformType == PLATFORM.TRICOPTER);
const path = './resources/motor_order/' const path = './resources/motor_order/'
+ currentMixerPreset.image + (isReversed ? "_reverse" : "") + '.svg'; + currentMixerPreset.image + (isReversed ? "_reverse" : "") + '.svg';
$('.mixerPreview img').attr('src', path); $('.mixerPreview img').attr('src', path);
if (MIXER_CONFIG.platformType == PLATFORM_MULTIROTOR || MIXER_CONFIG.platformType == PLATFORM_TRICOPTER) { if (MIXER_CONFIG.platformType == PLATFORM.MULTIROTOR || MIXER_CONFIG.platformType == PLATFORM.TRICOPTER) {
if (isReversed) { if (isReversed) {
motorDirectionCheckbox.parent().find("label span").html(localization.getMessage("motor_direction_isInverted")); motorDirectionCheckbox.parent().find("label span").html(i18n.getMessage("motor_direction_isInverted"));
} else { } else {
motorDirectionCheckbox.parent().find("label span").html(localization.getMessage("motor_direction_inverted")); motorDirectionCheckbox.parent().find("label span").html(i18n.getMessage("motor_direction_inverted"));
} }
} }
renderServoOutputImage(); renderServoOutputImage();
}; };
$("#motor_direction_inverted").change(updateMotorDirection); $("#motor_direction_inverted").on('change', updateMotorDirection);
$platformSelect.find("*").remove(); $platformSelect.find("*").remove();
@ -661,20 +661,20 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
} }
} }
$platformSelect.change(function () { $platformSelect.on('change', function () {
MIXER_CONFIG.platformType = parseInt($platformSelect.val(), 10); MIXER_CONFIG.platformType = parseInt($platformSelect.val(), 10);
currentPlatform = helper.platform.getById(MIXER_CONFIG.platformType); currentPlatform = helper.platform.getById(MIXER_CONFIG.platformType);
var $platformSelectParent = $platformSelect.parent('.select'); var $platformSelectParent = $platformSelect.parent('.select');
fillMixerPreset(); fillMixerPreset();
$mixerPreset.change(); $mixerPreset.trigger('change');
}); });
currentPlatform = helper.platform.getById(MIXER_CONFIG.platformType); currentPlatform = helper.platform.getById(MIXER_CONFIG.platformType);
$platformSelect.val(MIXER_CONFIG.platformType).change(); $platformSelect.val(MIXER_CONFIG.platformType).trigger('change');
$mixerPreset.change(function () { $mixerPreset.on('change', function () {
const presetId = parseInt($mixerPreset.val(), 10); const presetId = parseInt($mixerPreset.val(), 10);
currentMixerPreset = helper.mixer.getById(presetId); currentMixerPreset = helper.mixer.getById(presetId);
@ -686,13 +686,13 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
$wizardButton.parent().addClass("is-hidden"); $wizardButton.parent().addClass("is-hidden");
} }
if (MIXER_CONFIG.platformType == PLATFORM_AIRPLANE && currentMixerPreset.id != loadedMixerPresetID) { if (MIXER_CONFIG.platformType == PLATFORM.AIRPLANE && currentMixerPreset.id != loadedMixerPresetID) {
$("#needToUpdateMixerMessage").removeClass("is-hidden"); $("#needToUpdateMixerMessage").removeClass("is-hidden");
} else { } else {
$("#needToUpdateMixerMessage").addClass("is-hidden"); $("#needToUpdateMixerMessage").addClass("is-hidden");
} }
if (MIXER_CONFIG.platformType == PLATFORM_MULTIROTOR || MIXER_CONFIG.platformType == PLATFORM_TRICOPTER) { if (MIXER_CONFIG.platformType == PLATFORM.MULTIROTOR || MIXER_CONFIG.platformType == PLATFORM.TRICOPTER) {
$('#motor_direction_inverted').parent().removeClass("is-hidden"); $('#motor_direction_inverted').parent().removeClass("is-hidden");
$('#platform-type').parent('.select').removeClass('no-bottom-border'); $('#platform-type').parent('.select').removeClass('no-bottom-border');
} else { } else {
@ -700,7 +700,7 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
$('#platform-type').parent('.select').addClass('no-bottom-border'); $('#platform-type').parent('.select').addClass('no-bottom-border');
} }
if (!updateEzTuneTabVisibility(false)) { if (!GUI.updateEzTuneTabVisibility(false)) {
EZ_TUNE.enabled = 0; EZ_TUNE.enabled = 0;
mspHelper.saveEzTune(); mspHelper.saveEzTune();
} }
@ -713,9 +713,9 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
if (MIXER_CONFIG.appliedMixerPreset > -1) { if (MIXER_CONFIG.appliedMixerPreset > -1) {
loadedMixerPresetID = MIXER_CONFIG.appliedMixerPreset; loadedMixerPresetID = MIXER_CONFIG.appliedMixerPreset;
$("#needToUpdateMixerMessage").addClass("is-hidden"); $("#needToUpdateMixerMessage").addClass("is-hidden");
$mixerPreset.val(MIXER_CONFIG.appliedMixerPreset).change(); $mixerPreset.val(MIXER_CONFIG.appliedMixerPreset).trigger('change');
} else { } else {
$mixerPreset.change(); $mixerPreset.trigger('change');
} }
modal = new jBox('Modal', { modal = new jBox('Modal', {
@ -724,11 +724,11 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
closeButton: 'title', closeButton: 'title',
animation: false, animation: false,
attach: $('#load-and-apply-mixer-button'), attach: $('#load-and-apply-mixer-button'),
title: localization.getMessage("mixerApplyModalTitle"), title: i18n.getMessage("mixerApplyModalTitle"),
content: $('#mixerApplyContent') content: $('#mixerApplyContent')
}); });
$('#execute-button').click(function () { $('#execute-button').on('click', function () {
loadedMixerPresetID = currentMixerPreset.id; loadedMixerPresetID = currentMixerPreset.id;
helper.mixer.loadServoRules(currentMixerPreset); helper.mixer.loadServoRules(currentMixerPreset);
helper.mixer.loadMotorRules(currentMixerPreset); helper.mixer.loadMotorRules(currentMixerPreset);
@ -740,8 +740,8 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
saveAndReboot(); saveAndReboot();
}); });
$('#load-mixer-button').click(function () { $('#load-mixer-button').on('click', function () {
if (MIXER_CONFIG.platformType == PLATFORM_AIRPLANE) { if (MIXER_CONFIG.platformType == PLATFORM.AIRPLANE) {
$("#needToUpdateMixerMessage").addClass("is-hidden"); $("#needToUpdateMixerMessage").addClass("is-hidden");
} }
loadedMixerPresetID = currentMixerPreset.id; loadedMixerPresetID = currentMixerPreset.id;
@ -754,12 +754,12 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
updateRefreshButtonStatus(); updateRefreshButtonStatus();
}); });
$('#refresh-mixer-button').click(function () { $('#refresh-mixer-button').on('click', function () {
currentMixerPreset = helper.mixer.getById(loadedMixerPresetID); currentMixerPreset = helper.mixer.getById(loadedMixerPresetID);
MIXER_CONFIG.platformType = currentMixerPreset.platform; MIXER_CONFIG.platformType = currentMixerPreset.platform;
currentPlatform = helper.platform.getById(MIXER_CONFIG.platformType); currentPlatform = helper.platform.getById(MIXER_CONFIG.platformType);
$platformSelect.val(MIXER_CONFIG.platformType).change(); $platformSelect.val(MIXER_CONFIG.platformType).trigger('change');
$mixerPreset.val(loadedMixerPresetID).change(); $mixerPreset.val(loadedMixerPresetID).trigger('change');
renderServoMixRules(); renderServoMixRules();
renderMotorMixRules(); renderMotorMixRules();
renderOutputMapping(); renderOutputMapping();
@ -781,7 +781,7 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
renderOutputMapping(); renderOutputMapping();
}); });
$("[data-role='role-servo-add']").click(function () { $("[data-role='role-servo-add']").on('click', function () {
if (SERVO_RULES.hasFreeSlots()) { if (SERVO_RULES.hasFreeSlots()) {
SERVO_RULES.put(new ServoMixRule(SERVO_RULES.getNextUnusedIndex(), 0, 100, 0)); SERVO_RULES.put(new ServoMixRule(SERVO_RULES.getNextUnusedIndex(), 0, 100, 0));
renderServoMixRules(); renderServoMixRules();
@ -789,7 +789,7 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
} }
}); });
$("[data-role='role-motor-add']").click(function () { $("[data-role='role-motor-add']").on('click', function () {
if (MOTOR_RULES.hasFreeSlots()) { if (MOTOR_RULES.hasFreeSlots()) {
MOTOR_RULES.put(new MotorMixRule(1, 0, 0, 0)); MOTOR_RULES.put(new MotorMixRule(1, 0, 0, 0));
renderMotorMixRules(); renderMotorMixRules();
@ -797,11 +797,11 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
} }
}); });
$("[data-role='role-logic-conditions-open']").click(function () { $("[data-role='role-logic-conditions-open']").on('click', function () {
LOGIC_CONDITIONS.open(); LOGIC_CONDITIONS.open();
}); });
$('#save-button').click(saveAndReboot); $('#save-button').on('click', saveAndReboot);
renderServoMixRules(); renderServoMixRules();
renderMotorMixRules(); renderMotorMixRules();
@ -812,7 +812,7 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
LOGIC_CONDITIONS.init($('#logic-wrapper')); LOGIC_CONDITIONS.init($('#logic-wrapper'));
localization.localize();; i18n.localize();;
helper.mspBalancedInterval.add('logic_conditions_pull', 350, 1, getLogicConditionsStatus); helper.mspBalancedInterval.add('logic_conditions_pull', 350, 1, getLogicConditionsStatus);
@ -821,8 +821,8 @@ TABS.mixer.initialize = function (callback, scrollPosition) {
function updateRefreshButtonStatus() { function updateRefreshButtonStatus() {
if ( if (
(currentMixerPreset.id != loadedMixerPresetID && helper.mixer.getById(loadedMixerPresetID).platform == PLATFORM_AIRPLANE) || (currentMixerPreset.id != loadedMixerPresetID && helper.mixer.getById(loadedMixerPresetID).platform == PLATFORM.AIRPLANE) ||
(currentMixerPreset.id == loadedMixerPresetID && currentMixerPreset.platform == PLATFORM_AIRPLANE) (currentMixerPreset.id == loadedMixerPresetID && currentMixerPreset.platform == PLATFORM.AIRPLANE)
) { ) {
$("#refresh-mixer-button").parent().removeClass("is-hidden"); $("#refresh-mixer-button").parent().removeClass("is-hidden");
} else { } else {

View file

@ -44,7 +44,7 @@ TABS.modes.initialize = function (callback) {
} }
// translate to user-selected language // translate to user-selected language
localization.localize();; i18n.localize();;
// generate table from the supplied AUX names and AUX data // generate table from the supplied AUX names and AUX data
for (var i = 0; i < AUX_CONFIG.length; i++) { for (var i = 0; i < AUX_CONFIG.length; i++) {
@ -65,7 +65,7 @@ TABS.modes.initialize = function (callback) {
} }
// UI Hooks // UI Hooks
$('a.update').click(function () { $('a.update').on('click', function () {
// catch the input changes // catch the input changes
var main_needle = 0, var main_needle = 0,
needle = 0; needle = 0;
@ -87,7 +87,7 @@ TABS.modes.initialize = function (callback) {
function save_to_eeprom() { function save_to_eeprom() {
MSP.send_message(MSPCodes.MSP_EEPROM_WRITE, false, false, function () { MSP.send_message(MSPCodes.MSP_EEPROM_WRITE, false, false, function () {
GUI.log(localization.getMessage('auxiliaryEepromSaved')); GUI.log(i18n.getMessage('auxiliaryEepromSaved'));
}); });
} }

View file

@ -54,7 +54,7 @@ TABS.onboard_logging.initialize = function (callback) {
} }
function reboot() { function reboot() {
GUI.log(localization.getMessage('configurationEepromSaved')); GUI.log(i18n.getMessage('configurationEepromSaved'));
GUI.tab_switch_cleanup(function() { GUI.tab_switch_cleanup(function() {
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, reinitialize); MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, reinitialize);
@ -62,14 +62,14 @@ TABS.onboard_logging.initialize = function (callback) {
} }
function reinitialize() { function reinitialize() {
GUI.log(localization.getMessage('deviceRebooting')); GUI.log(i18n.getMessage('deviceRebooting'));
GUI.handleReconnect($('.tab_onboard_logging a')); GUI.handleReconnect($('.tab_onboard_logging a'));
} }
function load_html() { function load_html() {
GUI.load(path.join(__dirname, "tabs/onboard_logging.html"), function() { GUI.load(path.join(__dirname, "tabs/onboard_logging.html"), function() {
// translate to user-selected language // translate to user-selected language
localization.localize();; i18n.localize();;
var var
dataflashPresent = DATAFLASH.totalSize > 0, dataflashPresent = DATAFLASH.totalSize > 0,
@ -90,24 +90,24 @@ TABS.onboard_logging.initialize = function (callback) {
if (dataflashPresent) { if (dataflashPresent) {
// UI hooks // UI hooks
$('.tab-onboard_logging a.erase-flash').click(ask_to_erase_flash); $('.tab-onboard_logging a.erase-flash').on('click', ask_to_erase_flash);
$('.tab-onboard_logging a.erase-flash-confirm').click(flash_erase); $('.tab-onboard_logging a.erase-flash-confirm').on('click', flash_erase);
$('.tab-onboard_logging a.erase-flash-cancel').click(flash_erase_cancel); $('.tab-onboard_logging a.erase-flash-cancel').on('click', flash_erase_cancel);
$('.tab-onboard_logging a.save-flash').click(flash_save_begin); $('.tab-onboard_logging a.save-flash').on('click', flash_save_begin);
$('.tab-onboard_logging a.save-flash-cancel').click(flash_save_cancel); $('.tab-onboard_logging a.save-flash-cancel').on('click', flash_save_cancel);
$('.tab-onboard_logging a.save-flash-dismiss').click(dismiss_saving_dialog); $('.tab-onboard_logging a.save-flash-dismiss').on('click', dismiss_saving_dialog);
} }
$('.save-blackbox-feature').click(function () { $('.save-blackbox-feature').on('click', function () {
helper.features.reset(); helper.features.reset();
helper.features.fromUI($('.require-blackbox-unsupported')); helper.features.fromUI($('.require-blackbox-unsupported'));
helper.features.execute(save_to_eeprom); helper.features.execute(save_to_eeprom);
}); });
if (BLACKBOX.supported) { if (BLACKBOX.supported) {
$(".tab-onboard_logging a.save-settings").click(function() { $(".tab-onboard_logging a.save-settings").on('click', function () {
var rate = $(".blackboxRate select").val().split('/'); var rate = $(".blackboxRate select").val().split('/');
BLACKBOX.blackboxRateNum = parseInt(rate[0], 10); BLACKBOX.blackboxRateNum = parseInt(rate[0], 10);
@ -135,7 +135,7 @@ TABS.onboard_logging.initialize = function (callback) {
label.attr("for",FIELD_ID) label.attr("for",FIELD_ID)
const span = $('<span></span>'); const span = $('<span></span>');
span.html(localization.getMessage(FIELD_ID)) span.html(i18n.getMessage(FIELD_ID))
label.append(span); label.append(span);
const checkbox = $('<div class="checkbox"></div>') const checkbox = $('<div class="checkbox"></div>')

View file

@ -10,12 +10,12 @@
<input id="notificationsOptions" type="checkbox" /> <input id="notificationsOptions" type="checkbox" />
<label for="notificationsOptions"><span data-i18n="options_receive_app_notifications"></span></label> <label for="notificationsOptions"><span data-i18n="options_receive_app_notifications"></span></label>
</div> </div>
<!--
<div class="checkbox statistics"> <div class="checkbox statistics">
<input id="improveConfigurator" type="checkbox" /> <input id="improveConfigurator" type="checkbox" />
<label for="improveConfigurator"><span data-i18n="options_improve_configurator"></span></label> <label for="improveConfigurator"><span data-i18n="options_improve_configurator"></span></label>
</div> </div>
-->
<div class="checkbox show_profile_parameters"> <div class="checkbox show_profile_parameters">
<input id="showProfileParameters" type="checkbox" /> <input id="showProfileParameters" type="checkbox" />
<label for="showProfileParameters"><span data-i18n="options_showProfileParameters"></span></label> <label for="showProfileParameters"><span data-i18n="options_showProfileParameters"></span></label>
@ -24,6 +24,12 @@
<input id="cliAutocomplete" type="checkbox" /> <input id="cliAutocomplete" type="checkbox" />
<label for="cliAutocomplete"><span data-i18n="options_cliAutocomplete"></span></label> <label for="cliAutocomplete"><span data-i18n="options_cliAutocomplete"></span></label>
</div> </div>
<div class="select">
<select id="languageOption">
</select>
<label for="languageOption" data-i18n="language"></label>
</div>
</div> </div>
</div> </div>

View file

@ -1953,27 +1953,27 @@ OSD.constants = {
preview: 'TEX 0' preview: 'TEX 0'
}, },
{ {
name: 'STABILIZED_RC_EXPO', name: 'STABILIZED.RC_EXPO',
id: 64, id: 64,
preview: 'EXP 20' preview: 'EXP 20'
}, },
{ {
name: 'STABILIZED_RC_YAW_EXPO', name: 'STABILIZED.RC_YAW_EXPO',
id: 65, id: 65,
preview: 'YEX 20' preview: 'YEX 20'
}, },
{ {
name: 'STABILIZED_PITCH_RATE', name: 'STABILIZED.PITCH_RATE',
id: 67, id: 67,
preview: 'SPR 20' preview: 'SPR 20'
}, },
{ {
name: 'STABILIZED_ROLL_RATE', name: 'STABILIZED.ROLL_RATE',
id: 68, id: 68,
preview: 'SRR 20' preview: 'SRR 20'
}, },
{ {
name: 'STABILIZED_YAW_RATE', name: 'STABILIZED.YAW_RATE',
id: 69, id: 69,
preview: 'SYR 20' preview: 'SYR 20'
}, },
@ -2509,7 +2509,7 @@ OSD.GUI.preview = {
position += overflows_line; position += overflows_line;
} }
$('input.' + item_id + '.position').val(position).change(); $('input.' + item_id + '.position').val(position).trigger('change');
} }
}; };
@ -2573,7 +2573,7 @@ OSD.GUI.updateVideoMode = function() {
} }
} }
$videoTypes.change(function () { $videoTypes.on('change', function () {
OSD.data.preferences.video_system = $(this).find(':selected').data('type'); OSD.data.preferences.video_system = $(this).find(':selected').data('type');
OSD.updateDisplaySize(); OSD.updateDisplaySize();
OSD.GUI.saveConfig(); OSD.GUI.saveConfig();
@ -2590,7 +2590,7 @@ OSD.GUI.updateUnits = function() {
if (unitType.min_version && semver.lt(CONFIG.flightControllerVersion, unitType.min_version)) { if (unitType.min_version && semver.lt(CONFIG.flightControllerVersion, unitType.min_version)) {
continue; continue;
} }
var name = localization.getMessage(unitType.name); var name = i18n.getMessage(unitType.name);
var $option = $('<option>' + name + '</option>'); var $option = $('<option>' + name + '</option>');
$option.attr('value', name); $option.attr('value', name);
$option.data('type', unitType.value); $option.data('type', unitType.value);
@ -2603,7 +2603,7 @@ OSD.GUI.updateUnits = function() {
var unitType = OSD.constants.UNIT_TYPES[OSD.data.preferences.units]; var unitType = OSD.constants.UNIT_TYPES[OSD.data.preferences.units];
var tip; var tip;
if (unitType.tip) { if (unitType.tip) {
tip = localization.getMessage(unitType.tip); tip = i18n.getMessage(unitType.tip);
} }
if (tip) { if (tip) {
$unitTip.attr('title', tip); $unitTip.attr('title', tip);
@ -2613,7 +2613,7 @@ OSD.GUI.updateUnits = function() {
} }
} }
updateUnitHelp(); updateUnitHelp();
$unitMode.change(function (e) { $unitMode.on('change', function (e) {
var selected = $(this).find(':selected'); var selected = $(this).find(':selected');
OSD.data.preferences.units = selected.data('type'); OSD.data.preferences.units = selected.data('type');
globalSettings.osdUnits = OSD.data.preferences.units; globalSettings.osdUnits = OSD.data.preferences.units;
@ -2644,9 +2644,9 @@ OSD.GUI.updateFields = function() {
var groupContainer = $tmpl.clone().addClass('osd_group').show(); var groupContainer = $tmpl.clone().addClass('osd_group').show();
groupContainer.attr('id', group.name); groupContainer.attr('id', group.name);
var groupTitleContainer = groupContainer.find('.spacer_box_title'); var groupTitleContainer = groupContainer.find('.spacer_box_title');
var groupTitle = localization.getMessage(group.name); var groupTitle = i18n.getMessage(group.name);
groupTitleContainer.text(groupTitle); groupTitleContainer.text(groupTitle);
var groupHelp = localization.getMessage(group.name + '_HELP'); var groupHelp = i18n.getMessage(group.name + '_HELP');
if (groupHelp) { if (groupHelp) {
$('<div class="helpicon cf_tip"></div>') $('<div class="helpicon cf_tip"></div>')
.css('margin-top', '1px') .css('margin-top', '1px')
@ -2670,7 +2670,7 @@ OSD.GUI.updateFields = function() {
var $field = $('<div class="display-field field-' + item.id + '"/>'); var $field = $('<div class="display-field field-' + item.id + '"/>');
var name = item.name; var name = item.name;
var nameKey = 'osdElement_' + name; var nameKey = 'osdElement_' + name;
var nameMessage = localization.getMessage(nameKey); var nameMessage = i18n.getMessage(nameKey);
if (nameMessage) { if (nameMessage) {
name = nameMessage; name = nameMessage;
} else { } else {
@ -2680,7 +2680,7 @@ OSD.GUI.updateFields = function() {
if (searchTerm.length > 0 && !name.toLowerCase().includes(searchTerm.toLowerCase())) { if (searchTerm.length > 0 && !name.toLowerCase().includes(searchTerm.toLowerCase())) {
continue; continue;
} }
var help = localization.getMessage(nameKey + '_HELP'); var help = i18n.getMessage(nameKey + '_HELP');
if (help) { if (help) {
$('<div class="helpicon cf_tip"></div>') $('<div class="helpicon cf_tip"></div>')
.css('margin-top', '1px') .css('margin-top', '1px')
@ -2700,7 +2700,7 @@ OSD.GUI.updateFields = function() {
$('<input type="checkbox" name="' + item.name + '" class="togglesmall"></input>') $('<input type="checkbox" name="' + item.name + '" class="togglesmall"></input>')
.data('item', item) .data('item', item)
.attr('checked', itemData.isVisible) .attr('checked', itemData.isVisible)
.change(function () { .on('change', function () {
var item = $(this).data('item'); var item = $(this).data('item');
var itemData = OSD.data.items[item.id]; var itemData = OSD.data.items[item.id];
var $position = $(this).parent().find('.position.' + item.name); var $position = $(this).parent().find('.position.' + item.name);
@ -2729,7 +2729,7 @@ OSD.GUI.updateFields = function() {
$('<input type="number" class="' + item.id + ' position"></input>') $('<input type="number" class="' + item.id + ' position"></input>')
.data('item', item) .data('item', item)
.val(itemData.position) .val(itemData.position)
.change($.debounce(250, function (e) { .on('change', $.debounce(250, function (e) {
var item = $(this).data('item'); var item = $(this).data('item');
var itemData = OSD.data.items[item.id]; var itemData = OSD.data.items[item.id];
itemData.position = parseInt($(this).val()); itemData.position = parseInt($(this).val());
@ -3067,7 +3067,7 @@ OSD.GUI.updatePreviews = function() {
$img.find('img').css('pointer-events', 'none'); $img.find('img').css('pointer-events', 'none');
if (item && item.positionable !== false) { if (item && item.positionable !== false) {
var nameKey = 'osdElement_' + item.name; var nameKey = 'osdElement_' + item.name;
var nameMessage = localization.getMessage(nameKey); var nameMessage = i18n.getMessage(nameKey);
if (!nameMessage) { if (!nameMessage) {
nameMessage = inflection.titleize(item.name); nameMessage = inflection.titleize(item.name);
@ -3097,7 +3097,7 @@ OSD.GUI.updateAll = function() {
if (OSD.data.layout_count > 1) { if (OSD.data.layout_count > 1) {
layouts.empty(); layouts.empty();
for (var ii = 0; ii < OSD.data.layout_count; ii++) { for (var ii = 0; ii < OSD.data.layout_count; ii++) {
var name = ii > 0 ? localization.getMessage('osdLayoutAlternative', [ii]) : localization.getMessage('osdLayoutDefault'); var name = ii > 0 ? i18n.getMessage('osdLayoutAlternative', [ii]) : i18n.getMessage('osdLayoutDefault');
var opt = $('<option/>').val(ii).text(name).appendTo(layouts); var opt = $('<option/>').val(ii).text(name).appendTo(layouts);
} }
layouts.val(OSD.data.selected_layout); layouts.val(OSD.data.selected_layout);
@ -3156,7 +3156,7 @@ TABS.osd.initialize = function (callback) {
GUI.load(path.join(__dirname, "tabs/osd.html"), Settings.processHtml(function () { GUI.load(path.join(__dirname, "tabs/osd.html"), Settings.processHtml(function () {
// translate to user-selected language // translate to user-selected language
localization.localize(); i18n.localize();
// Open modal window // Open modal window
OSD.GUI.jbox = new jBox('Modal', { OSD.GUI.jbox = new jBox('Modal', {
@ -3171,11 +3171,11 @@ TABS.osd.initialize = function (callback) {
content: $('#fontmanagercontent') content: $('#fontmanagercontent')
}); });
$('a.save').click(function () { $('a.save').on('click', function () {
Settings.saveInputs().then(function () { Settings.saveInputs().then(function () {
var self = this; var self = this;
MSP.promise(MSPCodes.MSP_EEPROM_WRITE); MSP.promise(MSPCodes.MSP_EEPROM_WRITE);
GUI.log(localization.getMessage('osdSettingsSaved')); GUI.log(i18n.getMessage('osdSettingsSaved'));
var oldText = $(this).text(); var oldText = $(this).text();
$(this).html("Saved"); $(this).html("Saved");
setTimeout(function () { setTimeout(function () {
@ -3259,7 +3259,7 @@ TABS.osd.initialize = function (callback) {
FONT.initData(); FONT.initData();
var $fontPicker = $('.fontbuttons button'); var $fontPicker = $('.fontbuttons button');
$fontPicker.click(function (e) { $fontPicker.on('click', function () {
if (!$(this).data('font-file')) { if (!$(this).data('font-file')) {
return; return;
} }
@ -3282,13 +3282,13 @@ TABS.osd.initialize = function (callback) {
} }
if (typeof previous_font_button == "undefined") { if (typeof previous_font_button == "undefined") {
$fontPicker.first().click(); $fontPicker.first().trigger( "click" );
} else { } else {
previous_font_button.click(); previous_font_button.trigger( "click" );
} }
$('button.load_font_file').click(function () { $('button.load_font_file').on('click', function () {
$fontPicker.removeClass('active'); $fontPicker.removeClass('active');
FONT.openFontFile().then(function () { FONT.openFontFile().then(function () {
FONT.preview($preview); FONT.preview($preview);
@ -3297,16 +3297,16 @@ TABS.osd.initialize = function (callback) {
}); });
// font upload // font upload
$('a.flash_font').click(function () { $('a.flash_font').on('click', function () {
if (!GUI.connect_lock) { // button disabled while flashing is in progress if (!GUI.connect_lock) { // button disabled while flashing is in progress
var progressLabel = $('.progressLabel'); var progressLabel = $('.progressLabel');
var progressBar = $('.progress'); var progressBar = $('.progress');
var uploading = localization.getMessage('uploadingCharacters'); var uploading = i18n.getMessage('uploadingCharacters');
progressLabel.text(uploading); progressLabel.text(uploading);
var progressCallback = function(done, total, percentage) { var progressCallback = function(done, total, percentage) {
progressBar.val(percentage); progressBar.val(percentage);
if (done == total) { if (done == total) {
progressLabel.text(localization.getMessage('uploadedCharacters'), [total]); progressLabel.text(i18n.getMessage('uploadedCharacters'), [total]);
} else { } else {
progressLabel.text(uploading + ' (' + done + '/' + total + ')'); progressLabel.text(uploading + ' (' + done + '/' + total + ')');
} }

View file

@ -1,4 +1,4 @@
/*global helper,MSP,MSPChainerClass,GUI,mspHelper,MOTOR_RULES,TABS,$,MSPCodes,ANALOG,MOTOR_DATA,chrome,PLATFORM_MULTIROTOR,PLATFORM_TRICOPTER,SERVO_RULES,FC,SERVO_CONFIG,SENSOR_DATA,REVERSIBLE_MOTORS,MISC,MIXER_CONFIG,OUTPUT_MAPPING*/ /*global helper,MSP,MSPChainerClass,GUI,mspHelper,MOTOR_RULES,TABS,$,MSPCodes,ANALOG,MOTOR_DATA,chrome,PLATFORM.MULTIROTOR,PLATFORM.TRICOPTER,SERVO_RULES,FC,SERVO_CONFIG,SENSOR_DATA,REVERSIBLE_MOTORS,MISC,MIXER_CONFIG,OUTPUT_MAPPING*/
'use strict'; 'use strict';
TABS.outputs = { TABS.outputs = {
@ -55,7 +55,7 @@ TABS.outputs.initialize = function (callback) {
mspHelper.saveToEeprom mspHelper.saveToEeprom
]); ]);
saveChainer.setExitPoint(function () { saveChainer.setExitPoint(function () {
GUI.log(localization.getMessage('eeprom_saved_ok')); GUI.log(i18n.getMessage('eeprom_saved_ok'));
MOTOR_RULES.cleanup(); MOTOR_RULES.cleanup();
}); });
@ -103,14 +103,14 @@ TABS.outputs.initialize = function (callback) {
if (ADVANCED_CONFIG.motorPwmProtocol >= 5) { if (ADVANCED_CONFIG.motorPwmProtocol >= 5) {
$('.hide-for-shot').hide(); $('.hide-for-shot').hide();
if ($idlePercent.val() > 7.0) { if ($idlePercent.val() > 7.0) {
$idleInfoBox.html(localization.getMessage('throttleIdleDigitalInfo')); $idleInfoBox.html(i18n.getMessage('throttleIdleDigitalInfo'));
$idleInfoBox.addClass('ok-box'); $idleInfoBox.addClass('ok-box');
$idleInfoBox.show(); $idleInfoBox.show();
} }
} else { } else {
$('.hide-for-shot').show(); $('.hide-for-shot').show();
if ($idlePercent.val() > 10.0) { if ($idlePercent.val() > 10.0) {
$idleInfoBox.html(localization.getMessage('throttleIdleAnalogInfo')); $idleInfoBox.html(i18n.getMessage('throttleIdleAnalogInfo'));
$idleInfoBox.addClass('ok-box'); $idleInfoBox.addClass('ok-box');
$idleInfoBox.show(); $idleInfoBox.show();
} }
@ -128,11 +128,11 @@ TABS.outputs.initialize = function (callback) {
$escProtocol.val(ADVANCED_CONFIG.motorPwmProtocol); $escProtocol.val(ADVANCED_CONFIG.motorPwmProtocol);
$escProtocol.change(function () { $escProtocol.on('change', function () {
ADVANCED_CONFIG.motorPwmProtocol = $(this).val(); ADVANCED_CONFIG.motorPwmProtocol = $(this).val();
}); });
$idlePercent.change(handleIdleMessageBox); $idlePercent.on('change', handleIdleMessageBox);
handleIdleMessageBox(); handleIdleMessageBox();
$("#esc-protocols").show(); $("#esc-protocols").show();
@ -152,7 +152,7 @@ TABS.outputs.initialize = function (callback) {
} }
$servoRate.val(ADVANCED_CONFIG.servoPwmRate); $servoRate.val(ADVANCED_CONFIG.servoPwmRate);
$servoRate.change(function () { $servoRate.on('change', function () {
ADVANCED_CONFIG.servoPwmRate = $(this).val(); ADVANCED_CONFIG.servoPwmRate = $(this).val();
}); });
@ -173,12 +173,12 @@ TABS.outputs.initialize = function (callback) {
$reversibleMotorBox.hide(); $reversibleMotorBox.hide();
} }
} }
$reversibleMotorCheckbox.change(showHideReversibleMotorInfo); $reversibleMotorCheckbox.on('change', showHideReversibleMotorInfo);
showHideReversibleMotorInfo(); showHideReversibleMotorInfo();
let $motorStopCheckbox = $('#feature-4'); let $motorStopCheckbox = $('#feature-4');
function showHideMotorStopWarning() { function showHideMotorStopWarning() {
const platformNeedsMotorStop = [PLATFORM_AIRPLANE, PLATFORM_ROVER, PLATFORM_BOAT].includes(MIXER_CONFIG.platformType); const platformNeedsMotorStop = [PLATFORM.AIRPLANE, PLATFORM.ROVER, PLATFORM.BOAT].includes(MIXER_CONFIG.platformType);
const motorStopEnabled = $motorStopCheckbox.is(':checked'); const motorStopEnabled = $motorStopCheckbox.is(':checked');
if (platformNeedsMotorStop && motorStopEnabled || !platformNeedsMotorStop && !motorStopEnabled) { if (platformNeedsMotorStop && motorStopEnabled || !platformNeedsMotorStop && !motorStopEnabled) {
$motorStopWarningBox.hide(); $motorStopWarningBox.hide();
@ -186,7 +186,7 @@ TABS.outputs.initialize = function (callback) {
$motorStopWarningBox.show(); $motorStopWarningBox.show();
} }
} }
$motorStopCheckbox.change(showHideMotorStopWarning); $motorStopCheckbox.on('change', showHideMotorStopWarning);
showHideMotorStopWarning(); showHideMotorStopWarning();
$('#3ddeadbandlow').val(REVERSIBLE_MOTORS.deadband_low); $('#3ddeadbandlow').val(REVERSIBLE_MOTORS.deadband_low);
@ -237,7 +237,7 @@ TABS.outputs.initialize = function (callback) {
if (MIXER_CONFIG.appliedMixerPreset == -1) return; if (MIXER_CONFIG.appliedMixerPreset == -1) return;
const isMotorInverted = self.motorDirectionInverted; const isMotorInverted = self.motorDirectionInverted;
const isReversed = isMotorInverted && (MIXER_CONFIG.platformType == PLATFORM_MULTIROTOR || MIXER_CONFIG.platformType == PLATFORM_TRICOPTER); const isReversed = isMotorInverted && (MIXER_CONFIG.platformType == PLATFORM.MULTIROTOR || MIXER_CONFIG.platformType == PLATFORM.TRICOPTER);
const path = './resources/motor_order/' const path = './resources/motor_order/'
+ helper.mixer.getById(val).image + (isReversed ? "_reverse" : "") + '.svg'; + helper.mixer.getById(val).image + (isReversed ? "_reverse" : "") + '.svg';
@ -293,7 +293,7 @@ TABS.outputs.initialize = function (callback) {
let output, let output,
outputString; outputString;
if (MIXER_CONFIG.platformType == PLATFORM_MULTIROTOR || MIXER_CONFIG.platformType == PLATFORM_TRICOPTER) { if (MIXER_CONFIG.platformType == PLATFORM.MULTIROTOR || MIXER_CONFIG.platformType == PLATFORM.TRICOPTER) {
output = OUTPUT_MAPPING.getMrServoOutput(usedServoIndex); output = OUTPUT_MAPPING.getMrServoOutput(usedServoIndex);
} else { } else {
output = OUTPUT_MAPPING.getFwServoOutput(usedServoIndex); output = OUTPUT_MAPPING.getFwServoOutput(usedServoIndex);
@ -362,26 +362,26 @@ TABS.outputs.initialize = function (callback) {
} }
// UI hooks for dynamically generated elements // UI hooks for dynamically generated elements
$('table.directions select, table.directions input, #servo-config-table select, #servo-config-table input').change(function () { $('table.directions select, table.directions input, #servo-config-table select, #servo-config-table input').on('change', function () {
if ($('div.live input').is(':checked')) { if ($('div.live input').is(':checked')) {
// apply small delay as there seems to be some funky update business going wrong // apply small delay as there seems to be some funky update business going wrong
helper.timeout.add('servos_update', servos_update, 10); helper.timeout.add('servos_update', servos_update, 10);
} }
}); });
$('a.update').click(function () { $('a.update').on('click', function () {
helper.features.reset(); helper.features.reset();
helper.features.fromUI($('.tab-motors')); helper.features.fromUI($('.tab-motors'));
helper.features.execute(servos_update); helper.features.execute(servos_update);
}); });
$('a.save').click(function () { $('a.save').on('click', function () {
saveChainer.setExitPoint(function () { saveChainer.setExitPoint(function () {
//noinspection JSUnresolvedVariable //noinspection JSUnresolvedVariable
GUI.log(localization.getMessage('configurationEepromSaved')); GUI.log(i18n.getMessage('configurationEepromSaved'));
GUI.tab_switch_cleanup(function () { GUI.tab_switch_cleanup(function () {
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, function () { MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, function () {
GUI.log(localization.getMessage('deviceRebooting')); GUI.log(i18n.getMessage('deviceRebooting'));
GUI.handleReconnect($('.tab_outputs a')); GUI.handleReconnect($('.tab_outputs a'));
}); });
}); });
@ -583,7 +583,7 @@ TABS.outputs.initialize = function (callback) {
$('div.sliders input:not(:last):first').trigger('input'); $('div.sliders input:not(:last):first').trigger('input');
}); });
$motorsEnableTestMode.change(function () { $motorsEnableTestMode.on('change', function () {
if ($(this).is(':checked')) { if ($(this).is(':checked')) {
$slidersInput.slice(0, MOTOR_RULES.getNumberOfConfiguredMotors()).prop('disabled', false); $slidersInput.slice(0, MOTOR_RULES.getNumberOfConfiguredMotors()).prop('disabled', false);
@ -650,7 +650,7 @@ TABS.outputs.initialize = function (callback) {
} }
} }
$motorsEnableTestMode.change(); $motorsEnableTestMode.trigger('change');
function getPeriodicMotorOutput() { function getPeriodicMotorOutput() {
@ -717,7 +717,7 @@ TABS.outputs.initialize = function (callback) {
if (previousArmState != self.armed) { if (previousArmState != self.armed) {
console.log('arm state change detected'); console.log('arm state change detected');
$motorsEnableTestMode.change(); $motorsEnableTestMode.trigger('change');
} }
} }
@ -726,7 +726,7 @@ TABS.outputs.initialize = function (callback) {
} }
function finalize() { function finalize() {
localization.localize();; i18n.localize();;
GUI.content_ready(callback); GUI.content_ready(callback);
} }

View file

@ -134,7 +134,7 @@ TABS.pid_tuning.initialize = function (callback) {
$("#note-wrapper").remove(); $("#note-wrapper").remove();
} }
localization.localize();; i18n.localize();;
helper.tabs.init($('.tab-pid_tuning')); helper.tabs.init($('.tab-pid_tuning'));
helper.features.updateUI($('.tab-pid_tuning'), FEATURES); helper.features.updateUI($('.tab-pid_tuning'), FEATURES);
@ -155,7 +155,7 @@ TABS.pid_tuning.initialize = function (callback) {
$('#resetPIDs').on('click', function() { $('#resetPIDs').on('click', function() {
if (confirm(localization.getMessage('confirm_reset_pid'))) { if (confirm(i18n.getMessage('confirm_reset_pid'))) {
MSP.send_message(MSPCodes.MSP_SET_RESET_CURR_PID, false, false, false); MSP.send_message(MSPCodes.MSP_SET_RESET_CURR_PID, false, false, false);
updateActivatedTab(); updateActivatedTab();
} }
@ -163,14 +163,14 @@ TABS.pid_tuning.initialize = function (callback) {
$('#resetDefaults').on('click', function() { $('#resetDefaults').on('click', function() {
if (confirm(localization.getMessage('confirm_select_defaults'))) { if (confirm(i18n.getMessage('confirm_select_defaults'))) {
mspHelper.setSetting("applied_defaults", 0, function() { mspHelper.setSetting("applied_defaults", 0, function() {
mspHelper.saveToEeprom( function () { mspHelper.saveToEeprom( function () {
GUI.log(localization.getMessage('configurationEepromSaved')); GUI.log(i18n.getMessage('configurationEepromSaved'));
GUI.tab_switch_cleanup(function () { GUI.tab_switch_cleanup(function () {
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, function () { MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, function () {
GUI.log(localization.getMessage('deviceRebooting')); GUI.log(i18n.getMessage('deviceRebooting'));
GUI.handleReconnect(); GUI.handleReconnect();
}); });
}); });
@ -191,7 +191,7 @@ TABS.pid_tuning.initialize = function (callback) {
$theOtherPids.addClass("is-hidden"); $theOtherPids.addClass("is-hidden");
$showAdvancedPids.prop('checked', false); $showAdvancedPids.prop('checked', false);
} }
$showAdvancedPids.change(); $showAdvancedPids.trigger('change');
$showAdvancedPids.on('change', function() { $showAdvancedPids.on('change', function() {
@ -270,18 +270,18 @@ TABS.pid_tuning.initialize = function (callback) {
// UI Hooks // UI Hooks
$('a.refresh').click(function () { $('a.refresh').on('click', function () {
$("#content-watermark").remove(); $("#content-watermark").remove();
$(".tab-pid_tuning").remove(); $(".tab-pid_tuning").remove();
GUI.tab_switch_cleanup(function () { GUI.tab_switch_cleanup(function () {
GUI.log(localization.getMessage('pidTuningDataRefreshed')); GUI.log(i18n.getMessage('pidTuningDataRefreshed'));
TABS.pid_tuning.initialize(); TABS.pid_tuning.initialize();
}); });
}); });
// update == save. // update == save.
$('a.update').click(function () { $('a.update').on('click', function () {
form_to_pid_and_rc(); form_to_pid_and_rc();
function send_rc_tuning_changes() { function send_rc_tuning_changes() {
@ -310,7 +310,7 @@ TABS.pid_tuning.initialize = function (callback) {
function save_to_eeprom() { function save_to_eeprom() {
MSP.send_message(MSPCodes.MSP_EEPROM_WRITE, false, false, function () { MSP.send_message(MSPCodes.MSP_EEPROM_WRITE, false, false, function () {
GUI.log(localization.getMessage('pidTuningEepromSaved')); GUI.log(i18n.getMessage('pidTuningEepromSaved'));
}); });
} }

View file

@ -122,7 +122,7 @@ TABS.ports.initialize = function (callback) {
); );
for (var i = 0; i < portFunctionRules.length; i++) { for (var i = 0; i < portFunctionRules.length; i++) {
portFunctionRules[i].displayName = localization.getMessage('portsFunction_' + portFunctionRules[i].name); portFunctionRules[i].displayName = i18n.getMessage('portsFunction_' + portFunctionRules[i].name);
} }
var mspBaudRates = [ var mspBaudRates = [
@ -279,7 +279,7 @@ TABS.ports.initialize = function (callback) {
if (select_e.length == 0) { if (select_e.length == 0) {
functions_e.prepend('<span class="function"><select name="' + selectElementName + '" class="' + selectElementName + '" onchange="updateDefaultBaud(\'' + functions_e_id + '\', \'' + column + '\')" /></span>'); functions_e.prepend('<span class="function"><select name="' + selectElementName + '" class="' + selectElementName + '" onchange="updateDefaultBaud(\'' + functions_e_id + '\', \'' + column + '\')" /></span>');
select_e = functions_e.find(selectElementSelector); select_e = functions_e.find(selectElementSelector);
var disabledText = localization.getMessage('portsTelemetryDisabled'); var disabledText = i18n.getMessage('portsTelemetryDisabled');
select_e.append('<option value="">' + disabledText + '</option>'); select_e.append('<option value="">' + disabledText + '</option>');
} }
select_e.append('<option value="' + functionName + '">' + functionRule.displayName + '</option>'); select_e.append('<option value="' + functionName + '">' + functionRule.displayName + '</option>');
@ -297,11 +297,11 @@ TABS.ports.initialize = function (callback) {
function on_tab_loaded_handler() { function on_tab_loaded_handler() {
localization.localize();; i18n.localize();;
update_ui(); update_ui();
$('a.save').click(on_save_handler); $('a.save').on('click', on_save_handler);
GUI.content_ready(callback); GUI.content_ready(callback);
} }
@ -354,7 +354,7 @@ TABS.ports.initialize = function (callback) {
} }
function on_saved_handler() { function on_saved_handler() {
GUI.log(localization.getMessage('configurationEepromSaved')); GUI.log(i18n.getMessage('configurationEepromSaved'));
GUI.tab_switch_cleanup(function() { GUI.tab_switch_cleanup(function() {
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, on_reboot_success_handler); MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, on_reboot_success_handler);
@ -362,7 +362,7 @@ TABS.ports.initialize = function (callback) {
} }
function on_reboot_success_handler() { function on_reboot_success_handler() {
GUI.log(localization.getMessage('deviceRebooting')); GUI.log(i18n.getMessage('deviceRebooting'));
GUI.handleReconnect($('.tab_ports a')); GUI.handleReconnect($('.tab_ports a'));
} }
} }

View file

@ -49,11 +49,11 @@ TABS.programming.initialize = function (callback, scrollPosition) {
helper.tabs.init($('.tab-programming')); helper.tabs.init($('.tab-programming'));
localization.localize();; i18n.localize();;
$('#save-button').click(function () { $('#save-button').on('click', function () {
saveChainer.execute(); saveChainer.execute();
GUI.log(localization.getMessage('programmingEepromSaved')); GUI.log(i18n.getMessage('programmingEepromSaved'));
}); });
helper.mspBalancedInterval.add('logic_conditions_pull', 100, 1, function () { helper.mspBalancedInterval.add('logic_conditions_pull', 100, 1, function () {

View file

@ -73,7 +73,7 @@ TABS.receiver.initialize = function (callback) {
function process_html() { function process_html() {
// translate to user-selected language // translate to user-selected language
localization.localize();; i18n.localize();;
let $receiverMode = $('#receiver_type'), let $receiverMode = $('#receiver_type'),
$serialWrapper = $('#serialrx_provider-wrapper'); $serialWrapper = $('#serialrx_provider-wrapper');
@ -93,7 +93,7 @@ TABS.receiver.initialize = function (callback) {
$("#serialrx_provider").empty().append(serialRxProviders); $("#serialrx_provider").empty().append(serialRxProviders);
$('#serialrx_provider').val(selectedRxProvider); $('#serialrx_provider').val(selectedRxProvider);
$receiverMode.change(function () { $receiverMode.on('change', function () {
if ($(this).find("option:selected").text() == "SERIAL") { if ($(this).find("option:selected").text() == "SERIAL") {
$serialWrapper.show(); $serialWrapper.show();
$receiverMode.parent().removeClass("no-bottom-border"); $receiverMode.parent().removeClass("no-bottom-border");
@ -120,10 +120,10 @@ TABS.receiver.initialize = function (callback) {
// generate bars // generate bars
var bar_names = [ var bar_names = [
localization.getMessage('controlAxisRoll'), i18n.getMessage('controlAxisRoll'),
localization.getMessage('controlAxisPitch'), i18n.getMessage('controlAxisPitch'),
localization.getMessage('controlAxisYaw'), i18n.getMessage('controlAxisYaw'),
localization.getMessage('controlAxisThrottle') i18n.getMessage('controlAxisThrottle')
], ],
bar_container = $('.tab-receiver .bars'); bar_container = $('.tab-receiver .bars');
@ -132,7 +132,7 @@ TABS.receiver.initialize = function (callback) {
if (i < bar_names.length) { if (i < bar_names.length) {
name = bar_names[i]; name = bar_names[i];
} else { } else {
name = localization.getMessage("radioChannelShort") + (i + 1); name = i18n.getMessage("radioChannelShort") + (i + 1);
} }
bar_container.append('\ bar_container.append('\
@ -216,7 +216,7 @@ TABS.receiver.initialize = function (callback) {
// handle helper // handle helper
$('select[name="rcmap_helper"]').val(0); // go out of bounds $('select[name="rcmap_helper"]').val(0); // go out of bounds
$('select[name="rcmap_helper"]').change(function () { $('select[name="rcmap_helper"]').on('change', function () {
$rcMap.val($(this).val()); $rcMap.val($(this).val());
}); });
@ -279,7 +279,7 @@ TABS.receiver.initialize = function (callback) {
}, 0); }, 0);
}).trigger('input'); }).trigger('input');
$('a.update').click(function () { $('a.update').on('click', function () {
// catch RC_tuning changes // catch RC_tuning changes
RC_tuning.throttle_MID = parseFloat($('.tunings .throttle input[name="mid"]').val()); RC_tuning.throttle_MID = parseFloat($('.tunings .throttle input[name="mid"]').val());
RC_tuning.throttle_EXPO = parseFloat($('.tunings .throttle input[name="expo"]').val()); RC_tuning.throttle_EXPO = parseFloat($('.tunings .throttle input[name="expo"]').val());
@ -323,11 +323,11 @@ TABS.receiver.initialize = function (callback) {
function save_to_eeprom() { function save_to_eeprom() {
MSP.send_message(MSPCodes.MSP_EEPROM_WRITE, false, false, function () { MSP.send_message(MSPCodes.MSP_EEPROM_WRITE, false, false, function () {
GUI.log(localization.getMessage('receiverEepromSaved')); GUI.log(i18n.getMessage('receiverEepromSaved'));
GUI.tab_switch_cleanup(function () { GUI.tab_switch_cleanup(function () {
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, function () { MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, function () {
GUI.log(localization.getMessage('deviceRebooting')); GUI.log(i18n.getMessage('deviceRebooting'));
GUI.handleReconnect($('.tab_receiver a')); GUI.handleReconnect($('.tab_receiver a'));
}); });
}); });
@ -337,7 +337,7 @@ TABS.receiver.initialize = function (callback) {
MSP.send_message(MSPCodes.MSPV2_INAV_SET_RATE_PROFILE, mspHelper.crunch(MSPCodes.MSPV2_INAV_SET_RATE_PROFILE), false, save_rc_map); MSP.send_message(MSPCodes.MSPV2_INAV_SET_RATE_PROFILE, mspHelper.crunch(MSPCodes.MSPV2_INAV_SET_RATE_PROFILE), false, save_rc_map);
}); });
$("a.sticks").click(function () { $("a.sticks").on('click', function () {
var mspWin = window.open("tabs/receiver_msp.html", "receiver_msp", "width=420,height=720,menubar=no,contextIsolation=no,nodeIntegration=yes"); var mspWin = window.open("tabs/receiver_msp.html", "receiver_msp", "width=420,height=720,menubar=no,contextIsolation=no,nodeIntegration=yes");
mspWin.window.setRawRx = function (channels) { mspWin.window.setRawRx = function (channels) {

View file

@ -1,7 +1,7 @@
<html> <html>
<head> <head>
<script type="text/javascript" src="../js/localization.js"></script> <script type="text/javascript" src="../js/i18n.js"></script>
<script type="text/javascript" src="../tabs/receiver_msp.js"></script> <script type="text/javascript" src="../tabs/receiver_msp.js"></script>
<script type="text/javascript" src="../js/libraries/jquery.nouislider.all.min.js"></script> <script type="text/javascript" src="../js/libraries/jquery.nouislider.all.min.js"></script>
<link type="text/css" rel="stylesheet" href="../src/css/receiver-msp.css" media="all" /> <link type="text/css" rel="stylesheet" href="../src/css/receiver-msp.css" media="all" />

View file

@ -1,8 +1,7 @@
"use strict"; "use strict";
window.$ = window.jQuery = require('jquery'); window.$ = window.jQuery = require('jquery');
//const { i18n } = require('.js/i18n.js');
var localization = new Localiziation("en");
var var
CHANNEL_MIN_VALUE = 1000, CHANNEL_MIN_VALUE = 1000,
@ -122,17 +121,17 @@ function localizeAxisNames() {
var var
gimbal = gimbalElems.get(gimbalIndex); gimbal = gimbalElems.get(gimbalIndex);
$(".gimbal-label-vert", gimbal).text(localization.getMessage("controlAxis" + gimbals[gimbalIndex][0])); // $(".gimbal-label-vert", gimbal).text(i18n.getMessage("controlAxis" + gimbals[gimbalIndex][0]));
$(".gimbal-label-horz", gimbal).text(localization.getMessage("controlAxis" + gimbals[gimbalIndex][1])); // $(".gimbal-label-horz", gimbal).text(i18n.getMessage("controlAxis" + gimbals[gimbalIndex][1]));
} }
for (var sliderIndex = 0; sliderIndex < 8; sliderIndex++) { for (var sliderIndex = 0; sliderIndex < 8; sliderIndex++) {
$(".slider-label", sliderElems.get(sliderIndex)).text(localization.getMessage("radioChannelShort") + (sliderIndex + 5)); // $(".slider-label", sliderElems.get(sliderIndex)).text(i18n.getMessage("radioChannelShort") + (sliderIndex + 5));
} }
} }
$(document).ready(function() { $(document).ready(function() {
$("a.button-enable").click(function() { $("a.button-enable").on('click', function () {
var shrinkHeight = $(".warning").height(); var shrinkHeight = $(".warning").height();

View file

@ -199,7 +199,7 @@ TABS.sensors.initialize = function (callback) {
GUI.load(path.join(__dirname, "tabs/sensors.html"), function load_html() { GUI.load(path.join(__dirname, "tabs/sensors.html"), function load_html() {
// translate to user-selected language // translate to user-selected language
localization.localize();; i18n.localize();;
// disable graphs for sensors that are missing // disable graphs for sensors that are missing
var checkboxes = $('.tab-sensors .info .checkboxes input'); var checkboxes = $('.tab-sensors .info .checkboxes input');
@ -218,7 +218,7 @@ TABS.sensors.initialize = function (callback) {
checkboxes.eq(6).prop('disabled', true); checkboxes.eq(6).prop('disabled', true);
} }
$('.tab-sensors .info .checkboxes input').change(function () { $('.tab-sensors .info .checkboxes input').on('change', function () {
var enable = $(this).prop('checked'); var enable = $(this).prop('checked');
var index = $(this).parent().index(); var index = $(this).parent().index();
@ -254,7 +254,7 @@ TABS.sensors.initialize = function (callback) {
checkboxes.push($(this).prop('checked')); checkboxes.push($(this).prop('checked'));
}); });
$('.tab-sensors .rate select:first').change(); $('.tab-sensors .rate select:first').trigger('change');
store.set('graphs_enabled', checkboxes); store.set('graphs_enabled', checkboxes);
}); });
@ -263,10 +263,10 @@ TABS.sensors.initialize = function (callback) {
if (result.graphs_enabled) { if (result.graphs_enabled) {
var checkboxes = $('.tab-sensors .info .checkboxes input'); var checkboxes = $('.tab-sensors .info .checkboxes input');
for (var i = 0; i < result.graphs_enabled.length; i++) { for (var i = 0; i < result.graphs_enabled.length; i++) {
checkboxes.eq(i).not(':disabled').prop('checked', result.graphs_enabled[i]).change(); checkboxes.eq(i).not(':disabled').prop('checked', result.graphs_enabled[i]).trigger('change');
} }
} else { } else {
$('.tab-sensors .info input:lt(4):not(:disabled)').prop('checked', true).change(); $('.tab-sensors .info input:lt(4):not(:disabled)').prop('checked', true).trigger('change');
} }
}); });
@ -372,14 +372,14 @@ TABS.sensors.initialize = function (callback) {
$('.tab-sensors select[name="debug_refresh_rate"]').val(sensor_settings.rates.debug); $('.tab-sensors select[name="debug_refresh_rate"]').val(sensor_settings.rates.debug);
// start polling data by triggering refresh rate change event // start polling data by triggering refresh rate change event
$('.tab-sensors .rate select:first').change(); $('.tab-sensors .rate select:first').trigger('change');
} else { } else {
// start polling immediatly (as there is no configuration saved in the storage) // start polling immediatly (as there is no configuration saved in the storage)
$('.tab-sensors .rate select:first').change(); $('.tab-sensors .rate select:first').trigger('change');
} }
$('.tab-sensors .rate select, .tab-sensors .scale select').change(function () { $('.tab-sensors .rate select, .tab-sensors .scale select').on('change', function () {
// if any of the select fields change value, all of the select values are grabbed // if any of the select fields change value, all of the select values are grabbed
// and timers are re-initialized with the new settings // and timers are re-initialized with the new settings
var rates = { var rates = {
@ -591,7 +591,7 @@ TABS.sensors.initialize = function (callback) {
} }
}); });
$("a.debug-trace").click(function () { $("a.debug-trace").on('click', function () {
var windowWidth = 500; var windowWidth = 500;
var windowHeight = 510; var windowHeight = 510;

View file

@ -1,6 +1,22 @@
/*global $,chrome,FC,helper,mspHelper,MIXER_CONFIG*/
'use strict'; 'use strict';
const path = require('path');
const MSPChainerClass = require('./../js/msp/MSPchainer');
const FC = require('./../js/fc');
const { GUI, TABS } = require('./../js/gui');
const MSP = require('./../js/msp');
const MSPCodes = require('./../js/msp/MSPCodes');
const i18n = require('./../js/localization');
const mspHelper = require('./../js/msp/MSPHelper');
const mspBalancedInterval = require('./../js/msp_balanced_interval');
const interval = require('./../js/intervals');
const mspQueue = require('./../js/serial_queue');
const SerialBackend = require('./../js/serial_backend');
const { mixer } = require('./../js/model');
const BitHelper = require('./../js/bitHelper')
TABS.setup = { TABS.setup = {
yaw_fix: 0.0 yaw_fix: 0.0
}; };
@ -8,12 +24,6 @@ TABS.setup = {
TABS.setup.initialize = function (callback) { TABS.setup.initialize = function (callback) {
var self = this; var self = this;
// Update the osd units in global settings
// but only if we need it
if (globalSettings.unitType === UnitType.OSD) {
get_osd_settings();
}
if (GUI.active_tab != 'setup') { if (GUI.active_tab != 'setup') {
GUI.active_tab = 'setup'; GUI.active_tab = 'setup';
} }
@ -32,44 +42,44 @@ TABS.setup.initialize = function (callback) {
loadChainer.execute(); loadChainer.execute();
function load_html() { function load_html() {
GUI.load(path.join(__dirname, "tabs/setup.html"), process_html); GUI.load(path.join(__dirname, "setup.html"), process_html);
} }
function process_html() { function process_html() {
// translate to user-selected language // translate to user-selected language
localization.localize();; i18n.localize();;
if (!FC.isMotorOutputEnabled()) { if (!FC.isMotorOutputEnabled()) {
GUI_control.prototype.log("<span style='color: red; font-weight: bolder'><strong>" + localization.getMessage("logPwmOutputDisabled") + "</strong></span>"); GUI.log("<span style='color: red; font-weight: bolder'><strong>" + i18n.getMessage("logPwmOutputDisabled") + "</strong></span>");
} }
// initialize 3D // initialize 3D
self.initialize3D(); self.initialize3D();
// set roll in interactive block // set roll in interactive block
$('span.roll').text(localization.getMessage('initialSetupAttitude', [0])); $('span.roll').text(i18n.getMessage('initialSetupAttitude', [0]));
// set pitch in interactive block // set pitch in interactive block
$('span.pitch').text(localization.getMessage('initialSetupAttitude', [0])); $('span.pitch').text(i18n.getMessage('initialSetupAttitude', [0]));
// set heading in interactive block // set heading in interactive block
$('span.heading').text(localization.getMessage('initialSetupAttitude', [0])); $('span.heading').text(i18n.getMessage('initialSetupAttitude', [0]));
// check if we have magnetometer // check if we have magnetometer
if (!bit_check(CONFIG.activeSensors, 2)) { if (!BitHelper.bit_check(FC.CONFIG.activeSensors, 2)) {
$('a.calibrateMag').addClass('disabled'); $('a.calibrateMag').addClass('disabled');
$('default_btn').addClass('disabled'); $('default_btn').addClass('disabled');
} }
self.initializeInstruments(); self.initializeInstruments();
$('a.resetSettings').click(function () { $('a.resetSettings').on('click', function () {
if (confirm(localization.getMessage('confirm_reset_settings'))) { if (confirm(i18n.getMessage('confirm_reset_settings'))) {
MSP.send_message(MSPCodes.MSP_RESET_CONF, false, false, function () { MSP.send_message(MSPCodes.MSP_RESET_CONF, false, false, function () {
GUI.log(localization.getMessage('initialSetupSettingsRestored')); GUI.log(i18n.getMessage('initialSetupSettingsRestored'));
GUI.tab_switch_cleanup(function () { GUI.tab_switch_cleanup(function () {
MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, function() { MSP.send_message(MSPCodes.MSP_SET_REBOOT, false, false, function() {
GUI.log(localization.getMessage('deviceRebooting')); GUI.log(i18n.getMessage('deviceRebooting'));
GUI.handleReconnect(); GUI.handleReconnect();
}); });
}); });
@ -78,12 +88,12 @@ TABS.setup.initialize = function (callback) {
}); });
// display current yaw fix value (important during tab re-initialization) // display current yaw fix value (important during tab re-initialization)
$('div#interactive_block > a.reset').text(localization.getMessage('initialSetupButtonResetZaxisValue', [self.yaw_fix])); $('div#interactive_block > a.reset').text(i18n.getMessage('initialSetupButtonResetZaxisValue', [self.yaw_fix]));
// reset yaw button hook // reset yaw button hook
$('div#interactive_block > a.reset').click(function () { $('div#interactive_block > a.reset').on('click', function () {
self.yaw_fix = SENSOR_DATA.kinematics[2] * - 1.0; self.yaw_fix = FC.SENSOR_DATA.kinematics[2] * - 1.0;
$(this).text(localization.getMessage('initialSetupButtonResetZaxisValue', [self.yaw_fix])); $(this).text(i18n.getMessage('initialSetupButtonResetZaxisValue', [self.yaw_fix]));
console.log('YAW reset to 0 deg, fix: ' + self.yaw_fix + ' deg'); console.log('YAW reset to 0 deg, fix: ' + self.yaw_fix + ' deg');
}); });
@ -109,25 +119,25 @@ TABS.setup.initialize = function (callback) {
heading_e = $('dd.heading'); heading_e = $('dd.heading');
function get_slow_data() { function get_slow_data() {
if (have_sensor(CONFIG.activeSensors, 'gps')) { if (SerialBackend.have_sensor(FC.CONFIG.activeSensors, 'gps')) {
/* /*
* Enable balancer * Enable balancer
*/ */
if (helper.mspQueue.shouldDrop()) { if (mspQueue.shouldDrop()) {
return; return;
} }
MSP.send_message(MSPCodes.MSP_RAW_GPS, false, false, function () { MSP.send_message(MSPCodes.MSP_RAW_GPS, false, false, function () {
var gpsFixType = localization.getMessage('gpsFixNone'); var gpsFixType = i18n.getMessage('gpsFixNone');
if (GPS_DATA.fix >= 2) if (FC.GPS_DATA.fix >= 2)
gpsFixType = localization.getMessage('gpsFix3D'); gpsFixType = i18n.getMessage('gpsFix3D');
else if (GPS_DATA.fix >= 1) else if (FC.GPS_DATA.fix >= 1)
gpsFixType = localization.getMessage('gpsFix2D'); gpsFixType = i18n.getMessage('gpsFix2D');
gpsFix_e.html(gpsFixType); gpsFix_e.html(gpsFixType);
gpsSats_e.text(GPS_DATA.numSat); gpsSats_e.text(FC.GPS_DATA.numSat);
gpsLat_e.text((GPS_DATA.lat / 10000000).toFixed(4) + ' deg'); gpsLat_e.text((FC.GPS_DATA.lat / 10000000).toFixed(4) + ' deg');
gpsLon_e.text((GPS_DATA.lon / 10000000).toFixed(4) + ' deg'); gpsLon_e.text((FC.GPS_DATA.lon / 10000000).toFixed(4) + ' deg');
}); });
} }
} }
@ -137,49 +147,49 @@ TABS.setup.initialize = function (callback) {
/* /*
* Enable balancer * Enable balancer
*/ */
if (helper.mspQueue.shouldDrop()) { if (mspQueue.shouldDrop()) {
return; return;
} }
MSP.send_message(MSPCodes.MSP_ATTITUDE, false, false, function () { MSP.send_message(MSPCodes.MSP_ATTITUDE, false, false, function () {
roll_e.text(localization.getMessage('initialSetupAttitude', [SENSOR_DATA.kinematics[0]])); roll_e.text(i18n.getMessage('initialSetupAttitude', [FC.SENSOR_DATA.kinematics[0]]));
pitch_e.text(localization.getMessage('initialSetupAttitude', [SENSOR_DATA.kinematics[1]])); pitch_e.text(i18n.getMessage('initialSetupAttitude', [FC.SENSOR_DATA.kinematics[1]]));
heading_e.text(localization.getMessage('initialSetupAttitude', [SENSOR_DATA.kinematics[2]])); heading_e.text(i18n.getMessage('initialSetupAttitude', [FC.SENSOR_DATA.kinematics[2]]));
self.render3D(); self.render3D();
self.updateInstruments(); self.updateInstruments();
}); });
} }
helper.mspBalancedInterval.add('setup_data_pull_fast', 40, 1, get_fast_data); mspBalancedInterval.add('setup_data_pull_fast', 40, 1, get_fast_data);
helper.mspBalancedInterval.add('setup_data_pull_slow', 250, 1, get_slow_data); mspBalancedInterval.add('setup_data_pull_slow', 250, 1, get_slow_data);
helper.interval.add('gui_analog_update', function () { interval.add('gui_analog_update', function () {
bat_cells_e.text(localization.getMessage('initialSetupBatteryDetectedCellsValue', [ANALOG.cell_count])); bat_cells_e.text(i18n.getMessage('initialSetupBatteryDetectedCellsValue', [FC.ANALOG.cell_count]));
bat_voltage_e.text(localization.getMessage('initialSetupBatteryVoltageValue', [ANALOG.voltage])); bat_voltage_e.text(i18n.getMessage('initialSetupBatteryVoltageValue', [FC.ANALOG.voltage]));
let remaining_capacity_wh_decimals = ANALOG.battery_remaining_capacity.toString().length < 5 ? 3 : (7 - ANALOG.battery_remaining_capacity.toString().length); let remaining_capacity_wh_decimals = FC.ANALOG.battery_remaining_capacity.toString().length < 5 ? 3 : (7 - FC.ANALOG.battery_remaining_capacity.toString().length);
let remaining_capacity_value = MISC.battery_capacity_unit == 'mAh' ? ANALOG.battery_remaining_capacity : (ANALOG.battery_remaining_capacity / 1000).toFixed(remaining_capacity_wh_decimals < 0 ? 0 : remaining_capacity_wh_decimals); let remaining_capacity_value = FC.MISC.battery_capacity_unit == 'mAh' ? FC.ANALOG.battery_remaining_capacity : (FC.ANALOG.battery_remaining_capacity / 1000).toFixed(remaining_capacity_wh_decimals < 0 ? 0 : remaining_capacity_wh_decimals);
let remaining_capacity_unit = MISC.battery_capacity_unit == 'mAh' ? 'mAh' : 'Wh'; let remaining_capacity_unit = FC.MISC.battery_capacity_unit == 'mAh' ? 'mAh' : 'Wh';
bat_remaining_e.text(localization.getMessage('initialSetupBatteryRemainingCapacityValue', ((MISC.battery_capacity > 0) && ANALOG.battery_full_when_plugged_in) ? [remaining_capacity_value, remaining_capacity_unit] : ['NA', ''])); bat_remaining_e.text(i18n.getMessage('initialSetupBatteryRemainingCapacityValue', ((FC.MISC.battery_capacity > 0) && FC.ANALOG.battery_full_when_plugged_in) ? [remaining_capacity_value, remaining_capacity_unit] : ['NA', '']));
bat_percent_e.text(localization.getMessage('initialSetupBatteryPercentageValue', [ANALOG.battery_percentage])); bat_percent_e.text(i18n.getMessage('initialSetupBatteryPercentageValue', [FC.ANALOG.battery_percentage]));
bat_full_e.text(localization.getMessage('initialSetupBatteryFullValue', [ANALOG.battery_full_when_plugged_in])); bat_full_e.text(i18n.getMessage('initialSetupBatteryFullValue', [FC.ANALOG.battery_full_when_plugged_in]));
bat_thresh_e.text(localization.getMessage('initialSetupBatteryThresholdsValue', [ANALOG.use_capacity_thresholds])); bat_thresh_e.text(i18n.getMessage('initialSetupBatteryThresholdsValue', [FC.ANALOG.use_capacity_thresholds]));
bat_mah_drawn_e.text(localization.getMessage('initialSetupBatteryMahValue', [ANALOG.mAhdrawn])); bat_mah_drawn_e.text(i18n.getMessage('initialSetupBatteryMahValue', [FC.ANALOG.mAhdrawn]));
let capacity_drawn_decimals = ANALOG.mWhdrawn.toString().length < 5 ? 3 : (7 - ANALOG.mWhdrawn.toString().length); let capacity_drawn_decimals = FC.ANALOG.mWhdrawn.toString().length < 5 ? 3 : (7 - FC.ANALOG.mWhdrawn.toString().length);
bat_wh_drawn_e.text(localization.getMessage('initialSetup_Wh_drawnValue', [(ANALOG.mWhdrawn / 1000).toFixed(capacity_drawn_decimals < 0 ? 0 : capacity_drawn_decimals)])); bat_wh_drawn_e.text(i18n.getMessage('initialSetup_Wh_drawnValue', [(FC.ANALOG.mWhdrawn / 1000).toFixed(capacity_drawn_decimals < 0 ? 0 : capacity_drawn_decimals)]));
bat_current_draw_e.text(localization.getMessage('initialSetupCurrentDrawValue', [ANALOG.amperage.toFixed(2)])); bat_current_draw_e.text(i18n.getMessage('initialSetupCurrentDrawValue', [FC.ANALOG.amperage.toFixed(2)]));
bat_power_draw_e.text(localization.getMessage('initialSetupPowerDrawValue', [ANALOG.power.toFixed(2)])); bat_power_draw_e.text(i18n.getMessage('initialSetupPowerDrawValue', [FC.ANALOG.power.toFixed(2)]));
rssi_e.text(localization.getMessage('initialSetupRSSIValue', [((ANALOG.rssi / 1023) * 100).toFixed(0)])); rssi_e.text(i18n.getMessage('initialSetupRSSIValue', [((FC.ANALOG.rssi / 1023) * 100).toFixed(0)]));
}, 100, true); }, 100, true);
function updateArminFailure() { function updateArminFailure() {
var flagNames = FC.getArmingFlags(); var flagNames = FC.getArmingFlags();
for (var bit in flagNames) { for (var bit in flagNames) {
if (flagNames.hasOwnProperty(bit)) { if (flagNames.hasOwnProperty(bit)) {
if (bit_check(CONFIG.armingFlags, bit)) { if (BitHelper.bit_check(FC.CONFIG.armingFlags, bit)) {
$('#reason-' + flagNames[bit]).html(localization.getMessage('armingCheckFail')); $('#reason-' + flagNames[bit]).html(i18n.getMessage('armingCheckFail'));
} }
else { else {
$('#reason-' + flagNames[bit]).html(localization.getMessage('armingCheckPass')); $('#reason-' + flagNames[bit]).html(i18n.getMessage('armingCheckPass'));
} }
} }
} }
@ -188,21 +198,21 @@ TABS.setup.initialize = function (callback) {
/* /*
* 1fps update rate will be fully enough * 1fps update rate will be fully enough
*/ */
helper.interval.add('updateArminFailure', updateArminFailure, 500, true); interval.add('updateArminFailure', updateArminFailure, 500, true);
GUI.content_ready(callback); GUI.content_ready(callback);
} }
}; };
TABS.setup.initializeInstruments = function() { TABS.setup.initializeInstruments = function() {
var options = {size:90, showBox : false, img_directory: path.join(__dirname, '/images/flightindicators/')}; var options = {size:90, showBox : false, img_directory: path.join(__dirname, '/../images/flightindicators/')};
var attitude = $.flightIndicator('#attitude', 'attitude', options); var attitude = $.flightIndicator('#attitude', 'attitude', options);
var heading = $.flightIndicator('#heading', 'heading', options); var heading = $.flightIndicator('#heading', 'heading', options);
this.updateInstruments = function() { this.updateInstruments = function() {
attitude.setRoll(SENSOR_DATA.kinematics[0]); attitude.setRoll(FC.SENSOR_DATA.kinematics[0]);
attitude.setPitch(SENSOR_DATA.kinematics[1]); attitude.setPitch(FC.SENSOR_DATA.kinematics[1]);
heading.setHeading(SENSOR_DATA.kinematics[2]); heading.setHeading(FC.SENSOR_DATA.kinematics[2]);
}; };
}; };
@ -243,11 +253,11 @@ TABS.setup.initialize3D = function () {
// load the model including materials // load the model including materials
if (useWebGlRenderer) { if (useWebGlRenderer) {
if (MIXER_CONFIG.appliedMixerPreset === -1) { if (FC.MIXER_CONFIG.appliedMixerPreset === -1) {
model_file = 'custom'; model_file = 'custom';
GUI_control.prototype.log("<span style='color: red; font-weight: bolder'><strong>" + localization.getMessage("mixerNotConfigured") + "</strong></span>"); GUI_control.prototype.log("<span style='color: red; font-weight: bolder'><strong>" + i18n.getMessage("mixerNotConfigured") + "</strong></span>");
} else { } else {
model_file = helper.mixer.getById(MIXER_CONFIG.appliedMixerPreset).model; model_file = mixer.getById(FC.MIXER_CONFIG.appliedMixerPreset).model;
} }
} else { } else {
model_file = 'fallback' model_file = 'fallback'
@ -291,9 +301,9 @@ TABS.setup.initialize3D = function () {
} }
// compute the changes // compute the changes
model.rotation.x = (SENSOR_DATA.kinematics[1] * -1.0) * 0.017453292519943295; model.rotation.x = (FC.SENSOR_DATA.kinematics[1] * -1.0) * 0.017453292519943295;
modelWrapper.rotation.y = ((SENSOR_DATA.kinematics[2] * -1.0) - self.yaw_fix) * 0.017453292519943295; modelWrapper.rotation.y = ((FC.SENSOR_DATA.kinematics[2] * -1.0) - self.yaw_fix) * 0.017453292519943295;
model.rotation.z = (SENSOR_DATA.kinematics[0] * -1.0) * 0.017453292519943295; model.rotation.z = (FC.SENSOR_DATA.kinematics[0] * -1.0) * 0.017453292519943295;
// draw // draw
renderer.render(scene, camera); renderer.render(scene, camera);

View file

@ -1,4 +1,11 @@
'use strict' 'use strict'
const path = require('path');
const { GUI, TABS } = require('./../js/gui');
const i18n = require('./../js/localization');
const { Ser2TCP, SITLProcess } = require('./../js/sitl');
const Store = require('electron-store');
const store = new Store();
const localhost = "127.0.0.1" const localhost = "127.0.0.1"
@ -68,14 +75,14 @@ TABS.sitl.initialize = (callback) => {
GUI.active_tab = 'sitl'; GUI.active_tab = 'sitl';
} }
GUI.load(path.join(__dirname, "tabs/sitl.html"), function () { GUI.load(path.join(__dirname, "sitl.html"), function () {
localization.localize(); i18n.localize();
var os = GUI.operating_system; var os = GUI.operating_system;
if (os != 'Windows' && os != 'Linux') { if (os != 'Windows' && os != 'Linux') {
$('.content_wrapper').find('*').remove(); $('.content_wrapper').find('*').remove();
$('.content_wrapper').append(`<h2>${localization.getMessage('sitlOSNotSupported')}</h2>`); $('.content_wrapper').append(`<h2>${i18n.getMessage('sitlOSNotSupported')}</h2>`);
GUI.content_ready(callback); GUI.content_ready(callback);
return; return;
@ -111,8 +118,12 @@ TABS.sitl.initialize = (callback) => {
$('.sitlStart').removeClass('disabled'); $('.sitlStart').removeClass('disabled');
} }
$('#sitlLog').val(SITL_LOG); var $sitlLog = $('#sitlLog');
$('#sitlLog').animate({scrollTop: $('#sitlLog').scrollHeight}, "fast"); $sitlLog.val(SITL_LOG);
if ($sitlLog) {
$sitlLog.val(SITL_LOG);
$sitlLog.animate({scrollTop: $sitlLog[0].scrollHeight - $sitlLog.height()}, "fast");
}
profiles = stdProfiles.slice(0); profiles = stdProfiles.slice(0);
var sitlProfiles = store.get('sitlProfiles', false); var sitlProfiles = store.get('sitlProfiles', false);
@ -229,20 +240,20 @@ TABS.sitl.initialize = (callback) => {
$('.sitlStart').removeClass('disabled'); $('.sitlStart').removeClass('disabled');
Ser2TCP.stop(); Ser2TCP.stop();
SITLProcess.stop(); SITLProcess.stop();
appendLog(localization.getMessage('sitlStopped')); appendLog(i18n.getMessage('sitlStopped'));
}); });
profileSaveBtn_e.on('click', () => { profileSaveBtn_e.on('click', function () {
saveProfiles(); saveProfiles();
}); });
profileNewBtn_e.on('click', () => { profileNewBtn_e.on('click', function () {
var name = prompt(localization.getMessage('sitlNewProfile'), localization.getMessage('sitlEnterName')); var name = prompt(i18n.getMessage('sitlNewProfile'), i18n.getMessage('sitlEnterName'));
if (!name) if (!name)
return; return;
if (profiles.find(e => { return e.name == name })) { if (profiles.find(e => { return e.name == name })) {
alert(localization.getMessage('sitlProfileExists')) alert(i18n.getMessage('sitlProfileExists'))
return; return;
} }
var eerpromName = name.replace(/[^a-z0-9]/gi, '_').toLowerCase() + ".bin"; var eerpromName = name.replace(/[^a-z0-9]/gi, '_').toLowerCase() + ".bin";
@ -270,10 +281,10 @@ TABS.sitl.initialize = (callback) => {
saveProfiles(); saveProfiles();
}); });
profileDeleteBtn_e.on('click', () => { profileDeleteBtn_e.on('click', function () {
if (currentProfile.isStdProfile) { if (currentProfile.isStdProfile) {
alert(localization.getMessage('sitlStdProfileCantDeleted')); alert(i18n.getMessage('sitlStdProfileCantDeleted'));
return; return;
} }
@ -374,7 +385,7 @@ TABS.sitl.initialize = (callback) => {
function saveProfiles() { function saveProfiles() {
if (currentProfile.isStdProfile) { if (currentProfile.isStdProfile) {
alert(localization.getMessage('sitlStdProfileCantOverwritten')); alert(i18n.getMessage('sitlStdProfileCantOverwritten'));
return; return;
} }
var profilesToSave = []; var profilesToSave = [];
@ -498,8 +509,11 @@ TABS.sitl.initialize = (callback) => {
function appendLog(message){ function appendLog(message){
SITL_LOG += message; SITL_LOG += message;
$('#sitlLog').val(SITL_LOG); var $sitlLog = $('#sitlLog');
$('#sitlLog').animate({scrollTop: $('#sitlLog')[0].scrollHeight}, "fast"); if ($sitlLog) {
$sitlLog.val(SITL_LOG);
$sitlLog.animate({scrollTop: $sitlLog[0].scrollHeight - $sitlLog.height()}, "fast");
}
} }
GUI.content_ready(callback); GUI.content_ready(callback);