mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-13 11:29:58 +03:00
Use wasThrottleRaised in place of isAirmodeActivated where appropriate (#13968)
* use wasThrottleRaised in place of isAirmodeActivated where airmode isn't really needed * fix unit test * fix typo * remove unnecessary check * final changes and clarificartions * Update src/main/flight/mixer.c Co-authored-by: Ivan Efimov <gendalf44@yandex.ru> --------- Co-authored-by: Mark Haslinghuis <mark@numloq.nl> Co-authored-by: Ivan Efimov <gendalf44@yandex.ru>
This commit is contained in:
parent
58fc8bbbb8
commit
fc52b6b4ff
13 changed files with 42 additions and 37 deletions
|
@ -758,7 +758,7 @@ STATIC_UNIT_TESTED void applyAbsoluteControl(const int axis, const float gyroRat
|
|||
acErrorRate = (gyroRate > gmaxac ? gmaxac : gminac ) - gyroRate;
|
||||
}
|
||||
|
||||
if (isAirmodeActivated()) {
|
||||
if (wasThrottleRaised()) {
|
||||
axisError[axis] = constrainf(axisError[axis] + acErrorRate * pidRuntime.dT,
|
||||
-pidRuntime.acErrorLimit, pidRuntime.acErrorLimit);
|
||||
const float acCorrection = constrainf(axisError[axis] * pidRuntime.acGain, -pidRuntime.acLimit, pidRuntime.acLimit);
|
||||
|
@ -840,8 +840,8 @@ float pidGetAirmodeThrottleOffset(void)
|
|||
|
||||
static FAST_CODE_NOINLINE void disarmOnImpact(void)
|
||||
{
|
||||
// if, after takeoff...
|
||||
if (isAirmodeActivated()
|
||||
// if, being armed, and after takeoff...
|
||||
if (wasThrottleRaised()
|
||||
// and, either sticks are centred and throttle zeroed,
|
||||
&& ((getMaxRcDeflectionAbs() < 0.05f && mixerGetRcThrottle() < 0.05f)
|
||||
// we could test here for stage 2 failsafe (including both landing or GPS Rescue)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue