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

Fix fixed-wing auto-arming

This commit is contained in:
Konstantin (DigitalEntity) Sharlaimov 2019-07-09 20:57:22 +02:00
parent 6821ada395
commit 0246dd7c31

View file

@ -173,37 +173,48 @@ void processRcStickPositions(throttleStatus_e throttleStatus)
rcDelayCommand++; rcDelayCommand++;
} }
} }
} else } else {
rcDelayCommand = 0; rcDelayCommand = 0;
}
rcSticks = stTmp; rcSticks = stTmp;
// perform actions // perform actions
bool armingSwitchIsActive = IS_RC_MODE_ACTIVE(BOXARM); bool armingSwitchIsActive = IS_RC_MODE_ACTIVE(BOXARM);
emergencyArmingUpdate(armingSwitchIsActive); emergencyArmingUpdate(armingSwitchIsActive);
if (armingSwitchIsActive) {
rcDisarmTimeMs = currentTimeMs; if (STATE(FIXED_WING) && feature(FEATURE_MOTOR_STOP) && armingConfig()->fixed_wing_auto_arm) {
tryArm(); // Auto arm on throttle when using fixedwing and motorstop
} else { if (throttleStatus != THROTTLE_LOW) {
// Disarming via ARM BOX tryArm();
// Don't disarm via switch if failsafe is active or receiver doesn't receive data - we can't trust receiver return;
// and can't afford to risk disarming in the air
if (ARMING_FLAG(ARMED) && !IS_RC_MODE_ACTIVE(BOXFAILSAFE) && rxIsReceivingSignal() && !failsafeIsActive()) {
const timeMs_t disarmDelay = currentTimeMs - rcDisarmTimeMs;
if (disarmDelay > armingConfig()->switchDisarmDelayMs) {
if (armingConfig()->disarm_kill_switch || (throttleStatus == THROTTLE_LOW)) {
disarm(DISARM_SWITCH);
}
}
}
else {
rcDisarmTimeMs = currentTimeMs;
} }
} }
else {
if (armingSwitchIsActive) {
rcDisarmTimeMs = currentTimeMs;
tryArm();
} else {
// Disarming via ARM BOX
// Don't disarm via switch if failsafe is active or receiver doesn't receive data - we can't trust receiver
// and can't afford to risk disarming in the air
if (ARMING_FLAG(ARMED) && !IS_RC_MODE_ACTIVE(BOXFAILSAFE) && rxIsReceivingSignal() && !failsafeIsActive()) {
const timeMs_t disarmDelay = currentTimeMs - rcDisarmTimeMs;
if (disarmDelay > armingConfig()->switchDisarmDelayMs) {
if (armingConfig()->disarm_kill_switch || (throttleStatus == THROTTLE_LOW)) {
disarm(DISARM_SWITCH);
}
}
}
else {
rcDisarmTimeMs = currentTimeMs;
}
}
// KILLSWITCH disarms instantly // KILLSWITCH disarms instantly
if (IS_RC_MODE_ACTIVE(BOXKILLSWITCH)) { if (IS_RC_MODE_ACTIVE(BOXKILLSWITCH)) {
disarm(DISARM_KILLSWITCH); disarm(DISARM_KILLSWITCH);
}
} }
if (rcDelayCommand != 20) { if (rcDelayCommand != 20) {