1
0
Fork 0
mirror of https://github.com/iNavFlight/inav-configurator.git synced 2025-07-16 21:05:28 +03:00
This commit is contained in:
cTn 2014-08-13 13:12:39 +02:00 committed by Dominic Clifton
parent 36c4fef051
commit 179a3aa643
2 changed files with 11 additions and 12 deletions

View file

@ -8,12 +8,12 @@ function port_handler() {
this.port_removed_callbacks = []; this.port_removed_callbacks = [];
} }
port_handler.prototype.initialize = function() { port_handler.prototype.initialize = function () {
// start listening, check after 250ms // start listening, check after 250ms
this.check(); this.check();
}; };
port_handler.prototype.check = function() { port_handler.prototype.check = function () {
var self = this; var self = this;
serial.getDevices(function(current_ports) { serial.getDevices(function(current_ports) {
@ -60,7 +60,7 @@ port_handler.prototype.check = function() {
// auto-select last used port (only during initialization) // auto-select last used port (only during initialization)
if (!self.initial_ports) { if (!self.initial_ports) {
chrome.storage.local.get('last_used_port', function(result) { chrome.storage.local.get('last_used_port', function (result) {
// if last_used_port was set, we try to select it // if last_used_port was set, we try to select it
if (result.last_used_port) { if (result.last_used_port) {
current_ports.forEach(function(port) { current_ports.forEach(function(port) {
@ -109,7 +109,7 @@ port_handler.prototype.check = function() {
if (GUI.auto_connect && !GUI.connecting_to && !GUI.connected_to) { if (GUI.auto_connect && !GUI.connecting_to && !GUI.connected_to) {
// we need firmware flasher protection over here // we need firmware flasher protection over here
if (GUI.active_tab != 'firmware_flasher') { if (GUI.active_tab != 'firmware_flasher') {
GUI.timeout_add('auto-connect_timeout', function() { GUI.timeout_add('auto-connect_timeout', function () {
$('div#port-picker a.connect').click(); $('div#port-picker a.connect').click();
}, 50); // small timeout so we won't get any nasty connect errors due to system initializing the bus }, 50); // small timeout so we won't get any nasty connect errors due to system initializing the bus
} }
@ -137,13 +137,13 @@ port_handler.prototype.check = function() {
check_usb_devices(); check_usb_devices();
} }
self.main_timeout_reference = setTimeout(function() { self.main_timeout_reference = setTimeout(function () {
self.check(); self.check();
}, 250); }, 250);
}); });
function check_usb_devices() { function check_usb_devices() {
chrome.usb.getDevices(usbDevices.STM32DFU, function(result) { chrome.usb.getDevices(usbDevices.STM32DFU, function (result) {
if (result.length) { if (result.length) {
if (!$("div#port-picker #port [value='DFU']").length) { if (!$("div#port-picker #port [value='DFU']").length) {
$('div#port-picker #port').append('<option value="DFU">DFU</option>'); $('div#port-picker #port').append('<option value="DFU">DFU</option>');
@ -158,7 +158,7 @@ port_handler.prototype.check = function() {
} }
}; };
port_handler.prototype.update_port_select = function(ports) { port_handler.prototype.update_port_select = function (ports) {
$('div#port-picker #port').html(''); // drop previous one $('div#port-picker #port').html(''); // drop previous one
if (ports.length > 0) { if (ports.length > 0) {
@ -195,12 +195,12 @@ port_handler.prototype.port_detected = function(name, code, timeout, ignore_time
return obj; return obj;
}; };
port_handler.prototype.port_removed = function(name, code, timeout, ignore_timeout) { port_handler.prototype.port_removed = function (name, code, timeout, ignore_timeout) {
var self = this; var self = this;
var obj = {'name': name, 'code': code, 'timeout': (timeout) ? timeout : 10000}; var obj = {'name': name, 'code': code, 'timeout': (timeout) ? timeout : 10000};
if (!ignore_timeout) { if (!ignore_timeout) {
obj.timer = setTimeout(function() { obj.timer = setTimeout(function () {
console.log('PortHandler - timeout - ' + obj.name); console.log('PortHandler - timeout - ' + obj.name);
// trigger callback // trigger callback
@ -221,7 +221,7 @@ port_handler.prototype.port_removed = function(name, code, timeout, ignore_timeo
}; };
// accepting single level array with "value" as key // accepting single level array with "value" as key
port_handler.prototype.array_difference = function(firstArray, secondArray) { port_handler.prototype.array_difference = function (firstArray, secondArray) {
var cloneArray = []; var cloneArray = [];
// create hardcopy // create hardcopy
@ -238,7 +238,7 @@ port_handler.prototype.array_difference = function(firstArray, secondArray) {
return cloneArray; return cloneArray;
}; };
port_handler.prototype.flush_callbacks = function() { port_handler.prototype.flush_callbacks = function () {
var killed = 0; var killed = 0;
for (var i = this.port_detected_callbacks.length - 1; i >= 0; i--) { for (var i = this.port_detected_callbacks.length - 1; i >= 0; i--) {

View file

@ -12,7 +12,6 @@ body {
font-family: sans-serif; font-family: sans-serif;
font-size: 12px; font-size: 12px;
color: #303030; color: #303030;
-webkit-text-size-adjust: 100%;
background-color: #dfddd0; background-color: #dfddd0;
} }
a { a {