1
0
Fork 0
mirror of https://github.com/iNavFlight/inav.git synced 2025-07-23 16:25:26 +03:00

disable level trim when any stick is deflected

This commit is contained in:
Alexander van Saase 2021-05-26 13:37:40 +02:00
parent 119682826a
commit 966c73d4f8

View file

@ -1327,11 +1327,16 @@ void updateFixedWingLevelTrim(timeUs_t currentTimeUs)
*/
pidControllerFlags_e flags = PID_LIMIT_INTEGRATOR;
//Iterm should freeze when pitch stick is deflected
//Iterm should freeze when sticks are deflected
bool areSticksDeflected = false;
for (int stick = ROLL; stick <= YAW; stick++) {
areSticksDeflected = areSticksDeflected ||
rxGetChannelValue(stick) > (PWM_RANGE_MIDDLE + pidProfile()->fixedWingLevelTrimDeadband) ||
rxGetChannelValue(stick) < (PWM_RANGE_MIDDLE - pidProfile()->fixedWingLevelTrimDeadband);
}
if (
!IS_RC_MODE_ACTIVE(BOXAUTOLEVEL) ||
rxGetChannelValue(PITCH) > (PWM_RANGE_MIDDLE + pidProfile()->fixedWingLevelTrimDeadband) ||
rxGetChannelValue(PITCH) < (PWM_RANGE_MIDDLE - pidProfile()->fixedWingLevelTrimDeadband) ||
areSticksDeflected ||
(!FLIGHT_MODE(ANGLE_MODE) && !FLIGHT_MODE(HORIZON_MODE)) ||
navigationIsControllingAltitude()
) {