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" "message": "Video Transmitter"
}, },
"featureANTI_GRAVITY": { "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": { "featureDYNAMIC_FILTER": {
"message": "Dynamic gyro notch filtering" "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.gte(CONFIG.apiVersion, "1.16.0")) {
if (semver.lt(CONFIG.apiVersion, "1.20.0")) { if (semver.lt(CONFIG.apiVersion, "1.20.0")) {
features.push( 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")) { } else if (!semver.gte(config.apiVersion, "1.33.0")) {
features.push( features.push(
@ -84,7 +84,7 @@ var Features = function (config) {
if (semver.gte(CONFIG.apiVersion, "1.36.0")) { if (semver.gte(CONFIG.apiVersion, "1.36.0")) {
features.push( 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'} {bit: 29, group: 'other', name: 'DYNAMIC_FILTER'}
); );
} }
@ -161,15 +161,20 @@ Features.prototype.generateElements = function (featuresElements) {
newElements.push(newElement); newElements.push(newElement);
listElements.push(newElement); listElements.push(newElement);
} else { } 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-' var newElement = $('<tr><td><input class="feature toggle" id="feature-'
+ i + i
+ '" name="' + '" name="'
+ self._features[i].name + self._features[i].name
+ '" title="' + '" title="'
+ self._features[i].name + self._features[i].name
+ '" type="checkbox"/></td><td><div>' + '" type="checkbox"/></td>'
+ self._features[i].name + featureName
+ '</div></td><td><span i18n="feature' + self._features[i].name + '"></span>' + '<td><span i18n="feature' + self._features[i].name + '"></span>'
+ feature_tip_html + '</td></tr>'); + feature_tip_html + '</td></tr>');
var feature_e = newElement.find('input.feature'); 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="itermThrottleThreshold"]').val(ADVANCED_TUNING.itermThrottleThreshold);
$('.antigravity input[name="itermAcceleratorGain"]').val(ADVANCED_TUNING.itermAcceleratorGain / 1000); $('.antigravity input[name="itermAcceleratorGain"]').val(ADVANCED_TUNING.itermAcceleratorGain / 1000);
if (FEATURE_CONFIG.features.isEnabled('ANTI_GRAVITY')) {
$('.antigravity').show();
} else {
$('.antigravity').hide();
}
var antiGravitySwitch = $('#antiGravitySwitch'); var antiGravitySwitch = $('#antiGravitySwitch');
antiGravitySwitch.prop('checked', ADVANCED_TUNING.itermAcceleratorGain !== 1000); antiGravitySwitch.prop('checked', ADVANCED_TUNING.itermAcceleratorGain !== 1000);
antiGravitySwitch.change(function() { 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.dterm_lowpass_hz = parseInt($('.pid_filter input[name="dtermLowpassFrequency"]').val());
FILTER_CONFIG.yaw_lowpass_hz = parseInt($('.pid_filter input[name="yawLowpassFrequency"]').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")) { if (semver.gte(CONFIG.apiVersion, "1.16.0")) {
const element = $('input[id="vbatpidcompensation"]'); const element = $('input[id="vbatpidcompensation"]');
const value = element.is(':checked') ? 1 : 0; const value = element.is(':checked') ? 1 : 0;
@ -1000,10 +991,10 @@ TABS.pid_tuning.initialize = function (callback) {
} }
function process_html() { 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'));
FEATURE_CONFIG.features.generateElements($('.tab-pid_tuning .features'));
} else { if (semver.lt(CONFIG.apiVersion, "1.16.0") || semver.gte(CONFIG.apiVersion, "1.20.0")) {
$('.tab-pid_tuning .pidTuningFeatures').hide(); $('.tab-pid_tuning .pidTuningSuperexpoRate').hide();
} }
if (semver.lt(CONFIG.apiVersion, "1.39.0")) { if (semver.lt(CONFIG.apiVersion, "1.39.0")) {
@ -1497,7 +1488,14 @@ TABS.pid_tuning.initialize = function (callback) {
// UI Hooks // UI Hooks
// curves // 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'); $('.pid_tuning').on('input change', updateRates).trigger('input');
function redrawThrottleCurve(forced) { 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)); return MSP.promise(MSPCodes.MSP_SET_FILTER_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_FILTER_CONFIG));
}).then(function () { }).then(function () {
return MSP.promise(MSPCodes.MSP_SET_RC_TUNING, mspHelper.crunch(MSPCodes.MSP_SET_RC_TUNING)); 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 () { }).then(function () {
return MSP.promise(MSPCodes.MSP_EEPROM_WRITE); return MSP.promise(MSPCodes.MSP_EEPROM_WRITE);
}).then(function () { }).then(function () {

View file

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