From b6515a2117e948b0ca161a6a092aaa0ab445b187 Mon Sep 17 00:00:00 2001 From: Alessio Morale Date: Sat, 19 Sep 2015 12:04:37 +0200 Subject: [PATCH] LP-123 - EasyTune for yaw should only be enabled if any other (roll/pitch) option is also enabled --- flight/modules/TxPID/txpid.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/flight/modules/TxPID/txpid.c b/flight/modules/TxPID/txpid.c index 198194bda..b91bea02a 100644 --- a/flight/modules/TxPID/txpid.c +++ b/flight/modules/TxPID/txpid.c @@ -220,6 +220,8 @@ static void updatePIDs(UAVObjEvent *ev) TxPIDStatusData txpid_status; TxPIDStatusGet(&txpid_status); + bool easyTuneEnabled = false; + uint8_t needsUpdateBank = 0; uint8_t needsUpdateStab = 0; uint8_t needsUpdateAtt = 0; @@ -255,11 +257,13 @@ static void updatePIDs(UAVObjEvent *ev) needsUpdateBank |= update(&bank.RollRatePID.Kp, value); break; case TXPIDSETTINGS_PIDS_ROLLRATEPID: + easyTuneEnabled = true; needsUpdateBank |= update(&bank.RollRatePID.Kp, value); needsUpdateBank |= update(&bank.RollRatePID.Ki, value * inst.PitchRollRateFactors.I); needsUpdateBank |= update(&bank.RollRatePID.Kd, value * inst.PitchRollRateFactors.D); break; case TXPIDSETTINGS_PIDS_PITCHRATEPID: + easyTuneEnabled = true; needsUpdateBank |= update(&bank.PitchRatePID.Kp, value); needsUpdateBank |= update(&bank.PitchRatePID.Ki, value * inst.PitchRollRateFactors.I); needsUpdateBank |= update(&bank.PitchRatePID.Kd, value * inst.PitchRollRateFactors.D); @@ -447,7 +451,7 @@ static void updatePIDs(UAVObjEvent *ev) AltitudeHoldSettingsSet(&altitude); } #endif - if (inst.RatePIDRecalculateYaw != TXPIDSETTINGS_RATEPIDRECALCULATEYAW_FALSE) { + if (easyTuneEnabled && (inst.RatePIDRecalculateYaw != TXPIDSETTINGS_RATEPIDRECALCULATEYAW_FALSE)) { float newKp = (bank.RollRatePID.Kp + bank.PitchRatePID.Kp) * .5f * inst.YawRateFactors.P; needsUpdateBank |= update(&bank.YawRatePID.Kp, newKp); needsUpdateBank |= update(&bank.YawRatePID.Ki, newKp * inst.YawRateFactors.I);