1
0
Fork 0
mirror of https://github.com/betaflight/betaflight-configurator.git synced 2025-07-19 06:15:13 +03:00

Sonar and review fixes

This commit is contained in:
Miguel Angel Mulero Martinez 2020-08-26 19:58:01 +02:00
parent 612a4e4e37
commit 9111503886
2 changed files with 15 additions and 15 deletions

View file

@ -43,17 +43,17 @@ PortHandler.check_serial_devices = function () {
serial.getDevices(function(current_ports) { serial.getDevices(function(current_ports) {
// port got removed or initial_ports wasn't initialized yet // port got removed or initial_ports wasn't initialized yet
if (self.array_difference(self.initial_ports, current_ports).length > 0 || !self.initial_ports) { if (self.array_difference(self.initial_ports, current_ports).length > 0 || !self.initial_ports) {
const removed_ports = self.array_difference(self.initial_ports, current_ports); const removedPorts = self.array_difference(self.initial_ports, current_ports);
if (self.initial_ports !== false && removed_ports.length > 0) { if (self.initial_ports !== false && removedPorts.length > 0) {
console.log(`PortHandler - Removed: ${JSON.stringify(removed_ports)}`); console.log(`PortHandler - Removed: ${JSON.stringify(removedPorts)}`);
} }
// disconnect "UI" if necessary // disconnect "UI" if necessary
// Keep in mind that this routine can not fire during atmega32u4 reboot procedure !!! // Keep in mind that this routine can not fire during atmega32u4 reboot procedure !!!
if (GUI.connected_to) { if (GUI.connected_to) {
for (let i = 0; i < removed_ports.length; i++) { for (let i = 0; i < removedPorts.length; i++) {
if (removed_ports[i] === GUI.connected_to) { if (removedPorts[i] === GUI.connected_to) {
$('div#header_btns a.connect').click(); $('div#header_btns a.connect').click();
} }
} }
@ -70,7 +70,7 @@ PortHandler.check_serial_devices = function () {
clearTimeout(obj.timer); clearTimeout(obj.timer);
// trigger callback // trigger callback
obj.code(removed_ports); obj.code(removedPorts);
// remove object from array // remove object from array
const index = self.port_removed_callbacks.indexOf(obj); const index = self.port_removed_callbacks.indexOf(obj);
@ -102,25 +102,25 @@ PortHandler.check_serial_devices = function () {
// initialize // initialize
self.initial_ports = current_ports; self.initial_ports = current_ports;
} else { } else {
for (let i = 0; i < removed_ports.length; i++) { for (let i = 0; i < removedPorts.length; i++) {
self.initial_ports.splice(self.initial_ports.indexOf(removed_ports[i]), 1); self.initial_ports.splice(self.initial_ports.indexOf(removedPorts[i]), 1);
} }
} }
} }
// new port detected // new port detected
const new_ports = self.array_difference(current_ports, self.initial_ports); const newPorts = self.array_difference(current_ports, self.initial_ports);
if (new_ports.length) { if (newPorts.length) {
if (new_ports.length > 0) { if (newPorts.length > 0) {
console.log(`PortHandler - Found: ${JSON.stringify(new_ports)}`); console.log(`PortHandler - Found: ${JSON.stringify(newPorts)}`);
} }
self.update_port_select(current_ports); self.update_port_select(current_ports);
// select / highlight new port, if connected -> select connected port // select / highlight new port, if connected -> select connected port
if (!GUI.connected_to) { if (!GUI.connected_to) {
self.portPickerElement.val(new_ports[0].path); self.portPickerElement.val(newPorts[0].path);
} else { } else {
self.portPickerElement.val(GUI.connected_to); self.portPickerElement.val(GUI.connected_to);
} }
@ -141,7 +141,7 @@ PortHandler.check_serial_devices = function () {
clearTimeout(obj.timer); clearTimeout(obj.timer);
// trigger callback // trigger callback
obj.code(new_ports); obj.code(newPorts);
// remove object from array // remove object from array
const index = self.port_detected_callbacks.indexOf(obj); const index = self.port_detected_callbacks.indexOf(obj);

View file

@ -283,7 +283,7 @@ var serial = {
const devices = []; const devices = [];
devices_array.forEach(function (device) { devices_array.forEach(function (device) {
devices.push({ devices.push({
path:device.path, path: device.path,
displayName: device.displayName, displayName: device.displayName,
}); });
}); });