mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-13 11:29:58 +03:00
Refactoring of IMU and ACC
This commit is contained in:
parent
b6b24ba946
commit
f85ebba6a4
24 changed files with 141 additions and 195 deletions
|
@ -124,7 +124,7 @@ static void resetFlightDynamicsTrims(flightDynamicsTrims_t *accZero)
|
|||
void pgResetFn_accelerometerConfig(accelerometerConfig_t *instance)
|
||||
{
|
||||
RESET_CONFIG_2(accelerometerConfig_t, instance,
|
||||
.acc_lpf_hz = 10,
|
||||
.acc_lpf_hz = 25, // ATTITUDE/IMU runs at 100Hz (acro) or 500Hz (level modes) so we need to set 50 Hz (or lower) to avoid aliasing
|
||||
.acc_hardware = ACC_DEFAULT,
|
||||
.acc_high_fsr = false,
|
||||
);
|
||||
|
@ -352,9 +352,9 @@ void accInitFilters(void)
|
|||
// the filter initialization is not defined (sample rate = 0)
|
||||
accelerationRuntime.accLpfCutHz = (acc.sampleRateHz) ? accelerometerConfig()->acc_lpf_hz : 0;
|
||||
if (accelerationRuntime.accLpfCutHz) {
|
||||
const uint32_t accSampleTimeUs = 1e6 / acc.sampleRateHz;
|
||||
const float k = pt2FilterGain(accelerationRuntime.accLpfCutHz, 1.0f / acc.sampleRateHz);
|
||||
for (int axis = 0; axis < XYZ_AXIS_COUNT; axis++) {
|
||||
biquadFilterInitLPF(&accelerationRuntime.accFilter[axis], accelerationRuntime.accLpfCutHz, accSampleTimeUs);
|
||||
pt2FilterInit(&accelerationRuntime.accFilter[axis], k);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue