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

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