Reset out of range filter cutoffs
Protection against previous Configurator versions allowing higher cutoff values than the parameter limits in the firmware and causing out-of-range corrupted config errors.
This commit is contained in:
parent
d7f62a710c
commit
edd5bb947f
|
@ -162,6 +162,13 @@ static void activateConfig(void)
|
|||
#endif
|
||||
}
|
||||
|
||||
static void adjustFilterLimit(uint16_t *parm)
|
||||
{
|
||||
if (*parm > FILTER_FREQUENCY_MAX) {
|
||||
*parm = FILTER_FREQUENCY_MAX;
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
adjustFilterLimit(&pidProfilesMutable(i)->dterm_lowpass2_hz);
|
||||
adjustFilterLimit(&pidProfilesMutable(i)->dterm_notch_hz);
|
||||
adjustFilterLimit(&pidProfilesMutable(i)->dterm_notch_cutoff);
|
||||
|
||||
// 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);
|
||||
adjustFilterLimit(&gyroConfigMutable()->gyro_lowpass2_hz);
|
||||
adjustFilterLimit(&gyroConfigMutable()->gyro_soft_notch_hz_1);
|
||||
adjustFilterLimit(&gyroConfigMutable()->gyro_soft_notch_cutoff_1);
|
||||
adjustFilterLimit(&gyroConfigMutable()->gyro_soft_notch_hz_2);
|
||||
adjustFilterLimit(&gyroConfigMutable()->gyro_soft_notch_cutoff_2);
|
||||
|
||||
// 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