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:
parent
9ab8370379
commit
79abfb05fb
1 changed files with 18 additions and 8 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue