From 78b52c53d51b44fb2b2e9ce7ad54baa2be57d2b0 Mon Sep 17 00:00:00 2001 From: Dominic Clifton Date: Wed, 10 Jun 2015 12:15:21 +0100 Subject: [PATCH] Calculate maxThrottleDifference before use. * Easier to understand. * Reduces code size by 32 bytes. --- src/main/flight/mixer.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/flight/mixer.c b/src/main/flight/mixer.c index 737dffd6a0..f01378f0c6 100755 --- a/src/main/flight/mixer.c +++ b/src/main/flight/mixer.c @@ -731,11 +731,14 @@ void mixTable(void) } } + int16_t maxThrottleDifference = 0; + if (maxMotor > escAndServoConfig->maxthrottle) { + maxThrottleDifference = maxMotor - escAndServoConfig->maxthrottle; + } + for (i = 0; i < motorCount; i++) { - if (maxMotor > escAndServoConfig->maxthrottle) { - // this is a way to still have good gyro corrections if at least one motor reaches its max. - motor[i] -= maxMotor - escAndServoConfig->maxthrottle; - } + // this is a way to still have good gyro corrections if at least one motor reaches its max. + motor[i] -= maxThrottleDifference; if (feature(FEATURE_3D)) { if ((rcData[THROTTLE]) > rxConfig->midrc) {