1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-24 00:35:39 +03:00

Fix initialization of mixer related pidProfile settings

Previously the variables were only initialized at boot and were not updated when the pidProfile changed.
This commit is contained in:
Bruce Luckcuck 2020-03-18 10:32:17 -04:00
parent 9b6911f80c
commit 37069ba267
3 changed files with 15 additions and 3 deletions

View file

@ -814,6 +814,7 @@ void changePidProfile(uint8_t pidProfileIndex)
pidInit(currentPidProfile); pidInit(currentPidProfile);
initEscEndpoints(); initEscEndpoints();
mixerInitProfile();
} }
beeperConfirmationBeeps(pidProfileIndex + 1); beeperConfirmationBeeps(pidProfileIndex + 1);

View file

@ -347,6 +347,16 @@ void initEscEndpoints(void)
rcCommandThrottleRange = PWM_RANGE_MAX - PWM_RANGE_MIN; 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) void mixerInit(mixerMode_e mixerMode)
{ {
currentMixerMode = mixerMode; currentMixerMode = mixerMode;
@ -357,12 +367,12 @@ void mixerInit(mixerMode_e mixerMode)
mixerTricopterInit(); mixerTricopterInit();
} }
#endif #endif
#ifdef USE_DYN_IDLE #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; idleThrottleOffset = motorConfig()->digitalIdleOffsetValue * 0.0001f;
idleP = currentPidProfile->idle_p * 0.0001f;
#endif #endif
mixerInitProfile();
} }
#ifdef USE_LAUNCH_CONTROL #ifdef USE_LAUNCH_CONTROL

View file

@ -101,6 +101,7 @@ bool areMotorsRunning(void);
void mixerLoadMix(int index, motorMixer_t *customMixers); void mixerLoadMix(int index, motorMixer_t *customMixers);
void initEscEndpoints(void); void initEscEndpoints(void);
void mixerInit(mixerMode_e mixerMode); void mixerInit(mixerMode_e mixerMode);
void mixerInitProfile(void);
void mixerConfigureOutput(void); void mixerConfigureOutput(void);