mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-26 09:45:37 +03:00
Fixed defaults for lowpass filters.
This commit is contained in:
parent
8e10e73580
commit
d16f35d9cb
3 changed files with 41 additions and 27 deletions
|
@ -190,34 +190,30 @@ static void validateAndFixConfig(void)
|
|||
featureDisable(FEATURE_GPS);
|
||||
}
|
||||
|
||||
if (systemConfig()->activeRateProfile >= CONTROL_RATE_PROFILE_COUNT) {
|
||||
systemConfigMutable()->activeRateProfile = 0;
|
||||
}
|
||||
loadControlRateProfile();
|
||||
|
||||
if (systemConfig()->pidProfileIndex >= PID_PROFILE_COUNT) {
|
||||
systemConfigMutable()->pidProfileIndex = 0;
|
||||
}
|
||||
loadPidProfile();
|
||||
|
||||
// Prevent invalid notch cutoff
|
||||
if (currentPidProfile->dterm_notch_cutoff >= currentPidProfile->dterm_notch_hz) {
|
||||
currentPidProfile->dterm_notch_hz = 0;
|
||||
}
|
||||
for (unsigned i = 0; i < PID_PROFILE_COUNT; i++) {
|
||||
// Prevent invalid notch cutoff
|
||||
if (pidProfilesMutable(i)->dterm_notch_cutoff >= pidProfilesMutable(i)->dterm_notch_hz) {
|
||||
pidProfilesMutable(i)->dterm_notch_hz = 0;
|
||||
}
|
||||
|
||||
#ifdef USE_DYN_LPF
|
||||
//PRevent invalid dynamic lowpass
|
||||
if (currentPidProfile->dyn_lpf_dterm_min_hz > currentPidProfile->dyn_lpf_dterm_max_hz) {
|
||||
currentPidProfile->dyn_lpf_dterm_min_hz = 0;
|
||||
}
|
||||
//Prevent invalid dynamic lowpass
|
||||
if (pidProfilesMutable(i)->dyn_lpf_dterm_min_hz > pidProfilesMutable(i)->dyn_lpf_dterm_max_hz) {
|
||||
pidProfilesMutable(i)->dyn_lpf_dterm_min_hz = 0;
|
||||
}
|
||||
|
||||
if (pidProfilesMutable(i)->dyn_lpf_dterm_min_hz > 0) {
|
||||
pidProfilesMutable(i)->dterm_lowpass_hz = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (currentPidProfile->motor_output_limit > 100 || currentPidProfile->motor_output_limit == 0) {
|
||||
currentPidProfile->motor_output_limit = 100;
|
||||
}
|
||||
if (pidProfilesMutable(i)->motor_output_limit > 100 || pidProfilesMutable(i)->motor_output_limit == 0) {
|
||||
pidProfilesMutable(i)->motor_output_limit = 100;
|
||||
}
|
||||
|
||||
if (currentPidProfile->auto_profile_cell_count > MAX_AUTO_DETECT_CELL_COUNT || currentPidProfile->auto_profile_cell_count < AUTO_PROFILE_CELL_COUNT_CHANGE) {
|
||||
currentPidProfile->auto_profile_cell_count = AUTO_PROFILE_CELL_COUNT_STAY;
|
||||
if (pidProfilesMutable(i)->auto_profile_cell_count > MAX_AUTO_DETECT_CELL_COUNT || pidProfilesMutable(i)->auto_profile_cell_count < AUTO_PROFILE_CELL_COUNT_CHANGE) {
|
||||
pidProfilesMutable(i)->auto_profile_cell_count = AUTO_PROFILE_CELL_COUNT_STAY;
|
||||
}
|
||||
}
|
||||
|
||||
if (motorConfig()->dev.motorPwmProtocol == PWM_TYPE_BRUSHED) {
|
||||
|
@ -487,6 +483,10 @@ void validateAndFixGyroConfig(void)
|
|||
if (gyroConfig()->dyn_lpf_gyro_min_hz > gyroConfig()->dyn_lpf_gyro_max_hz) {
|
||||
gyroConfigMutable()->dyn_lpf_gyro_min_hz = 0;
|
||||
}
|
||||
|
||||
if (gyroConfig()->dyn_lpf_gyro_min_hz > 0) {
|
||||
gyroConfigMutable()->gyro_lowpass_hz = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (gyroConfig()->gyro_hardware_lpf == GYRO_HARDWARE_LPF_1KHZ_SAMPLE) {
|
||||
|
@ -574,6 +574,16 @@ void validateAndFixGyroConfig(void)
|
|||
}
|
||||
#endif // USE_SDCARD
|
||||
#endif // USE_BLACKBOX
|
||||
|
||||
if (systemConfig()->activeRateProfile >= CONTROL_RATE_PROFILE_COUNT) {
|
||||
systemConfigMutable()->activeRateProfile = 0;
|
||||
}
|
||||
loadControlRateProfile();
|
||||
|
||||
if (systemConfig()->pidProfileIndex >= PID_PROFILE_COUNT) {
|
||||
systemConfigMutable()->pidProfileIndex = 0;
|
||||
}
|
||||
loadPidProfile();
|
||||
}
|
||||
|
||||
bool readEEPROM(void)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue