From f3d2b379597e628fc77f0b38c7420efd8046f794 Mon Sep 17 00:00:00 2001 From: borisbstyle Date: Sat, 14 Jan 2017 23:52:13 +0100 Subject: [PATCH] Optimize processRcCommand() --- src/main/fc/fc_core.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/main/fc/fc_core.c b/src/main/fc/fc_core.c index 1b702329f..dd22a3b08 100644 --- a/src/main/fc/fc_core.c +++ b/src/main/fc/fc_core.c @@ -253,21 +253,23 @@ void processRcCommand(void) } // Interpolate steps of rcCommand - for (int channel=ROLL; channel < interpolationChannels; channel++) { - if (factor > 0) { + int channel; + if (factor > 0) { + for (channel=ROLL; channel < interpolationChannels; channel++) rcCommand[channel] = lastCommand[channel] - deltaRC[channel] * factor/rcInterpolationFactor; - readyToCalculateRateAxisCnt = MAX(channel, FD_YAW); // throttle channel doesn't require rate calculation - } else { - factor = 0; - } + } else { + factor = 0; } + readyToCalculateRateAxisCnt = MAX(channel, FD_YAW); // throttle channel doesn't require rate calculation readyToCalculateRate = true; } else { factor = 0; // reset factor in case of level modes flip flopping - readyToCalculateRateAxisCnt = FD_YAW; } if (readyToCalculateRate || isRXDataNew) { + if (isRXDataNew) + readyToCalculateRateAxisCnt = FD_YAW; + // Scaling of AngleRate to camera angle (Mixing Roll and Yaw) if (rxConfig()->fpvCamAngleDegrees && IS_RC_MODE_ACTIVE(BOXFPVANGLEMIX) && !FLIGHT_MODE(HEADFREE_MODE)) scaleRcCommandToFpvCamAngle(); -- 2.11.4.GIT