Skip to content

Commit

Permalink
Merge pull request #4640 from iNavFlight/dzikuvx-remove-sticks-arming
Browse files Browse the repository at this point in the history
Remove sticks arming
  • Loading branch information
DzikuVx authored Apr 24, 2019
2 parents 5754cf7 + cf431d7 commit 8dbb7e7
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 88 deletions.
23 changes: 5 additions & 18 deletions src/main/fc/fc_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,13 +250,11 @@ static void updateArmingStatus(void)
}

/* CHECK: Arming switch */
if (!isUsingSticksForArming()) {
// If arming is disabled and the ARM switch is on
if (isArmingDisabled() && IS_RC_MODE_ACTIVE(BOXARM)) {
ENABLE_ARMING_FLAG(ARMING_DISABLED_ARM_SWITCH);
} else if (!IS_RC_MODE_ACTIVE(BOXARM)) {
DISABLE_ARMING_FLAG(ARMING_DISABLED_ARM_SWITCH);
}
// If arming is disabled and the ARM switch is on
if (isArmingDisabled() && IS_RC_MODE_ACTIVE(BOXARM)) {
ENABLE_ARMING_FLAG(ARMING_DISABLED_ARM_SWITCH);
} else if (!IS_RC_MODE_ACTIVE(BOXARM)) {
DISABLE_ARMING_FLAG(ARMING_DISABLED_ARM_SWITCH);
}

/* CHECK: BOXFAILSAFE */
Expand Down Expand Up @@ -655,17 +653,6 @@ void taskMainPidLoop(timeUs_t currentTimeUs)
applyWaypointNavigationAndAltitudeHold();
#endif

// If we're armed, at minimum throttle, and we do arming via the
// sticks, do not process yaw input from the rx. We do this so the
// motors do not spin up while we are trying to arm or disarm.
// Allow yaw control for tricopters if the user wants the servo to move even when unarmed.
if (isUsingSticksForArming() && rxGetChannelValue(THROTTLE) <= rxConfig()->mincheck
&& !((mixerConfig()->platformType == PLATFORM_TRICOPTER) && servoConfig()->tri_unarmed_servo)
&& mixerConfig()->platformType != PLATFORM_AIRPLANE
) {
rcCommand[YAW] = 0;
}

// Apply throttle tilt compensation
if (!STATE(FIXED_WING)) {
int16_t thrTiltCompStrength = 0;
Expand Down
71 changes: 15 additions & 56 deletions src/main/fc/rc_controls.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,25 +177,23 @@ void processRcStickPositions(throttleStatus_e throttleStatus)
rcSticks = stTmp;

// perform actions
if (!isUsingSticksForArming()) {
if (IS_RC_MODE_ACTIVE(BOXARM)) {
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);
}
if (IS_RC_MODE_ACTIVE(BOXARM)) {
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;
}
}
else {
rcDisarmTimeMs = currentTimeMs;
}
}

Expand All @@ -208,23 +206,6 @@ void processRcStickPositions(throttleStatus_e throttleStatus)
return;
}

if (isUsingSticksForArming()) {
// Disarm on throttle down + yaw
if (rcSticks == THR_LO + YAW_LO + PIT_CE + ROL_CE) {
// Dont disarm if fixedwing and motorstop
if (STATE(FIXED_WING) && feature(FEATURE_MOTOR_STOP) && armingConfig()->fixed_wing_auto_arm) {
return;
}
else if (ARMING_FLAG(ARMED)) {
disarm(DISARM_STICKS);
}
else {
beeper(BEEPER_DISARM_REPEAT); // sound tone while stick held
rcDelayCommand = 0; // reset so disarm tone will repeat
}
}
}

if (ARMING_FLAG(ARMED)) {
// actions during armed
return;
Expand Down Expand Up @@ -294,40 +275,18 @@ void processRcStickPositions(throttleStatus_e throttleStatus)
saveConfigAndNotify();
}


// Arming by sticks
if (isUsingSticksForArming()) {
if (STATE(FIXED_WING) && feature(FEATURE_MOTOR_STOP) && armingConfig()->fixed_wing_auto_arm) {
// Auto arm on throttle when using fixedwing and motorstop
if (throttleStatus != THROTTLE_LOW) {
tryArm();
return;
}
}
else {
if (rcSticks == THR_LO + YAW_HI + PIT_CE + ROL_CE) {
// Arm via YAW
tryArm();
return;
}
}
}


