From 37069ba26751c23db236da7b23226ec4a379eded Mon Sep 17 00:00:00 2001 From: Bruce Luckcuck Date: Wed, 18 Mar 2020 10:32:17 -0400 Subject: [PATCH] Fix initialization of mixer related pidProfile settings Previously the variables were only initialized at boot and were not updated when the pidProfile changed. --- src/main/config/config.c | 1 + src/main/flight/mixer.c | 16 +++++++++++++--- src/main/flight/mixer.h | 1 + 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/main/config/config.c b/src/main/config/config.c index c0547ecaf..d0c9cbdee 100644 --- a/src/main/config/config.c +++ b/src/main/config/config.c @@ -814,6 +814,7 @@ void changePidProfile(uint8_t pidProfileIndex) pidInit(currentPidProfile); initEscEndpoints(); + mixerInitProfile(); } beeperConfirmationBeeps(pidProfileIndex + 1); diff --git a/src/main/flight/mixer.c b/src/main/flight/mixer.c index 7bf425ad8..067a55414 100644 --- a/src/main/flight/mixer.c +++ b/src/main/flight/mixer.c @@ -347,6 +347,16 @@ void initEscEndpoints(void) rcCommandThrottleRange = PWM_RANGE_MAX - PWM_RANGE_MIN; } +// Initialize pidProfile related mixer settings +void mixerInitProfile(void) +{ +#ifdef USE_DYN_IDLE + idleMinMotorRps = currentPidProfile->idle_min_rpm * 100.0f / 60.0f; + idleMaxIncrease = currentPidProfile->idle_max_increase * 0.001f; + idleP = currentPidProfile->idle_p * 0.0001f; +#endif +} + void mixerInit(mixerMode_e mixerMode) { currentMixerMode = mixerMode; @@ -357,12 +367,12 @@ void mixerInit(mixerMode_e mixerMode) mixerTricopterInit(); } #endif + #ifdef USE_DYN_IDLE - idleMinMotorRps = currentPidProfile->idle_min_rpm * 100.0f / 60.0f; - idleMaxIncrease = currentPidProfile->idle_max_increase * 0.001f; idleThrottleOffset = motorConfig()->digitalIdleOffsetValue * 0.0001f; - idleP = currentPidProfile->idle_p * 0.0001f; #endif + + mixerInitProfile(); } #ifdef USE_LAUNCH_CONTROL diff --git a/src/main/flight/mixer.h b/src/main/flight/mixer.h index 331d4dbe8..1afab8ce0 100644 --- a/src/main/flight/mixer.h +++ b/src/main/flight/mixer.h @@ -101,6 +101,7 @@ bool areMotorsRunning(void); void mixerLoadMix(int index, motorMixer_t *customMixers); void initEscEndpoints(void); void mixerInit(mixerMode_e mixerMode); +void mixerInitProfile(void); void mixerConfigureOutput(void); -- 2.11.4.GIT