Merge pull request #2953 from haslinghuis/remove-anti-gravity-step-mode

10.9-maintenance
J Blackman 2022-08-04 08:07:57 +10:00 committed by GitHub
commit 7bc1db46b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 80 additions and 41 deletions

View File

@ -486,7 +486,8 @@ const FC = {
levelAngleLimit: 0,
levelSensitivity: 0,
itermThrottleThreshold: 0,
itermAcceleratorGain: 0,
itermAcceleratorGain: 0, // depecrated in API 1.45
antiGravityGain: 0, // was itermAccelatorGain till API 1.45
itermRotation: 0,
smartFeedforward: 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)) {
FC.ADVANCED_TUNING.itermThrottleThreshold = data.readU16();
FC.ADVANCED_TUNING.itermAcceleratorGain = 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();
}
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_39)) {
FC.ADVANCED_TUNING.dtermSetpointWeight = data.readU16();
@ -2214,8 +2219,13 @@ MspHelper.prototype.crunch = function(code) {
.push8(FC.ADVANCED_TUNING.levelSensitivity);
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_36)) {
buffer.push16(FC.ADVANCED_TUNING.itermThrottleThreshold)
.push16(FC.ADVANCED_TUNING.itermAcceleratorGain);
buffer.push16(FC.ADVANCED_TUNING.itermThrottleThreshold);
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)) {
buffer.push16(FC.ADVANCED_TUNING.dtermSetpointWeight);

View File

@ -181,39 +181,62 @@ pid_tuning.initialize = function (callback) {
$('.pid_sensitivity').hide();
}
const antiGravitySwitch = $('#antiGravitySwitch');
const antiGravityGain = $('.antigravity input[name="itermAcceleratorGain"]');
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_36)) {
$('.pid_filter select[name="dtermLowpassType"]').val(FC.FILTER_CONFIG.dterm_lowpass_type);
$('.antigravity input[name="itermThrottleThreshold"]').val(FC.ADVANCED_TUNING.itermThrottleThreshold);
$('.antigravity input[name="itermAcceleratorGain"]').val(FC.ADVANCED_TUNING.itermAcceleratorGain / 1000);
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_44)) {
$('.antigravity input[name="itermAcceleratorGain"]').attr("min","0.1");
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);
antiGravityGain.val(FC.ADVANCED_TUNING.itermAcceleratorGain / 1000);
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() {
const checked = $(this).is(':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;
$('.antigravity input[name="itermAcceleratorGain"]').val(DEFAULT_ACCELERATOR_GAIN);
} else {
const itermAcceleratorGain = (FC.ADVANCED_TUNING.itermAcceleratorGain / 1000);
$('.antigravity input[name="itermAcceleratorGain"]').val(itermAcceleratorGain);
if (FC.ADVANCED_TUNING.itermAcceleratorGain === ITERM_ACCELERATOR_GAIN_OFF) {
antiGravityGain.val(DEFAULT_ACCELERATOR_GAIN);
} else {
const itermAcceleratorGain = (FC.ADVANCED_TUNING.itermAcceleratorGain / 1000);
antiGravityGain.val(itermAcceleratorGain);
}
}
$('.antigravity .suboption').show();
if (FC.ADVANCED_TUNING.antiGravityMode == 0) {
$('.antigravity .antiGravityThres').hide();
}
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_40)) {
$('.antigravity .antiGravityMode').show();
} else {
$('.antigravity .antiGravityMode').hide();
}
$('.antigravity .antiGravityThres').toggle(semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_45) && FC.ADVANCED_TUNING.itermAcceleratorGain === 0);
$('.antigravity .antiGravityMode').toggle(semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_40) && semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_45));
} else {
$('.antigravity select[id="antiGravityMode"]').val(0);
$('.antigravity input[name="itermAcceleratorGain"]').val(ITERM_ACCELERATOR_GAIN_OFF / 1000);
if (semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_45)) {
$('.antigravity select[id="antiGravityMode"]').val(0);
antiGravityGain.val(ITERM_ACCELERATOR_GAIN_OFF);
} else {
antiGravityGain.val(ITERM_ACCELERATOR_GAIN_OFF / 1000);
}
$('.antigravity .suboption').hide();
}
});
@ -308,20 +331,19 @@ pid_tuning.initialize = function (callback) {
const feedforwardTransitionNumberElement = $('input[name="feedforwardTransition-number"]');
feedforwardTransitionNumberElement.val(FC.ADVANCED_TUNING.feedforwardTransition / 100);
// AntiGravity Mode
const antiGravityModeSelect = $('.antigravity select[id="antiGravityMode"]');
antiGravityModeSelect.change(function () {
const antiGravityModeValue = $('.antigravity select[id="antiGravityMode"]').val();
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_40) && semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_45)) {
// AntiGravity Mode
const antiGravityModeSelect = $('.antigravity select[id="antiGravityMode"]');
// Smooth removes threshold
if (antiGravityModeValue == 0) {
$('.antiGravityThres').hide();
} else {
$('.antiGravityThres').show();
}
});
antiGravityModeSelect.on('change', function () {
const antiGravityModeValue = antiGravityModeSelect.val();
antiGravityModeSelect.val(FC.ADVANCED_TUNING.antiGravityMode).change();
// Smooth removes threshold
$('.antiGravityThres').toggle(antiGravityModeValue !== 0);
});
antiGravityModeSelect.val(FC.ADVANCED_TUNING.antiGravityMode).trigger('change');
}
} else {
$('.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)) {
FC.FILTER_CONFIG.dterm_lowpass_type = parseInt($('.pid_filter select[name="dtermLowpassType"]').val());
FC.ADVANCED_TUNING.itermThrottleThreshold = parseInt($('.antigravity input[name="itermThrottleThreshold"]').val());
FC.ADVANCED_TUNING.itermAcceleratorGain = parseInt($('.antigravity input[name="itermAcceleratorGain"]').val() * 1000);
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.itermAcceleratorGain = parseInt(antiGravityGain.val() * 1000);
}
}
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.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)) {