1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-17 05:15:25 +03:00

Renamed tpa....lower to tpa_low_..., + tpa_low_always = OFF by default (#13206)

Renamed tpa....lower to tpa_low_..., inverted the logic for it being active and renamed to a simple tpa_low_always which is OFF by default now
This commit is contained in:
Ivan Efimov 2023-12-08 13:51:52 -06:00 committed by GitHub
parent b2ce402635
commit 380d39e570
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 46 additions and 46 deletions

View file

@ -224,9 +224,9 @@ void resetPidProfile(pidProfile_t *pidProfile)
.angle_feedforward_smoothing_ms = 80,
.angle_earth_ref = 100,
.horizon_delay_ms = 500, // 500ms time constant on any increase in horizon strength
.tpa_rate_lower = 20,
.tpa_breakpoint_lower = 1050,
.tpa_breakpoint_lower_fade = 1,
.tpa_low_rate = 20,
.tpa_low_breakpoint = 1050,
.tpa_low_always = 0,
);
#ifndef USE_D_MIN
@ -276,18 +276,18 @@ void pidResetIterm(void)
void pidUpdateTpaFactor(float throttle)
{
static bool isTpaLowerFaded = false;
static bool isTpaLowFaded = false;
// don't permit throttle > 1 & throttle < 0 ? is this needed ? can throttle be > 1 or < 0 at this point
throttle = constrainf(throttle, 0.0f, 1.0f);
bool isThrottlePastTpaBreakpointLower = (throttle < pidRuntime.tpaBreakpointLower && pidRuntime.tpaBreakpointLower > 0.01f) ? false : true;
bool isThrottlePastTpaLowBreakpoint = (throttle < pidRuntime.tpaLowBreakpoint && pidRuntime.tpaLowBreakpoint > 0.01f) ? false : true;
float tpaRate = 0.0f;
if (isThrottlePastTpaBreakpointLower || isTpaLowerFaded) {
if (isThrottlePastTpaLowBreakpoint || isTpaLowFaded) {
tpaRate = pidRuntime.tpaMultiplier * fmaxf(throttle - pidRuntime.tpaBreakpoint, 0.0f);
if (pidRuntime.tpaBreakpointLowerFade && !isTpaLowerFaded) {
isTpaLowerFaded = true;
if (!pidRuntime.tpaLowAlways && !isTpaLowFaded) {
isTpaLowFaded = true;
}
} else {
tpaRate = pidRuntime.tpaMultiplierLower * (pidRuntime.tpaBreakpointLower - throttle);
tpaRate = pidRuntime.tpaLowMultiplier * (pidRuntime.tpaLowBreakpoint - throttle);
}
pidRuntime.tpaFactor = 1.0f - tpaRate;
}