From 3c1e8cb1c36aeb768397929da6cfdc7e4f060589 Mon Sep 17 00:00:00 2001 From: Bruce Luckcuck Date: Thu, 26 Mar 2020 19:45:07 -0400 Subject: [PATCH] Fix division by zero in mixer crashflip --- src/main/flight/mixer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/flight/mixer.c b/src/main/flight/mixer.c index 9c75e98ebf..ea487749c6 100644 --- a/src/main/flight/mixer.c +++ b/src/main/flight/mixer.c @@ -699,7 +699,7 @@ static void applyFlipOverAfterCrashModeToMotors(void) signYaw = 0; } - const float cosPhi = (stickDeflectionPitchAbs + stickDeflectionRollAbs) / (sqrtf(2.0f) * stickDeflectionLength); + const float cosPhi = (stickDeflectionLength > 0) ? (stickDeflectionPitchAbs + stickDeflectionRollAbs) / (sqrtf(2.0f) * stickDeflectionLength) : 0; const float cosThreshold = sqrtf(3.0f)/2.0f; // cos(PI/6.0f) if (cosPhi < cosThreshold) {