Reset out of range filter cutoffs (#8512)
Reset out of range filter cutoffs
This commit is contained in:
commit
07097431d2
|
@ -162,6 +162,13 @@ static void activateConfig(void)
|
|||
#endif
|
||||
}
|
||||
|
||||
static void adjustFilterLimit(uint16_t *parm, uint16_t resetValue)
|
||||
{
|
||||
if (*parm > FILTER_FREQUENCY_MAX) {
|
||||
*parm = resetValue;
|
||||
}
|
||||
}
|
||||
|
||||
static void validateAndFixConfig(void)
|
||||
{
|
||||
#if !defined(USE_QUAD_MIXER_ONLY)
|
||||
|
@ -200,6 +207,13 @@ static void validateAndFixConfig(void)
|
|||
}
|
||||
|
||||
for (unsigned i = 0; i < PID_PROFILE_COUNT; i++) {
|
||||
// Fix filter settings to handle cases where an older configurator was used that
|
||||
// allowed higher cutoff limits from previous firmware versions.
|
||||
adjustFilterLimit(&pidProfilesMutable(i)->dterm_lowpass_hz, FILTER_FREQUENCY_MAX);
|
||||
adjustFilterLimit(&pidProfilesMutable(i)->dterm_lowpass2_hz, FILTER_FREQUENCY_MAX);
|
||||
adjustFilterLimit(&pidProfilesMutable(i)->dterm_notch_hz, FILTER_FREQUENCY_MAX);
|
||||
adjustFilterLimit(&pidProfilesMutable(i)->dterm_notch_cutoff, 0);
|
||||
|
||||
// Prevent invalid notch cutoff
|
||||
if (pidProfilesMutable(i)->dterm_notch_cutoff >= pidProfilesMutable(i)->dterm_notch_hz) {
|
||||
pidProfilesMutable(i)->dterm_notch_hz = 0;
|
||||
|
@ -513,6 +527,15 @@ void validateAndFixGyroConfig(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
// Fix gyro filter settings to handle cases where an older configurator was used that
|
||||
// allowed higher cutoff limits from previous firmware versions.
|
||||
adjustFilterLimit(&gyroConfigMutable()->gyro_lowpass_hz, FILTER_FREQUENCY_MAX);
|
||||
adjustFilterLimit(&gyroConfigMutable()->gyro_lowpass2_hz, FILTER_FREQUENCY_MAX);
|
||||
adjustFilterLimit(&gyroConfigMutable()->gyro_soft_notch_hz_1, FILTER_FREQUENCY_MAX);
|
||||
adjustFilterLimit(&gyroConfigMutable()->gyro_soft_notch_cutoff_1, 0);
|
||||
adjustFilterLimit(&gyroConfigMutable()->gyro_soft_notch_hz_2, FILTER_FREQUENCY_MAX);
|
||||
adjustFilterLimit(&gyroConfigMutable()->gyro_soft_notch_cutoff_2, 0);
|
||||
|
||||
// Prevent invalid notch cutoff
|
||||
if (gyroConfig()->gyro_soft_notch_cutoff_1 >= gyroConfig()->gyro_soft_notch_hz_1) {
|
||||
gyroConfigMutable()->gyro_soft_notch_hz_1 = 0;
|
||||
|
|
Loading…
Reference in New Issue