added crashflip_motor_percent. This will use the other motors while doing a turtle. (#5600)

This commit is contained in:
Bryce Johnson 2018-04-06 03:24:48 -05:00 committed by Michael Keller
parent 3663230803
commit 588addd6dd
3 changed files with 13 additions and 3 deletions

View File

@ -65,6 +65,7 @@ PG_REGISTER_WITH_RESET_TEMPLATE(mixerConfig_t, mixerConfig, PG_MIXER_CONFIG, 0);
PG_RESET_TEMPLATE(mixerConfig_t, mixerConfig, PG_RESET_TEMPLATE(mixerConfig_t, mixerConfig,
.mixerMode = TARGET_DEFAULT_MIXER, .mixerMode = TARGET_DEFAULT_MIXER,
.yaw_motors_reversed = false, .yaw_motors_reversed = false,
.crashflip_motor_percent = 0,
); );
PG_REGISTER_WITH_RESET_FN(motorConfig_t, motorConfig, PG_MOTOR_CONFIG, 1); PG_REGISTER_WITH_RESET_FN(motorConfig_t, motorConfig, PG_MOTOR_CONFIG, 1);
@ -661,8 +662,15 @@ static void applyFlipOverAfterCrashModeToMotors(void)
signRoll*currentMixer[i].roll + signRoll*currentMixer[i].roll +
signYaw*currentMixer[i].yaw; signYaw*currentMixer[i].yaw;
motorOutput = MIN(1.0f, flipPower*motorOutput); if (motorOutput < 0) {
motorOutput = motorOutputMin + motorOutput*motorOutputRange; 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 // 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); motorOutput = (motorOutput < motorOutputMin + CRASH_FLIP_DEADBAND) ? disarmMotorOutput : (motorOutput - CRASH_FLIP_DEADBAND);

View File

@ -87,6 +87,7 @@ typedef struct mixer_s {
typedef struct mixerConfig_s { typedef struct mixerConfig_s {
uint8_t mixerMode; uint8_t mixerMode;
bool yaw_motors_reversed; bool yaw_motors_reversed;
uint8_t crashflip_motor_percent;
} mixerConfig_t; } mixerConfig_t;
PG_DECLARE(mixerConfig_t, mixerConfig); PG_DECLARE(mixerConfig_t, mixerConfig);

View File

@ -600,6 +600,7 @@ const clivalue_t valueTable[] = {
// PG_MIXER_CONFIG // 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) }, { "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 // 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) }, { "3d_deadband_low", VAR_UINT16 | MASTER_VALUE, .config.minmax = { PWM_PULSE_MIN, PWM_RANGE_MIDDLE }, PG_MOTOR_3D_CONFIG, offsetof(flight3DConfig_t, deadband3d_low) },