1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-23 08:15:30 +03:00

Refactor mixer motor_stop handling - reduces flash usage

Rearranges the placement of the motor_stop handling logic in relationship to the motor output calculations.

Saves 4124 bytes of flash on F3.
This commit is contained in:
Bruce Luckcuck 2018-10-18 17:32:27 -04:00
parent 9ab8370379
commit 79abfb05fb

View file

@ -712,12 +712,6 @@ static void applyMixToMotors(float motorMix[MAX_SUPPORTED_MOTORS])
} else {
motorOutput = constrain(motorOutput, motorRangeMin, motorRangeMax);
}
// Motor stop handling
if (featureIsEnabled(FEATURE_MOTOR_STOP) && ARMING_FLAG(ARMED) && !featureIsEnabled(FEATURE_3D) && !isAirmodeActive()) {
if (((rcData[THROTTLE]) < rxConfig()->mincheck)) {
motorOutput = disarmMotorOutput;
}
}
motor[i] = motorOutput;
}
@ -744,6 +738,13 @@ float applyThrottleLimit(float throttle)
return throttle;
}
void applyMotorStop(void)
{
for (int i = 0; i < motorCount; i++) {
motor[i] = disarmMotorOutput;
}
}
FAST_CODE_NOINLINE void mixTable(timeUs_t currentTimeUs, uint8_t vbatPidCompensation)
{
if (isFlipOverAfterCrashMode()) {
@ -844,8 +845,17 @@ FAST_CODE_NOINLINE void mixTable(timeUs_t currentTimeUs, uint8_t vbatPidCompensa
}
}
// Apply the mix to motor endpoints
applyMixToMotors(motorMix);
if (featureIsEnabled(FEATURE_MOTOR_STOP)
&& ARMING_FLAG(ARMED)
&& !featureIsEnabled(FEATURE_3D)
&& !isAirmodeActive()
&& (rcData[THROTTLE] < rxConfig()->mincheck)) {
// motor_stop handling
applyMotorStop();
} else {
// Apply the mix to motor endpoints
applyMixToMotors(motorMix);
}
}
float convertExternalToMotor(uint16_t externalValue)