mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-24 16:55:36 +03:00
Apply those good ledvinap suggestions
This commit is contained in:
parent
e7fa8b7c41
commit
69a39da2c0
2 changed files with 7 additions and 3 deletions
|
@ -164,3 +164,7 @@ static inline float constrainf(float amt, float low, float high)
|
|||
else
|
||||
return amt;
|
||||
}
|
||||
|
||||
static inline float lerp(float t, float a, float b) {
|
||||
return a + t * (b - a);
|
||||
}
|
||||
|
|
|
@ -342,13 +342,13 @@ static FAST_CODE_NOINLINE void rcSmoothingUpdateFilterTau(rcSmoothingFilter_t *s
|
|||
|
||||
const float dT = targetPidLooptime * 1e-6f;
|
||||
|
||||
for (int i = FD_ROLL; i <= FD_YAW; i++) {
|
||||
const float tau = (1.0f - rcDeflectionAbs[i]) * cen_tau + rcDeflectionAbs[i] * end_tau;
|
||||
for (unsigned int i = FD_ROLL; i <= FD_YAW; i++) {
|
||||
const float tau = lerp(rcDeflectionAbs[i], cen_tau, end_tau);
|
||||
const float pt3K = pt3FilterGainFromDelay(tau, dT);
|
||||
|
||||
pt3FilterUpdateCutoff(&smoothingData->filterSetpoint[i], pt3K);
|
||||
pt3FilterUpdateCutoff(&smoothingData->filterFeedforward[i], pt3K);
|
||||
if (i < FD_YAW) {
|
||||
if (i < ARRAYLEN(smoothingData->filterRcDeflection)) {
|
||||
pt3FilterUpdateCutoff(&smoothingData->filterRcDeflection[i], pt3K);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue