1
0
Fork 0
mirror of https://github.com/betaflight/betaflight-configurator.git synced 2025-07-19 06:15:13 +03:00

Fixed the antigravity feature switch.

This commit is contained in:
mikeller 2020-05-08 00:16:42 +12:00
parent 678823c9de
commit 16b0cfc051
4 changed files with 65 additions and 50 deletions

View file

@ -1114,7 +1114,10 @@
"message": "Video Transmitter"
},
"featureANTI_GRAVITY": {
"message": "Temporary boost I-Term on high throttle changes"
"message": "Permanently enable Anti Gravity"
},
"featureANTI_GRAVITYTip": {
"message": "If this is disabled, the 'ANTI GRAVITY' mode can be used to enable Anti Gravity with a switch."
},
"featureDYNAMIC_FILTER": {
"message": "Dynamic gyro notch filtering"

View file

@ -55,7 +55,7 @@ var Features = function (config) {
if (semver.gte(CONFIG.apiVersion, "1.16.0")) {
if (semver.lt(CONFIG.apiVersion, "1.20.0")) {
features.push(
{bit: 23, group: 'pidTuning', name: 'SUPEREXPO_RATES'}
{bit: 23, group: 'superexpoRates', name: 'SUPEREXPO_RATES'}
);
} else if (!semver.gte(config.apiVersion, "1.33.0")) {
features.push(
@ -84,7 +84,7 @@ var Features = function (config) {
if (semver.gte(CONFIG.apiVersion, "1.36.0")) {
features.push(
{bit: 28, group: 'other', name: 'ANTI_GRAVITY'},
{bit: 28, group: 'antiGravity', name: 'ANTI_GRAVITY', haveTip: true, hideName: true},
{bit: 29, group: 'other', name: 'DYNAMIC_FILTER'}
);
}
@ -161,15 +161,20 @@ Features.prototype.generateElements = function (featuresElements) {
newElements.push(newElement);
listElements.push(newElement);
} else {
let featureName = '';
if (!self._features[i].hideName) {
featureName = `<td><div>${self._features[i].name}</div></td>`;
}
var newElement = $('<tr><td><input class="feature toggle" id="feature-'
+ i
+ '" name="'
+ self._features[i].name
+ '" title="'
+ self._features[i].name
+ '" type="checkbox"/></td><td><div>'
+ self._features[i].name
+ '</div></td><td><span i18n="feature' + self._features[i].name + '"></span>'
+ '" type="checkbox"/></td>'
+ featureName
+ '<td><span i18n="feature' + self._features[i].name + '"></span>'
+ feature_tip_html + '</td></tr>');
var feature_e = newElement.find('input.feature');

View file

@ -171,11 +171,6 @@ TABS.pid_tuning.initialize = function (callback) {
$('.antigravity input[name="itermThrottleThreshold"]').val(ADVANCED_TUNING.itermThrottleThreshold);
$('.antigravity input[name="itermAcceleratorGain"]').val(ADVANCED_TUNING.itermAcceleratorGain / 1000);
if (FEATURE_CONFIG.features.isEnabled('ANTI_GRAVITY')) {
$('.antigravity').show();
} else {
$('.antigravity').hide();
}
var antiGravitySwitch = $('#antiGravitySwitch');
antiGravitySwitch.prop('checked', ADVANCED_TUNING.itermAcceleratorGain !== 1000);
antiGravitySwitch.change(function() {
@ -766,10 +761,6 @@ TABS.pid_tuning.initialize = function (callback) {
FILTER_CONFIG.dterm_lowpass_hz = parseInt($('.pid_filter input[name="dtermLowpassFrequency"]').val());
FILTER_CONFIG.yaw_lowpass_hz = parseInt($('.pid_filter input[name="yawLowpassFrequency"]').val());
if (semver.gte(CONFIG.apiVersion, "1.16.0") && !semver.gte(CONFIG.apiVersion, "1.20.0")) {
FEATURE_CONFIG.features.updateData($('input[name="SUPEREXPO_RATES"]'));
}
if (semver.gte(CONFIG.apiVersion, "1.16.0")) {
const element = $('input[id="vbatpidcompensation"]');
const value = element.is(':checked') ? 1 : 0;
@ -1000,10 +991,10 @@ TABS.pid_tuning.initialize = function (callback) {
}
function process_html() {
if (semver.gte(CONFIG.apiVersion, "1.16.0") && !semver.gte(CONFIG.apiVersion, "1.20.0")) {
FEATURE_CONFIG.features.generateElements($('.tab-pid_tuning .features'));
} else {
$('.tab-pid_tuning .pidTuningFeatures').hide();
FEATURE_CONFIG.features.generateElements($('.tab-pid_tuning .features'));
if (semver.lt(CONFIG.apiVersion, "1.16.0") || semver.gte(CONFIG.apiVersion, "1.20.0")) {
$('.tab-pid_tuning .pidTuningSuperexpoRate').hide();
}
if (semver.lt(CONFIG.apiVersion, "1.39.0")) {
@ -1497,7 +1488,14 @@ TABS.pid_tuning.initialize = function (callback) {
// UI Hooks
// curves
$('input.feature').on('input change', updateRates);
$('input.feature').on('input change', function () {
const element = $(this);
FEATURE_CONFIG.features.updateData(element);
updateRates();
});
$('.pid_tuning').on('input change', updateRates).trigger('input');
function redrawThrottleCurve(forced) {
@ -1907,6 +1905,8 @@ TABS.pid_tuning.initialize = function (callback) {
return MSP.promise(MSPCodes.MSP_SET_FILTER_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_FILTER_CONFIG));
}).then(function () {
return MSP.promise(MSPCodes.MSP_SET_RC_TUNING, mspHelper.crunch(MSPCodes.MSP_SET_RC_TUNING));
}).then(function () {
return MSP.promise(MSPCodes.MSP_SET_FEATURE_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_FEATURE_CONFIG));
}).then(function () {
return MSP.promise(MSPCodes.MSP_EEPROM_WRITE);
}).then(function () {

View file

@ -400,14 +400,14 @@
<div class="cf_column">
<!-- Pid controller advanced settings -->
<div class="gui_box grey pidTuningFeatures spacer_left">
<div class="gui_box grey pidTuningSuperexpoRates spacer_left">
<table class="pid_titlebar new_rates">
<tr>
<th i18n="pidTuningNonProfilePidSettings"></th>
</tr>
</table>
<table class="pidTuningFeatures new_rates">
<tbody class="features pidTuning">
<table class="pidTuningSuperexpoRates new_rates">
<tbody class="features superexpoRates">
<!-- table generated here -->
</tbody>
</table>
@ -617,36 +617,43 @@
</tr>
<tr class="antigravity">
<td><input type="checkbox" id="antiGravitySwitch" class="toggle" /></td>
<td colspan="3">
<div class="helpicon cf_tip" i18n_title="pidTuningAntiGravityHelp"></div>
<span i18n="pidTuningAntiGravity" />
<td><input type="checkbox" id="antiGravitySwitch" class="toggle" /></td>
<td colspan="3">
<div class="helpicon cf_tip" i18n_title="pidTuningAntiGravityHelp"></div>
<span i18n="pidTuningAntiGravity" />
<span class="suboption">
<table>
<tbody class="features antiGravity">
<!-- table generated here -->
</tbody>
</table>
</span>
<span class="suboption antiGravityMode">
<select id="antiGravityMode">
<option i18n="pidTuningAntiGravityModeOptionSmooth" value="0"/>
<option i18n="pidTuningAntiGravityModeOptionStep" value="1"/>
</select>
<label for="antiGravityMode">
<span i18n="pidTuningAntiGravityMode" />
</label>
</span>
<span class="suboption antiGravityMode">
<select id="antiGravityMode">
<option i18n="pidTuningAntiGravityModeOptionSmooth" value="0"/>
<option i18n="pidTuningAntiGravityModeOptionStep" value="1"/>
</select>
<label for="antiGravityMode">
<span i18n="pidTuningAntiGravityMode" />
</label>
</span>
<span class="suboption">
<input type="number" name="itermAcceleratorGain" step="0.1" min="1.1" max="30" />
<label for="antiGravityGain">
<span i18n="pidTuningAntiGravityGain" />
</label>
</span>
<span class="suboption">
<input type="number" name="itermAcceleratorGain" step="0.1" min="1.1" max="30" />
<label for="antiGravityGain">
<span i18n="pidTuningAntiGravityGain" />
</label>
</span>
<span class="suboption antiGravityThres">
<input type="number" name="itermThrottleThreshold" step="10" min="20" max="1000" />
<label for="antiGravityThres">
<span i18n="pidTuningAntiGravityThres" />
</label>
</span>
</td>
</tr>
<span class="suboption antiGravityThres">
<input type="number" name="itermThrottleThreshold" step="10" min="20" max="1000" />
<label for="antiGravityThres">
<span i18n="pidTuningAntiGravityThres" />
</label>
</span>
</td>
</tr>
</table>
</div>
</div>