diff --git a/locales/en/messages.json b/locales/en/messages.json index 0d73a890..6a456b71 100644 --- a/locales/en/messages.json +++ b/locales/en/messages.json @@ -2621,71 +2621,68 @@ "pidTuningNonProfileFilterSettings": { "message": "Profile independent Filter Settings" }, + "pidTuningGyroLowpassFiltersGroup": { + "message": "Gyro Lowpass Filters" + }, "pidTuningGyroLowpassFrequency": { - "message": "Gyro Soft Lowpass Frequency [Hz]" + "message": "Gyro Lowpass 1 Cutoff Frequency [Hz]" }, - "pidTuningGyroLowpassFrequencyHelp": { - "message": "Gyro Soft Lowpass Frequency [Hz]" + "pidTuningGyroLowpassType": { + "message": "Gyro Lowpass 1 Filter Type" }, - "pidTuningGyroNotch1Enable": { - "message": "Enable Gyro Notch Filter 1" + "pidTuningGyroLowpass2Frequency": { + "message": "Gyro Lowpass 2 Cutoff Frequency [Hz]" + }, + "pidTuningGyroLowpass2Type": { + "message": "Gyro Lowpass 2 Filter Type" + }, + "pidTuningGyroNotchFiltersGroup": { + "message": "Gyro Notch Filters" }, "pidTuningGyroNotch1Frequency": { - "message": "Gyro Notch Filter 1 Frequency [Hz]" - }, - "pidTuningGyroNotch2Enable": { - "message": "Enable Gyro Notch Filter 2" + "message": "Gyro Notch Filter 1 Center Frequency [Hz]" }, "pidTuningGyroNotch2Frequency": { - "message": "Gyro Notch Filter 2 Frequency [Hz]" - }, - "pidTuningGyroNotchFrequencyHelp": { - "message": "Gyro Notch Filter Frequency in Hz" + "message": "Gyro Notch Filter 2 Center Frequency [Hz]" }, "pidTuningGyroNotch1Cutoff": { - "message": "Gyro Notch Filter Cutoff 1 Frequency [Hz]" + "message": "Gyro Notch Filter 1 Cutoff Frequency [Hz]" }, "pidTuningGyroNotch2Cutoff": { - "message": "Gyro Notch Filter Cutoff 2 Frequency [Hz]" + "message": "Gyro Notch Filter 2 Cutoff Frequency [Hz]" }, - "pidTuningGyroNotchCutoffHelp": { - "message": "Gyro Notch Filter Cutoff Frequency in Hz (This is where notch filter starts. For example with notch filter 160 and notch Hz of 260 it means the range is 160-360Hz with most attenuation around center)" + "pidTuningNotchFilterHelp": { + "message": "The Notch Filter has a Center and a Cutoff. The filter is symmetrical. The Center Frequency is the center of the filter and the Cutoff Frequency is where Notch filter starts. For example with Notch Cutoff of 160 and Notch Center of 260 it means the range is 160-360Hz with most attenuation around center" }, "pidTuningFilterSettings": { - "message": "Filter Settings" + "message": "Profile dependent Filter Settings" }, + "pidTuningDTermLowpassFiltersGroup": { + "message": "D Term Lowpass Filters" + }, "pidTuningDTermLowpassType": { - "message": "D-Term Lowpass Filter" - }, - "pidTuningDTermLowpassTypeTip": { - "message": "Select D-Term lowpass filter type to use. Default is BIQUAD" + "message": "D Term Lowpass 1 Filter Type" }, "pidTuningDTermLowpassFrequency": { - "message": "D Term Lowpass Frequency [Hz]" + "message": "D Term Lowpass 1 Cutoff Frequency [Hz]" }, - "pidTuningDTermLowpassFrequencyHelp": { - "message": "D Term Lowpass Frequency [Hz] (0 means disabled)" - }, - "pidTuningDTermNotchEnable": { - "message": "Enable D Term Notch Filter" + "pidTuningDTermLowpass2Frequency": { + "message": "D Term Lowpass 2 Cutoff Frequency [Hz]" }, + "pidTuningDTermNotchFiltersGroup": { + "message": "D Term Notch Filters" + }, "pidTuningDTermNotchFrequency": { - "message": "D Term Notch Filter Frequency [Hz]" - }, - "pidTuningDTermNotchFrequencyHelp": { - "message": "D Term Notch Filter Frequency [Hz] (0 means disabled)" + "message": "D Term Notch Filter Center Frequency [Hz]" }, "pidTuningDTermNotchCutoff": { - "message": "D Term Notch Filter Cutoff [Hz]" - }, - "pidTuningDTermNotchCutoffHelp": { - "message": "D Term Notch Filter Cutoff in Hz (This is where notch filter starts. For example with notch filter 160 and notch Hz of 260 it means the range is 160-360Hz with most attenuation around center)" + "message": "D Term Notch Filter Cutoff Frequency [Hz]" }, + "pidTuningYawLospassFiltersGroup": { + "message": "Yaw Lowpass Filters" + }, "pidTuningYawLowpassFrequency": { - "message": "Yaw Lowpass Frequency [Hz]" - }, - "pidTuningYawLowpassFrequencyHelp": { - "message": "Yaw Lowpass Frequency [Hz] (Yaw axis can sometimes be noiser than the rest. This filter only affects the P of yaw)" + "message": "Yaw Lowpass Cutoff Frequency [Hz]" }, "pidTuningVbatPidCompensation": { "message": "Vbat PID Compensation" diff --git a/src/css/tabs/pid_tuning.css b/src/css/tabs/pid_tuning.css index 8b83d0ce..34392add 100644 --- a/src/css/tabs/pid_tuning.css +++ b/src/css/tabs/pid_tuning.css @@ -330,6 +330,13 @@ padding-right: 5px; } +.tab-pid_tuning table .groupSwitchValue { + display: inline-flex; +} + +.tab-pid_tuning table .groupSwitchValue .inputValue { + width: 80px; +} .tab-pid_tuning table input { display: block; width: calc(100% - 0px); @@ -340,6 +347,10 @@ border-radius: 0px; } +.tab-pid_tuning table select { + text-align-last: right; +} + .tab-pid_tuning .tab_container { float: left; width: 396px; @@ -440,7 +451,7 @@ .pid_mode { width: calc(100% - 5px); - height: 20px; + height: 18px; background-color: #D6D6D6; float: left; margin: 0px; @@ -448,7 +459,7 @@ text-align: left; padding-left: 5px; line-height: 13px; - padding-top: 8px; + padding-top: 5px; font-size: 12px; border-bottom: 1px solid #ccc; color: #828282; @@ -461,6 +472,10 @@ rgba(255, 255, 255, .2) 100%, transparent); } +.pid_mode > div:first-child { + float: left; +} + .pid_titlebar { color: #fff; background-color: #828885; @@ -745,6 +760,25 @@ width: 40%; padding-left: 5px; } +.subtab-filter table tr td:first-child { + text-align: right; + padding-left: 5px; + width: 1%; +} +.subtab-filter .two_columns { + display: flex; +} + +.subtab-filter .two_columns .two_columns_first { + margin-right: 10px; + height: fit-content; +} + +.subtab-filter .two_columns .two_columns_second{ + margin-left: 10px; + height: fit-content; +} + .tab-pid_tuning .tabboarder { background-color: #ffbb00; float: left; diff --git a/src/js/fc.js b/src/js/fc.js index d2a3c4ca..710d807c 100644 --- a/src/js/fc.js +++ b/src/js/fc.js @@ -333,16 +333,22 @@ var FC = { }; FILTER_CONFIG = { - gyro_soft_lpf_hz: 0, - dterm_lpf_hz: 0, - yaw_lpf_hz: 0, - gyro_soft_notch_hz_1: 0, - gyro_soft_notch_cutoff_1: 0, + gyro_hardware_lpf: 0, + gyro_32khz_hardware_lpf: 0, + gyro_lowpass_hz: 0, + gyro_lowpass_type: 0, + gyro_lowpass2_hz: 0, + gyro_lowpass2_type: 0, + gyro_notch_hz: 0, + gyro_notch_cutoff: 0, + gyro_notch2_hz: 0, + gyro_notch2_cutoff: 0, + dterm_lowpass_hz: 0, + dterm_lowpass_type: 0, + dterm_lowpass2_hz: 0, dterm_notch_hz: 0, dterm_notch_cutoff: 0, - gyro_soft_notch_hz_2: 0, - gyro_soft_notch_cutoff_2: 0, - dterm_filter_type: 0, + yaw_lowpass_hz: 0, }; ADVANCED_TUNING = { @@ -399,12 +405,20 @@ var FC = { RXFAIL_CONFIG = []; DEFAULT = { - gyro_soft_notch_cutoff_1: 300, - gyro_soft_notch_hz_1: 400, - gyro_soft_notch_cutoff_2: 100, - gyro_soft_notch_hz_2: 200, + gyro_lowpass_hz: 100, + gyro_lowpass_type: 0, + gyro_lowpass2_hz: 500, + gyro_lowpass2_type: 0, + gyro_notch_cutoff: 300, + gyro_notch_hz: 400, + gyro_notch2_cutoff: 100, + gyro_notch2_hz: 200, + dterm_lowpass_hz: 100, + dterm_lowpass_type: 0, + dterm_lowpass2_hz: 300, dterm_notch_cutoff: 160, dterm_notch_hz: 260, + yaw_lowpass_hz: 100, }; } }; diff --git a/src/js/msp/MSPHelper.js b/src/js/msp/MSPHelper.js index d48f71ec..b0b2caef 100644 --- a/src/js/msp/MSPHelper.js +++ b/src/js/msp/MSPHelper.js @@ -822,20 +822,29 @@ MspHelper.prototype.process_data = function(dataHandler) { } break; case MSPCodes.MSP_FILTER_CONFIG: - FILTER_CONFIG.gyro_soft_lpf_hz = data.readU8(); - FILTER_CONFIG.dterm_lpf_hz = data.readU16(); - FILTER_CONFIG.yaw_lpf_hz = data.readU16(); + FILTER_CONFIG.gyro_lowpass_hz = data.readU8(); + FILTER_CONFIG.dterm_lowpass_hz = data.readU16(); + FILTER_CONFIG.yaw_lowpass_hz = data.readU16(); if (semver.gte(CONFIG.apiVersion, "1.20.0")) { - FILTER_CONFIG.gyro_soft_notch_hz_1 = data.readU16(); - FILTER_CONFIG.gyro_soft_notch_cutoff_1 = data.readU16(); + FILTER_CONFIG.gyro_notch_hz = data.readU16(); + FILTER_CONFIG.gyro_notch_cutoff = data.readU16(); FILTER_CONFIG.dterm_notch_hz = data.readU16(); FILTER_CONFIG.dterm_notch_cutoff = data.readU16(); if (semver.gte(CONFIG.apiVersion, "1.21.0")) { - FILTER_CONFIG.gyro_soft_notch_hz_2 = data.readU16(); - FILTER_CONFIG.gyro_soft_notch_cutoff_2 = data.readU16(); + FILTER_CONFIG.gyro_notch2_hz = data.readU16(); + FILTER_CONFIG.gyro_notch2_cutoff = data.readU16(); } if (semver.gte(CONFIG.apiVersion, "1.36.0")) { - FILTER_CONFIG.dterm_filter_type = data.readU8(); + FILTER_CONFIG.dterm_lowpass_type = data.readU8(); + } + if (semver.gte(CONFIG.apiVersion, "1.39.0")) { + FILTER_CONFIG.gyro_hardware_lpf = data.readU8(); + FILTER_CONFIG.gyro_32khz_hardware_lpf = data.readU8(); + FILTER_CONFIG.gyro_soft_lpf_hz = data.readU16(); + FILTER_CONFIG.gyro_lowpass2_hz = data.readU16(); + FILTER_CONFIG.gyro_lowpass_type = data.readU8(); + FILTER_CONFIG.gyro_lowpass2_type = data.readU8(); + FILTER_CONFIG.dterm_lowpass2_hz = data.readU16(); } } break; @@ -1458,19 +1467,28 @@ MspHelper.prototype.crunch = function(code) { break; case MSPCodes.MSP_SET_FILTER_CONFIG: buffer.push8(FILTER_CONFIG.gyro_soft_lpf_hz) - .push16(FILTER_CONFIG.dterm_lpf_hz) - .push16(FILTER_CONFIG.yaw_lpf_hz); + .push16(FILTER_CONFIG.dterm_lowpass_hz) + .push16(FILTER_CONFIG.yaw_lowpass_hz); if (semver.gte(CONFIG.apiVersion, "1.20.0")) { - buffer.push16(FILTER_CONFIG.gyro_soft_notch_hz_1) - .push16(FILTER_CONFIG.gyro_soft_notch_cutoff_1) + buffer.push16(FILTER_CONFIG.gyro_notch_hz) + .push16(FILTER_CONFIG.gyro_notch_cutoff) .push16(FILTER_CONFIG.dterm_notch_hz) .push16(FILTER_CONFIG.dterm_notch_cutoff); if (semver.gte(CONFIG.apiVersion, "1.21.0")) { - buffer.push16(FILTER_CONFIG.gyro_soft_notch_hz_2) - .push16(FILTER_CONFIG.gyro_soft_notch_cutoff_2) + buffer.push16(FILTER_CONFIG.gyro_notch2_hz) + .push16(FILTER_CONFIG.gyro_notch2_cutoff) } if (semver.gte(CONFIG.apiVersion, "1.36.0")) { - buffer.push8(FILTER_CONFIG.dterm_filter_type); + buffer.push8(FILTER_CONFIG.dterm_lowpass_type); + } + if (semver.gte(CONFIG.apiVersion, "1.39.0")) { + buffer.push8(FILTER_CONFIG.gyro_hardware_lpf) + .push8(FILTER_CONFIG.gyro_32khz_hardware_lpf) + .push16(FILTER_CONFIG.gyro_lowpass_hz) + .push16(FILTER_CONFIG.gyro_lowpass2_hz) + .push8(FILTER_CONFIG.gyro_lowpass_type) + .push8(FILTER_CONFIG.gyro_lowpass2_type) + .push16(FILTER_CONFIG.dterm_lowpass2_hz); } } break; diff --git a/src/js/tabs/pid_tuning.js b/src/js/tabs/pid_tuning.js index 05b5bb92..a698327b 100755 --- a/src/js/tabs/pid_tuning.js +++ b/src/js/tabs/pid_tuning.js @@ -217,9 +217,9 @@ TABS.pid_tuning.initialize = function (callback) { if (semver.gte(CONFIG.apiVersion, "1.16.0")) { $('.pid_tuning input[name="rc_rate_yaw"]').val(RC_tuning.rcYawRate.toFixed(2)); - $('.pid_filter input[name="gyroLowpassFrequency"]').val(FILTER_CONFIG.gyro_soft_lpf_hz); - $('.pid_filter input[name="dtermLowpassFrequency"]').val(FILTER_CONFIG.dterm_lpf_hz); - $('.pid_filter input[name="yawLowpassFrequency"]').val(FILTER_CONFIG.yaw_lpf_hz); + $('.pid_filter input[name="gyroLowpassFrequency"]').val(FILTER_CONFIG.gyro_lowpass_hz); + $('.pid_filter input[name="dtermLowpassFrequency"]').val(FILTER_CONFIG.dterm_lowpass_hz); + $('.pid_filter input[name="yawLowpassFrequency"]').val(FILTER_CONFIG.yaw_lowpass_hz); } else { $('.tab-pid_tuning .subtab-filter').hide(); $('.tab-pid_tuning .tab_container').hide(); @@ -234,8 +234,8 @@ TABS.pid_tuning.initialize = function (callback) { } if (semver.gte(CONFIG.apiVersion, "1.20.0")) { - $('.pid_filter input[name="gyroNotch1Frequency"]').val(FILTER_CONFIG.gyro_soft_notch_hz_1); - $('.pid_filter input[name="gyroNotch1Cutoff"]').val(FILTER_CONFIG.gyro_soft_notch_cutoff_1); + $('.pid_filter input[name="gyroNotch1Frequency"]').val(FILTER_CONFIG.gyro_notch_hz); + $('.pid_filter input[name="gyroNotch1Cutoff"]').val(FILTER_CONFIG.gyro_notch_cutoff); $('.pid_filter input[name="dTermNotchFrequency"]').val(FILTER_CONFIG.dterm_notch_hz); $('.pid_filter input[name="dTermNotchCutoff"]').val(FILTER_CONFIG.dterm_notch_cutoff); @@ -260,8 +260,8 @@ TABS.pid_tuning.initialize = function (callback) { } if (semver.gte(CONFIG.apiVersion, "1.21.0")) { - $('.pid_filter input[name="gyroNotch2Frequency"]').val(FILTER_CONFIG.gyro_soft_notch_hz_2); - $('.pid_filter input[name="gyroNotch2Cutoff"]').val(FILTER_CONFIG.gyro_soft_notch_cutoff_2); + $('.pid_filter input[name="gyroNotch2Frequency"]').val(FILTER_CONFIG.gyro_notch2_hz); + $('.pid_filter input[name="gyroNotch2Cutoff"]').val(FILTER_CONFIG.gyro_notch2_cutoff); } else { $('.pid_filter .gyroNotch2').hide(); } @@ -274,28 +274,47 @@ TABS.pid_tuning.initialize = function (callback) { } if (semver.gte(CONFIG.apiVersion, "1.36.0")) { - $('.profile select[name="dtermFilterType"]').val(FILTER_CONFIG.dterm_filter_type); + $('.pid_filter select[name="dtermLowpassType"]').val(FILTER_CONFIG.dterm_lowpass_type); $('.antigravity input[name="itermThrottleThreshold"]').val(ADVANCED_TUNING.itermThrottleThreshold); $('.antigravity input[name="itermAcceleratorGain"]').val(ADVANCED_TUNING.itermAcceleratorGain / 1000); } else { - $('.dtermfiltertype').hide(); + $('.dtermLowpassType').hide(); $('.antigravity').hide(); } + if (semver.gte(CONFIG.apiVersion, "1.39.0")) { + + $('.pid_filter input[name="gyroLowpass2Frequency"]').val(FILTER_CONFIG.gyro_lowpass2_hz); + $('.pid_filter select[name="gyroLowpassType"]').val(FILTER_CONFIG.gyro_lowpass_type); + $('.pid_filter select[name="gyroLowpass2Type"]').val(FILTER_CONFIG.gyro_lowpass2_type); + $('.pid_filter input[name="dtermLowpass2Frequency"]').val(FILTER_CONFIG.dterm_lowpass2_hz); + + // We load it again because the limits are now bigger than in 1.16.0 + $('.pid_filter input[name="gyroLowpassFrequency"]').attr("max","16000"); + $('.pid_filter input[name="gyroLowpassFrequency"]').val(FILTER_CONFIG.gyro_lowpass_hz); + + } else { + $('.gyroLowpass2').hide(); + $('.gyroLowpass2Type').hide(); + $('.dtermLowpass2').hide(); + } + $('input[id="gyroNotch1Enabled"]').change(function() { var checked = $(this).is(':checked'); - var hz = FILTER_CONFIG.gyro_soft_notch_hz_1 > 0 ? FILTER_CONFIG.gyro_soft_notch_hz_1 : DEFAULT.gyro_soft_notch_hz_1; - var cutoff = FILTER_CONFIG.gyro_soft_notch_cutoff_1 > 0 ? FILTER_CONFIG.gyro_soft_notch_cutoff_1 : DEFAULT.gyro_soft_notch_cutoff_1; + var hz = FILTER_CONFIG.gyro_notch_hz > 0 ? FILTER_CONFIG.gyro_notch_hz : DEFAULT.gyro_notch_hz; + var cutoff = FILTER_CONFIG.gyro_notch_cutoff > 0 ? FILTER_CONFIG.gyro_notch_cutoff : DEFAULT.gyro_notch_cutoff; $('.pid_filter input[name="gyroNotch1Frequency"]').val(checked ? hz : 0).attr('disabled', !checked); + $('.pid_filter input[name="gyroNotch1Cutoff"]').attr('disabled', !checked); }); $('input[id="gyroNotch2Enabled"]').change(function() { var checked = $(this).is(':checked'); - var hz = FILTER_CONFIG.gyro_soft_notch_hz_2 > 0 ? FILTER_CONFIG.gyro_soft_notch_hz_2 : DEFAULT.gyro_soft_notch_hz_2; - var cutoff = FILTER_CONFIG.gyro_soft_notch_cutoff_2 > 0 ? FILTER_CONFIG.gyro_soft_notch_cutoff_2 : DEFAULT.gyro_soft_notch_cutoff_2; + var hz = FILTER_CONFIG.gyro_notch2_hz > 0 ? FILTER_CONFIG.gyro_notch2_hz : DEFAULT.gyro_notch2_hz; + var cutoff = FILTER_CONFIG.gyro_notch2_cutoff > 0 ? FILTER_CONFIG.gyro_notch2_cutoff : DEFAULT.gyro_notch2_cutoff; $('.pid_filter input[name="gyroNotch2Frequency"]').val(checked ? hz : 0).attr('disabled', !checked); + $('.pid_filter input[name="gyroNotch2Cutoff"]').attr('disabled', !checked); }); $('input[id="dtermNotchEnabled"]').change(function() { @@ -304,11 +323,83 @@ TABS.pid_tuning.initialize = function (callback) { var cutoff = FILTER_CONFIG.dterm_notch_cutoff > 0 ? FILTER_CONFIG.dterm_notch_cutoff : DEFAULT.dterm_notch_cutoff; $('.pid_filter input[name="dTermNotchFrequency"]').val(checked ? hz : 0).attr('disabled', !checked); + $('.pid_filter input[name="dTermNotchCutoff"]').attr('disabled', !checked); }); - $('input[id="gyroNotch1Enabled"]').prop('checked', FILTER_CONFIG.gyro_soft_notch_hz_1 != 0).change(); - $('input[id="gyroNotch2Enabled"]').prop('checked', FILTER_CONFIG.gyro_soft_notch_hz_2 != 0).change(); + $('input[id="gyroLowpassEnabled"]').change(function() { + var checked = $(this).is(':checked'); + var cutoff = FILTER_CONFIG.gyro_lowpass_hz > 0 ? FILTER_CONFIG.gyro_lowpass_hz : DEFAULT.gyro_lowpass_hz; + var type = FILTER_CONFIG.gyro_lowpass_type > 0 ? FILTER_CONFIG.gyro_lowpass_type : DEFAULT.gyro_lowpass_type; + + $('.pid_filter input[name="gyroLowpassFrequency"]').val(checked ? cutoff : 0).attr('disabled', !checked); + $('.pid_filter select[name="gyroLowpassType"]').val(checked ? type : 0).attr('disabled', !checked); + }); + + $('input[id="gyroLowpass2Enabled"]').change(function() { + var checked = $(this).is(':checked'); + var cutoff = FILTER_CONFIG.gyro_lowpass2_hz > 0 ? FILTER_CONFIG.gyro_lowpass2_hz : DEFAULT.gyro_lowpass2_hz; + var type = FILTER_CONFIG.gyro_lowpass2_type > 0 ? FILTER_CONFIG.gyro_lowpass2_type : DEFAULT.gyro_lowpass2_type; + + $('.pid_filter input[name="gyroLowpass2Frequency"]').val(checked ? cutoff : 0).attr('disabled', !checked); + $('.pid_filter select[name="gyroLowpass2Type"]').val(checked ? type : 0).attr('disabled', !checked); + }); + + $('input[id="dtermLowpassEnabled"]').change(function() { + var checked = $(this).is(':checked'); + var cutoff = FILTER_CONFIG.dterm_lowpass_hz > 0 ? FILTER_CONFIG.dterm_lowpass_hz : DEFAULT.dterm_lowpass_hz; + var type = FILTER_CONFIG.dterm_lowpass_type > 0 ? FILTER_CONFIG.dterm_lowpass_type : DEFAULT.dterm_lowpass_type; + + $('.pid_filter input[name="dtermLowpassFrequency"]').val(checked ? cutoff : 0).attr('disabled', !checked); + $('.pid_filter select[name="dtermLowpassType"]').val(checked ? type : 0).attr('disabled', !checked); + }); + + $('input[id="dtermLowpass2Enabled"]').change(function() { + var checked = $(this).is(':checked'); + var cutoff = FILTER_CONFIG.dterm_lowpass2_hz > 0 ? FILTER_CONFIG.dterm_lowpass2_hz : DEFAULT.dterm_lowpass2_hz; + + $('.pid_filter input[name="dtermLowpass2Frequency"]').val(checked ? cutoff : 0).attr('disabled', !checked); + }); + + $('input[id="yawLowpassEnabled"]').change(function() { + var checked = $(this).is(':checked'); + var cutoff = FILTER_CONFIG.yaw_lowpass_hz > 0 ? FILTER_CONFIG.yaw_lowpass_hz : DEFAULT.yaw_lowpass_hz; + + $('.pid_filter input[name="yawLowpassFrequency"]').val(checked ? cutoff : 0).attr('disabled', !checked); + }); + + // The notch cutoff must be smaller than the notch frecuency + function adjustNotchCutoff(frequencyName, cutoffName) { + var frecuency = $(".pid_filter input[name='" + frequencyName + "']").val(); + var cutoff = $(".pid_filter input[name='" + cutoffName + "']").val(); + + // Change the max and refresh the value if needed + $(".pid_filter input[name='" + cutoffName + "']").attr("max",frecuency - 1); + if (cutoff >= frecuency) { + $(".pid_filter input[name='" + cutoffName + "']").val(frecuency - 1); + } + } + + $('input[name="gyroNotch1Frequency"]').change(function() { + adjustNotchCutoff("gyroNotch1Frequency", "gyroNotch1Cutoff"); + }).change(); + + $('input[name="gyroNotch2Frequency"]').change(function() { + adjustNotchCutoff("gyroNotch2Frequency", "gyroNotch2Cutoff"); + }).change(); + + $('input[name="dTermNotchFrequency"]').change(function() { + adjustNotchCutoff("dTermNotchFrequency", "dTermNotchCutoff"); + }).change(); + + // Initial state of the filters: enabled or disabled + $('input[id="gyroNotch1Enabled"]').prop('checked', FILTER_CONFIG.gyro_notch_hz != 0).change(); + $('input[id="gyroNotch2Enabled"]').prop('checked', FILTER_CONFIG.gyro_notch2_hz != 0).change(); $('input[id="dtermNotchEnabled"]').prop('checked', FILTER_CONFIG.dterm_notch_hz != 0).change(); + $('input[id="gyroLowpassEnabled"]').prop('checked', FILTER_CONFIG.gyro_lowpass_hz != 0).change(); + $('input[id="gyroLowpass2Enabled"]').prop('checked', FILTER_CONFIG.gyro_lowpass2_hz != 0).change(); + $('input[id="dtermLowpassEnabled"]').prop('checked', FILTER_CONFIG.dterm_lowpass_hz != 0).change(); + $('input[id="dtermLowpass2Enabled"]').prop('checked', FILTER_CONFIG.dterm_lowpass2_hz != 0).change(); + $('input[id="yawLowpassEnabled"]').prop('checked', FILTER_CONFIG.yaw_lowpass_hz != 0).change(); } function form_to_pid_and_rc() { @@ -385,9 +476,9 @@ TABS.pid_tuning.initialize = function (callback) { RC_tuning.dynamic_THR_PID = parseFloat($('.tpa input[name="tpa"]').val()); RC_tuning.dynamic_THR_breakpoint = parseInt($('.tpa input[name="tpa-breakpoint"]').val()); - FILTER_CONFIG.gyro_soft_lpf_hz = parseInt($('.pid_filter input[name="gyroLowpassFrequency"]').val()); - FILTER_CONFIG.dterm_lpf_hz = parseInt($('.pid_filter input[name="dtermLowpassFrequency"]').val()); - FILTER_CONFIG.yaw_lpf_hz = parseInt($('.pid_filter input[name="yawLowpassFrequency"]').val()); + FILTER_CONFIG.gyro_lowpass_hz = parseInt($('.pid_filter input[name="gyroLowpassFrequency"]').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()); if (semver.gte(CONFIG.apiVersion, "1.16.0") && !semver.gte(CONFIG.apiVersion, "1.20.0")) { FEATURE_CONFIG.features.updateData($('input[name="SUPEREXPO_RATES"]')); @@ -405,13 +496,13 @@ TABS.pid_tuning.initialize = function (callback) { ADVANCED_TUNING.dtermSetpointTransition = parseInt($('input[name="dtermSetpointTransition-number"]').val() * 100); ADVANCED_TUNING.dtermSetpointWeight = parseInt($('input[name="dtermSetpoint-number"]').val() * 100); - FILTER_CONFIG.gyro_soft_notch_hz_1 = parseInt($('.pid_filter input[name="gyroNotch1Frequency"]').val()); - FILTER_CONFIG.gyro_soft_notch_cutoff_1 = parseInt($('.pid_filter input[name="gyroNotch1Cutoff"]').val()); + FILTER_CONFIG.gyro_notch_hz = parseInt($('.pid_filter input[name="gyroNotch1Frequency"]').val()); + FILTER_CONFIG.gyro_notch_cutoff = parseInt($('.pid_filter input[name="gyroNotch1Cutoff"]').val()); FILTER_CONFIG.dterm_notch_hz = parseInt($('.pid_filter input[name="dTermNotchFrequency"]').val()); FILTER_CONFIG.dterm_notch_cutoff = parseInt($('.pid_filter input[name="dTermNotchCutoff"]').val()); if (semver.gte(CONFIG.apiVersion, "1.21.0")) { - FILTER_CONFIG.gyro_soft_notch_hz_2 = parseInt($('.pid_filter input[name="gyroNotch2Frequency"]').val()); - FILTER_CONFIG.gyro_soft_notch_cutoff_2 = parseInt($('.pid_filter input[name="gyroNotch2Cutoff"]').val()); + FILTER_CONFIG.gyro_notch2_hz = parseInt($('.pid_filter input[name="gyroNotch2Frequency"]').val()); + FILTER_CONFIG.gyro_notch2_cutoff = parseInt($('.pid_filter input[name="gyroNotch2Cutoff"]').val()); } } @@ -421,10 +512,17 @@ TABS.pid_tuning.initialize = function (callback) { } if (semver.gte(CONFIG.apiVersion, "1.36.0")) { - FILTER_CONFIG.dterm_filter_type = $('.profile select[name="dtermFilterType"]').val(); + FILTER_CONFIG.dterm_lowpass_type = $('.pid_filter select[name="dtermLowpassType"]').val(); ADVANCED_TUNING.itermThrottleThreshold = parseInt($('.antigravity input[name="itermThrottleThreshold"]').val()); ADVANCED_TUNING.itermAcceleratorGain = parseInt($('.antigravity input[name="itermAcceleratorGain"]').val() * 1000); } + + if (semver.gte(CONFIG.apiVersion, "1.39.0")) { + FILTER_CONFIG.gyro_lowpass2_hz = parseInt($('.pid_filter input[name="gyroLowpass2Frequency"]').val()); + FILTER_CONFIG.gyro_lowpass_type = parseInt($('.pid_filter select[name="gyroLowpassType"]').val()); + FILTER_CONFIG.gyro_lowpass2_type = parseInt($('.pid_filter select[name="gyroLowpass2Type"]').val()); + FILTER_CONFIG.dterm_lowpass2_hz = parseInt($('.pid_filter input[name="dtermLowpass2Frequency"]').val()); + } } function showAllPids() { @@ -756,6 +854,29 @@ TABS.pid_tuning.initialize = function (callback) { } }); + + // DTerm filter options + function loadFilterTypeValues() { + var filterTypeValues = []; + filterTypeValues.push("PT1"); + filterTypeValues.push("BIQUAD"); + if (semver.lt(CONFIG.apiVersion, "1.39.0")) { + filterTypeValues.push("FIR"); + } + return filterTypeValues; + } + + function populateFilterTypeSelector(name, selectDtermValues) { + var dtermFilterSelect = $('select[name="' + name + '"]'); + selectDtermValues.forEach(function(value, key) { + dtermFilterSelect.append(''); + }); + } + + populateFilterTypeSelector('gyroLowpassType', loadFilterTypeValues()); + populateFilterTypeSelector('gyroLowpass2Type', loadFilterTypeValues()); + populateFilterTypeSelector('dtermLowpassType', loadFilterTypeValues()); + pid_and_rc_to_form(); var pidController_e = $('select[name="controller"]'); diff --git a/src/tabs/pid_tuning.html b/src/tabs/pid_tuning.html index 0e6afff1..37c370cf 100755 --- a/src/tabs/pid_tuning.html +++ b/src/tabs/pid_tuning.html @@ -465,66 +465,108 @@ -
-
-
-
-
- -
-
-
- -
-
+
+
+ + + + + - - + + + + + + + + + + + + + + + + + - - - - + +
+
+
- + + + +
-
- + +
+
+ + + + + +
+ +
+
+ + +
+ +
+
+
+
+
+
+
- + + + +
-
@@ -534,35 +576,26 @@ -
- - -
- -
-
- + + + +
-
@@ -572,57 +605,101 @@ -
-
+
+ + + + + + - - + + + + + + + + + + + + + + + + +
+
+
+
+
- + + + +
-
- + +
+
+ + + + + +
+ +
+
+
+
+
+
+ +
- + + + +
-
@@ -632,20 +709,28 @@ -
+
+
- + + + +
-