1
0
Fork 0
mirror of https://github.com/betaflight/betaflight-configurator.git synced 2025-07-23 16:25:22 +03:00

Rearrange configuration and motor tab

This commit is contained in:
Mark Haslinghuis 2020-12-25 11:18:16 +01:00
parent de071bc136
commit 4d64cda9aa
10 changed files with 1821 additions and 1737 deletions

View file

@ -1,31 +1,17 @@
'use strict';
TABS.configuration = {
SHOW_OLD_BATTERY_CONFIG: false,
previousDshotBidir: null,
previousFilterDynQ: null,
previousFilterDynWidth: null,
analyticsChanges: {},
};
TABS.configuration.initialize = function (callback, scrollPosition) {
const self = this;
// Update filtering defaults based on API version
const FILTER_DEFAULT = FC.getFilterDefaults();
if (GUI.active_tab != 'configuration') {
GUI.active_tab = 'configuration';
GUI.configuration_loaded = true;
}
if (semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_36)) {
//Show old battery configuration for pre-BF-3.2
self.SHOW_OLD_BATTERY_CONFIG = true;
} else {
self.SHOW_OLD_BATTERY_CONFIG = false;
}
function load_config() {
MSP.send_message(MSPCodes.MSP_FEATURE_CONFIG, false, false, load_beeper_config);
}
@ -44,28 +30,15 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
}
function load_board_alignment_config() {
MSP.send_message(MSPCodes.MSP_BOARD_ALIGNMENT_CONFIG, false, false, load_rc_map);
MSP.send_message(MSPCodes.MSP_BOARD_ALIGNMENT_CONFIG, false, false, load_rx_map);
}
function load_rc_map() {
MSP.send_message(MSPCodes.MSP_RX_MAP, false, false, load_mixer_config);
}
function load_mixer_config() {
MSP.send_message(MSPCodes.MSP_MIXER_CONFIG, false, false, load_rssi_config);
function load_rx_map() {
MSP.send_message(MSPCodes.MSP_RX_MAP, false, false, load_rssi_config);
}
function load_rssi_config() {
MSP.send_message(MSPCodes.MSP_RSSI_CONFIG, false, false, load_motor_config);
}
function load_motor_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, nextCallBack);
} else {
nextCallBack();
}
MSP.send_message(MSPCodes.MSP_RSSI_CONFIG, false, false, load_gps_config);
}
function load_gps_config() {
@ -91,7 +64,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
}
function load_arming_config() {
const nextCallBack = load_3d;
const nextCallBack = load_rc_deadband;
if (semver.gte(FC.CONFIG.apiVersion, "1.8.0")) {
MSP.send_message(MSPCodes.MSP_ARMING_CONFIG, false, false, nextCallBack);
} else {
@ -99,17 +72,8 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
}
}
function load_3d() {
const nextCallBack = load_rc_deadband;
if (semver.gte(FC.CONFIG.apiVersion, "1.14.0")) {
MSP.send_message(MSPCodes.MSP_MOTOR_3D_CONFIG, false, false, nextCallBack);
} else {
nextCallBack();
}
}
function load_rc_deadband() {
const nextCallBack = esc_protocol;
const nextCallBack = load_sensor_config;
if (semver.gte(FC.CONFIG.apiVersion, "1.17.0")) {
MSP.send_message(MSPCodes.MSP_RC_DEADBAND, false, false, nextCallBack);
} else {
@ -117,16 +81,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
}
}
function esc_protocol() {
const nextCallBack = sensor_config;
if (semver.gte(FC.CONFIG.apiVersion, "1.16.0")) {
MSP.send_message(MSPCodes.MSP_ADVANCED_CONFIG, false, false, nextCallBack);
} else {
nextCallBack();
}
}
function sensor_config() {
function load_sensor_config() {
const nextCallBack = load_sensor_alignment;
if (semver.gte(FC.CONFIG.apiVersion, "1.16.0")) {
MSP.send_message(MSPCodes.MSP_SENSOR_CONFIG, false, false, nextCallBack);
@ -145,12 +100,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
}
function load_name() {
let nextCallBack = load_rx_config;
if (self.SHOW_OLD_BATTERY_CONFIG) {
nextCallBack = load_battery;
}
const nextCallBack = load_rx_config;
if (semver.gte(FC.CONFIG.apiVersion, "1.20.0")) {
MSP.send_message(MSPCodes.MSP_NAME, false, false, nextCallBack);
} else {
@ -158,24 +108,6 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
}
}
function load_battery() {
const nextCallBack = load_current;
if (semver.gte(FC.CONFIG.flightControllerVersion, "3.1.0")) {
MSP.send_message(MSPCodes.MSP_VOLTAGE_METER_CONFIG, false, false, nextCallBack);
} else {
nextCallBack();
}
}
function load_current() {
const nextCallBack = load_rx_config;
if (semver.gte(FC.CONFIG.flightControllerVersion, "3.1.0")) {
MSP.send_message(MSPCodes.MSP_CURRENT_METER_CONFIG, false, false, nextCallBack);
} else {
nextCallBack();
}
}
function load_rx_config() {
const nextCallBack = load_filter_config;
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_31)) {
@ -186,7 +118,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
}
function load_filter_config() {
const nextCallBack = load_html;
const nextCallBack = load_advanced_config;
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_42)) {
MSP.send_message(MSPCodes.MSP_FILTER_CONFIG, false, false, nextCallBack);
} else {
@ -194,6 +126,10 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
}
}
function load_advanced_config() {
MSP.send_message(MSPCodes.MSP_ADVANCED_CONFIG, false, false, load_html);
}
function load_html() {
$('#content').load("./tabs/configuration.html", process_html);
}
@ -203,45 +139,6 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
function process_html() {
self.analyticsChanges = {};
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>');
}
});
}
function refreshMixerPreview() {
const imgSrc = CommonUtils.GetMixerImageSrc(FC.MIXER_CONFIG.mixer, FC.MIXER_CONFIG.reverseMotorDir, FC.CONFIG.apiVersion);
$('.mixerPreview img').attr('src', imgSrc);
}
const reverseMotorSwitch_e = $('#reverseMotorSwitch');
const reverseMotor_e = $('.reverseMotor');
reverseMotorSwitch_e.change(function() {
FC.MIXER_CONFIG.reverseMotorDir = $(this).prop('checked') ? 1 : 0;
refreshMixerPreview();
});
reverseMotorSwitch_e.prop('checked', FC.MIXER_CONFIG.reverseMotorDir != 0).change();
mixer_list_e.change(function () {
const mixerValue = parseInt($(this).val());
let newValue;
if (mixerValue !== FC.MIXER_CONFIG.mixer) {
newValue = $(this).find('option:selected').text();
}
self.analyticsChanges['Mixer'] = newValue;
FC.MIXER_CONFIG.mixer = mixerValue;
refreshMixerPreview();
});
// select current mixer configuration
mixer_list_e.val(FC.MIXER_CONFIG.mixer).change();
const features_e = $('.tab-configuration .features');
FC.FEATURE_CONFIG.features.generateElements(features_e);
@ -256,7 +153,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_37)) {
for (let i = 1; i <= 5; i++) {
dshotBeeperBeaconTone.append('<option value="' + (i) + '">'+ (i) + '</option>');
dshotBeeperBeaconTone.append(`<option value="${(i)}">${(i)}</option>`);
}
dshotBeeper_e.show();
} else {
@ -304,7 +201,6 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
FC.BEEPER_CONFIG.beepers.generateElements(template, destination);
} else {
beeper_e.hide();
reverseMotor_e.hide();
}
// translate to user-selected language
@ -343,9 +239,9 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
} else {
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>');
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>`);
}
orientation_gyro_e.val(FC.SENSOR_ALIGNMENT.align_gyro);
@ -406,18 +302,18 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
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>');
orientation_gyro_to_use_e.append(`<option value="0">${i18n.getMessage('configurationSensorGyroToUseFirst')}</option>`);
}
if (detected_gyro_2) {
orientation_gyro_to_use_e.append('<option value="1">'+ i18n.getMessage('configurationSensorGyroToUseSecond') + '</option>');
orientation_gyro_to_use_e.append(`<option value="1">${i18n.getMessage('configurationSensorGyroToUseSecond')}</option>`);
}
if (detected_dual_gyros) {
orientation_gyro_to_use_e.append('<option value="2">'+ i18n.getMessage('configurationSensorGyroToUseBoth') + '</option>');
orientation_gyro_to_use_e.append(`<option value="2">${i18n.getMessage('configurationSensorGyroToUseBoth')}</option>`);
}
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>');
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>`);
}
orientation_gyro_to_use_e.val(FC.SENSOR_ALIGNMENT.gyro_to_use);
@ -455,127 +351,6 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
}
}
// ESC protocols
const escProtocols = EscProtocols.GetAvailableProtocols(FC.CONFIG.apiVersion);
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>`);
}
$("input[id='unsyncedPWMSwitch']").change(function() {
if ($(this).is(':checked')) {
$('div.unsyncedpwmfreq').show();
} else {
$('div.unsyncedpwmfreq').hide();
}
});
$('input[id="unsyncedPWMSwitch"]').prop('checked', FC.PID_ADVANCED_CONFIG.use_unsyncedPwm !== 0).change();
$('input[name="unsyncedpwmfreq"]').val(FC.PID_ADVANCED_CONFIG.motor_pwm_rate);
$('input[name="digitalIdlePercent"]').val(FC.PID_ADVANCED_CONFIG.digitalIdlePercent);
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_42)) {
let dshotBidirectional_e = $('input[id="dshotBidir"]');
dshotBidirectional_e.prop('checked', FC.MOTOR_CONFIG.use_dshot_telemetry).change();
self.previousDshotBidir = FC.MOTOR_CONFIG.use_dshot_telemetry;
self.previousFilterDynQ = FC.FILTER_CONFIG.dyn_notch_q;
self.previousFilterDynWidth = FC.FILTER_CONFIG.dyn_notch_width_percent;
dshotBidirectional_e.change(function () {
let value = $(this).prop('checked');
let newValue = undefined;
if (value !== FC.MOTOR_CONFIG.use_dshot_telemetry) {
newValue = value ? 'On' : 'Off';
}
self.analyticsChanges['BidirectionalDshot'] = newValue;
FC.MOTOR_CONFIG.use_dshot_telemetry = value;
FC.FILTER_CONFIG.dyn_notch_width_percent = self.previousFilterDynWidth;
FC.FILTER_CONFIG.dyn_notch_q = self.previousFilterDynQ;
if (FC.FILTER_CONFIG.gyro_rpm_notch_harmonics !== 0) { // if rpm filter is active
if (value && !self.previousDshotBidir) {
FC.FILTER_CONFIG.dyn_notch_width_percent = FILTER_DEFAULT.dyn_notch_width_percent_rpm;
FC.FILTER_CONFIG.dyn_notch_q = FILTER_DEFAULT.dyn_notch_q_rpm;
} else if (!value && self.previousDshotBidir) {
FC.FILTER_CONFIG.dyn_notch_width_percent = FILTER_DEFAULT.dyn_notch_width_percent;
FC.FILTER_CONFIG.dyn_notch_q = FILTER_DEFAULT.dyn_notch_q;
}
}
if (FC.FILTER_CONFIG.dyn_notch_width_percent !== self.previousFilterDynWidth) {
showDialogDynFiltersChange();
}
});
$('input[name="motorPoles"]').val(FC.MOTOR_CONFIG.motor_poles);
}
$('#escProtocolTooltip').toggle(semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_42));
$('#escProtocolTooltipNoDSHOT1200').toggle(semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_42));
function updateVisibility() {
// Hide unused settings
const protocolName = $('select.escprotocol option:selected').text();
const protocolConfigured = protocolName !== 'DISABLED';
let digitalProtocol = false;
switch (protocolName) {
case 'DSHOT150':
case 'DSHOT300':
case 'DSHOT600':
case 'DSHOT1200':
case 'PROSHOT1000':
digitalProtocol = true;
break;
default:
break;
}
const rpmFeaturesVisible = digitalProtocol && ($("input[id='dshotBidir']").is(':checked') || $("input[name='ESC_SENSOR']").is(':checked'));
$('div.minthrottle').toggle(protocolConfigured && !digitalProtocol);
$('div.maxthrottle').toggle(protocolConfigured && !digitalProtocol);
$('div.mincommand').toggle(protocolConfigured && !digitalProtocol);
$('div.checkboxPwm').toggle(protocolConfigured && !digitalProtocol);
$('div.unsyncedpwmfreq').toggle(protocolConfigured && !digitalProtocol);
$('div.digitalIdlePercent').toggle(protocolConfigured && digitalProtocol);
$('.escSensor').toggle(protocolConfigured && digitalProtocol);
$('div.checkboxDshotBidir').toggle(protocolConfigured && semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_42) && digitalProtocol);
$('div.motorPoles').toggle(protocolConfigured && rpmFeaturesVisible && semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_42));
$('.escMotorStop').toggle(protocolConfigured);
$('#escProtocolDisabled').toggle(!protocolConfigured);
//trigger change unsyncedPWMSwitch to show/hide Motor PWM freq input
$("input[id='unsyncedPWMSwitch']").change();
}
esc_protocol_e.val(FC.PID_ADVANCED_CONFIG.fast_pwm_protocol + 1);
esc_protocol_e.change(function () {
const escProtocolValue = parseInt($(this).val()) - 1;
let newValue = undefined;
if (escProtocolValue !== FC.PID_ADVANCED_CONFIG.fast_pwm_protocol) {
newValue = $(this).find('option:selected').text();
}
self.analyticsChanges['EscProtocol'] = newValue;
updateVisibility();
}).change();
//trigger change dshotBidir and ESC_SENSOR to show/hide Motor Poles tab
$("input[id='dshotBidir']").change(updateVisibility).change();
$("input[name='ESC_SENSOR']").change(updateVisibility).change();
// Gyro and PID update
const gyroUse32kHzElement = $('input[id="gyroUse32kHz"]');
const gyroTextElement = $('input.gyroFrequency');
@ -600,7 +375,8 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
gyroSelectElement.empty();
const MAX_DENOM = semver.gte(FC.CONFIG.apiVersion, "1.25.0") ? 32 : 8;
const MAX_DENOM = semver.gte(FC.CONFIG.apiVersion, "1.25.0") && semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_41) ? 32 : 8;
for (let denom = 1; denom <= MAX_DENOM; denom++) {
addDenomOption(gyroSelectElement, denom, gyroBaseFreq);
}
@ -647,7 +423,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
$('.systemconfigNote').html(i18n.getMessage('configurationLoopTimeHelp'));
gyroSelectElement.change(function () {
const originalPidDenom = pidSelectElement.val();
const originalPidDenom = parseInt(pidSelectElement.val());
let pidBaseFreq;
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_43)) {
@ -811,7 +587,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
}
const serialRXSelectEl = $('select.serialRX');
FC.getSerialRxTypes().forEach((serialRxType, index) => {
FC.getSerialRxTypes().forEach(function(serialRxType, index) {
serialRXSelectEl.append(`<option value="${index}">${serialRxType}</option>`);
});
@ -829,9 +605,10 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
// select current serial RX type
serialRXSelectEl.val(FC.RX_CONFIG.serialrx_provider);
const spiRxTypes = [];
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_31)) {
const spiRxTypes = [
spiRxTypes.push(
'NRF24_V202_250K',
'NRF24_V202_1M',
'NRF24_SYMA_X',
@ -840,8 +617,8 @@ 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)) {
spiRxTypes.push(
@ -875,7 +652,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
const spiRx_e = $('select.spiRx');
for (let i = 0; i < spiRxTypes.length; i++) {
spiRx_e.append('<option value="' + i + '">' + spiRxTypes[i] + '</option>');
spiRx_e.append(`<option value="${i}">${spiRxTypes[i]}</option>`);
}
spiRx_e.change(function () {
@ -908,150 +685,12 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
$('input[name="roll"]').val(FC.CONFIG.accelerometerTrims[1]);
$('input[name="pitch"]').val(FC.CONFIG.accelerometerTrims[0]);
//fill motor disarm params and FC loop time
if(semver.gte(FC.CONFIG.apiVersion, "1.8.0")) {
$('input[name="autodisarmdelay"]').val(FC.ARMING_CONFIG.auto_disarm_delay);
$('input[id="disarmkillswitch"]').prop('checked', FC.ARMING_CONFIG.disarm_kill_switch !== 0);
$('div.disarm').show();
$('div.cycles').show();
}
if(semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_37) || !isExpertModeEnabled()) {
$('input[id="disarmkillswitch"]').prop('checked', true);
$('div.disarm').hide();
}
$('._smallAngle').toggle(semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_37));
if(semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_37)) {
$('input[id="configurationSmallAngle"]').val(FC.ARMING_CONFIG.small_angle);
}
// fill throttle
$('input[name="minthrottle"]').val(FC.MOTOR_CONFIG.minthrottle);
$('input[name="maxthrottle"]').val(FC.MOTOR_CONFIG.maxthrottle);
$('input[name="mincommand"]').val(FC.MOTOR_CONFIG.mincommand);
// fill battery
if (self.SHOW_OLD_BATTERY_CONFIG) {
if (semver.gte(FC.CONFIG.flightControllerVersion, "3.1.0")) {
const batteryMeterTypes = [
'Onboard ADC',
'ESC Sensor',
];
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 () {
FC.MISC.batterymetertype = parseInt($(this).val());
checkUpdateVbatControls();
});
batteryMeterType_e.val(FC.MISC.batterymetertype).change();
} else {
$('div.batterymetertype').hide();
}
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_41)) {
$('input[name="mincellvoltage"]').prop('step','0.01');
$('input[name="maxcellvoltage"]').prop('step','0.01');
$('input[name="warningcellvoltage"]').prop('step','0.01');
}
$('input[name="mincellvoltage"]').val(FC.MISC.vbatmincellvoltage);
$('input[name="maxcellvoltage"]').val(FC.MISC.vbatmaxcellvoltage);
$('input[name="warningcellvoltage"]').val(FC.MISC.vbatwarningcellvoltage);
$('input[name="voltagescale"]').val(FC.MISC.vbatscale);
// fill current
const currentMeterTypes = [
'None',
'Onboard ADC',
'Virtual',
];
if (semver.gte(FC.CONFIG.flightControllerVersion, "3.1.0")) {
currentMeterTypes.push('ESC Sensor');
}
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 () {
FC.BF_CONFIG.currentmetertype = parseInt($(this).val());
checkUpdateCurrentControls();
});
currentMeterType_e.val(FC.BF_CONFIG.currentmetertype).change();
$('input[name="currentscale"]').val(FC.BF_CONFIG.currentscale);
$('input[name="currentoffset"]').val(FC.BF_CONFIG.currentoffset);
$('input[name="multiwiicurrentoutput"]').prop('checked', FC.MISC.multiwiicurrentoutput !== 0);
} else {
$('.oldBatteryConfig').hide();
}
function checkUpdateVbatControls() {
if (FC.FEATURE_CONFIG.features.isEnabled('VBAT')) {
$('.vbatmonitoring').show();
if (semver.gte(FC.CONFIG.flightControllerVersion, "3.1.0")) {
$('select.batterymetertype').show();
if (FC.MISC.batterymetertype !== 0) {
$('.vbatCalibration').hide();
}
} else {
$('select.batterymetertype').hide();
}
} else {
$('.vbatmonitoring').hide();
}
}
function checkUpdateCurrentControls() {
if (FC.FEATURE_CONFIG.features.isEnabled('CURRENT_METER')) {
$('.currentMonitoring').show();
switch(FC.BF_CONFIG.currentmetertype) {
case 0:
$('.currentCalibration').hide();
$('.currentOutput').hide();
break;
case 3:
$('.currentCalibration').hide();
}
if (FC.BF_CONFIG.currentmetertype !== 1 && FC.BF_CONFIG.currentmetertype !== 2) {
$('.currentCalibration').hide();
}
} else {
$('.currentMonitoring').hide();
}
}
//fill 3D
if (semver.lt(FC.CONFIG.apiVersion, "1.14.0")) {
$('.tab-configuration ._3d').hide();
} else {
$('input[name="3ddeadbandlow"]').val(FC.MOTOR_3D_CONFIG.deadband3d_low);
$('input[name="3ddeadbandhigh"]').val(FC.MOTOR_3D_CONFIG.deadband3d_high);
$('input[name="3dneutral"]').val(FC.MOTOR_3D_CONFIG.neutral);
}
// UI hooks
function checkShowDisarmDelay() {
if (FC.FEATURE_CONFIG.features.isEnabled('MOTOR_STOP')) {
$('div.disarmdelay').show();
} else {
$('div.disarmdelay').hide();
}
}
function checkShowSerialRxBox() {
if (FC.FEATURE_CONFIG.features.isEnabled('RX_SERIAL')) {
$('div.serialRXBox').show();
@ -1076,46 +715,14 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
}
}
function checkUpdate3dControls() {
if (FC.FEATURE_CONFIG.features.isEnabled('3D')) {
$('._3dSettings').show();
} else {
$('._3dSettings').hide();
}
}
$('input.feature', features_e).change(function () {
const element = $(this);
FC.FEATURE_CONFIG.features.updateData(element);
updateTabList(FC.FEATURE_CONFIG.features);
switch (element.attr('name')) {
case 'MOTOR_STOP':
checkShowDisarmDelay();
break;
case 'VBAT':
if (self.SHOW_OLD_BATTERY_CONFIG) {
checkUpdateVbatControls();
}
break;
case 'CURRENT_METER':
if (self.SHOW_OLD_BATTERY_CONFIG) {
checkUpdateCurrentControls();
}
break;
case 'GPS':
checkUpdateGpsControls();
break;
case '3D':
checkUpdate3dControls();
break;
default:
break;
if (element.attr('name') === 'GPS') {
checkUpdateGpsControls();
}
});
@ -1143,18 +750,11 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
FC.BEEPER_CONFIG.beepers.updateData(element);
});
checkShowDisarmDelay();
checkShowSerialRxBox();
checkShowSpiRxBox();
checkUpdateGpsControls();
checkUpdate3dControls();
if (self.SHOW_OLD_BATTERY_CONFIG) {
checkUpdateVbatControls();
checkUpdateCurrentControls();
}
$('a.save').click(function () {
$('a.save').on('click', function() {
// gather data that doesn't have automatic change event bound
FC.BOARD_ALIGNMENT_CONFIG.roll = parseInt($('input[name="board_align_roll"]').val());
FC.BOARD_ALIGNMENT_CONFIG.pitch = parseInt($('input[name="board_align_pitch"]').val());
@ -1163,46 +763,15 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
FC.CONFIG.accelerometerTrims[1] = parseInt($('input[name="roll"]').val());
FC.CONFIG.accelerometerTrims[0] = parseInt($('input[name="pitch"]').val());
// motor disarm
if(semver.gte(FC.CONFIG.apiVersion, "1.8.0")) {
FC.ARMING_CONFIG.auto_disarm_delay = parseInt($('input[name="autodisarmdelay"]').val());
FC.ARMING_CONFIG.disarm_kill_switch = $('input[id="disarmkillswitch"]').is(':checked') ? 1 : 0;
}
// small angle configuration
if(semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_37)) {
FC.ARMING_CONFIG.small_angle = parseInt($('input[id="configurationSmallAngle"]').val());
}
FC.MOTOR_CONFIG.minthrottle = parseInt($('input[name="minthrottle"]').val());
FC.MOTOR_CONFIG.maxthrottle = parseInt($('input[name="maxthrottle"]').val());
FC.MOTOR_CONFIG.mincommand = parseInt($('input[name="mincommand"]').val());
if(semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_42)) {
FC.MOTOR_CONFIG.motor_poles = parseInt($('input[name="motorPoles"]').val());
}
if(self.SHOW_OLD_BATTERY_CONFIG) {
FC.MISC.vbatmincellvoltage = parseFloat($('input[name="mincellvoltage"]').val());
FC.MISC.vbatmaxcellvoltage = parseFloat($('input[name="maxcellvoltage"]').val());
FC.MISC.vbatwarningcellvoltage = parseFloat($('input[name="warningcellvoltage"]').val());
FC.MISC.vbatscale = parseInt($('input[name="voltagescale"]').val());
FC.BF_CONFIG.currentscale = parseInt($('input[name="currentscale"]').val());
FC.BF_CONFIG.currentoffset = parseInt($('input[name="currentoffset"]').val());
FC.MISC.multiwiicurrentoutput = $('input[name="multiwiicurrentoutput"]').is(':checked') ? 1 : 0;
}
if(semver.gte(FC.CONFIG.apiVersion, "1.14.0")) {
FC.MOTOR_3D_CONFIG.deadband3d_low = parseInt($('input[name="3ddeadbandlow"]').val());
FC.MOTOR_3D_CONFIG.deadband3d_high = parseInt($('input[name="3ddeadbandhigh"]').val());
FC.MOTOR_3D_CONFIG.neutral = parseInt($('input[name="3dneutral"]').val());
}
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_41)) {
FC.SENSOR_ALIGNMENT.gyro_to_use = parseInt(orientation_gyro_to_use_e.val());
}
FC.PID_ADVANCED_CONFIG.fast_pwm_protocol = parseInt(esc_protocol_e.val()-1);
FC.PID_ADVANCED_CONFIG.use_unsyncedPwm = $('input[id="unsyncedPWMSwitch"]').is(':checked') ? 1 : 0;
FC.PID_ADVANCED_CONFIG.motor_pwm_rate = parseInt($('input[name="unsyncedpwmfreq"]').val());
FC.PID_ADVANCED_CONFIG.gyro_sync_denom = parseInt(gyroSelectElement.val());
const value = parseInt(pidSelectElement.val());
@ -1215,19 +784,26 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
}
FC.PID_ADVANCED_CONFIG.pid_process_denom = value;
FC.PID_ADVANCED_CONFIG.digitalIdlePercent = parseFloat($('input[name="digitalIdlePercent"]').val());
if (semver.gte(FC.CONFIG.apiVersion, "1.25.0") && semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_41)) {
FC.PID_ADVANCED_CONFIG.gyroUse32kHz = $('input[id="gyroUse32kHz"]').is(':checked') ? 1 : 0;
}
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_31)) {
FC.RX_CONFIG.fpvCamAngleDegrees = parseInt($('input[name="fpvCamAngleDegrees"]').val());
}
FC.RX_CONFIG.fpvCamAngleDegrees = parseInt($('input[name="fpvCamAngleDegrees"]').val());
analytics.sendChangeEvents(analytics.EVENT_CATEGORIES.FLIGHT_CONTROLLER, self.analyticsChanges);
self.analyticsChanges = {};
// fill some data
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_34)) {
FC.GPS_CONFIG.auto_baud = $('input[name="gps_auto_baud"]').is(':checked') ? 1 : 0;
FC.GPS_CONFIG.auto_config = $('input[name="gps_auto_config"]').is(':checked') ? 1 : 0;
}
FC.SENSOR_CONFIG.acc_hardware = $('input[id="accHardwareSwitch"]').is(':checked') ? 0 : 1;
FC.SENSOR_CONFIG.baro_hardware = $('input[id="baroHardwareSwitch"]').is(':checked') ? 0 : 1;
FC.SENSOR_CONFIG.mag_hardware = $('input[id="magHardwareSwitch"]').is(':checked') ? 0 : 1;
FC.CONFIG.name = $.trim($('input[name="craftName"]').val());
function save_serial_config() {
const nextCallBack = save_feature_config;
mspHelper.sendSerialConfig(nextCallBack);
@ -1248,7 +824,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
}
function save_misc() {
const nextCallBack = save_mixer_config;
const nextCallBack = save_board_alignment_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, nextCallBack);
} else {
@ -1256,32 +832,14 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
}
}
function save_mixer_config() {
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() {
const nextCallBack = save_motor_config;
const nextCallBack = save_gps_config;
MSP.send_message(MSPCodes.MSP_SET_BOARD_ALIGNMENT_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_BOARD_ALIGNMENT_CONFIG), false, nextCallBack);
}
function save_motor_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, nextCallBack);
} else {
nextCallBack();
}
}
function save_gps_config() {
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_34)) {
FC.GPS_CONFIG.auto_baud = $('input[name="gps_auto_baud"]').is(':checked') ? 1 : 0;
FC.GPS_CONFIG.auto_config = $('input[name="gps_auto_config"]').is(':checked') ? 1 : 0;
}
const nextCallBack = save_motor_3d_config;
const nextCallBack = save_rc_deadband;
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, nextCallBack);
} else {
@ -1289,28 +847,20 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
}
}
function save_motor_3d_config() {
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() {
const nextCallBack = save_sensor_alignment;
MSP.send_message(MSPCodes.MSP_SET_RC_DEADBAND, mspHelper.crunch(MSPCodes.MSP_SET_RC_DEADBAND), false, nextCallBack);
MSP.send_message(MSPCodes.MSP_SET_RC_DEADBAND, mspHelper.crunch(MSPCodes.MSP_SET_RC_DEADBAND), false, save_sensor_alignment);
}
function save_sensor_alignment() {
const nextCallBack = save_esc_protocol;
MSP.send_message(MSPCodes.MSP_SET_SENSOR_ALIGNMENT, mspHelper.crunch(MSPCodes.MSP_SET_SENSOR_ALIGNMENT), false, nextCallBack);
MSP.send_message(MSPCodes.MSP_SET_SENSOR_ALIGNMENT, mspHelper.crunch(MSPCodes.MSP_SET_SENSOR_ALIGNMENT), false, save_esc_protocol);
}
function save_esc_protocol() {
const nextCallBack = save_acc_trim;
MSP.send_message(MSPCodes.MSP_SET_ADVANCED_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_ADVANCED_CONFIG), false, nextCallBack);
MSP.send_message(MSPCodes.MSP_SET_ADVANCED_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_ADVANCED_CONFIG), false, save_acc_trim);
}
function save_acc_trim() {
const nextCallBack = save_arming_config;
MSP.send_message(MSPCodes.MSP_SET_ACC_TRIM, mspHelper.crunch(MSPCodes.MSP_SET_ACC_TRIM), false, nextCallBack);
MSP.send_message(MSPCodes.MSP_SET_ACC_TRIM, mspHelper.crunch(MSPCodes.MSP_SET_ACC_TRIM), false, save_arming_config);
}
function save_arming_config() {
@ -1318,41 +868,11 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
}
function save_sensor_config() {
FC.SENSOR_CONFIG.acc_hardware = $('input[id="accHardwareSwitch"]').is(':checked') ? 0 : 1;
FC.SENSOR_CONFIG.baro_hardware = $('input[id="baroHardwareSwitch"]').is(':checked') ? 0 : 1;
FC.SENSOR_CONFIG.mag_hardware = $('input[id="magHardwareSwitch"]').is(':checked') ? 0 : 1;
const nextCallBack = save_name;
MSP.send_message(MSPCodes.MSP_SET_SENSOR_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_SENSOR_CONFIG), false, nextCallBack);
MSP.send_message(MSPCodes.MSP_SET_SENSOR_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_SENSOR_CONFIG), false, save_name);
}
function save_name() {
let nextCallBack = save_rx_config;
if(self.SHOW_OLD_BATTERY_CONFIG) {
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, nextCallBack);
}
function save_battery() {
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, nextCallBack);
} else {
nextCallBack();
}
}
function save_current() {
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, nextCallBack);
} else {
nextCallBack();
}
MSP.send_message(MSPCodes.MSP_SET_NAME, mspHelper.crunch(MSPCodes.MSP_SET_NAME), false, save_rx_config);
}
function save_rx_config() {
@ -1390,7 +910,7 @@ TABS.configuration.initialize = function (callback, scrollPosition) {
});
// status data pulled via separate timer with static speed
GUI.interval_add('status_pull', function status_pull() {
GUI.interval_add('status_pull', function() {
MSP.send_message(MSPCodes.MSP_STATUS);
}, 250, true);
GUI.content_ready(callback);