// Calibrating Acc
if (rcSticks == THR_HI + YAW_LO + PIT_LO + ROL_CE) {
accStartCalibration();
return;
}


// Calibrating Mag
if (rcSticks == THR_HI + YAW_HI + PIT_LO + ROL_CE) {
ENABLE_STATE(CALIBRATE_MAG);
return;
}


// Accelerometer Trim
if (rcSticks == THR_HI + YAW_CE + PIT_HI + ROL_CE) {
applyAndSaveBoardAlignmentDelta(0, -2);
Expand Down
8 changes: 0 additions & 8 deletions src/main/fc/rc_modes.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
#include "rx/rx.h"

static uint8_t specifiedConditionCountPerMode[CHECKBOX_ITEM_COUNT];
static bool isUsingSticksToArm = true;
#ifdef USE_NAV
static bool isUsingNAVModes = false;
#endif
Expand All @@ -54,11 +53,6 @@ boxBitmask_t rcModeActivationMask; // one bit per mode defined in boxId_e
PG_REGISTER_ARRAY(modeActivationCondition_t, MAX_MODE_ACTIVATION_CONDITION_COUNT, modeActivationConditions, PG_MODE_ACTIVATION_PROFILE, 0);
PG_REGISTER(modeActivationOperatorConfig_t, modeActivationOperatorConfig, PG_MODE_ACTIVATION_OPERATOR_CONFIG, 0);

bool isUsingSticksForArming(void)
{
return isUsingSticksToArm;
}

bool isAirmodeActive(void)
{
return feature(FEATURE_AIRMODE) || IS_RC_MODE_ACTIVE(BOXAIRMODE);
Expand Down Expand Up @@ -159,8 +153,6 @@ void updateUsedModeActivationConditionFlags(void)
}
}

isUsingSticksToArm = !isModeActivationConditionPresent(BOXARM);

#ifdef USE_NAV
isUsingNAVModes = isModeActivationConditionPresent(BOXNAVPOSHOLD) ||
isModeActivationConditionPresent(BOXNAVRTH) ||
Expand Down
1 change: 0 additions & 1 deletion src/main/fc/rc_modes.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ void rcModeUpdate(boxBitmask_t *newState);

bool isModeActivationConditionPresent(boxId_e modeId);

bool isUsingSticksForArming(void);
bool isAirmodeActive(void);
bool isUsingNavigationModes(void);
bool isRangeActive(uint8_t auxChannelIndex, const channelRange_t *range);
Expand Down
2 changes: 1 addition & 1 deletion src/main/flight/failsafe.c
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ void failsafeUpdateState(void)
if (receivingRxDataAndNotFailsafeMode) {
if (millis() > failsafeState.receivingRxDataPeriod) {
// rx link is good now, when arming via ARM switch, it must be OFF first
if (!(!isUsingSticksForArming() && IS_RC_MODE_ACTIVE(BOXARM))) {
if (!IS_RC_MODE_ACTIVE(BOXARM)) {
// XXX: Requirements for removing the ARMING_DISABLED_FAILSAFE_SYSTEM flag
// are tested by osd.c to show the user how to re-arm. If these
// requirements change, update osdArmingDisabledReasonMessage().
Expand Down
4 changes: 0 additions & 4 deletions src/main/io/osd.c
Original file line number Diff line number Diff line change
Expand Up @@ -600,10 +600,6 @@ static const char * osdArmingDisabledReasonMessage(void)
// See handling of FAILSAFE_RX_LOSS_MONITORING in failsafe.c
if (failsafePhase() == FAILSAFE_RX_LOSS_MONITORING) {
if (failsafeIsReceivingRxData()) {
if (isUsingSticksForArming()) {
// Need to power-cycle
return OSD_MESSAGE_STR("POWER CYCLE TO ARM");
}
// If we're not using sticks, it means the ARM switch
// hasn't been off since entering FAILSAFE_RX_LOSS_MONITORING
// yet
Expand Down

0 comments on commit 8dbb7e7

Please sign in to comment.