mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-19 14:25:20 +03:00
Merge pull request #6901 from jflyper/bfdev-improve-USE_SERVOS-handling
Improve handling of USE_SERVOS in mixer.c
This commit is contained in:
commit
93c38d09bd
1 changed files with 8 additions and 4 deletions
|
@ -285,6 +285,8 @@ static const motorMixer_t mixerQuadX1234[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Keep synced with mixerMode_e
|
// Keep synced with mixerMode_e
|
||||||
|
// Some of these entries are bogus when servos (USE_SERVOS) are not configured,
|
||||||
|
// but left untouched to keep ordinals synced with mixerMode_e (and configurator).
|
||||||
const mixer_t mixers[] = {
|
const mixer_t mixers[] = {
|
||||||
// motors, use servo, motor mixer
|
// motors, use servo, motor mixer
|
||||||
{ 0, false, NULL }, // entry 0
|
{ 0, false, NULL }, // entry 0
|
||||||
|
@ -350,14 +352,12 @@ bool areMotorsRunning(void)
|
||||||
return motorsRunning;
|
return motorsRunning;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef USE_SERVOS
|
||||||
bool mixerIsTricopter(void)
|
bool mixerIsTricopter(void)
|
||||||
{
|
{
|
||||||
#ifdef USE_SERVOS
|
|
||||||
return (currentMixerMode == MIXER_TRI || currentMixerMode == MIXER_CUSTOM_TRI);
|
return (currentMixerMode == MIXER_TRI || currentMixerMode == MIXER_CUSTOM_TRI);
|
||||||
#else
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// All PWM motor scaling is done to standard PWM range of 1000-2000 for easier tick conversion with legacy code / configurator
|
// All PWM motor scaling is done to standard PWM range of 1000-2000 for easier tick conversion with legacy code / configurator
|
||||||
// DSHOT scaling is done to the actual dshot range
|
// DSHOT scaling is done to the actual dshot range
|
||||||
|
@ -406,9 +406,11 @@ void mixerInit(mixerMode_e mixerMode)
|
||||||
currentMixerMode = mixerMode;
|
currentMixerMode = mixerMode;
|
||||||
|
|
||||||
initEscEndpoints();
|
initEscEndpoints();
|
||||||
|
#ifdef USE_SERVOS
|
||||||
if (mixerIsTricopter()) {
|
if (mixerIsTricopter()) {
|
||||||
mixerTricopterInit();
|
mixerTricopterInit();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef USE_QUAD_MIXER_ONLY
|
#ifndef USE_QUAD_MIXER_ONLY
|
||||||
|
@ -697,9 +699,11 @@ static void applyMixToMotors(float motorMix[MAX_SUPPORTED_MOTORS])
|
||||||
// roll/pitch/yaw. This could move throttle down, but also up for those low throttle flips.
|
// roll/pitch/yaw. This could move throttle down, but also up for those low throttle flips.
|
||||||
for (int i = 0; i < motorCount; i++) {
|
for (int i = 0; i < motorCount; i++) {
|
||||||
float motorOutput = motorOutputMin + (motorOutputRange * (motorOutputMixSign * motorMix[i] + throttle * currentMixer[i].throttle));
|
float motorOutput = motorOutputMin + (motorOutputRange * (motorOutputMixSign * motorMix[i] + throttle * currentMixer[i].throttle));
|
||||||
|
#ifdef USE_SERVOS
|
||||||
if (mixerIsTricopter()) {
|
if (mixerIsTricopter()) {
|
||||||
motorOutput += mixerTricopterMotorCorrection(i);
|
motorOutput += mixerTricopterMotorCorrection(i);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
if (failsafeIsActive()) {
|
if (failsafeIsActive()) {
|
||||||
if (isMotorProtocolDshot()) {
|
if (isMotorProtocolDshot()) {
|
||||||
motorOutput = (motorOutput < motorRangeMin) ? disarmMotorOutput : motorOutput; // Prevent getting into special reserved range
|
motorOutput = (motorOutput < motorRangeMin) ? disarmMotorOutput : motorOutput; // Prevent getting into special reserved range
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue