1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-15 12:25:20 +03:00

Fix the normal airmode mixer

https://github.com/betaflight/betaflight/issues/11854 Should fix this. Didn't realize that it was actually possible for it to somewhat act wrong.
This commit is contained in:
Kevin Plaizier 2022-09-26 23:25:46 -06:00
parent d72f18fb3f
commit c533990d6a

View file

@ -445,22 +445,20 @@ static void applyMixerAdjustment(float *motorMix, const float motorMixMin, const
throttle += pidGetAirmodeThrottleOffset(); throttle += pidGetAirmodeThrottleOffset();
float airmodeThrottleChange = 0; float airmodeThrottleChange = 0;
#endif #endif
const float motorMixNormalizationFactor = motorMixRange > 1.0f ? motorMixRange : 1.0f;
if (motorMixRange > 1.0f) { for (int i = 0; i < mixerRuntime.motorCount; i++) {
for (int i = 0; i < mixerRuntime.motorCount; i++) { motorMix[i] /= motorMixNormalizationFactor;
motorMix[i] /= motorMixRange; }
}
// Get the maximum correction by setting offset to center when airmode enabled if (airmodeEnabled || throttle > 0.5f) {
if (airmodeEnabled) { float normalizedMotorMixMin = motorMixMin / motorMixNormalizationFactor;
throttle = 0.5f; float normalizedMotorMixMax = motorMixMax / motorMixNormalizationFactor;
} throttle = constrainf(throttle, -normalizedMotorMixMin, 1.0f - normalizedMotorMixMax);
} else {
if (airmodeEnabled || throttle > 0.5f) {
throttle = constrainf(throttle, -motorMixMin, 1.0f - motorMixMax);
#ifdef USE_AIRMODE_LPF #ifdef USE_AIRMODE_LPF
airmodeThrottleChange = constrainf(unadjustedThrottle, -motorMixMin, 1.0f - motorMixMax) - unadjustedThrottle; airmodeThrottleChange = constrainf(unadjustedThrottle, -normalizedMotorMixMin, 1.0f - normalizedMotorMixMax) - unadjustedThrottle;
#endif #endif
}
} }
#ifdef USE_AIRMODE_LPF #ifdef USE_AIRMODE_LPF