diff --git a/src/main/flight/mixer.c b/src/main/flight/mixer.c index edf0c00c79..1699016809 100755 --- a/src/main/flight/mixer.c +++ b/src/main/flight/mixer.c @@ -117,9 +117,6 @@ float motor_disarmed[MAX_SUPPORTED_MOTORS]; mixerMode_e currentMixerMode; static motorMixer_t currentMixer[MAX_SUPPORTED_MOTORS]; -float pidSumLimit; -float pidSumLimitYaw; - static const motorMixer_t mixerQuadX[] = { { 1.0f, -1.0f, 1.0f, -1.0f }, // REAR_R @@ -409,12 +406,6 @@ void mixerInit(mixerMode_e mixerMode) initEscEndpoints(); } -void pidInitMixer(const struct pidProfile_s *pidProfile) -{ - pidSumLimit = CONVERT_PARAMETER_TO_FLOAT(pidProfile->pidSumLimit); - pidSumLimitYaw = CONVERT_PARAMETER_TO_FLOAT(pidProfile->pidSumLimitYaw); -} - #ifndef USE_QUAD_MIXER_ONLY void mixerConfigureOutput(void) @@ -680,17 +671,17 @@ void mixTable(uint8_t vbatPidCompensation) // Calculate and Limit the PIDsum float scaledAxisPidRoll = - constrainf((axisPID_P[FD_ROLL] + axisPID_I[FD_ROLL] + axisPID_D[FD_ROLL]) / PID_MIXER_SCALING, -pidSumLimit, pidSumLimit); + constrainf(axisPID_P[FD_ROLL] + axisPID_I[FD_ROLL] + axisPID_D[FD_ROLL], -currentPidProfile->pidSumLimit, currentPidProfile->pidSumLimit) / PID_MIXER_SCALING; float scaledAxisPidPitch = - constrainf((axisPID_P[FD_PITCH] + axisPID_I[FD_PITCH] + axisPID_D[FD_PITCH]) / PID_MIXER_SCALING, -pidSumLimit, pidSumLimit); + constrainf(axisPID_P[FD_PITCH] + axisPID_I[FD_PITCH] + axisPID_D[FD_PITCH], -currentPidProfile->pidSumLimit, currentPidProfile->pidSumLimit) / PID_MIXER_SCALING; float scaledAxisPidYaw = - -constrainf((axisPID_P[FD_YAW] + axisPID_I[FD_YAW]) / PID_MIXER_SCALING, -pidSumLimitYaw, pidSumLimitYaw); + constrainf(axisPID_P[FD_YAW] + axisPID_I[FD_YAW], -currentPidProfile->pidSumLimitYaw, currentPidProfile->pidSumLimitYaw) / PID_MIXER_SCALING; if (isMotorsReversed()) { scaledAxisPidRoll = -scaledAxisPidRoll; scaledAxisPidPitch = -scaledAxisPidPitch; scaledAxisPidYaw = -scaledAxisPidYaw; } - if (mixerConfig()->yaw_motors_reversed) { + if (!mixerConfig()->yaw_motors_reversed) { scaledAxisPidYaw = -scaledAxisPidYaw; } diff --git a/src/main/flight/mixer.h b/src/main/flight/mixer.h index e4803a6548..bba402d290 100644 --- a/src/main/flight/mixer.h +++ b/src/main/flight/mixer.h @@ -115,8 +115,6 @@ bool mixerIsOutputSaturated(int axis, float errorRate); void mixerLoadMix(int index, motorMixer_t *customMixers); void mixerInit(mixerMode_e mixerMode); -struct pidProfile_s; -void pidInitMixer(const struct pidProfile_s *pidProfile); void mixerConfigureOutput(void); diff --git a/src/main/flight/pid.c b/src/main/flight/pid.c index a64d20dd9c..90da2ed987 100644 --- a/src/main/flight/pid.c +++ b/src/main/flight/pid.c @@ -297,7 +297,6 @@ void pidInit(const pidProfile_t *pidProfile) pidSetTargetLooptime(gyro.targetLooptime * pidConfig()->pid_process_denom); // Initialize pid looptime pidInitFilters(pidProfile); pidInitConfig(pidProfile); - pidInitMixer(pidProfile); }