Skip to content

Commit

Permalink
Applied changes for 'crashflip_motor_percent'
Browse files Browse the repository at this point in the history
From:  Turtle/Flip after crash: Add options to use all the motors betaflight#5600
betaflight#5600
  • Loading branch information
ethomas997 committed Apr 10, 2018
1 parent 9f516e6 commit 85ac1bc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/main/flight/mixer.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ PG_REGISTER_WITH_RESET_TEMPLATE(mixerConfig_t, mixerConfig, PG_MIXER_CONFIG, 0);
PG_RESET_TEMPLATE(mixerConfig_t, mixerConfig,
.mixerMode = TARGET_DEFAULT_MIXER,
.yaw_motors_reversed = false,
.crashflip_motor_percent = 0,
);

PG_REGISTER_WITH_RESET_FN(motorConfig_t, motorConfig, PG_MOTOR_CONFIG, 1);
Expand Down Expand Up @@ -671,9 +672,16 @@ static void applyFlipOverAfterCrashModeToMotors(void)
signPitch*currentMixer[i].pitch +
signRoll*currentMixer[i].roll +
signYaw*currentMixer[i].yaw;

motorOutput = MIN(1.0f, flipPower*motorOutput);
motorOutput = motorOutputMin + motorOutput*motorOutputRange;

if (motorOutput < 0) {
if (mixerConfig()->crashflip_motor_percent > 0) {
motorOutput = -motorOutput * (float)mixerConfig()->crashflip_motor_percent / 100.0f;
} else {
motorOutput = disarmMotorOutput;
}
}
motorOutput = MIN(1.0f, flipPower * motorOutput);
motorOutput = motorOutputMin + motorOutput * motorOutputRange;

// 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);
Expand Down
1 change: 1 addition & 0 deletions src/main/flight/mixer.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ typedef struct mixer_s {
typedef struct mixerConfig_s {
uint8_t mixerMode;
bool yaw_motors_reversed;
uint8_t crashflip_motor_percent;
} mixerConfig_t;

PG_DECLARE(mixerConfig_t, mixerConfig);
Expand Down
1 change: 1 addition & 0 deletions src/main/interface/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,7 @@ const clivalue_t valueTable[] = {

// PG_MIXER_CONFIG
{ "yaw_motors_reversed", VAR_INT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_MIXER_CONFIG, offsetof(mixerConfig_t, yaw_motors_reversed) },
{ "crashflip_motor_percent", VAR_UINT8 | MASTER_VALUE, .config.minmax = { 0, 100 }, PG_MIXER_CONFIG, offsetof(mixerConfig_t, crashflip_motor_percent) },

// PG_MOTOR_3D_CONFIG
{ "3d_deadband_low", VAR_UINT16 | MASTER_VALUE, .config.minmax = { PWM_PULSE_MIN, PWM_RANGE_MIDDLE }, PG_MOTOR_3D_CONFIG, offsetof(flight3DConfig_t, deadband3d_low) },
Expand Down

0 comments on commit 85ac1bc

Please sign in to comment.