diff --git a/js/boards.js b/js/boards.js index 05e1d8fd..ca8a632c 100644 --- a/js/boards.js +++ b/js/boards.js @@ -56,6 +56,22 @@ var BOARD_DEFINITIONS = [ name: "MotoLab", identifier: "MOTO", vcp: true + }, { + name: "Omnibus", + identifier: "OMNI", + vcp: true + }, { + name: "Airbot F4", + identifier: "ABF4", + vcp: true + }, { + name: "Revolution", + identifier: "REVO", + vcp: true + }, { + name: "Omnibus F4", + identifier: "OBF4", + vcp: true } ]; @@ -66,7 +82,6 @@ var DEFAULT_BOARD_DEFINITION = { }; var BOARD = { - }; BOARD.find_board_definition = function (identifier) { diff --git a/js/serial.js b/js/serial.js index 17214f18..05b4f133 100644 --- a/js/serial.js +++ b/js/serial.js @@ -1,5 +1,7 @@ 'use strict'; +/*global chrome*/ + var serial = { connectionId: false, openRequested: false, @@ -291,4 +293,5 @@ var serial = { this.outputBuffer = []; this.transmitting = false; } + }; \ No newline at end of file diff --git a/js/serial_backend.js b/js/serial_backend.js index 0b4225bc..b738caa8 100755 --- a/js/serial_backend.js +++ b/js/serial_backend.js @@ -7,6 +7,45 @@ $(document).ready(function () { $baud = $('#baud'), $portOverride = $('#port-override'); + GUI.handleReconnect = function ($tabElement) { + if (BOARD.find_board_definition(CONFIG.boardIdentifier).vcp) { // VCP-based flight controls may crash old drivers, we catch and reconnect + + /* + Disconnect + */ + setTimeout(function () { + $('a.connect').click(); + }, 100); + + /* + Connect again + */ + setTimeout(function start_connection() { + $('a.connect').click(); + + /* + Open configuration tab + */ + if ($tabElement != null) { + setTimeout(function () { + $tabElement.click(); + }, 250); + } + + }, 5000); + } else { + + GUI.timeout_add('waiting_for_bootup', function waiting_for_bootup() { + MSP.send_message(MSPCodes.MSP_IDENT, false, false, function () { + //noinspection JSUnresolvedVariable + GUI.log(chrome.i18n.getMessage('deviceReady')); + //noinspection JSValidateTypes + TABS.configuration.initialize(false, $('#content').scrollTop()); + }); + },1500); // 1500 ms seems to be just the right amount of delay to prevent data request timeouts + } + }; + GUI.updateManualPortVisibility = function(){ var selected_port = $port.find('option:selected'); if (selected_port.data().isManual) { @@ -148,9 +187,6 @@ $(document).ready(function () { PortUsage.initialize(); }); - - - function onOpen(openInfo) { if (openInfo) { // update connected_to diff --git a/tabs/cli.js b/tabs/cli.js index 7160027f..3aa5e6d2 100644 --- a/tabs/cli.js +++ b/tabs/cli.js @@ -1,5 +1,5 @@ 'use strict'; - +/*global chrome*/ TABS.cli = { 'validateText': "", 'currentLine': "", @@ -163,23 +163,7 @@ TABS.cli.read = function (readInfo) { CONFIGURATOR.cliValid = false; GUI.log(chrome.i18n.getMessage('cliReboot')); GUI.log(chrome.i18n.getMessage('deviceRebooting')); - - if (BOARD.find_board_definition(CONFIG.boardIdentifier).vcp) { // VCP-based flight controls may crash old drivers, we catch and reconnect - $('a.connect').click(); - GUI.timeout_add('start_connection',function start_connection() { - $('a.connect').click(); - },2500); - } else { - - GUI.timeout_add('waiting_for_bootup', function waiting_for_bootup() { - MSP.send_message(MSPCodes.MSP_IDENT, false, false, function () { - GUI.log(chrome.i18n.getMessage('deviceReady')); - if (!GUI.tab_switch_in_progress) { - $('#tabs ul.mode-connected .tab_setup a').click(); - } - }); - },1500); // 1500 ms seems to be just the right amount of delay to prevent data request timeouts - } + GUI.handleReconnect(); } } else { // try to catch part of valid CLI enter message diff --git a/tabs/configuration.html b/tabs/configuration.html index 7db8f9c9..ebcaaf87 100644 --- a/tabs/configuration.html +++ b/tabs/configuration.html @@ -188,29 +188,33 @@ -
+
-
-
-
-
-
diff --git a/tabs/configuration.js b/tabs/configuration.js index e4c197ec..cdc829b2 100644 --- a/tabs/configuration.js +++ b/tabs/configuration.js @@ -72,9 +72,9 @@ TABS.configuration.initialize = function (callback, scrollPosition) { //Update Analog/Battery Data function load_analog() { MSP.send_message(MSPCodes.MSP_ANALOG, false, false, function () { - $('input[name="batteryvoltage"]').val([ANALOG.voltage.toFixed(1)]); - $('input[name="batterycurrent"]').val([ANALOG.amperage.toFixed(2)]); - }); + $('#batteryvoltage').val([ANALOG.voltage.toFixed(1)]); + $('#batterycurrent').val([ANALOG.amperage.toFixed(2)]); + }); } function load_html() { @@ -114,7 +114,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) { var feature_tip_html = ''; if (features[i].haveTip) { - feature_tip_html = '
'; + feature_tip_html = '
'; } if (features[i].mode === 'group') { @@ -543,13 +543,13 @@ TABS.configuration.initialize = function (callback, scrollPosition) { $(".requires-v1_5").hide(); } - $('input[name="3ddeadbandlow"]').val(_3D.deadband3d_low); - $('input[name="3ddeadbandhigh"]').val(_3D.deadband3d_high); - $('input[name="3dneutral"]').val(_3D.neutral3d); + $('#3ddeadbandlow').val(_3D.deadband3d_low); + $('#3ddeadbandhigh').val(_3D.deadband3d_high); + $('#3dneutral').val(_3D.neutral3d); if (semver.lt(CONFIG.apiVersion, "1.17.0")) { - $('input[name="3ddeadbandthrottle"]').val(_3D.deadband3d_throttle); + $('#3ddeadbandthrottle').val(_3D.deadband3d_throttle); } else { - $('.3ddeadbandthrottle').hide(); + $('#deadband-3d-throttle-container').remove(); } $('input[type="checkbox"].feature', features_e).change(function () { @@ -615,11 +615,11 @@ TABS.configuration.initialize = function (callback, scrollPosition) { BF_CONFIG.currentoffset = parseInt($('#currentoffset').val()); MISC.multiwiicurrentoutput = ~~$('#multiwiicurrentoutput').is(':checked'); // ~~ boolean to decimal conversion - _3D.deadband3d_low = parseInt($('input[name="3ddeadbandlow"]').val()); - _3D.deadband3d_high = parseInt($('input[name="3ddeadbandhigh"]').val()); - _3D.neutral3d = parseInt($('input[name="3dneutral"]').val()); + _3D.deadband3d_low = parseInt($('#3ddeadbandlow').val()); + _3D.deadband3d_high = parseInt($('#3ddeadbandhigh').val()); + _3D.neutral3d = parseInt($('#3dneutral').val()); if (semver.lt(CONFIG.apiVersion, "1.17.0")) { - _3D.deadband3d_throttle = ($('input[name="3ddeadbandthrottle"]').val()); + _3D.deadband3d_throttle = ($('#3ddeadbandthrottle').val()); } @@ -729,23 +729,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) { function reinitialize() { //noinspection JSUnresolvedVariable GUI.log(chrome.i18n.getMessage('deviceRebooting')); - - if (BOARD.find_board_definition(CONFIG.boardIdentifier).vcp) { // VCP-based flight controls may crash old drivers, we catch and reconnect - $('a.connect').click(); - GUI.timeout_add('start_connection',function start_connection() { - $('a.connect').click(); - },2500); - } else { - - GUI.timeout_add('waiting_for_bootup', function waiting_for_bootup() { - MSP.send_message(MSPCodes.MSP_IDENT, false, false, function () { - //noinspection JSUnresolvedVariable - GUI.log(chrome.i18n.getMessage('deviceReady')); - //noinspection JSValidateTypes - TABS.configuration.initialize(false, $('#content').scrollTop()); - }); - },1500); // 1500 ms seems to be just the right amount of delay to prevent data request timeouts - } + GUI.handleReconnect($('.tab_configuration a')); } MSP.send_message(MSPCodes.MSP_SET_BF_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_BF_CONFIG), false, save_misc); diff --git a/tabs/failsafe.js b/tabs/failsafe.js index c076f74d..264d75c0 100644 --- a/tabs/failsafe.js +++ b/tabs/failsafe.js @@ -348,21 +348,7 @@ TABS.failsafe.initialize = function (callback, scrollPosition) { function reinitialize() { GUI.log(chrome.i18n.getMessage('deviceRebooting')); - - if (BOARD.find_board_definition(CONFIG.boardIdentifier).vcp) { // VCP-based flight controls may crash old drivers, we catch and reconnect - $('a.connect').click(); - GUI.timeout_add('start_connection',function start_connection() { - $('a.connect').click(); - },2500); - } else { - - GUI.timeout_add('waiting_for_bootup', function waiting_for_bootup() { - MSP.send_message(MSPCodes.MSP_IDENT, false, false, function () { - GUI.log(chrome.i18n.getMessage('deviceReady')); - TABS.failsafe.initialize(false, $('#content').scrollTop()); - }); - },1500); // 1500 ms seems to be just the right amount of delay to prevent data request timeouts - } + GUI.handleReconnect($('.tab_failsafe a')); } if(apiVersionGte1_15_0) { diff --git a/tabs/onboard_logging.js b/tabs/onboard_logging.js index ef9afa91..923c7b42 100644 --- a/tabs/onboard_logging.js +++ b/tabs/onboard_logging.js @@ -51,21 +51,7 @@ TABS.onboard_logging.initialize = function (callback) { function reinitialize() { GUI.log(chrome.i18n.getMessage('deviceRebooting')); - - if (BOARD.find_board_definition(CONFIG.boardIdentifier).vcp) { // VCP-based flight controls may crash old drivers, we catch and reconnect - $('a.connect').click(); - GUI.timeout_add('start_connection',function start_connection() { - $('a.connect').click(); - },2000); - } else { - - GUI.timeout_add('waiting_for_bootup', function waiting_for_bootup() { - MSP.send_message(MSPCodes.MSP_IDENT, false, false, function () { - GUI.log(chrome.i18n.getMessage('deviceReady')); - TABS.onboard_logging.initialize(false, $('#content').scrollTop()); - }); - },1500); // 1500 ms seems to be just the right amount of delay to prevent data request timeouts - } + GUI.handleReconnect($('.tab_onboard_logging a')); } function load_html() { diff --git a/tabs/ports.js b/tabs/ports.js index 782df265..4b0b3eb8 100644 --- a/tabs/ports.js +++ b/tabs/ports.js @@ -278,20 +278,7 @@ TABS.ports.initialize = function (callback, scrollPosition) { function on_reboot_success_handler() { GUI.log(chrome.i18n.getMessage('deviceRebooting')); - - if (BOARD.find_board_definition(CONFIG.boardIdentifier).vcp) { // VCP-based flight controls may crash old drivers, we catch and reconnect - $('a.connect').click(); - GUI.timeout_add('start_connection',function start_connection() { - $('a.connect').click(); - },2500); - } else { - GUI.timeout_add('waiting_for_bootup', function waiting_for_bootup() { - MSP.send_message(MSPCodes.MSP_IDENT, false, false, function () { - GUI.log(chrome.i18n.getMessage('deviceReady')); - TABS.ports.initialize(false, $('#content').scrollTop()); - }); - }, 1500); // seems to be just the right amount of delay to prevent data request timeouts - } + GUI.handleReconnect($('.tab_ports a')); } } };