1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-26 01:35:41 +03:00

Optimize processRcCommand()

This commit is contained in:
borisbstyle 2017-01-14 23:52:13 +01:00
parent 05e5beee7e
commit f3d2b37959

View file

@ -253,21 +253,23 @@ void processRcCommand(void)
} }
// Interpolate steps of rcCommand // Interpolate steps of rcCommand
for (int channel=ROLL; channel < interpolationChannels; channel++) { int channel;
if (factor > 0) { if (factor > 0) {
for (channel=ROLL; channel < interpolationChannels; channel++)
rcCommand[channel] = lastCommand[channel] - deltaRC[channel] * factor/rcInterpolationFactor; rcCommand[channel] = lastCommand[channel] - deltaRC[channel] * factor/rcInterpolationFactor;
readyToCalculateRateAxisCnt = MAX(channel, FD_YAW); // throttle channel doesn't require rate calculation } else {
} else { factor = 0;
factor = 0;
}
} }
readyToCalculateRateAxisCnt = MAX(channel, FD_YAW); // throttle channel doesn't require rate calculation
readyToCalculateRate = true; readyToCalculateRate = true;
} else { } else {
factor = 0; // reset factor in case of level modes flip flopping factor = 0; // reset factor in case of level modes flip flopping
readyToCalculateRateAxisCnt = FD_YAW;
} }
if (readyToCalculateRate || isRXDataNew) { if (readyToCalculateRate || isRXDataNew) {
if (isRXDataNew)
readyToCalculateRateAxisCnt = FD_YAW;
// Scaling of AngleRate to camera angle (Mixing Roll and Yaw) // Scaling of AngleRate to camera angle (Mixing Roll and Yaw)
if (rxConfig()->fpvCamAngleDegrees && IS_RC_MODE_ACTIVE(BOXFPVANGLEMIX) && !FLIGHT_MODE(HEADFREE_MODE)) if (rxConfig()->fpvCamAngleDegrees && IS_RC_MODE_ACTIVE(BOXFPVANGLEMIX) && !FLIGHT_MODE(HEADFREE_MODE))
scaleRcCommandToFpvCamAngle(); scaleRcCommandToFpvCamAngle();