From 40a2bee49201358ce8121c5da1cf40d167835a54 Mon Sep 17 00:00:00 2001 From: Michael Keller Date: Fri, 21 Apr 2017 13:18:23 +1200 Subject: [PATCH] Made float parameter calculation static. --- src/main/flight/mixer.c | 15 ++++++++++++--- src/main/flight/mixer.h | 3 ++- src/main/flight/pid.c | 1 + 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/main/flight/mixer.c b/src/main/flight/mixer.c index aef38122da..f02319291d 100755 --- a/src/main/flight/mixer.c +++ b/src/main/flight/mixer.c @@ -128,6 +128,9 @@ int16_t 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 @@ -391,6 +394,12 @@ void mixerInit(mixerMode_e mixerMode) initEscEndpoints(); } +void pidInitMixer(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) @@ -555,13 +564,13 @@ void mixTable(pidProfile_t *pidProfile) // Calculate and Limit the PIDsum scaledAxisPIDf[FD_ROLL] = constrainf((axisPID_P[FD_ROLL] + axisPID_I[FD_ROLL] + axisPID_D[FD_ROLL]) / PID_MIXER_SCALING, - -CONVERT_PARAMETER_TO_FLOAT(pidProfile->pidSumLimit), CONVERT_PARAMETER_TO_FLOAT(pidProfile->pidSumLimit)); + -pidSumLimit, pidSumLimit); scaledAxisPIDf[FD_PITCH] = constrainf((axisPID_P[FD_PITCH] + axisPID_I[FD_PITCH] + axisPID_D[FD_PITCH]) / PID_MIXER_SCALING, - -CONVERT_PARAMETER_TO_FLOAT(pidProfile->pidSumLimit), CONVERT_PARAMETER_TO_FLOAT(pidProfile->pidSumLimit)); + -pidSumLimit, pidSumLimit); scaledAxisPIDf[FD_YAW] = constrainf((axisPID_P[FD_YAW] + axisPID_I[FD_YAW]) / PID_MIXER_SCALING, - -CONVERT_PARAMETER_TO_FLOAT(pidProfile->pidSumLimit), CONVERT_PARAMETER_TO_FLOAT(pidProfile->pidSumLimitYaw)); + -pidSumLimitYaw, pidSumLimitYaw); // Calculate voltage compensation const float vbatCompensationFactor = (pidProfile->vbatPidCompensation) ? calculateVbatPidCompensation() : 1.0f; diff --git a/src/main/flight/mixer.h b/src/main/flight/mixer.h index ad6bcdb1c4..ff9f5fd4cd 100644 --- a/src/main/flight/mixer.h +++ b/src/main/flight/mixer.h @@ -128,11 +128,12 @@ bool mixerIsOutputSaturated(int axis, float errorRate); void mixerLoadMix(int index, motorMixer_t *customMixers); void mixerInit(mixerMode_e mixerMode); +struct pidProfile_s; +void pidInitMixer(struct pidProfile_s *pidProfile); void mixerConfigureOutput(void); void mixerResetDisarmedMotors(void); -struct pidProfile_s; void mixTable(struct pidProfile_s *pidProfile); void syncMotors(bool enabled); void writeMotors(void); diff --git a/src/main/flight/pid.c b/src/main/flight/pid.c index 819d2ae6ae..c397ef900f 100644 --- a/src/main/flight/pid.c +++ b/src/main/flight/pid.c @@ -277,6 +277,7 @@ void pidInit(const pidProfile_t *pidProfile) pidSetTargetLooptime(gyro.targetLooptime * pidConfig()->pid_process_denom); // Initialize pid looptime pidInitFilters(pidProfile); pidInitConfig(pidProfile); + pidInitMixer(pidProfile); } // calculates strength of horizon leveling; 0 = none, 1.0 = most leveling