mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-24 00:35:39 +03:00
Improved mixer code for crash flip mode.
This commit is contained in:
parent
d22fb0dde4
commit
79651ec6c8
2 changed files with 19 additions and 18 deletions
|
@ -76,7 +76,7 @@ static const box_t boxes[CHECKBOX_ITEM_COUNT] = {
|
||||||
{ BOXCAMERA1, "CAMERA CONTROL 1", 32},
|
{ BOXCAMERA1, "CAMERA CONTROL 1", 32},
|
||||||
{ BOXCAMERA2, "CAMERA CONTROL 2", 33},
|
{ BOXCAMERA2, "CAMERA CONTROL 2", 33},
|
||||||
{ BOXCAMERA3, "CAMERA CONTROL 3", 34 },
|
{ BOXCAMERA3, "CAMERA CONTROL 3", 34 },
|
||||||
{ BOXFLIPOVERAFTERCRASH, "FLIP OVER AFTER CRASH (DSHOT ONLY)", 35 },
|
{ BOXFLIPOVERAFTERCRASH, "FLIP OVER AFTER CRASH", 35 },
|
||||||
{ BOXPREARM, "PREARM", 36 },
|
{ BOXPREARM, "PREARM", 36 },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -605,28 +605,29 @@ void calculateThrottleAndCurrentMotorEndpoints(void)
|
||||||
throttle = constrainf(throttle / currentThrottleInputRange, 0.0f, 1.0f);
|
throttle = constrainf(throttle / currentThrottleInputRange, 0.0f, 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define CRASH_FLIP_DEADBAND 20
|
||||||
|
|
||||||
static void applyFlipOverAfterCrashModeToMotors(void)
|
static void applyFlipOverAfterCrashModeToMotors(void)
|
||||||
{
|
{
|
||||||
float motorMix[MAX_SUPPORTED_MOTORS];
|
float motorMix[MAX_SUPPORTED_MOTORS];
|
||||||
|
|
||||||
for (int i = 0; i < motorCount; i++) {
|
if (ARMING_FLAG(ARMED)) {
|
||||||
if (getRcDeflectionAbs(FD_ROLL) > getRcDeflectionAbs(FD_PITCH)) {
|
for (int i = 0; i < motorCount; i++) {
|
||||||
motorMix[i] = getRcDeflection(FD_ROLL) * currentMixer[i].roll * (-1);
|
if (getRcDeflectionAbs(FD_ROLL) > getRcDeflectionAbs(FD_PITCH)) {
|
||||||
} else {
|
motorMix[i] = getRcDeflection(FD_ROLL) * currentMixer[i].roll * -1;
|
||||||
motorMix[i] = getRcDeflection(FD_PITCH) * currentMixer[i].pitch * (-1);
|
} else {
|
||||||
|
motorMix[i] = getRcDeflection(FD_PITCH) * currentMixer[i].pitch * -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply the mix to motor endpoints
|
||||||
|
float motorOutput = motorOutputMin + motorOutputRange * motorMix[i];
|
||||||
|
//Add a little bit to the motorOutputMin so props aren't spinning when sticks are centered
|
||||||
|
motorOutput = (motorOutput < motorOutputMin + CRASH_FLIP_DEADBAND ) ? disarmMotorOutput : motorOutput - CRASH_FLIP_DEADBAND;
|
||||||
|
|
||||||
|
motor[i] = motorOutput;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
// Apply the mix to motor endpoints
|
// Disarmed mode
|
||||||
for (uint32_t i = 0; i < motorCount; i++) {
|
|
||||||
float motorOutput = motorOutputMin + motorOutputRange * (motorMix[i]);
|
|
||||||
//Add a little bit to the motorOutputMin so props aren't spinning when sticks are centered
|
|
||||||
motorOutput = (motorOutput < motorOutputMin + 20 ) ? disarmMotorOutput : motorOutput;
|
|
||||||
|
|
||||||
motor[i] = motorOutput;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Disarmed mode
|
|
||||||
if (!ARMING_FLAG(ARMED)) {
|
|
||||||
for (int i = 0; i < motorCount; i++) {
|
for (int i = 0; i < motorCount; i++) {
|
||||||
motor[i] = motor_disarmed[i];
|
motor[i] = motor_disarmed[i];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue