mirror of
https://github.com/betaflight/betaflight-configurator.git
synced 2025-07-23 16:25:22 +03:00
Change lexical scope motors, sensors, configuration
This commit is contained in:
parent
317f937fd5
commit
565c8a04c0
3 changed files with 356 additions and 354 deletions
|
@ -9,7 +9,7 @@ TABS.configuration = {
|
|||
};
|
||||
|
||||
TABS.configuration.initialize = function (callback, scrollPosition) {
|
||||
var self = this;
|
||||
const self = this;
|
||||
|
||||
// Update filtering defaults based on API version
|
||||
const FILTER_DEFAULT = FC.getFilterDefaults();
|
||||
|
@ -31,11 +31,11 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
|
|||
}
|
||||
|
||||
function load_beeper_config() {
|
||||
var next_callback = load_serial_config;
|
||||
const nextCallBack = load_serial_config;
|
||||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_36)) {
|
||||
MSP.send_message(MSPCodes.MSP_BEEPER_CONFIG, false, false, next_callback);
|
||||
MSP.send_message(MSPCodes.MSP_BEEPER_CONFIG, false, false, nextCallBack);
|
||||
} else {
|
||||
next_callback();
|
||||
nextCallBack();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -60,20 +60,20 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
|
|||
}
|
||||
|
||||
function load_motor_config() {
|
||||
var next_callback = load_gps_config;
|
||||
const nextCallBack = load_gps_config;
|
||||
if(semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_33)) {
|
||||
MSP.send_message(MSPCodes.MSP_MOTOR_CONFIG, false, false, next_callback);
|
||||
MSP.send_message(MSPCodes.MSP_MOTOR_CONFIG, false, false, nextCallBack);
|
||||
} else {
|
||||
next_callback();
|
||||
nextCallBack();
|
||||
}
|
||||
}
|
||||
|
||||
function load_gps_config() {
|
||||
var next_callback = load_acc_trim;
|
||||
const nextCallBack = load_acc_trim;
|
||||
if(semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_33)) {
|
||||
MSP.send_message(MSPCodes.MSP_GPS_CONFIG, false, false, load_acc_trim);
|
||||
} else {
|
||||
next_callback();
|
||||
nextCallBack();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -82,115 +82,115 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
|
|||
}
|
||||
|
||||
function load_misc() {
|
||||
var next_callback = load_arming_config;
|
||||
const nextCallBack = load_arming_config;
|
||||
if (semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_33)) {
|
||||
MSP.send_message(MSPCodes.MSP_MISC, false, false, next_callback);
|
||||
MSP.send_message(MSPCodes.MSP_MISC, false, false, nextCallBack);
|
||||
} else {
|
||||
next_callback();
|
||||
nextCallBack();
|
||||
}
|
||||
}
|
||||
|
||||
function load_arming_config() {
|
||||
var next_callback = load_3d;
|
||||
const nextCallBack = load_3d;
|
||||
if (semver.gte(FC.CONFIG.apiVersion, "1.8.0")) {
|
||||
MSP.send_message(MSPCodes.MSP_ARMING_CONFIG, false, false, next_callback);
|
||||
MSP.send_message(MSPCodes.MSP_ARMING_CONFIG, false, false, nextCallBack);
|
||||
} else {
|
||||
next_callback();
|
||||
nextCallBack();
|
||||
}
|
||||
}
|
||||
|
||||
function load_3d() {
|
||||
var next_callback = load_rc_deadband;
|
||||
const nextCallBack = load_rc_deadband;
|
||||
if (semver.gte(FC.CONFIG.apiVersion, "1.14.0")) {
|
||||
MSP.send_message(MSPCodes.MSP_MOTOR_3D_CONFIG, false, false, next_callback);
|
||||
MSP.send_message(MSPCodes.MSP_MOTOR_3D_CONFIG, false, false, nextCallBack);
|
||||
} else {
|
||||
next_callback();
|
||||
nextCallBack();
|
||||
}
|
||||
}
|
||||
|
||||
function load_rc_deadband() {
|
||||
var next_callback = esc_protocol;
|
||||
const nextCallBack = esc_protocol;
|
||||
if (semver.gte(FC.CONFIG.apiVersion, "1.17.0")) {
|
||||
MSP.send_message(MSPCodes.MSP_RC_DEADBAND, false, false, next_callback);
|
||||
MSP.send_message(MSPCodes.MSP_RC_DEADBAND, false, false, nextCallBack);
|
||||
} else {
|
||||
next_callback();
|
||||
nextCallBack();
|
||||
}
|
||||
}
|
||||
|
||||
function esc_protocol() {
|
||||
var next_callback = sensor_config;
|
||||
const nextCallBack = sensor_config;
|
||||
if (semver.gte(FC.CONFIG.apiVersion, "1.16.0")) {
|
||||
MSP.send_message(MSPCodes.MSP_ADVANCED_CONFIG, false, false, next_callback);
|
||||
MSP.send_message(MSPCodes.MSP_ADVANCED_CONFIG, false, false, nextCallBack);
|
||||
} else {
|
||||
next_callback();
|
||||
nextCallBack();
|
||||
}
|
||||
}
|
||||
|
||||
function sensor_config() {
|
||||
var next_callback = load_sensor_alignment;
|
||||
const nextCallBack = load_sensor_alignment;
|
||||
if (semver.gte(FC.CONFIG.apiVersion, "1.16.0")) {
|
||||
MSP.send_message(MSPCodes.MSP_SENSOR_CONFIG, false, false, next_callback);
|
||||
MSP.send_message(MSPCodes.MSP_SENSOR_CONFIG, false, false, nextCallBack);
|
||||
} else {
|
||||
next_callback();
|
||||
nextCallBack();
|
||||
}
|
||||
}
|
||||
|
||||
function load_sensor_alignment() {
|
||||
var next_callback = load_name;
|
||||
const nextCallBack = load_name;
|
||||
if (semver.gte(FC.CONFIG.apiVersion, "1.15.0")) {
|
||||
MSP.send_message(MSPCodes.MSP_SENSOR_ALIGNMENT, false, false, next_callback);
|
||||
MSP.send_message(MSPCodes.MSP_SENSOR_ALIGNMENT, false, false, nextCallBack);
|
||||
} else {
|
||||
next_callback();
|
||||
nextCallBack();
|
||||
}
|
||||
}
|
||||
|
||||
function load_name() {
|
||||
var next_callback = load_rx_config;
|
||||
let nextCallBack = load_rx_config;
|
||||
|
||||
if (self.SHOW_OLD_BATTERY_CONFIG) {
|
||||
next_callback = load_battery;
|
||||
nextCallBack = load_battery;
|
||||
}
|
||||
|
||||
if (semver.gte(FC.CONFIG.apiVersion, "1.20.0")) {
|
||||
MSP.send_message(MSPCodes.MSP_NAME, false, false, next_callback);
|
||||
MSP.send_message(MSPCodes.MSP_NAME, false, false, nextCallBack);
|
||||
} else {
|
||||
next_callback();
|
||||
nextCallBack();
|
||||
}
|
||||
}
|
||||
|
||||
function load_battery() {
|
||||
var next_callback = load_current;
|
||||
const nextCallBack = load_current;
|
||||
if (semver.gte(FC.CONFIG.flightControllerVersion, "3.1.0")) {
|
||||
MSP.send_message(MSPCodes.MSP_VOLTAGE_METER_CONFIG, false, false, next_callback);
|
||||
MSP.send_message(MSPCodes.MSP_VOLTAGE_METER_CONFIG, false, false, nextCallBack);
|
||||
} else {
|
||||
next_callback();
|
||||
nextCallBack();
|
||||
}
|
||||
}
|
||||
|
||||
function load_current() {
|
||||
var next_callback = load_rx_config;
|
||||
const nextCallBack = load_rx_config;
|
||||
if (semver.gte(FC.CONFIG.flightControllerVersion, "3.1.0")) {
|
||||
MSP.send_message(MSPCodes.MSP_CURRENT_METER_CONFIG, false, false, next_callback);
|
||||
MSP.send_message(MSPCodes.MSP_CURRENT_METER_CONFIG, false, false, nextCallBack);
|
||||
} else {
|
||||
next_callback();
|
||||
nextCallBack();
|
||||
}
|
||||
}
|
||||
|
||||
function load_rx_config() {
|
||||
const next_callback = load_filter_config;
|
||||
const nextCallBack = load_filter_config;
|
||||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_31)) {
|
||||
MSP.send_message(MSPCodes.MSP_RX_CONFIG, false, false, next_callback);
|
||||
MSP.send_message(MSPCodes.MSP_RX_CONFIG, false, false, nextCallBack);
|
||||
} else {
|
||||
next_callback();
|
||||
nextCallBack();
|
||||
}
|
||||
}
|
||||
|
||||
function load_filter_config() {
|
||||
const next_callback = load_html;
|
||||
const nextCallBack = load_html;
|
||||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_42)) {
|
||||
MSP.send_message(MSPCodes.MSP_FILTER_CONFIG, false, false, next_callback);
|
||||
MSP.send_message(MSPCodes.MSP_FILTER_CONFIG, false, false, nextCallBack);
|
||||
} else {
|
||||
next_callback();
|
||||
nextCallBack();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -203,8 +203,8 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
|
|||
function process_html() {
|
||||
self.analyticsChanges = {};
|
||||
|
||||
var mixer_list_e = $('select.mixerList');
|
||||
for (var selectIndex = 0; selectIndex < mixerList.length; selectIndex++) {
|
||||
const mixer_list_e = $('select.mixerList');
|
||||
for (let selectIndex = 0; selectIndex < mixerList.length; selectIndex++) {
|
||||
mixerList.forEach(function (mixerEntry, mixerIndex) {
|
||||
if (mixerEntry.pos === selectIndex) {
|
||||
mixer_list_e.append('<option value="' + (mixerIndex + 1) + '">' + mixerEntry.name + '</option>');
|
||||
|
@ -213,18 +213,18 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
|
|||
}
|
||||
|
||||
function refreshMixerPreview() {
|
||||
var mixer = FC.MIXER_CONFIG.mixer
|
||||
var reverse = "";
|
||||
const mixer = FC.MIXER_CONFIG.mixer
|
||||
let reverse = "";
|
||||
|
||||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_36)) {
|
||||
reverse = FC.MIXER_CONFIG.reverseMotorDir ? "_reversed" : "";
|
||||
}
|
||||
|
||||
$('.mixerPreview img').attr('src', './resources/motor_order/' + mixerList[mixer - 1].image + reverse + '.svg');
|
||||
};
|
||||
}
|
||||
|
||||
var reverseMotorSwitch_e = $('#reverseMotorSwitch');
|
||||
var reverseMotor_e = $('.reverseMotor');
|
||||
const reverseMotorSwitch_e = $('#reverseMotorSwitch');
|
||||
const reverseMotor_e = $('.reverseMotor');
|
||||
|
||||
reverseMotorSwitch_e.change(function() {
|
||||
FC.MIXER_CONFIG.reverseMotorDir = $(this).prop('checked') ? 1 : 0;
|
||||
|
@ -233,9 +233,9 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
|
|||
reverseMotorSwitch_e.prop('checked', FC.MIXER_CONFIG.reverseMotorDir != 0).change();
|
||||
|
||||
mixer_list_e.change(function () {
|
||||
var mixerValue = parseInt($(this).val());
|
||||
const mixerValue = parseInt($(this).val());
|
||||
|
||||
var newValue;
|
||||
let newValue;
|
||||
if (mixerValue !== FC.MIXER_CONFIG.mixer) {
|
||||
newValue = $(this).find('option:selected').text();
|
||||
}
|
||||
|
@ -248,20 +248,20 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
|
|||
// select current mixer configuration
|
||||
mixer_list_e.val(FC.MIXER_CONFIG.mixer).change();
|
||||
|
||||
var features_e = $('.tab-configuration .features');
|
||||
const features_e = $('.tab-configuration .features');
|
||||
|
||||
FC.FEATURE_CONFIG.features.generateElements(features_e);
|
||||
|
||||
// Dshot Beeper
|
||||
var dshotBeeper_e = $('.tab-configuration .dshotbeeper');
|
||||
var dshotBeacon_e = $('.tab-configuration .dshotbeacon');
|
||||
var dshotBeeperSwitch = $('#dshotBeeperSwitch');
|
||||
var dshotBeeperBeaconTone = $('select.dshotBeeperBeaconTone');
|
||||
var dshotBeaconCondition_e = $('tbody.dshotBeaconConditions');
|
||||
var dshotBeaconSwitch_e = $('tr.dshotBeaconSwitch');
|
||||
const dshotBeeper_e = $('.tab-configuration .dshotbeeper');
|
||||
const dshotBeacon_e = $('.tab-configuration .dshotbeacon');
|
||||
const dshotBeeperSwitch = $('#dshotBeeperSwitch');
|
||||
const dshotBeeperBeaconTone = $('select.dshotBeeperBeaconTone');
|
||||
const dshotBeaconCondition_e = $('tbody.dshotBeaconConditions');
|
||||
const dshotBeaconSwitch_e = $('tr.dshotBeaconSwitch');
|
||||
|
||||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_37)) {
|
||||
for (var i = 1; i <= 5; i++) {
|
||||
for (let i = 1; i <= 5; i++) {
|
||||
dshotBeeperBeaconTone.append('<option value="' + (i) + '">'+ (i) + '</option>');
|
||||
}
|
||||
dshotBeeper_e.show();
|
||||
|
@ -275,13 +275,13 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
|
|||
|
||||
dshotBeeperBeaconTone.val(FC.BEEPER_CONFIG.dshotBeaconTone);
|
||||
|
||||
var template = $('.beepers .beeper-template');
|
||||
const template = $('.beepers .beeper-template');
|
||||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_39)) {
|
||||
dshotBeaconSwitch_e.hide();
|
||||
FC.BEEPER_CONFIG.dshotBeaconConditions.generateElements(template, dshotBeaconCondition_e);
|
||||
|
||||
$('input.condition', dshotBeaconCondition_e).change(function () {
|
||||
var element = $(this);
|
||||
const element = $(this);
|
||||
FC.BEEPER_CONFIG.dshotBeaconConditions.updateData(element);
|
||||
});
|
||||
} else {
|
||||
|
@ -303,8 +303,8 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
|
|||
}
|
||||
|
||||
// Analog Beeper
|
||||
var destination = $('.beepers .beeper-configuration');
|
||||
var beeper_e = $('.tab-configuration .beepers');
|
||||
const destination = $('.beepers .beeper-configuration');
|
||||
const beeper_e = $('.tab-configuration .beepers');
|
||||
|
||||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_36)) {
|
||||
FC.BEEPER_CONFIG.beepers.generateElements(template, destination);
|
||||
|
@ -316,7 +316,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
|
|||
// translate to user-selected language
|
||||
i18n.localizePage();
|
||||
|
||||
var alignments = [
|
||||
const alignments = [
|
||||
'CW 0°',
|
||||
'CW 90°',
|
||||
'CW 180°',
|
||||
|
@ -324,31 +324,31 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
|
|||
'CW 0° flip',
|
||||
'CW 90° flip',
|
||||
'CW 180° flip',
|
||||
'CW 270° flip'
|
||||
'CW 270° flip',
|
||||
];
|
||||
|
||||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_42)) {
|
||||
alignments.push('Custom');
|
||||
}
|
||||
|
||||
var gyro_align_content_e = $('.tab-configuration .gyro_align_content');
|
||||
var legacy_gyro_alignment_e = $('.tab-configuration .legacy_gyro_alignment');
|
||||
var legacy_accel_alignment_e = $('.tab-configuration .legacy_accel_alignment');
|
||||
const gyro_align_content_e = $('.tab-configuration .gyro_align_content');
|
||||
const legacy_gyro_alignment_e = $('.tab-configuration .legacy_gyro_alignment');
|
||||
const legacy_accel_alignment_e = $('.tab-configuration .legacy_accel_alignment');
|
||||
|
||||
var orientation_gyro_e = $('select.gyroalign');
|
||||
var orientation_acc_e = $('select.accalign');
|
||||
var orientation_mag_e = $('select.magalign');
|
||||
const orientation_gyro_e = $('select.gyroalign');
|
||||
const orientation_acc_e = $('select.accalign');
|
||||
const orientation_mag_e = $('select.magalign');
|
||||
|
||||
var orientation_gyro_to_use_e = $('select.gyro_to_use');
|
||||
var orientation_gyro_1_align_e = $('select.gyro_1_align');
|
||||
var orientation_gyro_2_align_e = $('select.gyro_2_align');
|
||||
const orientation_gyro_to_use_e = $('select.gyro_to_use');
|
||||
const orientation_gyro_1_align_e = $('select.gyro_1_align');
|
||||
const orientation_gyro_2_align_e = $('select.gyro_2_align');
|
||||
|
||||
gyro_align_content_e.hide(); // default value
|
||||
if (semver.lt(FC.CONFIG.apiVersion, "1.15.0")) {
|
||||
$('.tab-configuration .sensoralignment').hide();
|
||||
} else {
|
||||
|
||||
for (var i = 0; i < alignments.length; i++) {
|
||||
for (let i = 0; i < alignments.length; i++) {
|
||||
orientation_gyro_e.append('<option value="' + (i+1) + '">'+ alignments[i] + '</option>');
|
||||
orientation_acc_e.append('<option value="' + (i+1) + '">'+ alignments[i] + '</option>');
|
||||
orientation_mag_e.append('<option value="' + (i+1) + '">'+ alignments[i] + '</option>');
|
||||
|
@ -404,12 +404,12 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
|
|||
const GYRO_DETECTION_FLAGS = {
|
||||
DETECTED_GYRO_1: (1 << 0),
|
||||
DETECTED_GYRO_2: (1 << 1),
|
||||
DETECTED_DUAL_GYROS: (1 << 7)
|
||||
DETECTED_DUAL_GYROS: (1 << 7),
|
||||
};
|
||||
|
||||
var detected_gyro_1 = (FC.SENSOR_ALIGNMENT.gyro_detection_flags & GYRO_DETECTION_FLAGS.DETECTED_GYRO_1) != 0;
|
||||
var detected_gyro_2 = (FC.SENSOR_ALIGNMENT.gyro_detection_flags & GYRO_DETECTION_FLAGS.DETECTED_GYRO_2) != 0;
|
||||
var detected_dual_gyros = (FC.SENSOR_ALIGNMENT.gyro_detection_flags & GYRO_DETECTION_FLAGS.DETECTED_DUAL_GYROS) != 0;
|
||||
const detected_gyro_1 = (FC.SENSOR_ALIGNMENT.gyro_detection_flags & GYRO_DETECTION_FLAGS.DETECTED_GYRO_1) != 0;
|
||||
const detected_gyro_2 = (FC.SENSOR_ALIGNMENT.gyro_detection_flags & GYRO_DETECTION_FLAGS.DETECTED_GYRO_2) != 0;
|
||||
const detected_dual_gyros = (FC.SENSOR_ALIGNMENT.gyro_detection_flags & GYRO_DETECTION_FLAGS.DETECTED_DUAL_GYROS) != 0;
|
||||
|
||||
if (detected_gyro_1) {
|
||||
orientation_gyro_to_use_e.append('<option value="0">'+ i18n.getMessage('configurationSensorGyroToUseFirst') + '</option>');
|
||||
|
@ -421,7 +421,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
|
|||
orientation_gyro_to_use_e.append('<option value="2">'+ i18n.getMessage('configurationSensorGyroToUseBoth') + '</option>');
|
||||
}
|
||||
|
||||
for (var i = 0; i < alignments.length; i++) {
|
||||
for (let i = 0; i < alignments.length; i++) {
|
||||
orientation_gyro_1_align_e.append('<option value="' + (i+1) + '">'+ alignments[i] + '</option>');
|
||||
orientation_gyro_2_align_e.append('<option value="' + (i+1) + '">'+ alignments[i] + '</option>');
|
||||
}
|
||||
|
@ -466,7 +466,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
|
|||
'PWM',
|
||||
'ONESHOT125',
|
||||
'ONESHOT42',
|
||||
'MULTISHOT'
|
||||
'MULTISHOT',
|
||||
];
|
||||
|
||||
if (semver.gte(FC.CONFIG.apiVersion, "1.20.0")) {
|
||||
|
@ -491,7 +491,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
|
|||
escProtocols.push('DISABLED');
|
||||
}
|
||||
|
||||
var esc_protocol_e = $('select.escprotocol');
|
||||
const esc_protocol_e = $('select.escprotocol');
|
||||
|
||||
for (let j = 0; j < escProtocols.length; j++) {
|
||||
esc_protocol_e.append(`<option value="${j + 1}">${escProtocols[j]}</option>`);
|
||||
|
@ -519,7 +519,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
|
|||
dshotBidirectional_e.change(function () {
|
||||
let value = $(this).prop('checked');
|
||||
|
||||
var newValue = undefined;
|
||||
let newValue = undefined;
|
||||
if (value !== FC.MOTOR_CONFIG.use_dshot_telemetry) {
|
||||
newValue = value ? 'On' : 'Off';
|
||||
}
|
||||
|
@ -737,23 +737,23 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
|
|||
}
|
||||
|
||||
// generate GPS
|
||||
var gpsProtocols = [
|
||||
const gpsProtocols = [
|
||||
'NMEA',
|
||||
'UBLOX'
|
||||
'UBLOX',
|
||||
];
|
||||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_41)) {
|
||||
gpsProtocols.push('MSP');
|
||||
}
|
||||
|
||||
var gpsBaudRates = [
|
||||
const gpsBaudRates = [
|
||||
'115200',
|
||||
'57600',
|
||||
'38400',
|
||||
'19200',
|
||||
'9600'
|
||||
'9600',
|
||||
];
|
||||
|
||||
var gpsSbas = [
|
||||
const gpsSbas = [
|
||||
i18n.getMessage('gpsSbasAutoDetect'),
|
||||
i18n.getMessage('gpsSbasEuropeanEGNOS'),
|
||||
i18n.getMessage('gpsSbasNorthAmericanWAAS'),
|
||||
|
@ -849,9 +849,9 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
|
|||
});
|
||||
|
||||
serialRXSelectEl.change(function () {
|
||||
var serialRxValue = parseInt($(this).val());
|
||||
const serialRxValue = parseInt($(this).val());
|
||||
|
||||
var newValue;
|
||||
let newValue;
|
||||
if (serialRxValue !== FC.RX_CONFIG.serialrx_provider) {
|
||||
newValue = $(this).find('option:selected').text();
|
||||
}
|
||||
|
@ -864,7 +864,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
|
|||
serialRXSelectEl.val(FC.RX_CONFIG.serialrx_provider);
|
||||
|
||||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_31)) {
|
||||
var spiRxTypes = [
|
||||
const spiRxTypes = [
|
||||
'NRF24_V202_250K',
|
||||
'NRF24_V202_1M',
|
||||
'NRF24_SYMA_X',
|
||||
|
@ -873,7 +873,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
|
|||
'CX10A',
|
||||
'NRF24_H8_3D',
|
||||
'NRF24_INAV',
|
||||
'FRSKY_D'
|
||||
'FRSKY_D',
|
||||
];
|
||||
|
||||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_37)) {
|
||||
|
@ -881,7 +881,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
|
|||
'FRSKY_X',
|
||||
'A7105_FLYSKY',
|
||||
'A7105_FLYSKY_2A',
|
||||
'NRF24_KN'
|
||||
'NRF24_KN',
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -889,7 +889,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
|
|||
spiRxTypes.push(
|
||||
'SFHSS',
|
||||
'SPEKTRUM',
|
||||
'FRSKY_X_LBT'
|
||||
'FRSKY_X_LBT',
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -902,12 +902,12 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
|
|||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_44)) {
|
||||
spiRxTypes.push(
|
||||
'FRSKY_X_V2',
|
||||
'FRSKY_X_LBT_V2'
|
||||
'FRSKY_X_LBT_V2',
|
||||
);
|
||||
}
|
||||
|
||||
var spiRx_e = $('select.spiRx');
|
||||
for (var i = 0; i < spiRxTypes.length; i++) {
|
||||
const spiRx_e = $('select.spiRx');
|
||||
for (let i = 0; i < spiRxTypes.length; i++) {
|
||||
spiRx_e.append('<option value="' + i + '">' + spiRxTypes[i] + '</option>');
|
||||
}
|
||||
|
||||
|
@ -968,14 +968,14 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
|
|||
// fill battery
|
||||
if (self.SHOW_OLD_BATTERY_CONFIG) {
|
||||
if (semver.gte(FC.CONFIG.flightControllerVersion, "3.1.0")) {
|
||||
var batteryMeterTypes = [
|
||||
const batteryMeterTypes = [
|
||||
'Onboard ADC',
|
||||
'ESC Sensor'
|
||||
'ESC Sensor',
|
||||
];
|
||||
|
||||
var batteryMeterType_e = $('select.batterymetertype');
|
||||
for (i = 0; i < batteryMeterTypes.length; i++) {
|
||||
batteryMeterType_e.append('<option value="' + i + '">' + batteryMeterTypes[i] + '</option>');
|
||||
const batteryMeterType_e = $('select.batterymetertype');
|
||||
for (let i = 0; i < batteryMeterTypes.length; i++) {
|
||||
batteryMeterType_e.append(`<option value="${i}">${batteryMeterTypes[i]}</option>`);
|
||||
}
|
||||
|
||||
batteryMeterType_e.change(function () {
|
||||
|
@ -999,19 +999,19 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
|
|||
$('input[name="voltagescale"]').val(FC.MISC.vbatscale);
|
||||
|
||||
// fill current
|
||||
var currentMeterTypes = [
|
||||
const currentMeterTypes = [
|
||||
'None',
|
||||
'Onboard ADC',
|
||||
'Virtual'
|
||||
'Virtual',
|
||||
];
|
||||
|
||||
if (semver.gte(FC.CONFIG.flightControllerVersion, "3.1.0")) {
|
||||
currentMeterTypes.push('ESC Sensor');
|
||||
}
|
||||
|
||||
var currentMeterType_e = $('select.currentmetertype');
|
||||
for (i = 0; i < currentMeterTypes.length; i++) {
|
||||
currentMeterType_e.append('<option value="' + i + '">' + currentMeterTypes[i] + '</option>');
|
||||
const currentMeterType_e = $('select.currentmetertype');
|
||||
for (let i = 0; i < currentMeterTypes.length; i++) {
|
||||
currentMeterType_e.append(`<option value="${i}">${currentMeterTypes[i]}</option>`);
|
||||
}
|
||||
|
||||
currentMeterType_e.change(function () {
|
||||
|
@ -1118,7 +1118,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
|
|||
}
|
||||
|
||||
$('input.feature', features_e).change(function () {
|
||||
var element = $(this);
|
||||
const element = $(this);
|
||||
|
||||
FC.FEATURE_CONFIG.features.updateData(element);
|
||||
updateTabList(FC.FEATURE_CONFIG.features);
|
||||
|
@ -1138,7 +1138,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
|
|||
if (self.SHOW_OLD_BATTERY_CONFIG) {
|
||||
checkUpdateCurrentControls();
|
||||
}
|
||||
|
||||
break;
|
||||
case 'GPS':
|
||||
checkUpdateGpsControls();
|
||||
break;
|
||||
|
@ -1154,30 +1154,25 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
|
|||
|
||||
$('input[id="accHardwareSwitch"]').change(function() {
|
||||
if(semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_37)) {
|
||||
var checked = $(this).is(':checked');
|
||||
const checked = $(this).is(':checked');
|
||||
$('.accelNeeded').toggle(checked);
|
||||
}
|
||||
}).change();
|
||||
|
||||
$(features_e).filter('select').change(function () {
|
||||
var element = $(this);
|
||||
const element = $(this);
|
||||
|
||||
FC.FEATURE_CONFIG.features.updateData(element);
|
||||
updateTabList(FC.FEATURE_CONFIG.features);
|
||||
|
||||
switch (element.attr('name')) {
|
||||
case 'rxMode':
|
||||
if (element.attr('name') === 'rxMode') {
|
||||
checkShowSerialRxBox();
|
||||
checkShowSpiRxBox();
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
$('input.condition', beeper_e).change(function () {
|
||||
var element = $(this);
|
||||
const element = $(this);
|
||||
FC.BEEPER_CONFIG.beepers.updateData(element);
|
||||
});
|
||||
|
||||
|
@ -1267,49 +1262,49 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
|
|||
self.analyticsChanges = {};
|
||||
|
||||
function save_serial_config() {
|
||||
var next_callback = save_feature_config;
|
||||
mspHelper.sendSerialConfig(next_callback);
|
||||
const nextCallBack = save_feature_config;
|
||||
mspHelper.sendSerialConfig(nextCallBack);
|
||||
}
|
||||
|
||||
function save_feature_config() {
|
||||
var next_callback = save_beeper_config;
|
||||
MSP.send_message(MSPCodes.MSP_SET_FEATURE_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_FEATURE_CONFIG), false, next_callback);
|
||||
const nextCallBack = save_beeper_config;
|
||||
MSP.send_message(MSPCodes.MSP_SET_FEATURE_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_FEATURE_CONFIG), false, nextCallBack);
|
||||
}
|
||||
|
||||
function save_beeper_config() {
|
||||
var next_callback = save_misc;
|
||||
const nextCallBack = save_misc;
|
||||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_36)) {
|
||||
MSP.send_message(MSPCodes.MSP_SET_BEEPER_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_BEEPER_CONFIG), false, next_callback);
|
||||
MSP.send_message(MSPCodes.MSP_SET_BEEPER_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_BEEPER_CONFIG), false, nextCallBack);
|
||||
} else {
|
||||
next_callback();
|
||||
nextCallBack();
|
||||
}
|
||||
}
|
||||
|
||||
function save_misc() {
|
||||
var next_callback = save_mixer_config;
|
||||
const nextCallBack = save_mixer_config;
|
||||
if(semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_33)) {
|
||||
MSP.send_message(MSPCodes.MSP_SET_MISC, mspHelper.crunch(MSPCodes.MSP_SET_MISC), false, next_callback);
|
||||
MSP.send_message(MSPCodes.MSP_SET_MISC, mspHelper.crunch(MSPCodes.MSP_SET_MISC), false, nextCallBack);
|
||||
} else {
|
||||
next_callback();
|
||||
nextCallBack();
|
||||
}
|
||||
}
|
||||
|
||||
function save_mixer_config() {
|
||||
var next_callback = save_board_alignment_config;
|
||||
MSP.send_message(MSPCodes.MSP_SET_MIXER_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_MIXER_CONFIG), false, next_callback);
|
||||
const nextCallBack = save_board_alignment_config;
|
||||
MSP.send_message(MSPCodes.MSP_SET_MIXER_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_MIXER_CONFIG), false, nextCallBack);
|
||||
}
|
||||
|
||||
function save_board_alignment_config() {
|
||||
var next_callback = save_motor_config;
|
||||
MSP.send_message(MSPCodes.MSP_SET_BOARD_ALIGNMENT_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_BOARD_ALIGNMENT_CONFIG), false, next_callback);
|
||||
const nextCallBack = save_motor_config;
|
||||
MSP.send_message(MSPCodes.MSP_SET_BOARD_ALIGNMENT_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_BOARD_ALIGNMENT_CONFIG), false, nextCallBack);
|
||||
}
|
||||
|
||||
function save_motor_config() {
|
||||
var next_callback = save_gps_config;
|
||||
const nextCallBack = save_gps_config;
|
||||
if(semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_33)) {
|
||||
MSP.send_message(MSPCodes.MSP_SET_MOTOR_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_MOTOR_CONFIG), false, next_callback);
|
||||
MSP.send_message(MSPCodes.MSP_SET_MOTOR_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_MOTOR_CONFIG), false, nextCallBack);
|
||||
} else {
|
||||
next_callback();
|
||||
nextCallBack();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1319,36 +1314,36 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
|
|||
FC.GPS_CONFIG.auto_config = $('input[name="gps_auto_config"]').is(':checked') ? 1 : 0;
|
||||
}
|
||||
|
||||
var next_callback = save_motor_3d_config;
|
||||
const nextCallBack = save_motor_3d_config;
|
||||
if(semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_33)) {
|
||||
MSP.send_message(MSPCodes.MSP_SET_GPS_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_GPS_CONFIG), false, next_callback);
|
||||
MSP.send_message(MSPCodes.MSP_SET_GPS_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_GPS_CONFIG), false, nextCallBack);
|
||||
} else {
|
||||
next_callback();
|
||||
nextCallBack();
|
||||
}
|
||||
}
|
||||
|
||||
function save_motor_3d_config() {
|
||||
var next_callback = save_rc_deadband;
|
||||
MSP.send_message(MSPCodes.MSP_SET_MOTOR_3D_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_MOTOR_3D_CONFIG), false, next_callback);
|
||||
const nextCallBack = save_rc_deadband;
|
||||
MSP.send_message(MSPCodes.MSP_SET_MOTOR_3D_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_MOTOR_3D_CONFIG), false, nextCallBack);
|
||||
}
|
||||
|
||||
function save_rc_deadband() {
|
||||
var next_callback = save_sensor_alignment;
|
||||
MSP.send_message(MSPCodes.MSP_SET_RC_DEADBAND, mspHelper.crunch(MSPCodes.MSP_SET_RC_DEADBAND), false, next_callback);
|
||||
const nextCallBack = save_sensor_alignment;
|
||||
MSP.send_message(MSPCodes.MSP_SET_RC_DEADBAND, mspHelper.crunch(MSPCodes.MSP_SET_RC_DEADBAND), false, nextCallBack);
|
||||
}
|
||||
|
||||
function save_sensor_alignment() {
|
||||
var next_callback = save_esc_protocol;
|
||||
MSP.send_message(MSPCodes.MSP_SET_SENSOR_ALIGNMENT, mspHelper.crunch(MSPCodes.MSP_SET_SENSOR_ALIGNMENT), false, next_callback);
|
||||
const nextCallBack = save_esc_protocol;
|
||||
MSP.send_message(MSPCodes.MSP_SET_SENSOR_ALIGNMENT, mspHelper.crunch(MSPCodes.MSP_SET_SENSOR_ALIGNMENT), false, nextCallBack);
|
||||
}
|
||||
function save_esc_protocol() {
|
||||
var next_callback = save_acc_trim;
|
||||
MSP.send_message(MSPCodes.MSP_SET_ADVANCED_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_ADVANCED_CONFIG), false, next_callback);
|
||||
const nextCallBack = save_acc_trim;
|
||||
MSP.send_message(MSPCodes.MSP_SET_ADVANCED_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_ADVANCED_CONFIG), false, nextCallBack);
|
||||
}
|
||||
|
||||
function save_acc_trim() {
|
||||
var next_callback = save_arming_config;
|
||||
MSP.send_message(MSPCodes.MSP_SET_ACC_TRIM, mspHelper.crunch(MSPCodes.MSP_SET_ACC_TRIM), false, next_callback);
|
||||
const nextCallBack = save_arming_config;
|
||||
MSP.send_message(MSPCodes.MSP_SET_ACC_TRIM, mspHelper.crunch(MSPCodes.MSP_SET_ACC_TRIM), false, nextCallBack);
|
||||
}
|
||||
|
||||
function save_arming_config() {
|
||||
|
@ -1360,54 +1355,54 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
|
|||
FC.SENSOR_CONFIG.baro_hardware = $('input[id="baroHardwareSwitch"]').is(':checked') ? 0 : 1;
|
||||
FC.SENSOR_CONFIG.mag_hardware = $('input[id="magHardwareSwitch"]').is(':checked') ? 0 : 1;
|
||||
|
||||
var next_callback = save_name;
|
||||
MSP.send_message(MSPCodes.MSP_SET_SENSOR_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_SENSOR_CONFIG), false, next_callback);
|
||||
const nextCallBack = save_name;
|
||||
MSP.send_message(MSPCodes.MSP_SET_SENSOR_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_SENSOR_CONFIG), false, nextCallBack);
|
||||
}
|
||||
|
||||
function save_name() {
|
||||
var next_callback = save_rx_config;
|
||||
let nextCallBack = save_rx_config;
|
||||
|
||||
if(self.SHOW_OLD_BATTERY_CONFIG) {
|
||||
next_callback = save_battery;
|
||||
nextCallBack = save_battery;
|
||||
}
|
||||
|
||||
FC.CONFIG.name = $.trim($('input[name="craftName"]').val());
|
||||
MSP.send_message(MSPCodes.MSP_SET_NAME, mspHelper.crunch(MSPCodes.MSP_SET_NAME), false, next_callback);
|
||||
MSP.send_message(MSPCodes.MSP_SET_NAME, mspHelper.crunch(MSPCodes.MSP_SET_NAME), false, nextCallBack);
|
||||
}
|
||||
|
||||
function save_battery() {
|
||||
var next_callback = save_current;
|
||||
const nextCallBack = save_current;
|
||||
if (semver.gte(FC.CONFIG.flightControllerVersion, "3.1.0")) {
|
||||
MSP.send_message(MSPCodes.MSP_SET_VOLTAGE_METER_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_VOLTAGE_METER_CONFIG), false, next_callback);
|
||||
MSP.send_message(MSPCodes.MSP_SET_VOLTAGE_METER_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_VOLTAGE_METER_CONFIG), false, nextCallBack);
|
||||
} else {
|
||||
next_callback();
|
||||
nextCallBack();
|
||||
}
|
||||
}
|
||||
|
||||
function save_current() {
|
||||
var next_callback = save_rx_config;
|
||||
const nextCallBack = save_rx_config;
|
||||
if (semver.gte(FC.CONFIG.flightControllerVersion, "3.1.0")) {
|
||||
MSP.send_message(MSPCodes.MSP_SET_CURRENT_METER_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_CURRENT_METER_CONFIG), false, next_callback);
|
||||
MSP.send_message(MSPCodes.MSP_SET_CURRENT_METER_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_CURRENT_METER_CONFIG), false, nextCallBack);
|
||||
} else {
|
||||
next_callback();
|
||||
nextCallBack();
|
||||
}
|
||||
}
|
||||
|
||||
function save_rx_config() {
|
||||
const next_callback = save_filter_config;
|
||||
const nextCallBack = save_filter_config;
|
||||
if (semver.gte(FC.CONFIG.apiVersion, "1.20.0")) {
|
||||
MSP.send_message(MSPCodes.MSP_SET_RX_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_RX_CONFIG), false, next_callback);
|
||||
MSP.send_message(MSPCodes.MSP_SET_RX_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_RX_CONFIG), false, nextCallBack);
|
||||
} else {
|
||||
next_callback();
|
||||
nextCallBack();
|
||||
}
|
||||
}
|
||||
|
||||
function save_filter_config() {
|
||||
const next_callback = save_to_eeprom;
|
||||
const nextCallBack = save_to_eeprom;
|
||||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_42)) {
|
||||
MSP.send_message(MSPCodes.MSP_SET_FILTER_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_FILTER_CONFIG), false, next_callback);
|
||||
MSP.send_message(MSPCodes.MSP_SET_FILTER_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_FILTER_CONFIG), false, nextCallBack);
|
||||
} else {
|
||||
next_callback();
|
||||
nextCallBack();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ TABS.motors = {
|
|||
};
|
||||
|
||||
TABS.motors.initialize = function (callback) {
|
||||
var self = this;
|
||||
const self = this;
|
||||
|
||||
self.armed = false;
|
||||
self.escProtocolIsDshot = false;
|
||||
|
@ -98,15 +98,15 @@ TABS.motors.initialize = function (callback) {
|
|||
}
|
||||
|
||||
function initSensorData() {
|
||||
for (var i = 0; i < 3; i++) {
|
||||
for (let i = 0; i < 3; i++) {
|
||||
FC.SENSOR_DATA.accelerometer[i] = 0;
|
||||
FC.SENSOR_DATA.gyroscope[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
function initDataArray(length) {
|
||||
var data = new Array(length);
|
||||
for (var i = 0; i < length; i++) {
|
||||
const data = new Array(length);
|
||||
for (let i = 0; i < length; i++) {
|
||||
data[i] = [];
|
||||
data[i].min = -1;
|
||||
data[i].max = 1;
|
||||
|
@ -115,8 +115,8 @@ TABS.motors.initialize = function (callback) {
|
|||
}
|
||||
|
||||
function addSampleToData(data, sampleNumber, sensorData) {
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var dataPoint = sensorData[i];
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
const dataPoint = sensorData[i];
|
||||
data[i].push([sampleNumber, dataPoint]);
|
||||
if (dataPoint < data[i].min) {
|
||||
data[i].min = dataPoint;
|
||||
|
@ -126,14 +126,14 @@ TABS.motors.initialize = function (callback) {
|
|||
}
|
||||
}
|
||||
while (data[0].length > 300) {
|
||||
for (i = 0; i < data.length; i++) {
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
data[i].shift();
|
||||
}
|
||||
}
|
||||
return sampleNumber + 1;
|
||||
}
|
||||
|
||||
var margin = {top: 20, right: 30, bottom: 10, left: 20};
|
||||
const margin = {top: 20, right: 30, bottom: 10, left: 20};
|
||||
function updateGraphHelperSize(helpers) {
|
||||
helpers.width = helpers.targetElement.width() - margin.left - margin.right;
|
||||
helpers.height = helpers.targetElement.height() - margin.top - margin.bottom;
|
||||
|
@ -146,15 +146,15 @@ TABS.motors.initialize = function (callback) {
|
|||
}
|
||||
|
||||
function initGraphHelpers(selector, sampleNumber, heightDomain) {
|
||||
var helpers = {selector: selector, targetElement: $(selector), dynamicHeightDomain: !heightDomain};
|
||||
const helpers = {selector: selector, targetElement: $(selector), dynamicHeightDomain: !heightDomain};
|
||||
|
||||
helpers.widthScale = d3.scale.linear()
|
||||
.clamp(true)
|
||||
.domain([(sampleNumber - 299), sampleNumber]);
|
||||
.clamp(true)
|
||||
.domain([(sampleNumber - 299), sampleNumber]);
|
||||
|
||||
helpers.heightScale = d3.scale.linear()
|
||||
.clamp(true)
|
||||
.domain(heightDomain || [1, -1]);
|
||||
.clamp(true)
|
||||
.domain(heightDomain || [1, -1]);
|
||||
|
||||
helpers.xGrid = d3.svg.axis();
|
||||
helpers.yGrid = d3.svg.axis();
|
||||
|
@ -162,42 +162,41 @@ TABS.motors.initialize = function (callback) {
|
|||
updateGraphHelperSize(helpers);
|
||||
|
||||
helpers.xGrid
|
||||
.scale(helpers.widthScale)
|
||||
.orient("bottom")
|
||||
.ticks(5)
|
||||
.tickFormat("");
|
||||
.scale(helpers.widthScale)
|
||||
.orient("bottom")
|
||||
.ticks(5)
|
||||
.tickFormat("");
|
||||
|
||||
helpers.yGrid
|
||||
.scale(helpers.heightScale)
|
||||
.orient("left")
|
||||
.ticks(5)
|
||||
.tickFormat("");
|
||||
|
||||
.scale(helpers.heightScale)
|
||||
.orient("left")
|
||||
.ticks(5)
|
||||
.tickFormat("");
|
||||
helpers.xAxis = d3.svg.axis()
|
||||
.scale(helpers.widthScale)
|
||||
.ticks(5)
|
||||
.orient("bottom")
|
||||
.tickFormat(function (d) {return d;});
|
||||
.scale(helpers.widthScale)
|
||||
.ticks(5)
|
||||
.orient("bottom")
|
||||
.tickFormat(function (d) {return d;});
|
||||
|
||||
helpers.yAxis = d3.svg.axis()
|
||||
.scale(helpers.heightScale)
|
||||
.ticks(5)
|
||||
.orient("left")
|
||||
.tickFormat(function (d) {return d;});
|
||||
.scale(helpers.heightScale)
|
||||
.ticks(5)
|
||||
.orient("left")
|
||||
.tickFormat(function (d) {return d;});
|
||||
|
||||
helpers.line = d3.svg.line()
|
||||
.x(function (d) { return helpers.widthScale(d[0]); })
|
||||
.y(function (d) { return helpers.heightScale(d[1]); });
|
||||
.x(function (d) { return helpers.widthScale(d[0]); })
|
||||
.y(function (d) { return helpers.heightScale(d[1]); });
|
||||
|
||||
return helpers;
|
||||
}
|
||||
|
||||
function drawGraph(graphHelpers, data, sampleNumber) {
|
||||
|
||||
var svg = d3.select(graphHelpers.selector);
|
||||
const svg = d3.select(graphHelpers.selector);
|
||||
|
||||
if (graphHelpers.dynamicHeightDomain) {
|
||||
var limits = [];
|
||||
const limits = [];
|
||||
$.each(data, function (idx, datum) {
|
||||
limits.push(datum.min);
|
||||
limits.push(datum.max);
|
||||
|
@ -211,15 +210,17 @@ TABS.motors.initialize = function (callback) {
|
|||
svg.select(".x.axis").call(graphHelpers.xAxis);
|
||||
svg.select(".y.axis").call(graphHelpers.yAxis);
|
||||
|
||||
var group = svg.select("g.data");
|
||||
var lines = group.selectAll("path").data(data, function (d, i) {return i;});
|
||||
const group = svg.select("g.data");
|
||||
const lines = group.selectAll("path").data(data, function (d, i) {
|
||||
return i;
|
||||
});
|
||||
|
||||
lines.enter().append("path").attr("class", "line");
|
||||
lines.attr('d', graphHelpers.line);
|
||||
}
|
||||
|
||||
function update_model(mixer) {
|
||||
var reverse = "";
|
||||
let reverse = "";
|
||||
|
||||
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_36)) {
|
||||
reverse = FC.MIXER_CONFIG.reverseMotorDir ? "_reversed" : "";
|
||||
|
@ -266,25 +267,25 @@ TABS.motors.initialize = function (callback) {
|
|||
initSensorData();
|
||||
|
||||
// Setup variables
|
||||
var samples_gyro_i = 0,
|
||||
gyro_data = initDataArray(3),
|
||||
gyro_helpers = initGraphHelpers('#graph', samples_gyro_i, [-2, 2]),
|
||||
gyro_max_read = [0, 0, 0];
|
||||
let samplesGyro = 0;
|
||||
const gyroData = initDataArray(3);
|
||||
let gyroHelpers = initGraphHelpers('#graph', samplesGyro, [-2, 2]);
|
||||
let gyroMaxRead = [0, 0, 0];
|
||||
|
||||
var samples_accel_i = 0,
|
||||
accel_data = initDataArray(3),
|
||||
accel_helpers = initGraphHelpers('#graph', samples_accel_i, [-2, 2]),
|
||||
accel_max_read = [0, 0, 0],
|
||||
accel_offset = [0, 0, 0],
|
||||
accel_offset_established = false;
|
||||
let samplesAccel = 0;
|
||||
const accelData = initDataArray(3);
|
||||
let accelHelpers = initGraphHelpers('#graph', samplesAccel, [-2, 2]);
|
||||
let accelMaxRead = [0, 0, 0];
|
||||
const accelOffset = [0, 0, 0];
|
||||
let accelOffsetEstablished = false;
|
||||
|
||||
// cached elements
|
||||
var motor_voltage_e = $('.motors-bat-voltage'),
|
||||
const motorVoltage = $('.motors-bat-voltage'),
|
||||
motor_mah_drawing_e = $('.motors-bat-mah-drawing'),
|
||||
motor_mah_drawn_e = $('.motors-bat-mah-drawn');
|
||||
|
||||
|
||||
var raw_data_text_ements = {
|
||||
const rawDataTextElements = {
|
||||
x: [],
|
||||
y: [],
|
||||
z: [],
|
||||
|
@ -292,15 +293,15 @@ TABS.motors.initialize = function (callback) {
|
|||
};
|
||||
|
||||
$('.plot_control .x, .plot_control .y, .plot_control .z, .plot_control .rms').each(function () {
|
||||
var el = $(this);
|
||||
const el = $(this);
|
||||
if (el.hasClass('x')) {
|
||||
raw_data_text_ements.x.push(el);
|
||||
rawDataTextElements.x.push(el);
|
||||
} else if (el.hasClass('y')) {
|
||||
raw_data_text_ements.y.push(el);
|
||||
rawDataTextElements.y.push(el);
|
||||
} else if (el.hasClass('z')) {
|
||||
raw_data_text_ements.z.push(el);
|
||||
rawDataTextElements.z.push(el);
|
||||
} else if (el.hasClass('rms')) {
|
||||
raw_data_text_ements.rms.push(el);
|
||||
rawDataTextElements.rms.push(el);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -339,8 +340,8 @@ TABS.motors.initialize = function (callback) {
|
|||
});
|
||||
|
||||
$('.tab-motors .rate select, .tab-motors .scale select').change(function () {
|
||||
var rate = parseInt($('.tab-motors select[name="rate"]').val(), 10);
|
||||
var scale = parseFloat($('.tab-motors select[name="scale"]').val());
|
||||
const rate = parseInt($('.tab-motors select[name="rate"]').val(), 10);
|
||||
const scale = parseFloat($('.tab-motors select[name="scale"]').val());
|
||||
|
||||
GUI.interval_kill_all(['motor_and_status_pull','motors_power_data_pull_slow']);
|
||||
|
||||
|
@ -350,7 +351,7 @@ TABS.motors.initialize = function (callback) {
|
|||
TABS.motors.sensorGyroRate = rate;
|
||||
TABS.motors.sensorGyroScale = scale;
|
||||
|
||||
gyro_helpers = initGraphHelpers('#graph', samples_gyro_i, [-scale, scale]);
|
||||
gyroHelpers = initGraphHelpers('#graph', samplesGyro, [-scale, scale]);
|
||||
|
||||
GUI.interval_add('IMU_pull', function imu_data_pull() {
|
||||
MSP.send_message(MSPCodes.MSP_RAW_IMU, false, false, update_gyro_graph);
|
||||
|
@ -360,7 +361,7 @@ TABS.motors.initialize = function (callback) {
|
|||
ConfigStorage.set({'motors_tab_accel_settings': {'rate': rate, 'scale': scale}});
|
||||
TABS.motors.sensorAccelRate = rate;
|
||||
TABS.motors.sensorAccelScale = scale;
|
||||
accel_helpers = initGraphHelpers('#graph', samples_accel_i, [-scale, scale]);
|
||||
accelHelpers = initGraphHelpers('#graph', samplesAccel, [-scale, scale]);
|
||||
|
||||
GUI.interval_add('IMU_pull', function imu_data_pull() {
|
||||
MSP.send_message(MSPCodes.MSP_RAW_IMU, false, false, update_accel_graph);
|
||||
|
@ -369,59 +370,63 @@ TABS.motors.initialize = function (callback) {
|
|||
}
|
||||
|
||||
function update_accel_graph() {
|
||||
if (!accel_offset_established) {
|
||||
for (var i = 0; i < 3; i++) {
|
||||
accel_offset[i] = FC.SENSOR_DATA.accelerometer[i] * -1;
|
||||
if (!accelOffsetEstablished) {
|
||||
for (let i = 0; i < 3; i++) {
|
||||
accelOffset[i] = FC.SENSOR_DATA.accelerometer[i] * -1;
|
||||
}
|
||||
|
||||
accel_offset_established = true;
|
||||
accelOffsetEstablished = true;
|
||||
}
|
||||
|
||||
var accel_with_offset = [
|
||||
accel_offset[0] + FC.SENSOR_DATA.accelerometer[0],
|
||||
accel_offset[1] + FC.SENSOR_DATA.accelerometer[1],
|
||||
accel_offset[2] + FC.SENSOR_DATA.accelerometer[2]
|
||||
const accelWithOffset = [
|
||||
accelOffset[0] + FC.SENSOR_DATA.accelerometer[0],
|
||||
accelOffset[1] + FC.SENSOR_DATA.accelerometer[1],
|
||||
accelOffset[2] + FC.SENSOR_DATA.accelerometer[2],
|
||||
];
|
||||
|
||||
updateGraphHelperSize(accel_helpers);
|
||||
samples_accel_i = addSampleToData(accel_data, samples_accel_i, accel_with_offset);
|
||||
drawGraph(accel_helpers, accel_data, samples_accel_i);
|
||||
for (var i = 0; i < 3; i++) {
|
||||
if (Math.abs(accel_with_offset[i]) > Math.abs(accel_max_read[i])) accel_max_read[i] = accel_with_offset[i];
|
||||
updateGraphHelperSize(accelHelpers);
|
||||
samplesAccel = addSampleToData(accelData, samplesAccel, accelWithOffset);
|
||||
drawGraph(accelHelpers, accelData, samplesAccel);
|
||||
for (let i = 0; i < 3; i++) {
|
||||
if (Math.abs(accelWithOffset[i]) > Math.abs(accelMaxRead[i])) {
|
||||
accelMaxRead[i] = accelWithOffset[i];
|
||||
}
|
||||
}
|
||||
computeAndUpdate(accel_with_offset, accel_data, accel_max_read);
|
||||
computeAndUpdate(accelWithOffset, accelData, accelMaxRead);
|
||||
|
||||
}
|
||||
|
||||
function update_gyro_graph() {
|
||||
var gyro = [
|
||||
const gyro = [
|
||||
FC.SENSOR_DATA.gyroscope[0],
|
||||
FC.SENSOR_DATA.gyroscope[1],
|
||||
FC.SENSOR_DATA.gyroscope[2]
|
||||
];
|
||||
];
|
||||
|
||||
updateGraphHelperSize(gyro_helpers);
|
||||
samples_gyro_i = addSampleToData(gyro_data, samples_gyro_i, gyro);
|
||||
drawGraph(gyro_helpers, gyro_data, samples_gyro_i);
|
||||
for (var i = 0; i < 3; i++) {
|
||||
if (Math.abs(gyro[i]) > Math.abs(gyro_max_read[i])) gyro_max_read[i] = gyro[i];
|
||||
updateGraphHelperSize(gyroHelpers);
|
||||
samplesGyro = addSampleToData(gyroData, samplesGyro, gyro);
|
||||
drawGraph(gyroHelpers, gyroData, samplesGyro);
|
||||
for (let i = 0; i < 3; i++) {
|
||||
if (Math.abs(gyro[i]) > Math.abs(gyroMaxRead[i])) {
|
||||
gyroMaxRead[i] = gyro[i];
|
||||
}
|
||||
}
|
||||
computeAndUpdate(gyro, gyro_data, gyro_max_read);
|
||||
computeAndUpdate(gyro, gyroData, gyroMaxRead);
|
||||
}
|
||||
|
||||
function computeAndUpdate(sensor_data, data, max_read) {
|
||||
var sum = 0.0;
|
||||
for (var j = 0, jlength = data.length; j < jlength; j++) {
|
||||
for (var k = 0, klength = data[j].length; k < klength; k++){
|
||||
let sum = 0.0;
|
||||
for (let j = 0, jlength = data.length; j < jlength; j++) {
|
||||
for (let k = 0, klength = data[j].length; k < klength; k++){
|
||||
sum += data[j][k][1]*data[j][k][1];
|
||||
}
|
||||
}
|
||||
var rms = Math.sqrt(sum/(data[0].length+data[1].length+data[2].length));
|
||||
const rms = Math.sqrt(sum/(data[0].length+data[1].length+data[2].length));
|
||||
|
||||
raw_data_text_ements.x[0].text(sensor_data[0].toFixed(2) + ' (' + max_read[0].toFixed(2) + ')');
|
||||
raw_data_text_ements.y[0].text(sensor_data[1].toFixed(2) + ' (' + max_read[1].toFixed(2) + ')');
|
||||
raw_data_text_ements.z[0].text(sensor_data[2].toFixed(2) + ' (' + max_read[2].toFixed(2) + ')');
|
||||
raw_data_text_ements.rms[0].text(rms.toFixed(4));
|
||||
rawDataTextElements.x[0].text(`${sensor_data[0].toFixed(2)} ( ${max_read[0].toFixed(2)} )`);
|
||||
rawDataTextElements.y[0].text(`${sensor_data[1].toFixed(2)} ( ${max_read[1].toFixed(2)} )`);
|
||||
rawDataTextElements.z[0].text(`${sensor_data[2].toFixed(2)} ( ${max_read[2].toFixed(2)} )`);
|
||||
rawDataTextElements.rms[0].text(rms.toFixed(4));
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -429,7 +434,6 @@ TABS.motors.initialize = function (callback) {
|
|||
// set refresh speeds according to configuration saved in storage
|
||||
ConfigStorage.get(['motors_tab_sensor_settings', 'motors_tab_gyro_settings', 'motors_tab_accel_settings'], function (result) {
|
||||
if (result.motors_tab_sensor_settings) {
|
||||
var sensor = result.motors_tab_sensor_settings.sensor;
|
||||
$('.tab-motors select[name="sensor_choice"]').val(result.motors_tab_sensor_settings.sensor);
|
||||
}
|
||||
|
||||
|
@ -448,7 +452,7 @@ TABS.motors.initialize = function (callback) {
|
|||
|
||||
// Amperage
|
||||
function power_data_pull() {
|
||||
motor_voltage_e.text(i18n.getMessage('motorsVoltageValue', [FC.ANALOG.voltage]));
|
||||
motorVoltage.text(i18n.getMessage('motorsVoltageValue', [FC.ANALOG.voltage]));
|
||||
motor_mah_drawing_e.text(i18n.getMessage('motorsADrawingValue', [FC.ANALOG.amperage.toFixed(2)]));
|
||||
motor_mah_drawn_e.text(i18n.getMessage('motorsmAhDrawnValue', [FC.ANALOG.mAhdrawn]));
|
||||
|
||||
|
@ -456,15 +460,15 @@ TABS.motors.initialize = function (callback) {
|
|||
GUI.interval_add('motors_power_data_pull_slow', power_data_pull, 250, true); // 4 fps
|
||||
|
||||
$('a.reset_max').click(function () {
|
||||
gyro_max_read = [0, 0, 0];
|
||||
accel_max_read = [0, 0, 0];
|
||||
accel_offset_established = false;
|
||||
gyroMaxRead = [0, 0, 0];
|
||||
accelMaxRead = [0, 0, 0];
|
||||
accelOffsetEstablished = false;
|
||||
});
|
||||
|
||||
var number_of_valid_outputs = (FC.MOTOR_DATA.indexOf(0) > -1) ? FC.MOTOR_DATA.indexOf(0) : 8;
|
||||
var rangeMin;
|
||||
var rangeMax;
|
||||
var neutral3d;
|
||||
const numberOfValidOutputs = (FC.MOTOR_DATA.indexOf(0) > -1) ? FC.MOTOR_DATA.indexOf(0) : 8;
|
||||
let rangeMin;
|
||||
let rangeMax;
|
||||
let neutral3d;
|
||||
if (self.escProtocolIsDshot) {
|
||||
rangeMin = self.DSHOT_DISARMED_VALUE;
|
||||
rangeMax = self.DSHOT_MAX_VALUE;
|
||||
|
@ -477,12 +481,12 @@ TABS.motors.initialize = function (callback) {
|
|||
neutral3d = (FC.MOTOR_3D_CONFIG.neutral > 1575 || FC.MOTOR_3D_CONFIG.neutral < 1425) ? 1500 : FC.MOTOR_3D_CONFIG.neutral;
|
||||
}
|
||||
|
||||
var motors_wrapper = $('.motors .bar-wrapper'),
|
||||
const motorsWrapper = $('.motors .bar-wrapper'),
|
||||
servos_wrapper = $('.servos .bar-wrapper');
|
||||
|
||||
for (var i = 0; i < 8; i++) {
|
||||
motors_wrapper.append('\
|
||||
<div class="m-block motor-' + i + '">\
|
||||
for (let i = 0; i < 8; i++) {
|
||||
motorsWrapper.append(`\
|
||||
<div class="m-block motor-${i}">\
|
||||
<div class="meter-bar">\
|
||||
<div class="label"></div>\
|
||||
<div class="indicator">\
|
||||
|
@ -492,7 +496,7 @@ TABS.motors.initialize = function (callback) {
|
|||
</div>\
|
||||
</div>\
|
||||
</div>\
|
||||
');
|
||||
`);
|
||||
|
||||
servos_wrapper.append('\
|
||||
<div class="m-block servo-' + (7 - i) + '">\
|
||||
|
@ -524,7 +528,7 @@ TABS.motors.initialize = function (callback) {
|
|||
|
||||
function setSlidersEnabled(isEnabled) {
|
||||
if (isEnabled && !self.armed) {
|
||||
$('div.sliders input').slice(0, number_of_valid_outputs).prop('disabled', false);
|
||||
$('div.sliders input').slice(0, numberOfValidOutputs).prop('disabled', false);
|
||||
|
||||
// unlock master slider
|
||||
$('div.sliders input:last').prop('disabled', false);
|
||||
|
@ -541,7 +545,7 @@ TABS.motors.initialize = function (callback) {
|
|||
setSlidersDefault();
|
||||
|
||||
$('#motorsEnableTestMode').change(function () {
|
||||
var enabled = $(this).is(':checked');
|
||||
const enabled = $(this).is(':checked');
|
||||
|
||||
setSlidersEnabled(enabled);
|
||||
|
||||
|
@ -550,70 +554,70 @@ TABS.motors.initialize = function (callback) {
|
|||
mspHelper.setArmingEnabled(enabled, enabled);
|
||||
}).change();
|
||||
|
||||
var buffering_set_motor = [],
|
||||
let bufferingSetMotor = [],
|
||||
buffer_delay = false;
|
||||
$('div.sliders input:not(.master)').on('input', function () {
|
||||
var index = $(this).index(),
|
||||
buffer = [];
|
||||
const index = $(this).index();
|
||||
let buffer = [];
|
||||
|
||||
$('div.values li').eq(index).text($(this).val());
|
||||
|
||||
for (var i = 0; i < 8; i++) {
|
||||
var val = parseInt($('div.sliders input').eq(i).val());
|
||||
for (let i = 0; i < 8; i++) {
|
||||
const val = parseInt($('div.sliders input').eq(i).val());
|
||||
buffer.push16(val);
|
||||
}
|
||||
|
||||
buffering_set_motor.push(buffer);
|
||||
bufferingSetMotor.push(buffer);
|
||||
|
||||
if (!buffer_delay) {
|
||||
buffer_delay = setTimeout(function () {
|
||||
buffer = buffering_set_motor.pop();
|
||||
buffer = bufferingSetMotor.pop();
|
||||
|
||||
MSP.send_message(MSPCodes.MSP_SET_MOTOR, buffer);
|
||||
|
||||
buffering_set_motor = [];
|
||||
bufferingSetMotor = [];
|
||||
buffer_delay = false;
|
||||
}, 10);
|
||||
}
|
||||
});
|
||||
|
||||
$('div.sliders input.master').on('input', function () {
|
||||
var val = $(this).val();
|
||||
const val = $(this).val();
|
||||
|
||||
$('div.sliders input:not(:disabled, :last)').val(val);
|
||||
$('div.values li:not(:last)').slice(0, number_of_valid_outputs).text(val);
|
||||
$('div.values li:not(:last)').slice(0, numberOfValidOutputs).text(val);
|
||||
$('div.sliders input:not(:last):first').trigger('input');
|
||||
});
|
||||
|
||||
// check if motors are already spinning
|
||||
var motors_running = false;
|
||||
let motorsRunning = false;
|
||||
|
||||
for (var i = 0; i < number_of_valid_outputs; i++) {
|
||||
for (let i = 0; i < numberOfValidOutputs; i++) {
|
||||
if (!self.feature3DEnabled) {
|
||||
if (FC.MOTOR_DATA[i] > rangeMin) {
|
||||
motors_running = true;
|
||||
motorsRunning = true;
|
||||
}
|
||||
} else {
|
||||
if ((FC.MOTOR_DATA[i] < FC.MOTOR_3D_CONFIG.deadband3d_low) || (FC.MOTOR_DATA[i] > FC.MOTOR_3D_CONFIG.deadband3d_high)) {
|
||||
motors_running = true;
|
||||
motorsRunning = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (motors_running) {
|
||||
if (motorsRunning) {
|
||||
$('#motorsEnableTestMode').prop('checked', true).change();
|
||||
|
||||
// motors are running adjust sliders to current values
|
||||
|
||||
var sliders = $('div.sliders input:not(.master)');
|
||||
const sliders = $('div.sliders input:not(.master)');
|
||||
|
||||
var master_value = FC.MOTOR_DATA[0];
|
||||
for (var i = 0; i < FC.MOTOR_DATA.length; i++) {
|
||||
let masterValue = FC.MOTOR_DATA[0];
|
||||
for (let i = 0; i < FC.MOTOR_DATA.length; i++) {
|
||||
if (FC.MOTOR_DATA[i] > 0) {
|
||||
sliders.eq(i).val(FC.MOTOR_DATA[i]);
|
||||
|
||||
if (master_value != FC.MOTOR_DATA[i]) {
|
||||
master_value = false;
|
||||
if (masterValue !== FC.MOTOR_DATA[i]) {
|
||||
masterValue = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -622,8 +626,8 @@ TABS.motors.initialize = function (callback) {
|
|||
sliders.trigger('input');
|
||||
|
||||
// slide master slider if condition is valid
|
||||
if (master_value) {
|
||||
$('div.sliders input.master').val(master_value)
|
||||
if (masterValue) {
|
||||
$('div.sliders input.master').val(masterValue)
|
||||
.trigger('input');
|
||||
}
|
||||
}
|
||||
|
@ -651,24 +655,24 @@ TABS.motors.initialize = function (callback) {
|
|||
MSP.send_message(MSPCodes.MSP_SERVO, false, false, update_ui);
|
||||
}
|
||||
|
||||
var full_block_scale = rangeMax - rangeMin;
|
||||
const fullBlockScale = rangeMax - rangeMin;
|
||||
|
||||
function update_ui() {
|
||||
var previousArmState = self.armed;
|
||||
var block_height = $('div.m-block:first').height();
|
||||
const previousArmState = self.armed;
|
||||
const blockHeight = $('div.m-block:first').height();
|
||||
|
||||
for (var i = 0; i < FC.MOTOR_DATA.length; i++) {
|
||||
var motorValue = FC.MOTOR_DATA[i];
|
||||
var barHeight = motorValue - rangeMin,
|
||||
margin_top = block_height - (barHeight * (block_height / full_block_scale)).clamp(0, block_height),
|
||||
height = (barHeight * (block_height / full_block_scale)).clamp(0, block_height),
|
||||
for (let i = 0; i < FC.MOTOR_DATA.length; i++) {
|
||||
const motorValue = FC.MOTOR_DATA[i];
|
||||
const barHeight = motorValue - rangeMin,
|
||||
marginTop = blockHeight - (barHeight * (blockHeight / fullBlockScale)).clamp(0, blockHeight),
|
||||
height = (barHeight * (blockHeight / fullBlockScale)).clamp(0, blockHeight),
|
||||
color = parseInt(barHeight * 0.009);
|
||||
|
||||
$('.motor-' + i + ' .label', motors_wrapper).text(motorValue);
|
||||
$('.motor-' + i + ' .indicator', motors_wrapper).css({
|
||||
'margin-top' : margin_top + 'px',
|
||||
'height' : height + 'px',
|
||||
'background-color' : 'rgba(255,187,0,1.'+ color +')'
|
||||
$(`.motor-${i} .label`, motorsWrapper).text(motorValue);
|
||||
$(`.motor-${i} .indicator`, motorsWrapper).css({
|
||||
'margin-top' : `${marginTop}px`,
|
||||
'height' : `${height}px`,
|
||||
'background-color' : `rgba(255,187,0,1.${color})`,
|
||||
});
|
||||
|
||||
if (i < FC.MOTOR_CONFIG.motor_count && (FC.MOTOR_CONFIG.use_dshot_telemetry || FC.MOTOR_CONFIG.use_esc_sensor)) {
|
||||
|
@ -715,14 +719,18 @@ TABS.motors.initialize = function (callback) {
|
|||
}
|
||||
|
||||
// servo indicators are still using old (not flexible block scale), it will be changed in the future accordingly
|
||||
for (var i = 0; i < FC.SERVO_DATA.length; i++) {
|
||||
var data = FC.SERVO_DATA[i] - 1000,
|
||||
margin_top = block_height - (data * (block_height / 1000)).clamp(0, block_height),
|
||||
height = (data * (block_height / 1000)).clamp(0, block_height),
|
||||
for (let i = 0; i < FC.SERVO_DATA.length; i++) {
|
||||
const data = FC.SERVO_DATA[i] - 1000,
|
||||
marginTop = blockHeight - (data * (blockHeight / 1000)).clamp(0, blockHeight),
|
||||
height = (data * (blockHeight / 1000)).clamp(0, blockHeight),
|
||||
color = parseInt(data * 0.009);
|
||||
|
||||
$('.servo-' + i + ' .label', servos_wrapper).text(FC.SERVO_DATA[i]);
|
||||
$('.servo-' + i + ' .indicator', servos_wrapper).css({'margin-top' : margin_top + 'px', 'height' : height + 'px', 'background-color' : 'rgba(255,187,0,1'+ color +')'});
|
||||
$(`.servo-${i} .label`, servos_wrapper).text(FC.SERVO_DATA[i]);
|
||||
$(`.servo-${i} .indicator`, servos_wrapper).css({
|
||||
'margin-top' : `${marginTop}px`,
|
||||
'height' : `${height}px`,
|
||||
'background-color' : `rgba(255,187,0,1${color})`,
|
||||
});
|
||||
}
|
||||
//keep the following here so at least we get a visual cue of our motor setup
|
||||
update_arm_status();
|
||||
|
|
|
@ -2,14 +2,13 @@
|
|||
|
||||
TABS.sensors = {};
|
||||
TABS.sensors.initialize = function (callback) {
|
||||
var self = this;
|
||||
|
||||
if (GUI.active_tab != 'sensors') {
|
||||
GUI.active_tab = 'sensors';
|
||||
}
|
||||
|
||||
function initSensorData(){
|
||||
for (var i = 0; i < 3; i++) {
|
||||
for (let i = 0; i < 3; i++) {
|
||||
FC.SENSOR_DATA.accelerometer[i] = 0;
|
||||
FC.SENSOR_DATA.gyroscope[i] = 0;
|
||||
FC.SENSOR_DATA.magnetometer[i] = 0;
|
||||
|
@ -20,8 +19,8 @@ TABS.sensors.initialize = function (callback) {
|
|||
}
|
||||
|
||||
function initDataArray(length) {
|
||||
var data = new Array(length);
|
||||
for (var i = 0; i < length; i++) {
|
||||
const data = new Array(length);
|
||||
for (let i = 0; i < length; i++) {
|
||||
data[i] = new Array();
|
||||
data[i].min = -1;
|
||||
data[i].max = 1;
|
||||
|
@ -30,8 +29,8 @@ TABS.sensors.initialize = function (callback) {
|
|||
}
|
||||
|
||||
function addSampleToData(data, sampleNumber, sensorData) {
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
var dataPoint = sensorData[i];
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
const dataPoint = sensorData[i];
|
||||
data[i].push([sampleNumber, dataPoint]);
|
||||
if (dataPoint < data[i].min) {
|
||||
data[i].min = dataPoint;
|
||||
|
@ -41,14 +40,14 @@ TABS.sensors.initialize = function (callback) {
|
|||
}
|
||||
}
|
||||
while (data[0].length > 300) {
|
||||
for (i = 0; i < data.length; i++) {
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
data[i].shift();
|
||||
}
|
||||
}
|
||||
return sampleNumber + 1;
|
||||
}
|
||||
|
||||
var margin = {top: 20, right: 10, bottom: 10, left: 40};
|
||||
const margin = {top: 20, right: 10, bottom: 10, left: 40};
|
||||
function updateGraphHelperSize(helpers) {
|
||||
helpers.width = helpers.targetElement.width() - margin.left - margin.right;
|
||||
helpers.height = helpers.targetElement.height() - margin.top - margin.bottom;
|
||||
|
@ -61,7 +60,7 @@ TABS.sensors.initialize = function (callback) {
|
|||
}
|
||||
|
||||
function initGraphHelpers(selector, sampleNumber, heightDomain) {
|
||||
var helpers = {selector: selector, targetElement: $(selector), dynamicHeightDomain: !heightDomain};
|
||||
const helpers = {selector: selector, targetElement: $(selector), dynamicHeightDomain: !heightDomain};
|
||||
|
||||
helpers.widthScale = d3.scale.linear()
|
||||
.clamp(true)
|
||||
|
@ -108,10 +107,10 @@ TABS.sensors.initialize = function (callback) {
|
|||
}
|
||||
|
||||
function drawGraph(graphHelpers, data, sampleNumber) {
|
||||
var svg = d3.select(graphHelpers.selector);
|
||||
const svg = d3.select(graphHelpers.selector);
|
||||
|
||||
if (graphHelpers.dynamicHeightDomain) {
|
||||
var limits = [];
|
||||
const limits = [];
|
||||
$.each(data, function (idx, datum) {
|
||||
limits.push(datum.min);
|
||||
limits.push(datum.max);
|
||||
|
@ -125,9 +124,9 @@ TABS.sensors.initialize = function (callback) {
|
|||
svg.select(".x.axis").call(graphHelpers.xAxis);
|
||||
svg.select(".y.axis").call(graphHelpers.yAxis);
|
||||
|
||||
var group = svg.select("g.data");
|
||||
var lines = group.selectAll("path").data(data, function (d, i) {return i;});
|
||||
var newLines = lines.enter().append("path").attr("class", "line");
|
||||
const group = svg.select("g.data");
|
||||
const lines = group.selectAll("path").data(data, function (d, i) {return i;});
|
||||
lines.enter().append("path").attr("class", "line");
|
||||
lines.attr('d', graphHelpers.line);
|
||||
}
|
||||
|
||||
|
@ -184,7 +183,7 @@ TABS.sensors.initialize = function (callback) {
|
|||
i18n.localizePage();
|
||||
|
||||
// disable graphs for sensors that are missing
|
||||
var checkboxes = $('.tab-sensors .info .checkboxes input');
|
||||
let checkboxes = $('.tab-sensors .info .checkboxes input');
|
||||
checkboxes.parent().show();
|
||||
|
||||
if (FC.CONFIG.boardType == 0 || FC.CONFIG.boardType == 2) {
|
||||
|
@ -201,15 +200,15 @@ TABS.sensors.initialize = function (callback) {
|
|||
checkboxes.eq(4).prop('disabled', true);
|
||||
}
|
||||
} else {
|
||||
for (var i = 0; i <= 4; i++) {
|
||||
for (let i = 0; i <= 4; i++) {
|
||||
checkboxes.eq(i).prop('disabled', true);
|
||||
checkboxes.eq(i).parent().hide();
|
||||
}
|
||||
}
|
||||
|
||||
$('.tab-sensors .info .checkboxes input').change(function () {
|
||||
var enable = $(this).prop('checked');
|
||||
var index = $(this).parent().index();
|
||||
const enable = $(this).prop('checked');
|
||||
const index = $(this).parent().index();
|
||||
|
||||
switch (index) {
|
||||
case 0:
|
||||
|
@ -232,14 +231,14 @@ TABS.sensors.initialize = function (callback) {
|
|||
break;
|
||||
}
|
||||
|
||||
var checkboxes = [];
|
||||
const _checkboxes = [];
|
||||
$('.tab-sensors .info .checkboxes input').each(function () {
|
||||
checkboxes.push($(this).prop('checked'));
|
||||
_checkboxes.push($(this).prop('checked'));
|
||||
});
|
||||
|
||||
$('.tab-sensors .rate select:first').change();
|
||||
|
||||
ConfigStorage.set({'graphs_enabled': checkboxes});
|
||||
ConfigStorage.set({'graphs_enabled': _checkboxes});
|
||||
});
|
||||
|
||||
let altitudeHint_e = $('.tab-sensors #sensorsAltitudeHint');
|
||||
|
@ -251,13 +250,13 @@ TABS.sensors.initialize = function (callback) {
|
|||
initSensorData();
|
||||
|
||||
// Setup variables
|
||||
var samples_gyro_i = 0,
|
||||
let samples_gyro_i = 0,
|
||||
samples_accel_i = 0,
|
||||
samples_mag_i = 0,
|
||||
samples_altitude_i = 0,
|
||||
samples_sonar_i = 0,
|
||||
samples_debug_i = 0,
|
||||
gyro_data = initDataArray(3),
|
||||
samples_debug_i = 0;
|
||||
const gyro_data = initDataArray(3),
|
||||
accel_data = initDataArray(3),
|
||||
mag_data = initDataArray(3),
|
||||
altitude_data = initDataArray(1),
|
||||
|
@ -269,25 +268,25 @@ TABS.sensors.initialize = function (callback) {
|
|||
initDataArray(1)
|
||||
];
|
||||
|
||||
var gyroHelpers = initGraphHelpers('#gyro', samples_gyro_i, [-2000, 2000]);
|
||||
var accelHelpers = initGraphHelpers('#accel', samples_accel_i, [-2, 2]);
|
||||
var magHelpers = initGraphHelpers('#mag', samples_mag_i, [-1, 1]);
|
||||
var altitudeHelpers = initGraphHelpers('#altitude', samples_altitude_i);
|
||||
var sonarHelpers = initGraphHelpers('#sonar', samples_sonar_i);
|
||||
var debugHelpers = [
|
||||
let gyroHelpers = initGraphHelpers('#gyro', samples_gyro_i, [-2000, 2000]);
|
||||
let accelHelpers = initGraphHelpers('#accel', samples_accel_i, [-2, 2]);
|
||||
let magHelpers = initGraphHelpers('#mag', samples_mag_i, [-1, 1]);
|
||||
const altitudeHelpers = initGraphHelpers('#altitude', samples_altitude_i);
|
||||
const sonarHelpers = initGraphHelpers('#sonar', samples_sonar_i);
|
||||
const debugHelpers = [
|
||||
initGraphHelpers('#debug1', samples_debug_i),
|
||||
initGraphHelpers('#debug2', samples_debug_i),
|
||||
initGraphHelpers('#debug3', samples_debug_i),
|
||||
initGraphHelpers('#debug4', samples_debug_i)
|
||||
];
|
||||
|
||||
var raw_data_text_ements = {
|
||||
const raw_data_text_ements = {
|
||||
x: [],
|
||||
y: [],
|
||||
z: []
|
||||
};
|
||||
$('.plot_control .x, .plot_control .y, .plot_control .z').each(function () {
|
||||
var el = $(this);
|
||||
const el = $(this);
|
||||
if (el.hasClass('x')) {
|
||||
raw_data_text_ements.x.push(el);
|
||||
} else if (el.hasClass('y')) {
|
||||
|
@ -300,7 +299,7 @@ TABS.sensors.initialize = function (callback) {
|
|||
$('.tab-sensors .rate select, .tab-sensors .scale select').change(function () {
|
||||
// if any of the select fields change value, all of the select values are grabbed
|
||||
// and timers are re-initialized with the new settings
|
||||
var rates = {
|
||||
const rates = {
|
||||
'gyro': parseInt($('.tab-sensors select[name="gyro_refresh_rate"]').val(), 10),
|
||||
'accel': parseInt($('.tab-sensors select[name="accel_refresh_rate"]').val(), 10),
|
||||
'mag': parseInt($('.tab-sensors select[name="mag_refresh_rate"]').val(), 10),
|
||||
|
@ -309,7 +308,7 @@ TABS.sensors.initialize = function (callback) {
|
|||
'debug': parseInt($('.tab-sensors select[name="debug_refresh_rate"]').val(), 10)
|
||||
};
|
||||
|
||||
var scales = {
|
||||
const scales = {
|
||||
'gyro': parseFloat($('.tab-sensors select[name="gyro_scale"]').val()),
|
||||
'accel': parseFloat($('.tab-sensors select[name="accel_scale"]').val()),
|
||||
'mag': parseFloat($('.tab-sensors select[name="mag_scale"]').val())
|
||||
|
@ -319,7 +318,7 @@ TABS.sensors.initialize = function (callback) {
|
|||
// this means that setting a slower refresh rate on any of the attributes would have no effect
|
||||
// what we will do instead is = determinate the fastest refresh rate for those 3 attributes, use that as a "polling rate"
|
||||
// and use the "slower" refresh rates only for re-drawing the graphs (to save resources/computing power)
|
||||
var fastest = d3.min([rates.gyro, rates.accel, rates.mag]);
|
||||
const fastest = d3.min([rates.gyro, rates.accel, rates.mag]);
|
||||
|
||||
// store current/latest refresh rates in the storage
|
||||
ConfigStorage.set({'sensor_settings': {'rates': rates, 'scales': scales}});
|
||||
|
@ -330,7 +329,7 @@ TABS.sensors.initialize = function (callback) {
|
|||
magHelpers = initGraphHelpers('#mag', samples_mag_i, [-scales.mag, scales.mag]);
|
||||
|
||||
// fetch currently enabled plots
|
||||
var checkboxes = [];
|
||||
checkboxes = [];
|
||||
$('.tab-sensors .info .checkboxes input').each(function () {
|
||||
checkboxes.push($(this).prop('checked'));
|
||||
});
|
||||
|
@ -418,7 +417,7 @@ TABS.sensors.initialize = function (callback) {
|
|||
}
|
||||
|
||||
function update_debug_graphs() {
|
||||
for (var i = 0; i < 4; i++) {
|
||||
for (let i = 0; i < 4; i++) {
|
||||
updateGraphHelperSize(debugHelpers[i]);
|
||||
|
||||
addSampleToData(debug_data[i], samples_debug_i, [FC.SENSOR_DATA.debug[i]]);
|
||||
|
@ -454,9 +453,9 @@ TABS.sensors.initialize = function (callback) {
|
|||
}
|
||||
ConfigStorage.get('graphs_enabled', function (resultGraphs) {
|
||||
if (resultGraphs.graphs_enabled) {
|
||||
var checkboxes = $('.tab-sensors .info .checkboxes input');
|
||||
for (var i = 0; i < resultGraphs.graphs_enabled.length; i++) {
|
||||
checkboxes.eq(i).not(':disabled').prop('checked', resultGraphs.graphs_enabled[i]).change();
|
||||
const _checkboxes = $('.tab-sensors .info .checkboxes input');
|
||||
for (let i = 0; i < resultGraphs.graphs_enabled.length; i++) {
|
||||
_checkboxes.eq(i).not(':disabled').prop('checked', resultGraphs.graphs_enabled[i]).change();
|
||||
}
|
||||
} else {
|
||||
$('.tab-sensors .info input:lt(4):not(:disabled)').prop('checked', true).change();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue