Skip to content

Commit

Permalink
moved flipOverAfterPowerFactor in motorConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
kernel-machine committed Mar 8, 2021
1 parent 6e9ba4e commit 561f13b
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
1 change: 0 additions & 1 deletion src/main/fc/controlrate_profile.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ void pgResetFn_controlRateProfiles(controlRateConfig_t *instance)

.misc = {
.fpvCamAngleDegrees = 0,
.flipOverAfterPowerFactor = 65
}
);
}
Expand Down
1 change: 0 additions & 1 deletion src/main/fc/controlrate_profile.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ typedef struct controlRateConfig_s {

struct {
uint8_t fpvCamAngleDegrees; // Camera angle to treat as "forward" base axis in ACRO (Roll and Yaw sticks will command rotation considering this axis)
uint8_t flipOverAfterPowerFactor;
} misc;

} controlRateConfig_t;
Expand Down
12 changes: 6 additions & 6 deletions src/main/fc/settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,12 @@ groups:
default_value: "14"
min: 4
max: 255
- name: flip_over_after_crash_power_factor
field: flipOverAfterPowerFactor
default_value: "65"
description: "flip over after crash power factor"
min: 0
max: 100

- name: PG_FAILSAFE_CONFIG
type: failsafeConfig_t
Expand Down Expand Up @@ -1159,12 +1165,6 @@ groups:
field: misc.fpvCamAngleDegrees
min: 0
max: 50
- name: flip_over_after_crash_power_factor
field: misc.flipOverAfterPowerFactor
default_value: "65"
description: "flip over after crash power factor"
min: 0
max: 100

- name: PG_SERIAL_CONFIG
type: serialConfig_t
Expand Down
7 changes: 4 additions & 3 deletions src/main/flight/mixer.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ PG_RESET_TEMPLATE(mixerConfig_t, mixerConfig,

#define DEFAULT_MAX_THROTTLE 1850

PG_REGISTER_WITH_RESET_TEMPLATE(motorConfig_t, motorConfig, PG_MOTOR_CONFIG, 6);
PG_REGISTER_WITH_RESET_TEMPLATE(motorConfig_t, motorConfig, PG_MOTOR_CONFIG, 7);

PG_RESET_TEMPLATE(motorConfig_t, motorConfig,
.motorPwmProtocol = DEFAULT_PWM_PROTOCOL,
Expand All @@ -111,7 +111,8 @@ PG_RESET_TEMPLATE(motorConfig_t, motorConfig,
.motorDecelTimeMs = 0,
.throttleIdle = 15.0f,
.throttleScale = 1.0f,
.motorPoleCount = 14 // Most brushless motors that we use are 14 poles
.motorPoleCount = 14, // Most brushless motors that we use are 14 poles
.flipOverAfterPowerFactor = 65
);

PG_REGISTER_ARRAY(motorMixer_t, MAX_SUPPORTED_MOTORS, primaryMotorMixer, PG_MOTOR_MIXER, 0);
Expand Down Expand Up @@ -326,7 +327,7 @@ static uint16_t handleOutputScaling(
static void applyFlipOverAfterCrashModeToMotors(void) {

if (ARMING_FLAG(ARMED)) {
const float flipPowerFactor = ((float)currentControlRateProfile->misc.flipOverAfterPowerFactor/100.0f);
const float flipPowerFactor = ((float)motorConfig()->flipOverAfterPowerFactor)/100.0f;
const float stickDeflectionPitchAbs = ABS(((float) rcCommand[PITCH]) / 500.0f);
const float stickDeflectionRollAbs = ABS(((float) rcCommand[ROLL]) / 500.0f);
const float stickDeflectionYawAbs = ABS(((float) rcCommand[YAW]) / 500.0f);
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 @@ -92,6 +92,7 @@ typedef struct motorConfig_s {
float throttleIdle; // Throttle IDLE value based on min_command, max_throttle, in percent
float throttleScale; // Scaling factor for throttle.
uint8_t motorPoleCount; // Magnetic poles in the motors for calculating actual RPM from eRPM provided by ESC telemetry
uint8_t flipOverAfterPowerFactor; // Power factor from 0 to 100% of flip over after crash
} motorConfig_t;

PG_DECLARE(motorConfig_t, motorConfig);
Expand Down

0 comments on commit 561f13b

Please sign in to comment.