Skip to content
This repository was archived by the owner on Apr 19, 2023. It is now read-only.

Commit 16b0cfc

Browse files
committed
Fixed the antigravity feature switch.
1 parent 678823c commit 16b0cfc

File tree

4 files changed

+68
-53
lines changed

4 files changed

+68
-53
lines changed

locales/en/messages.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1114,7 +1114,10 @@
11141114
"message": "Video Transmitter"
11151115
},
11161116
"featureANTI_GRAVITY": {
1117-
"message": "Temporary boost I-Term on high throttle changes"
1117+
"message": "Permanently enable Anti Gravity"
1118+
},
1119+
"featureANTI_GRAVITYTip": {
1120+
"message": "If this is disabled, the 'ANTI GRAVITY' mode can be used to enable Anti Gravity with a switch."
11181121
},
11191122
"featureDYNAMIC_FILTER": {
11201123
"message": "Dynamic gyro notch filtering"

src/js/Features.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ var Features = function (config) {
5555
if (semver.gte(CONFIG.apiVersion, "1.16.0")) {
5656
if (semver.lt(CONFIG.apiVersion, "1.20.0")) {
5757
features.push(
58-
{bit: 23, group: 'pidTuning', name: 'SUPEREXPO_RATES'}
58+
{bit: 23, group: 'superexpoRates', name: 'SUPEREXPO_RATES'}
5959
);
6060
} else if (!semver.gte(config.apiVersion, "1.33.0")) {
6161
features.push(
@@ -84,7 +84,7 @@ var Features = function (config) {
8484

8585
if (semver.gte(CONFIG.apiVersion, "1.36.0")) {
8686
features.push(
87-
{bit: 28, group: 'other', name: 'ANTI_GRAVITY'},
87+
{bit: 28, group: 'antiGravity', name: 'ANTI_GRAVITY', haveTip: true, hideName: true},
8888
{bit: 29, group: 'other', name: 'DYNAMIC_FILTER'}
8989
);
9090
}
@@ -161,15 +161,20 @@ Features.prototype.generateElements = function (featuresElements) {
161161
newElements.push(newElement);
162162
listElements.push(newElement);
163163
} else {
164+
let featureName = '';
165+
if (!self._features[i].hideName) {
166+
featureName = `<td><div>${self._features[i].name}</div></td>`;
167+
}
168+
164169
var newElement = $('<tr><td><input class="feature toggle" id="feature-'
165170
+ i
166171
+ '" name="'
167172
+ self._features[i].name
168173
+ '" title="'
169174
+ self._features[i].name
170-
+ '" type="checkbox"/></td><td><div>'
171-
+ self._features[i].name
172-
+ '</div></td><td><span i18n="feature' + self._features[i].name + '"></span>'
175+
+ '" type="checkbox"/></td>'
176+
+ featureName
177+
+ '<td><span i18n="feature' + self._features[i].name + '"></span>'
173178
+ feature_tip_html + '</td></tr>');
174179

175180
var feature_e = newElement.find('input.feature');

src/js/tabs/pid_tuning.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,6 @@ TABS.pid_tuning.initialize = function (callback) {
171171
$('.antigravity input[name="itermThrottleThreshold"]').val(ADVANCED_TUNING.itermThrottleThreshold);
172172
$('.antigravity input[name="itermAcceleratorGain"]').val(ADVANCED_TUNING.itermAcceleratorGain / 1000);
173173

174-
if (FEATURE_CONFIG.features.isEnabled('ANTI_GRAVITY')) {
175-
$('.antigravity').show();
176-
} else {
177-
$('.antigravity').hide();
178-
}
179174
var antiGravitySwitch = $('#antiGravitySwitch');
180175
antiGravitySwitch.prop('checked', ADVANCED_TUNING.itermAcceleratorGain !== 1000);
181176
antiGravitySwitch.change(function() {
@@ -766,10 +761,6 @@ TABS.pid_tuning.initialize = function (callback) {
766761
FILTER_CONFIG.dterm_lowpass_hz = parseInt($('.pid_filter input[name="dtermLowpassFrequency"]').val());
767762
FILTER_CONFIG.yaw_lowpass_hz = parseInt($('.pid_filter input[name="yawLowpassFrequency"]').val());
768763

769-
if (semver.gte(CONFIG.apiVersion, "1.16.0") && !semver.gte(CONFIG.apiVersion, "1.20.0")) {
770-
FEATURE_CONFIG.features.updateData($('input[name="SUPEREXPO_RATES"]'));
771-
}
772-
773764
if (semver.gte(CONFIG.apiVersion, "1.16.0")) {
774765
const element = $('input[id="vbatpidcompensation"]');
775766
const value = element.is(':checked') ? 1 : 0;
@@ -1000,10 +991,10 @@ TABS.pid_tuning.initialize = function (callback) {
1000991
}
1001992

1002993
function process_html() {
1003-
if (semver.gte(CONFIG.apiVersion, "1.16.0") && !semver.gte(CONFIG.apiVersion, "1.20.0")) {
1004-
FEATURE_CONFIG.features.generateElements($('.tab-pid_tuning .features'));
1005-
} else {
1006-
$('.tab-pid_tuning .pidTuningFeatures').hide();
994+
FEATURE_CONFIG.features.generateElements($('.tab-pid_tuning .features'));
995+
996+
if (semver.lt(CONFIG.apiVersion, "1.16.0") || semver.gte(CONFIG.apiVersion, "1.20.0")) {
997+
$('.tab-pid_tuning .pidTuningSuperexpoRate').hide();
1007998
}
1008999

10091000
if (semver.lt(CONFIG.apiVersion, "1.39.0")) {
@@ -1497,7 +1488,14 @@ TABS.pid_tuning.initialize = function (callback) {
14971488

14981489
// UI Hooks
14991490
// curves
1500-
$('input.feature').on('input change', updateRates);
1491+
$('input.feature').on('input change', function () {
1492+
const element = $(this);
1493+
1494+
FEATURE_CONFIG.features.updateData(element);
1495+
1496+
updateRates();
1497+
});
1498+
15011499
$('.pid_tuning').on('input change', updateRates).trigger('input');
15021500

15031501
function redrawThrottleCurve(forced) {
@@ -1907,6 +1905,8 @@ TABS.pid_tuning.initialize = function (callback) {
19071905
return MSP.promise(MSPCodes.MSP_SET_FILTER_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_FILTER_CONFIG));
19081906
}).then(function () {
19091907
return MSP.promise(MSPCodes.MSP_SET_RC_TUNING, mspHelper.crunch(MSPCodes.MSP_SET_RC_TUNING));
1908+
}).then(function () {
1909+
return MSP.promise(MSPCodes.MSP_SET_FEATURE_CONFIG, mspHelper.crunch(MSPCodes.MSP_SET_FEATURE_CONFIG));
19101910
}).then(function () {
19111911
return MSP.promise(MSPCodes.MSP_EEPROM_WRITE);
19121912
}).then(function () {

src/tabs/pid_tuning.html

Lines changed: 40 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -400,14 +400,14 @@
400400

401401
<div class="cf_column">
402402
<!-- Pid controller advanced settings -->
403-
<div class="gui_box grey pidTuningFeatures spacer_left">
403+
<div class="gui_box grey pidTuningSuperexpoRates spacer_left">
404404
<table class="pid_titlebar new_rates">
405405
<tr>
406406
<th i18n="pidTuningNonProfilePidSettings"></th>
407407
</tr>
408408
</table>
409-
<table class="pidTuningFeatures new_rates">
410-
<tbody class="features pidTuning">
409+
<table class="pidTuningSuperexpoRates new_rates">
410+
<tbody class="features superexpoRates">
411411
<!-- table generated here -->
412412
</tbody>
413413
</table>
@@ -617,36 +617,43 @@
617617
</tr>
618618

619619
<tr class="antigravity">
620-
<td><input type="checkbox" id="antiGravitySwitch" class="toggle" /></td>
621-
<td colspan="3">
622-
<div class="helpicon cf_tip" i18n_title="pidTuningAntiGravityHelp"></div>
623-
<span i18n="pidTuningAntiGravity" />
624-
625-
<span class="suboption antiGravityMode">
626-
<select id="antiGravityMode">
627-
<option i18n="pidTuningAntiGravityModeOptionSmooth" value="0"/>
628-
<option i18n="pidTuningAntiGravityModeOptionStep" value="1"/>
629-
</select>
630-
<label for="antiGravityMode">
631-
<span i18n="pidTuningAntiGravityMode" />
632-
</label>
633-
</span>
634-
635-
<span class="suboption">
636-
<input type="number" name="itermAcceleratorGain" step="0.1" min="1.1" max="30" />
637-
<label for="antiGravityGain">
638-
<span i18n="pidTuningAntiGravityGain" />
639-
</label>
640-
</span>
641-
642-
<span class="suboption antiGravityThres">
643-
<input type="number" name="itermThrottleThreshold" step="10" min="20" max="1000" />
644-
<label for="antiGravityThres">
645-
<span i18n="pidTuningAntiGravityThres" />
646-
</label>
647-
</span>
648-
</td>
649-
</tr>
620+
<td><input type="checkbox" id="antiGravitySwitch" class="toggle" /></td>
621+
<td colspan="3">
622+
<div class="helpicon cf_tip" i18n_title="pidTuningAntiGravityHelp"></div>
623+
<span i18n="pidTuningAntiGravity" />
624+
<span class="suboption">
625+
<table>
626+
<tbody class="features antiGravity">
627+
<!-- table generated here -->
628+
</tbody>
629+
</table>
630+
</span>
631+
632+
<span class="suboption antiGravityMode">
633+
<select id="antiGravityMode">
634+
<option i18n="pidTuningAntiGravityModeOptionSmooth" value="0"/>
635+
<option i18n="pidTuningAntiGravityModeOptionStep" value="1"/>
636+
</select>
637+
<label for="antiGravityMode">
638+
<span i18n="pidTuningAntiGravityMode" />
639+
</label>
640+
</span>
641+
642+
<span class="suboption">
643+
<input type="number" name="itermAcceleratorGain" step="0.1" min="1.1" max="30" />
644+
<label for="antiGravityGain">
645+
<span i18n="pidTuningAntiGravityGain" />
646+
</label>
647+
</span>
648+
649+
<span class="suboption antiGravityThres">
650+
<input type="number" name="itermThrottleThreshold" step="10" min="20" max="1000" />
651+
<label for="antiGravityThres">
652+
<span i18n="pidTuningAntiGravityThres" />
653+
</label>
654+
</span>
655+
</td>
656+
</tr>
650657
</table>
651658
</div>
652659
</div>

0 commit comments

Comments
 (0)