1
0
Fork 0
mirror of https://github.com/betaflight/betaflight-configurator.git synced 2025-07-26 17:55:24 +03:00

Remove antiGravityMode and change itermAcceleratorGain to antiGravityGain

This commit is contained in:
Mark Haslinghuis 2022-06-20 02:31:14 +02:00
parent 1c775439a1
commit 7e3ff0b27b
3 changed files with 80 additions and 41 deletions

View file

@ -486,7 +486,8 @@ const FC = {
levelAngleLimit: 0, levelAngleLimit: 0,
levelSensitivity: 0, levelSensitivity: 0,
itermThrottleThreshold: 0, itermThrottleThreshold: 0,
itermAcceleratorGain: 0, itermAcceleratorGain: 0, // depecrated in API 1.45
antiGravityGain: 0, // was itermAccelatorGain till API 1.45
itermRotation: 0, itermRotation: 0,
smartFeedforward: 0, smartFeedforward: 0,
itermRelax: 0, itermRelax: 0,

View file

@ -1212,7 +1212,12 @@ MspHelper.prototype.process_data = function(dataHandler) {
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_36)) { if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_36)) {
FC.ADVANCED_TUNING.itermThrottleThreshold = data.readU16(); FC.ADVANCED_TUNING.itermThrottleThreshold = data.readU16();
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)) {
FC.ADVANCED_TUNING.antiGravityGain = data.readU16();
} else {
FC.ADVANCED_TUNING.itermAcceleratorGain = data.readU16(); FC.ADVANCED_TUNING.itermAcceleratorGain = data.readU16();
}
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_39)) { if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_39)) {
FC.ADVANCED_TUNING.dtermSetpointWeight = data.readU16(); FC.ADVANCED_TUNING.dtermSetpointWeight = data.readU16();
@ -2214,8 +2219,13 @@ MspHelper.prototype.crunch = function(code) {
.push8(FC.ADVANCED_TUNING.levelSensitivity); .push8(FC.ADVANCED_TUNING.levelSensitivity);
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_36)) { if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_36)) {
buffer.push16(FC.ADVANCED_TUNING.itermThrottleThreshold) buffer.push16(FC.ADVANCED_TUNING.itermThrottleThreshold);
.push16(FC.ADVANCED_TUNING.itermAcceleratorGain);
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)) {
buffer.push16(FC.ADVANCED_TUNING.antiGravityGain);
} else {
buffer.push16(FC.ADVANCED_TUNING.itermAcceleratorGain);
}
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_39)) { if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_39)) {
buffer.push16(FC.ADVANCED_TUNING.dtermSetpointWeight); buffer.push16(FC.ADVANCED_TUNING.dtermSetpointWeight);

View file

@ -181,39 +181,62 @@ pid_tuning.initialize = function (callback) {
$('.pid_sensitivity').hide(); $('.pid_sensitivity').hide();
} }
const antiGravitySwitch = $('#antiGravitySwitch');
const antiGravityGain = $('.antigravity input[name="itermAcceleratorGain"]');
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_36)) { if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_36)) {
$('.pid_filter select[name="dtermLowpassType"]').val(FC.FILTER_CONFIG.dterm_lowpass_type); $('.pid_filter select[name="dtermLowpassType"]').val(FC.FILTER_CONFIG.dterm_lowpass_type);
const ITERM_ACCELERATOR_GAIN_OFF = semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_44) ? 0 : 1000;
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)) {
// we keep the same name in html - just switching variable.
antiGravityGain.val(FC.ADVANCED_TUNING.antiGravityGain);
antiGravitySwitch.prop('checked', FC.ADVANCED_TUNING.antiGravityGain !== ITERM_ACCELERATOR_GAIN_OFF);
} else {
$('.antigravity input[name="itermThrottleThreshold"]').val(FC.ADVANCED_TUNING.itermThrottleThreshold); $('.antigravity input[name="itermThrottleThreshold"]').val(FC.ADVANCED_TUNING.itermThrottleThreshold);
$('.antigravity input[name="itermAcceleratorGain"]').val(FC.ADVANCED_TUNING.itermAcceleratorGain / 1000); antiGravityGain.val(FC.ADVANCED_TUNING.itermAcceleratorGain / 1000);
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_44)) {
$('.antigravity input[name="itermAcceleratorGain"]').attr("min","0.1"); antiGravitySwitch.prop('checked', FC.ADVANCED_TUNING.itermAcceleratorGain !== ITERM_ACCELERATOR_GAIN_OFF);
}
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_44)) {
antiGravityGain.attr("min","0.1");
}
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)) {
antiGravityGain.attr({ "min": "1", "max": "250", "step": "1" });
} }
const antiGravitySwitch = $('#antiGravitySwitch');
const ITERM_ACCELERATOR_GAIN_OFF = semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_44) ? 0 : 1000;
antiGravitySwitch.prop('checked', FC.ADVANCED_TUNING.itermAcceleratorGain !== ITERM_ACCELERATOR_GAIN_OFF);
antiGravitySwitch.change(function() { antiGravitySwitch.change(function() {
const checked = $(this).is(':checked'); const checked = $(this).is(':checked');
if (checked) { if (checked) {
if (FC.ADVANCED_TUNING.itermAcceleratorGain === ITERM_ACCELERATOR_GAIN_OFF) { if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)) {
antiGravityGain.val(FC.ADVANCED_TUNING.antiGravityGain || 1);
} else {
const DEFAULT_ACCELERATOR_GAIN = semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_43) ? 3.5 : 1.1; const DEFAULT_ACCELERATOR_GAIN = semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_43) ? 3.5 : 1.1;
$('.antigravity input[name="itermAcceleratorGain"]').val(DEFAULT_ACCELERATOR_GAIN);
if (FC.ADVANCED_TUNING.itermAcceleratorGain === ITERM_ACCELERATOR_GAIN_OFF) {
antiGravityGain.val(DEFAULT_ACCELERATOR_GAIN);
} else { } else {
const itermAcceleratorGain = (FC.ADVANCED_TUNING.itermAcceleratorGain / 1000); const itermAcceleratorGain = (FC.ADVANCED_TUNING.itermAcceleratorGain / 1000);
$('.antigravity input[name="itermAcceleratorGain"]').val(itermAcceleratorGain); antiGravityGain.val(itermAcceleratorGain);
} }
}
$('.antigravity .suboption').show(); $('.antigravity .suboption').show();
if (FC.ADVANCED_TUNING.antiGravityMode == 0) { $('.antigravity .antiGravityThres').toggle(semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_45) && FC.ADVANCED_TUNING.itermAcceleratorGain === 0);
$('.antigravity .antiGravityThres').hide(); $('.antigravity .antiGravityMode').toggle(semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_40) && semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_45));
}
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_40)) {
$('.antigravity .antiGravityMode').show();
} else {
$('.antigravity .antiGravityMode').hide();
}
} else { } else {
if (semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_45)) {
$('.antigravity select[id="antiGravityMode"]').val(0); $('.antigravity select[id="antiGravityMode"]').val(0);
$('.antigravity input[name="itermAcceleratorGain"]').val(ITERM_ACCELERATOR_GAIN_OFF / 1000); antiGravityGain.val(ITERM_ACCELERATOR_GAIN_OFF);
} else {
antiGravityGain.val(ITERM_ACCELERATOR_GAIN_OFF / 1000);
}
$('.antigravity .suboption').hide(); $('.antigravity .suboption').hide();
} }
}); });
@ -308,20 +331,19 @@ pid_tuning.initialize = function (callback) {
const feedforwardTransitionNumberElement = $('input[name="feedforwardTransition-number"]'); const feedforwardTransitionNumberElement = $('input[name="feedforwardTransition-number"]');
feedforwardTransitionNumberElement.val(FC.ADVANCED_TUNING.feedforwardTransition / 100); feedforwardTransitionNumberElement.val(FC.ADVANCED_TUNING.feedforwardTransition / 100);
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_40) && semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_45)) {
// AntiGravity Mode // AntiGravity Mode
const antiGravityModeSelect = $('.antigravity select[id="antiGravityMode"]'); const antiGravityModeSelect = $('.antigravity select[id="antiGravityMode"]');
antiGravityModeSelect.change(function () {
const antiGravityModeValue = $('.antigravity select[id="antiGravityMode"]').val(); antiGravityModeSelect.on('change', function () {
const antiGravityModeValue = antiGravityModeSelect.val();
// Smooth removes threshold // Smooth removes threshold
if (antiGravityModeValue == 0) { $('.antiGravityThres').toggle(antiGravityModeValue !== 0);
$('.antiGravityThres').hide();
} else {
$('.antiGravityThres').show();
}
}); });
antiGravityModeSelect.val(FC.ADVANCED_TUNING.antiGravityMode).change(); antiGravityModeSelect.val(FC.ADVANCED_TUNING.antiGravityMode).trigger('change');
}
} else { } else {
$('.itermrotation').hide(); $('.itermrotation').hide();
@ -1201,10 +1223,16 @@ pid_tuning.initialize = function (callback) {
} }
} }
const antiGravityGain = $('.antigravity input[name="itermAcceleratorGain"]');
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_36)) { if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_36)) {
FC.FILTER_CONFIG.dterm_lowpass_type = parseInt($('.pid_filter select[name="dtermLowpassType"]').val()); FC.FILTER_CONFIG.dterm_lowpass_type = parseInt($('.pid_filter select[name="dtermLowpassType"]').val());
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_45)) {
FC.ADVANCED_TUNING.antiGravityGain = parseInt(antiGravityGain.val());
} else {
FC.ADVANCED_TUNING.itermThrottleThreshold = parseInt($('.antigravity input[name="itermThrottleThreshold"]').val()); FC.ADVANCED_TUNING.itermThrottleThreshold = parseInt($('.antigravity input[name="itermThrottleThreshold"]').val());
FC.ADVANCED_TUNING.itermAcceleratorGain = parseInt($('.antigravity input[name="itermAcceleratorGain"]').val() * 1000); FC.ADVANCED_TUNING.itermAcceleratorGain = parseInt(antiGravityGain.val() * 1000);
}
} }
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_39)) { if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_39)) {
@ -1236,7 +1264,7 @@ pid_tuning.initialize = function (callback) {
FC.ADVANCED_TUNING.feedforwardTransition = parseInt($('input[name="feedforwardTransition-number"]').val() * 100); FC.ADVANCED_TUNING.feedforwardTransition = parseInt($('input[name="feedforwardTransition-number"]').val() * 100);
FC.ADVANCED_TUNING.antiGravityMode = $('select[id="antiGravityMode"]').val(); FC.ADVANCED_TUNING.antiGravityMode = semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_45) ? $('select[id="antiGravityMode"]').val() : 0;
} }
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_41)) { if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_41)) {