mirror of
https://github.com/betaflight/betaflight-configurator.git
synced 2025-07-19 06:15:13 +03:00
Change lexical scope serial
This commit is contained in:
parent
317f937fd5
commit
625931c4ba
4 changed files with 102 additions and 102 deletions
|
@ -90,7 +90,7 @@ PortHandler.check_usb_devices = function (callback) {
|
||||||
callback(self.dfu_available);
|
callback(self.dfu_available);
|
||||||
}
|
}
|
||||||
if (!$('option:selected', self.portPickerElement).data().isDFU) {
|
if (!$('option:selected', self.portPickerElement).data().isDFU) {
|
||||||
if (!GUI.connected_to) {
|
if (!(GUI.connected_to || GUI.connect_lock)) {
|
||||||
FC.resetState();
|
FC.resetState();
|
||||||
}
|
}
|
||||||
self.portPickerElement.trigger('change');
|
self.portPickerElement.trigger('change');
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var PortUsage = {
|
const PortUsage = {
|
||||||
previous_received: 0,
|
previous_received: 0,
|
||||||
previous_sent: 0,
|
previous_sent: 0,
|
||||||
port_usage_down: 0,
|
port_usage_down: 0,
|
||||||
port_usage_up: 0,
|
port_usage_up: 0,
|
||||||
|
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
var self = this;
|
const self = this;
|
||||||
|
|
||||||
self.main_timer_reference = setInterval(function() {
|
self.main_timer_reference = setInterval(function() {
|
||||||
self.update();
|
self.update();
|
||||||
|
@ -15,8 +15,8 @@ var PortUsage = {
|
||||||
},
|
},
|
||||||
update: function() {
|
update: function() {
|
||||||
if (serial.bitrate) {
|
if (serial.bitrate) {
|
||||||
var port_usage_down = parseInt(((serial.bytesReceived - this.previous_received) * 10 / serial.bitrate) * 100);
|
const port_usage_down = parseInt(((serial.bytesReceived - this.previous_received) * 10 / serial.bitrate) * 100);
|
||||||
var port_usage_up = parseInt(((serial.bytesSent - this.previous_sent) * 10 / serial.bitrate) * 100);
|
const port_usage_up = parseInt(((serial.bytesSent - this.previous_sent) * 10 / serial.bitrate) * 100);
|
||||||
|
|
||||||
this.previous_received = serial.bytesReceived;
|
this.previous_received = serial.bytesReceived;
|
||||||
this.previous_sent = serial.bytesSent;
|
this.previous_sent = serial.bytesSent;
|
||||||
|
@ -35,4 +35,4 @@ var PortUsage = {
|
||||||
this.port_usage_down = 0;
|
this.port_usage_down = 0;
|
||||||
this.port_usage_up = 0;
|
this.port_usage_up = 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -46,15 +46,15 @@ const serial = {
|
||||||
case 'system_error': // we might be able to recover from this one
|
case 'system_error': // we might be able to recover from this one
|
||||||
if (!self.failed++) {
|
if (!self.failed++) {
|
||||||
chrome.serial.setPaused(self.connectionId, false, function () {
|
chrome.serial.setPaused(self.connectionId, false, function () {
|
||||||
self.getInfo(function (info) {
|
self.getInfo(function (getInfo) {
|
||||||
if (info) {
|
if (getInfo) {
|
||||||
if (!info.paused) {
|
if (!getInfo.paused) {
|
||||||
console.log(`${self.connectionType}: connection recovered from last onReceiveError`);
|
console.log(`${self.connectionType}: connection recovered from last onReceiveError`);
|
||||||
self.failed = 0;
|
self.failed = 0;
|
||||||
} else {
|
} else {
|
||||||
console.log(`${self.connectionType}: connection did not recover from last onReceiveError, disconnecting`);
|
console.log(`${self.connectionType}: connection did not recover from last onReceiveError, disconnecting`);
|
||||||
GUI.log(i18n.getMessage('serialUnrecoverable'));
|
GUI.log(i18n.getMessage('serialUnrecoverable'));
|
||||||
self.errorHandler(info.error, 'receive');
|
self.errorHandler(getInfo.error, 'receive');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
self.checkChromeRunTimeError();
|
self.checkChromeRunTimeError();
|
||||||
|
@ -69,13 +69,13 @@ const serial = {
|
||||||
self.error = info.error;
|
self.error = info.error;
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
chrome.serial.setPaused(info.connectionId, false, function() {
|
chrome.serial.setPaused(info.connectionId, false, function() {
|
||||||
self.getInfo(function (info) {
|
self.getInfo(function (_info) {
|
||||||
if (info) {
|
if (_info) {
|
||||||
if (info.paused) {
|
if (_info.paused) {
|
||||||
// assume unrecoverable, disconnect
|
// assume unrecoverable, disconnect
|
||||||
console.log(`${self.connectionType}: connection did not recover from ${self.error} condition, disconnecting`);
|
console.log(`${self.connectionType}: connection did not recover from ${self.error} condition, disconnecting`);
|
||||||
GUI.log(i18n.getMessage('serialUnrecoverable'));
|
GUI.log(i18n.getMessage('serialUnrecoverable'));
|
||||||
self.errorHandler(info.error, 'receive');
|
self.errorHandler(_info.error, 'receive');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
console.log(`${self.connectionType}: connection recovered from ${self.error} condition`);
|
console.log(`${self.connectionType}: connection recovered from ${self.error} condition`);
|
||||||
|
@ -94,6 +94,8 @@ const serial = {
|
||||||
case 'frame_error':
|
case 'frame_error':
|
||||||
case 'parity_error':
|
case 'parity_error':
|
||||||
GUI.log(i18n.getMessage('serialError' + inflection.camelize(info.error)));
|
GUI.log(i18n.getMessage('serialError' + inflection.camelize(info.error)));
|
||||||
|
self.errorHandler(info.error, 'receive');
|
||||||
|
break;
|
||||||
case 'break': // This seems to be the error that is thrown under NW.js in Windows when the device reboots after typing 'exit' in CLI
|
case 'break': // This seems to be the error that is thrown under NW.js in Windows when the device reboots after typing 'exit' in CLI
|
||||||
case 'disconnected':
|
case 'disconnected':
|
||||||
case 'device_lost':
|
case 'device_lost':
|
||||||
|
@ -299,7 +301,7 @@ const serial = {
|
||||||
if (self.outputBuffer.length) {
|
if (self.outputBuffer.length) {
|
||||||
// keep the buffer withing reasonable limits
|
// keep the buffer withing reasonable limits
|
||||||
if (self.outputBuffer.length > 100) {
|
if (self.outputBuffer.length > 100) {
|
||||||
var counter = 0;
|
let counter = 0;
|
||||||
|
|
||||||
while (self.outputBuffer.length > 100) {
|
while (self.outputBuffer.length > 100) {
|
||||||
self.outputBuffer.pop();
|
self.outputBuffer.pop();
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
var mspHelper;
|
|
||||||
|
|
||||||
var connectionTimestamp;
|
let mspHelper;
|
||||||
|
let connectionTimestamp;
|
||||||
|
|
||||||
function initializeSerialBackend() {
|
function initializeSerialBackend() {
|
||||||
GUI.updateManualPortVisibility = function(){
|
GUI.updateManualPortVisibility = function(){
|
||||||
var selected_port = $('div#port-picker #port option:selected');
|
const selected_port = $('div#port-picker #port option:selected');
|
||||||
if (selected_port.data().isManual) {
|
if (selected_port.data().isManual) {
|
||||||
$('#port-override-option').show();
|
$('#port-override-option').show();
|
||||||
}
|
}
|
||||||
|
@ -37,16 +37,16 @@ function initializeSerialBackend() {
|
||||||
$('div.connect_controls a.connect').click(function () {
|
$('div.connect_controls a.connect').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 thisElement = $(this);
|
const thisElement = $(this);
|
||||||
var clicks = thisElement.data('clicks');
|
const clicks = thisElement.data('clicks');
|
||||||
|
|
||||||
var toggleStatus = function() {
|
const toggleStatus = function() {
|
||||||
thisElement.data("clicks", !clicks);
|
thisElement.data("clicks", !clicks);
|
||||||
};
|
};
|
||||||
|
|
||||||
GUI.configuration_loaded = false;
|
GUI.configuration_loaded = false;
|
||||||
|
|
||||||
var selected_baud = parseInt($('div#port-picker #baud').val());
|
const selected_baud = parseInt($('div#port-picker #baud').val());
|
||||||
const selectedPort = $('div#port-picker #port option:selected');
|
const selectedPort = $('div#port-picker #port option:selected');
|
||||||
|
|
||||||
let portName;
|
let portName;
|
||||||
|
@ -60,7 +60,7 @@ function initializeSerialBackend() {
|
||||||
$('select#baud').hide();
|
$('select#baud').hide();
|
||||||
} else if (portName !== '0') {
|
} else if (portName !== '0') {
|
||||||
if (!clicks) {
|
if (!clicks) {
|
||||||
console.log(`Connecting to: ${portName}`);
|
console.log(`${serial.connectionType}: connecting to: ${portName}`);
|
||||||
GUI.connecting_to = portName;
|
GUI.connecting_to = portName;
|
||||||
|
|
||||||
// lock port select & baud while we are connecting / connected
|
// lock port select & baud while we are connecting / connected
|
||||||
|
@ -148,14 +148,12 @@ function finishClose(finishedCallback) {
|
||||||
UI_PHONES.reset();
|
UI_PHONES.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
var wasConnected = CONFIGURATOR.connectionValid;
|
const wasConnected = CONFIGURATOR.connectionValid;
|
||||||
|
|
||||||
analytics.sendEvent(analytics.EVENT_CATEGORIES.FLIGHT_CONTROLLER, 'Disconnected');
|
analytics.sendEvent(analytics.EVENT_CATEGORIES.FLIGHT_CONTROLLER, 'Disconnected');
|
||||||
if (connectionTimestamp) {
|
if (connectionTimestamp) {
|
||||||
var connectedTime = Date.now() - connectionTimestamp;
|
const connectedTime = Date.now() - connectionTimestamp;
|
||||||
analytics.sendTiming(analytics.EVENT_CATEGORIES.FLIGHT_CONTROLLER, 'Connected', connectedTime);
|
analytics.sendTiming(analytics.EVENT_CATEGORIES.FLIGHT_CONTROLLER, 'Connected', connectedTime);
|
||||||
|
|
||||||
connectedTime = undefined;
|
|
||||||
}
|
}
|
||||||
// close reset to custom defaults dialog
|
// close reset to custom defaults dialog
|
||||||
$('#dialogResetToCustomDefaults')[0].close();
|
$('#dialogResetToCustomDefaults')[0].close();
|
||||||
|
@ -229,14 +227,12 @@ function onOpen(openInfo) {
|
||||||
});
|
});
|
||||||
|
|
||||||
serial.onReceive.addListener(read_serial);
|
serial.onReceive.addListener(read_serial);
|
||||||
|
|
||||||
setConnectionTimeout();
|
setConnectionTimeout();
|
||||||
|
|
||||||
FC.resetState();
|
FC.resetState();
|
||||||
mspHelper = new MspHelper();
|
mspHelper = new MspHelper();
|
||||||
MSP.listen(mspHelper.process_data.bind(mspHelper));
|
MSP.listen(mspHelper.process_data.bind(mspHelper));
|
||||||
console.log(`Requesting configuration data`);
|
console.log(`Requesting configuration data`);
|
||||||
// request configuration data
|
|
||||||
MSP.send_message(MSPCodes.MSP_API_VERSION, false, false, function () {
|
MSP.send_message(MSPCodes.MSP_API_VERSION, false, false, function () {
|
||||||
analytics.setFlightControllerData(analytics.DATA.API_VERSION, FC.CONFIG.apiVersion);
|
analytics.setFlightControllerData(analytics.DATA.API_VERSION, FC.CONFIG.apiVersion);
|
||||||
|
|
||||||
|
@ -262,7 +258,7 @@ function onOpen(openInfo) {
|
||||||
} else {
|
} else {
|
||||||
analytics.sendEvent(analytics.EVENT_CATEGORIES.FLIGHT_CONTROLLER, 'ConnectionRefusedFirmwareType', FC.CONFIG.flightControllerIdentifier);
|
analytics.sendEvent(analytics.EVENT_CATEGORIES.FLIGHT_CONTROLLER, 'ConnectionRefusedFirmwareType', FC.CONFIG.flightControllerIdentifier);
|
||||||
|
|
||||||
var dialog = $('.dialogConnectWarning')[0];
|
const dialog = $('.dialogConnectWarning')[0];
|
||||||
|
|
||||||
$('.dialogConnectWarning-content').html(i18n.getMessage('firmwareTypeNotSupported'));
|
$('.dialogConnectWarning-content').html(i18n.getMessage('firmwareTypeNotSupported'));
|
||||||
|
|
||||||
|
@ -278,7 +274,7 @@ function onOpen(openInfo) {
|
||||||
} else {
|
} else {
|
||||||
analytics.sendEvent(analytics.EVENT_CATEGORIES.FLIGHT_CONTROLLER, 'ConnectionRefusedFirmwareVersion', FC.CONFIG.apiVersion);
|
analytics.sendEvent(analytics.EVENT_CATEGORIES.FLIGHT_CONTROLLER, 'ConnectionRefusedFirmwareVersion', FC.CONFIG.apiVersion);
|
||||||
|
|
||||||
var dialog = $('.dialogConnectWarning')[0];
|
const dialog = $('.dialogConnectWarning')[0];
|
||||||
|
|
||||||
$('.dialogConnectWarning-content').html(i18n.getMessage('firmwareVersionNotSupported', [CONFIGURATOR.API_VERSION_ACCEPTED]));
|
$('.dialogConnectWarning-content').html(i18n.getMessage('firmwareVersionNotSupported', [CONFIGURATOR.API_VERSION_ACCEPTED]));
|
||||||
|
|
||||||
|
@ -322,12 +318,12 @@ function processBoardInfo() {
|
||||||
GUI.log(i18n.getMessage('boardInfoReceived', [FC.getHardwareName(), FC.CONFIG.boardVersion]));
|
GUI.log(i18n.getMessage('boardInfoReceived', [FC.getHardwareName(), FC.CONFIG.boardVersion]));
|
||||||
|
|
||||||
if (bit_check(FC.CONFIG.targetCapabilities, FC.TARGET_CAPABILITIES_FLAGS.SUPPORTS_CUSTOM_DEFAULTS) && bit_check(FC.CONFIG.targetCapabilities, FC.TARGET_CAPABILITIES_FLAGS.HAS_CUSTOM_DEFAULTS) && FC.CONFIG.configurationState === FC.CONFIGURATION_STATES.DEFAULTS_BARE) {
|
if (bit_check(FC.CONFIG.targetCapabilities, FC.TARGET_CAPABILITIES_FLAGS.SUPPORTS_CUSTOM_DEFAULTS) && bit_check(FC.CONFIG.targetCapabilities, FC.TARGET_CAPABILITIES_FLAGS.HAS_CUSTOM_DEFAULTS) && FC.CONFIG.configurationState === FC.CONFIGURATION_STATES.DEFAULTS_BARE) {
|
||||||
var dialog = $('#dialogResetToCustomDefaults')[0];
|
const dialog = $('#dialogResetToCustomDefaults')[0];
|
||||||
|
|
||||||
$('#dialogResetToCustomDefaults-acceptbtn').click(function() {
|
$('#dialogResetToCustomDefaults-acceptbtn').click(function() {
|
||||||
analytics.sendEvent(analytics.EVENT_CATEGORIES.FLIGHT_CONTROLLER, 'AcceptResetToCustomDefaults');
|
analytics.sendEvent(analytics.EVENT_CATEGORIES.FLIGHT_CONTROLLER, 'AcceptResetToCustomDefaults');
|
||||||
|
|
||||||
var buffer = [];
|
const buffer = [];
|
||||||
buffer.push(mspHelper.RESET_TYPES.CUSTOM_DEFAULTS);
|
buffer.push(mspHelper.RESET_TYPES.CUSTOM_DEFAULTS);
|
||||||
MSP.send_message(MSPCodes.MSP_RESET_CONF, buffer, false);
|
MSP.send_message(MSPCodes.MSP_RESET_CONF, buffer, false);
|
||||||
|
|
||||||
|
@ -409,7 +405,7 @@ function checkReportProblems() {
|
||||||
|
|
||||||
function processUid() {
|
function processUid() {
|
||||||
MSP.send_message(MSPCodes.MSP_UID, false, false, function () {
|
MSP.send_message(MSPCodes.MSP_UID, false, false, function () {
|
||||||
var uniqueDeviceIdentifier = FC.CONFIG.uid[0].toString(16) + FC.CONFIG.uid[1].toString(16) + FC.CONFIG.uid[2].toString(16);
|
const uniqueDeviceIdentifier = FC.CONFIG.uid[0].toString(16) + FC.CONFIG.uid[1].toString(16) + FC.CONFIG.uid[2].toString(16);
|
||||||
|
|
||||||
analytics.setFlightControllerData(analytics.DATA.MCU_ID, objectHash.sha1(uniqueDeviceIdentifier));
|
analytics.setFlightControllerData(analytics.DATA.MCU_ID, objectHash.sha1(uniqueDeviceIdentifier));
|
||||||
analytics.sendEvent(analytics.EVENT_CATEGORIES.FLIGHT_CONTROLLER, 'Connected');
|
analytics.sendEvent(analytics.EVENT_CATEGORIES.FLIGHT_CONTROLLER, 'Connected');
|
||||||
|
@ -480,14 +476,14 @@ function onConnect() {
|
||||||
// show only appropriate tabs
|
// show only appropriate tabs
|
||||||
$('#tabs ul.mode-connected li').hide();
|
$('#tabs ul.mode-connected li').hide();
|
||||||
$('#tabs ul.mode-connected li').filter(function (index) {
|
$('#tabs ul.mode-connected li').filter(function (index) {
|
||||||
var classes = $(this).attr("class").split(/\s+/);
|
const classes = $(this).attr("class").split(/\s+/);
|
||||||
var found = false;
|
let found = false;
|
||||||
$.each(GUI.allowedTabs, function (index, value) {
|
$.each(GUI.allowedTabs, (_index, value) => {
|
||||||
var tabName = "tab_" + value;
|
const tabName = `tab_${value}`;
|
||||||
if ($.inArray(tabName, classes) >= 0) {
|
if ($.inArray(tabName, classes) >= 0) {
|
||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (FC.CONFIG.boardType == 0) {
|
if (FC.CONFIG.boardType == 0) {
|
||||||
if (classes.indexOf("osd-required") >= 0) {
|
if (classes.indexOf("osd-required") >= 0) {
|
||||||
|
@ -517,13 +513,13 @@ function onConnect() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var sensor_state = $('#sensor-status');
|
const sensorState = $('#sensor-status');
|
||||||
sensor_state.show();
|
sensorState.show();
|
||||||
|
|
||||||
var port_picker = $('#portsinput');
|
const portPicker = $('#portsinput');
|
||||||
port_picker.hide();
|
portPicker.hide();
|
||||||
|
|
||||||
var dataflash = $('#dataflash_wrapper_global');
|
const dataflash = $('#dataflash_wrapper_global');
|
||||||
dataflash.show();
|
dataflash.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -538,16 +534,16 @@ function onClosed(result) {
|
||||||
$('#tabs ul.mode-connected-cli').hide();
|
$('#tabs ul.mode-connected-cli').hide();
|
||||||
$('#tabs ul.mode-disconnected').show();
|
$('#tabs ul.mode-disconnected').show();
|
||||||
|
|
||||||
var sensor_state = $('#sensor-status');
|
const sensorState = $('#sensor-status');
|
||||||
sensor_state.hide();
|
sensorState.hide();
|
||||||
|
|
||||||
var port_picker = $('#portsinput');
|
const portPicker = $('#portsinput');
|
||||||
port_picker.show();
|
portPicker.show();
|
||||||
|
|
||||||
var dataflash = $('#dataflash_wrapper_global');
|
const dataflash = $('#dataflash_wrapper_global');
|
||||||
dataflash.hide();
|
dataflash.hide();
|
||||||
|
|
||||||
var battery = $('#quad-status_wrapper');
|
const battery = $('#quad-status_wrapper');
|
||||||
battery.hide();
|
battery.hide();
|
||||||
|
|
||||||
MSP.clearListeners();
|
MSP.clearListeners();
|
||||||
|
@ -579,55 +575,55 @@ function sensor_status(sensors_detected) {
|
||||||
// set current value
|
// set current value
|
||||||
sensor_status.previous_sensors_detected = sensors_detected;
|
sensor_status.previous_sensors_detected = sensors_detected;
|
||||||
|
|
||||||
var e_sensor_status = $('div#sensor-status');
|
const eSensorStatus = $('div#sensor-status');
|
||||||
|
|
||||||
if (have_sensor(sensors_detected, 'acc')) {
|
if (have_sensor(sensors_detected, 'acc')) {
|
||||||
$('.accel', e_sensor_status).addClass('on');
|
$('.accel', eSensorStatus).addClass('on');
|
||||||
$('.accicon', e_sensor_status).addClass('active');
|
$('.accicon', eSensorStatus).addClass('active');
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$('.accel', e_sensor_status).removeClass('on');
|
$('.accel', eSensorStatus).removeClass('on');
|
||||||
$('.accicon', e_sensor_status).removeClass('active');
|
$('.accicon', eSensorStatus).removeClass('active');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((FC.CONFIG.boardType == 0 || FC.CONFIG.boardType == 2) && have_sensor(sensors_detected, 'gyro')) {
|
if ((FC.CONFIG.boardType == 0 || FC.CONFIG.boardType == 2) && have_sensor(sensors_detected, 'gyro')) {
|
||||||
$('.gyro', e_sensor_status).addClass('on');
|
$('.gyro', eSensorStatus).addClass('on');
|
||||||
$('.gyroicon', e_sensor_status).addClass('active');
|
$('.gyroicon', eSensorStatus).addClass('active');
|
||||||
} else {
|
} else {
|
||||||
$('.gyro', e_sensor_status).removeClass('on');
|
$('.gyro', eSensorStatus).removeClass('on');
|
||||||
$('.gyroicon', e_sensor_status).removeClass('active');
|
$('.gyroicon', eSensorStatus).removeClass('active');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (have_sensor(sensors_detected, 'baro')) {
|
if (have_sensor(sensors_detected, 'baro')) {
|
||||||
$('.baro', e_sensor_status).addClass('on');
|
$('.baro', eSensorStatus).addClass('on');
|
||||||
$('.baroicon', e_sensor_status).addClass('active');
|
$('.baroicon', eSensorStatus).addClass('active');
|
||||||
} else {
|
} else {
|
||||||
$('.baro', e_sensor_status).removeClass('on');
|
$('.baro', eSensorStatus).removeClass('on');
|
||||||
$('.baroicon', e_sensor_status).removeClass('active');
|
$('.baroicon', eSensorStatus).removeClass('active');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (have_sensor(sensors_detected, 'mag')) {
|
if (have_sensor(sensors_detected, 'mag')) {
|
||||||
$('.mag', e_sensor_status).addClass('on');
|
$('.mag', eSensorStatus).addClass('on');
|
||||||
$('.magicon', e_sensor_status).addClass('active');
|
$('.magicon', eSensorStatus).addClass('active');
|
||||||
} else {
|
} else {
|
||||||
$('.mag', e_sensor_status).removeClass('on');
|
$('.mag', eSensorStatus).removeClass('on');
|
||||||
$('.magicon', e_sensor_status).removeClass('active');
|
$('.magicon', eSensorStatus).removeClass('active');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (have_sensor(sensors_detected, 'gps')) {
|
if (have_sensor(sensors_detected, 'gps')) {
|
||||||
$('.gps', e_sensor_status).addClass('on');
|
$('.gps', eSensorStatus).addClass('on');
|
||||||
$('.gpsicon', e_sensor_status).addClass('active');
|
$('.gpsicon', eSensorStatus).addClass('active');
|
||||||
} else {
|
} else {
|
||||||
$('.gps', e_sensor_status).removeClass('on');
|
$('.gps', eSensorStatus).removeClass('on');
|
||||||
$('.gpsicon', e_sensor_status).removeClass('active');
|
$('.gpsicon', eSensorStatus).removeClass('active');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (have_sensor(sensors_detected, 'sonar')) {
|
if (have_sensor(sensors_detected, 'sonar')) {
|
||||||
$('.sonar', e_sensor_status).addClass('on');
|
$('.sonar', eSensorStatus).addClass('on');
|
||||||
$('.sonaricon', e_sensor_status).addClass('active');
|
$('.sonaricon', eSensorStatus).addClass('active');
|
||||||
} else {
|
} else {
|
||||||
$('.sonar', e_sensor_status).removeClass('on');
|
$('.sonar', eSensorStatus).removeClass('on');
|
||||||
$('.sonaricon', e_sensor_status).removeClass('active');
|
$('.sonaricon', eSensorStatus).removeClass('active');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -660,7 +656,7 @@ function startLiveDataRefreshTimer() {
|
||||||
|
|
||||||
function update_live_status() {
|
function update_live_status() {
|
||||||
|
|
||||||
var statuswrapper = $('#quad-status_wrapper');
|
const statuswrapper = $('#quad-status_wrapper');
|
||||||
|
|
||||||
$(".quad-status-contents").css({
|
$(".quad-status-contents").css({
|
||||||
display: 'inline-block'
|
display: 'inline-block'
|
||||||
|
@ -676,33 +672,35 @@ function update_live_status() {
|
||||||
MSP.send_message(MSPCodes.MSP_ANALOG, false, false);
|
MSP.send_message(MSPCodes.MSP_ANALOG, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
var active = ((Date.now() - FC.ANALOG.last_received_timestamp) < 300);
|
const active = ((Date.now() - FC.ANALOG.last_received_timestamp) < 300);
|
||||||
|
|
||||||
for (var i = 0; i < FC.AUX_CONFIG.length; i++) {
|
for (let i = 0; i < FC.AUX_CONFIG.length; i++) {
|
||||||
if (FC.AUX_CONFIG[i] == 'ARM') {
|
if (FC.AUX_CONFIG[i] === 'ARM') {
|
||||||
if (bit_check(FC.CONFIG.mode, i))
|
if (bit_check(FC.CONFIG.mode, i)) {
|
||||||
$(".armedicon").addClass('active');
|
$(".armedicon").addClass('active');
|
||||||
else
|
} else {
|
||||||
$(".armedicon").removeClass('active');
|
$(".armedicon").removeClass('active');
|
||||||
}
|
}
|
||||||
if (FC.AUX_CONFIG[i] == 'FAILSAFE') {
|
}
|
||||||
if (bit_check(FC.CONFIG.mode, i))
|
}
|
||||||
$(".failsafeicon").addClass('active');
|
if (FC.AUX_CONFIG[index] === 'FAILSAFE') {
|
||||||
else
|
if (bit_check(FC.CONFIG.mode, i)) {
|
||||||
$(".failsafeicon").removeClass('active');
|
$(".failsafeicon").addClass('active');
|
||||||
}
|
} else {
|
||||||
|
$(".failsafeicon").removeClass('active');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FC.ANALOG != undefined) {
|
if (FC.ANALOG != undefined) {
|
||||||
var nbCells = Math.floor(FC.ANALOG.voltage / FC.BATTERY_CONFIG.vbatmaxcellvoltage) + 1;
|
let nbCells = Math.floor(FC.ANALOG.voltage / FC.BATTERY_CONFIG.vbatmaxcellvoltage) + 1;
|
||||||
|
|
||||||
if (FC.ANALOG.voltage == 0) {
|
if (FC.ANALOG.voltage == 0) {
|
||||||
nbCells = 1;
|
nbCells = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
var min = FC.BATTERY_CONFIG.vbatmincellvoltage * nbCells;
|
const min = FC.BATTERY_CONFIG.vbatmincellvoltage * nbCells;
|
||||||
var max = FC.BATTERY_CONFIG.vbatmaxcellvoltage * nbCells;
|
const max = FC.BATTERY_CONFIG.vbatmaxcellvoltage * nbCells;
|
||||||
var warn = FC.BATTERY_CONFIG.vbatwarningcellvoltage * nbCells;
|
const warn = FC.BATTERY_CONFIG.vbatwarningcellvoltage * nbCells;
|
||||||
|
|
||||||
const NO_BATTERY_VOLTAGE_MAXIMUM = 1.8; // Maybe is better to add a call to MSP_BATTERY_STATE but is not available for all versions
|
const NO_BATTERY_VOLTAGE_MAXIMUM = 1.8; // Maybe is better to add a call to MSP_BATTERY_STATE but is not available for all versions
|
||||||
|
|
||||||
|
@ -713,7 +711,7 @@ function update_live_status() {
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
$(".battery-status").css({
|
$(".battery-status").css({
|
||||||
width: ((FC.ANALOG.voltage - min) / (max - min) * 100) + "%",
|
width: `${((FC.ANALOG.voltage - min) / (max - min) * 100)}%`,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (FC.ANALOG.voltage < warn) {
|
if (FC.ANALOG.voltage < warn) {
|
||||||
|
@ -757,18 +755,18 @@ function update_dataflash_global() {
|
||||||
if (bytes < 1024) {
|
if (bytes < 1024) {
|
||||||
return bytes + "B";
|
return bytes + "B";
|
||||||
}
|
}
|
||||||
var kilobytes = bytes / 1024;
|
const kilobytes = bytes / 1024;
|
||||||
|
|
||||||
if (kilobytes < 1024) {
|
if (kilobytes < 1024) {
|
||||||
return Math.round(kilobytes) + "kB";
|
return Math.round(kilobytes) + "kB";
|
||||||
}
|
}
|
||||||
|
|
||||||
var megabytes = kilobytes / 1024;
|
const megabytes = kilobytes / 1024;
|
||||||
|
|
||||||
return megabytes.toFixed(1) + "MB";
|
return megabytes.toFixed(1) + "MB";
|
||||||
}
|
}
|
||||||
|
|
||||||
var supportsDataflash = FC.DATAFLASH.totalSize > 0;
|
const supportsDataflash = FC.DATAFLASH.totalSize > 0;
|
||||||
|
|
||||||
if (supportsDataflash){
|
if (supportsDataflash){
|
||||||
$(".noflash_global").css({
|
$(".noflash_global").css({
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue