Skip to content

Commit 476ba71

Browse files
committed
disable only if rpy
1 parent 5a13439 commit 476ba71

File tree

2 files changed

+29
-9
lines changed

2 files changed

+29
-9
lines changed

src/js/TuningSliders.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,8 +405,10 @@ TuningSliders.updatePidSlidersDisplay = function() {
405405
});
406406
});
407407

408-
if ($('input[id="useIntegratedYaw"]').is(':checked')) {
409-
this.pidSlidersUnavailable = true;
408+
if (semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_44)) {
409+
if ($('input[id="useIntegratedYaw"]').is(':checked')) {
410+
this.pidSlidersUnavailable = true;
411+
}
410412
}
411413

412414
if (!this.pidSlidersUnavailable) {

src/js/tabs/pid_tuning.js

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -547,10 +547,10 @@ TABS.pid_tuning.initialize = function (callback) {
547547

548548
$('input[id="useIntegratedYaw"]').change(function() {
549549
const checked = $(this).is(':checked');
550-
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_44)) {
551-
this.sliderPidsMode = 0;
550+
// 4.3 firmware has RP mode.
551+
if (semver.lt(FC.CONFIG.apiVersion, API_VERSION_1_44)) {
552+
$('#pid_main .pid_data input').prop('disabled', !checked);
552553
}
553-
$('#pid_main .pid_data input').prop('disabled', !checked);
554554
$('#pidTuningIntegratedYawCaution').toggle(checked);
555555
}).change();
556556

@@ -1806,9 +1806,11 @@ TABS.pid_tuning.initialize = function (callback) {
18061806
});
18071807
});
18081808

1809+
// exclude integratedYaw from setDirty for 4.3 as it uses RP mode.
18091810
$('#pid-tuning').find('input').each(function (k, item) {
18101811
if ($(item).attr('class') !== "feature toggle"
1811-
&& $(item).attr('class') !== "nonProfile") {
1812+
&& $(item).attr('class') !== "nonProfile"
1813+
&& (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_44) && $(item).attr('id'))) {
18121814
$(item).change(function () {
18131815
self.setDirty(true);
18141816
});
@@ -1931,12 +1933,23 @@ TABS.pid_tuning.initialize = function (callback) {
19311933
});
19321934
}
19331935

1934-
// disable slides if Integrated Yaw is enabled or Slider PID mode is set to OFF
1935-
$('input[id="useIntegratedYaw"]').change(() => TuningSliders.updatePidSlidersDisplay());
1936+
const useIntegratedYaw = $('input[id="useIntegratedYaw"]');
1937+
1938+
useIntegratedYaw.on('change', () => {
1939+
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_44)) {
1940+
// set slider to RP mode if Integrated Yaw is enabled and sliders are enabled
1941+
if (useIntegratedYaw.is(':checked') && TuningSliders.sliderPidsMode) {
1942+
sliderPidsModeSelect.val(1).trigger('change');
1943+
}
1944+
} else {
1945+
// disable sliders if Integrated Yaw is enabled or Slider PID mode is set to OFF
1946+
TuningSliders.updatePidSlidersDisplay();
1947+
}
1948+
});
19361949

19371950
// trigger Slider Display update when PID mode is changed
19381951
if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_44)) {
1939-
$('select[id="sliderPidsModeSelect"]').on('change', function () {
1952+
sliderPidsModeSelect.on('change', function () {
19401953
const setMode = parseInt($(this).val());
19411954

19421955
TuningSliders.sliderPidsMode = setMode;
@@ -1947,6 +1960,11 @@ TABS.pid_tuning.initialize = function (callback) {
19471960
const disableRP = !!setMode;
19481961
const disableY = setMode > 1;
19491962

1963+
// disable Integrated Yaw when going into RPY mode
1964+
if (setMode === 2) {
1965+
useIntegratedYaw.prop('checked', false).trigger('change');
1966+
}
1967+
19501968
$('#pid_main .ROLL .pid_data input, #pid_main .PITCH .pid_data input').each(function() {
19511969
$(this).prop('disabled', disableRP);
19521970
});

0 commit comments

Comments
 (0)