From a84f24080551f751182e92953081ea27020df354 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alberto=20Garci=CC=81a=20Hierro?= Date: Tue, 7 Apr 2020 14:48:12 +0100 Subject: Enhance port discovery and port option storage/restoring - Detect when a port is backed by BLE and force wireless mode - Detect port types that don't use the BPS and disable the input - Disable manual port selection for runtimes that don't support it - Save bps/wireless mode per port instead of globally --- _locales/en/messages.json | 3 + js/port_handler.js | 100 +++++++++++++++++++++++------ js/serial.js | 5 +- js/serial_backend.js | 50 ++++++++++----- main.css | 5 ++ src/css/dropdown-lists/css/style_lists.css | 6 +- 6 files changed, 131 insertions(+), 38 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 600f07fa..af3f2095 100755 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -2342,6 +2342,9 @@ "w_z_gos_p_help": { "message": "When this value is set to 0, GPS is not used for altitude computation" }, + "portManual": { + "message": "Manual Selection" + }, "wirelessModeSwitch": { "message": "Wireless mode" }, diff --git a/js/port_handler.js b/js/port_handler.js index 28023291..1162e701 100755 --- a/js/port_handler.js +++ b/js/port_handler.js @@ -76,20 +76,8 @@ PortHandler.check = function () { } else { console.log('Last used port wasn\'t saved "yet", auto-select disabled.'); } + self.restorePortOptions(); }); - - chrome.storage.local.get('last_used_bps', function (result) { - if (result['last_used_bps']) { - $('#baud').val(result['last_used_bps']); - } - }); - - chrome.storage.local.get('wireless_mode_enabled', function (result) { - if (result['wireless_mode_enabled']) { - $('#wireless-mode').prop('checked', true).change(); - } - }); - } if (!self.initial_ports) { @@ -141,7 +129,7 @@ PortHandler.check = function () { self.check_usb_devices(); - GUI.updateManualPortVisibility(); + GUI.updatePortOptions(); setTimeout(function () { self.check(); }, 250); @@ -149,10 +137,11 @@ PortHandler.check = function () { }; PortHandler.check_usb_devices = function (callback) { + const self = this; chrome.usb.getDevices(usbDevices.STM32DFU, function (result) { if (result.length) { if (!$("div#port-picker #port [value='DFU']").length) { - $('div#port-picker #port').append($('