diff options
author | haslinghuis <mark@numloq.nl> | 2022-02-20 01:59:44 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-20 01:59:44 +0300 |
commit | 94a1f1f6fd63afe1290546c89123ca5e76bd29fc (patch) | |
tree | f5bd9ae3c9dab4961c8b35ba495f071640641d4d | |
parent | fee9dca083bddc26067fe9289ac52fb3eecb8bf1 (diff) | |
parent | 96ab7d8a8e242fd7c2bb9e441d1b26d26fd2b5fa (diff) |
Merge pull request #2817 from Asizon/fix_dshot_bidir_shiwtch
Fix dshot bidir switch
-rw-r--r-- | src/js/tabs/motors.js | 55 | ||||
-rw-r--r-- | src/js/tabs/pid_tuning.js | 44 |
2 files changed, 52 insertions, 47 deletions
diff --git a/src/js/tabs/motors.js b/src/js/tabs/motors.js index f4ea4d45..290d3845 100644 --- a/src/js/tabs/motors.js +++ b/src/js/tabs/motors.js @@ -665,7 +665,7 @@ TABS.motors.initialize = function (callback) { unsyncedPWMSwitchElement.prop('checked', FC.PID_ADVANCED_CONFIG.use_unsyncedPwm !== 0).trigger("change"); $('input[name="unsyncedpwmfreq"]').val(FC.PID_ADVANCED_CONFIG.motor_pwm_rate); $('input[name="digitalIdlePercent"]').val(FC.PID_ADVANCED_CONFIG.digitalIdlePercent); - if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_44)) { + if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_42)) { dshotBidirElement.prop('checked', FC.MOTOR_CONFIG.use_dshot_telemetry).trigger("change"); self.previousDshotBidir = FC.MOTOR_CONFIG.use_dshot_telemetry; @@ -678,33 +678,36 @@ TABS.motors.initialize = function (callback) { self.analyticsChanges['BidirectionalDshot'] = newValue; FC.MOTOR_CONFIG.use_dshot_telemetry = value; - FC.FILTER_CONFIG.dyn_notch_count = self.previousFilterDynCount; - FC.FILTER_CONFIG.dyn_notch_q = self.previousFilterDynQ; - - const dialogSettings = { - title: i18n.getMessage("dialogDynFiltersChangeTitle"), - text: i18n.getMessage("dialogDynFiltersChangeNote"), - buttonYesText: i18n.getMessage("presetsWarningDialogYesButton"), - buttonNoText: i18n.getMessage("presetsWarningDialogNoButton"), - buttonYesCallback: () => _dynFilterChange(), - buttonNoCallback: null, - }; - - const _dynFilterChange = function() { - if (value && !self.previousDshotBidir) { - FC.FILTER_CONFIG.dyn_notch_count = FILTER_DEFAULT.dyn_notch_count_rpm; - FC.FILTER_CONFIG.dyn_notch_q = FILTER_DEFAULT.dyn_notch_q_rpm; - } else if (!value && self.previousDshotBidir) { - FC.FILTER_CONFIG.dyn_notch_count = FILTER_DEFAULT.dyn_notch_count; - FC.FILTER_CONFIG.dyn_notch_q = FILTER_DEFAULT.dyn_notch_q; - } - }; - - if (FC.MOTOR_CONFIG.use_dshot_telemetry !== self.previousDshotBidir) { // if rpmFilterEnabled is not the same value as saved in the fc - GUI.showYesNoDialog(dialogSettings); - } else { + if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_44)) { + const rpmFilterIsDisabled = FC.FILTER_CONFIG.gyro_rpm_notch_harmonics === 0; FC.FILTER_CONFIG.dyn_notch_count = self.previousFilterDynCount; FC.FILTER_CONFIG.dyn_notch_q = self.previousFilterDynQ; + + const dialogDynFilterSettings = { + title: i18n.getMessage("dialogDynFiltersChangeTitle"), + text: i18n.getMessage("dialogDynFiltersChangeNote"), + buttonYesText: i18n.getMessage("presetsWarningDialogYesButton"), + buttonNoText: i18n.getMessage("presetsWarningDialogNoButton"), + buttonYesCallback: () => _dynFilterChange(), + buttonNoCallback: null, + }; + + const _dynFilterChange = function() { + if (value && !self.previousDshotBidir) { + FC.FILTER_CONFIG.dyn_notch_count = FILTER_DEFAULT.dyn_notch_count_rpm; + FC.FILTER_CONFIG.dyn_notch_q = FILTER_DEFAULT.dyn_notch_q_rpm; + } else if (!value && self.previousDshotBidir) { + FC.FILTER_CONFIG.dyn_notch_count = FILTER_DEFAULT.dyn_notch_count; + FC.FILTER_CONFIG.dyn_notch_q = FILTER_DEFAULT.dyn_notch_q; + } + }; + + if ((FC.MOTOR_CONFIG.use_dshot_telemetry !== self.previousDshotBidir) && !(rpmFilterIsDisabled)) { + GUI.showYesNoDialog(dialogDynFilterSettings); + } else { + FC.FILTER_CONFIG.dyn_notch_count = self.previousFilterDynCount; + FC.FILTER_CONFIG.dyn_notch_q = self.previousFilterDynQ; + } } }); diff --git a/src/js/tabs/pid_tuning.js b/src/js/tabs/pid_tuning.js index 1a45fcdc..8b31af85 100644 --- a/src/js/tabs/pid_tuning.js +++ b/src/js/tabs/pid_tuning.js @@ -455,30 +455,32 @@ TABS.pid_tuning.initialize = function (callback) { rpmFilterHarmonics_e.val(FILTER_DEFAULT.gyro_rpm_notch_harmonics); } - const dialogSettings = { - title: i18n.getMessage("dialogDynFiltersChangeTitle"), - text: i18n.getMessage("dialogDynFiltersChangeNote"), - buttonYesText: i18n.getMessage("presetsWarningDialogYesButton"), - buttonNoText: i18n.getMessage("presetsWarningDialogNoButton"), - buttonYesCallback: () => _dynFilterChange(), - buttonNoCallback: null, - }; + if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_44)) { + const dialogDynFilterSettings = { + title: i18n.getMessage("dialogDynFiltersChangeTitle"), + text: i18n.getMessage("dialogDynFiltersChangeNote"), + buttonYesText: i18n.getMessage("presetsWarningDialogYesButton"), + buttonNoText: i18n.getMessage("presetsWarningDialogNoButton"), + buttonYesCallback: () => _dynFilterChange(), + buttonNoCallback: null, + }; + + const _dynFilterChange = function() { + if (checked) { + dynamicNotchCount_e.val(FILTER_DEFAULT.dyn_notch_count_rpm); + dynamicNotchQ_e.val(FILTER_DEFAULT.dyn_notch_q_rpm); + } else { + dynamicNotchCount_e.val(FILTER_DEFAULT.dyn_notch_count); + dynamicNotchQ_e.val(FILTER_DEFAULT.dyn_notch_q); + } + }; - const _dynFilterChange = function() { - if (checked) { - dynamicNotchCount_e.val(FILTER_DEFAULT.dyn_notch_count_rpm); - dynamicNotchQ_e.val(FILTER_DEFAULT.dyn_notch_q_rpm); + if (checked !== (FC.FILTER_CONFIG.gyro_rpm_notch_harmonics !== 0)) { + GUI.showYesNoDialog(dialogDynFilterSettings); } else { - dynamicNotchCount_e.val(FILTER_DEFAULT.dyn_notch_count); - dynamicNotchQ_e.val(FILTER_DEFAULT.dyn_notch_q); + dynamicNotchCount_e.val(self.previousFilterDynCount); + dynamicNotchQ_e.val(self.previousFilterDynQ); } - }; - - if (checked !== (FC.FILTER_CONFIG.gyro_rpm_notch_harmonics !== 0)) { // if rpmFilterEnabled is not the same value as saved in the fc - GUI.showYesNoDialog(dialogSettings); - } else { - dynamicNotchCount_e.val(self.previousFilterDynCount); - dynamicNotchQ_e.val(self.previousFilterDynQ); } $('.rpmFilter span.suboption').toggle(checked); |