Only set OK-to-arm flag when arm switches are disabled.

This prevents arming after connecting a battery when the throttle is in
low; when using a switch to arm and when the switch is left in the ON
position.

The previous solution was flawed because of the way rc input is handled.

This also removes an extra test of rcOptions by re-arranging the logic
that handles arming/disarming via a switch.
This commit is contained in:
Dominic Clifton 2014-08-24 22:59:27 +01:00
parent f5d9589f0a
commit 9b4ccdc73a
3 changed files with 16 additions and 17 deletions

View File

@ -48,8 +48,7 @@ extern uint8_t rcOptions[CHECKBOX_ITEM_COUNT];
typedef enum { typedef enum {
OK_TO_ARM = (1 << 0), OK_TO_ARM = (1 << 0),
PREVENT_ARMING = (1 << 1), PREVENT_ARMING = (1 << 1),
SEEN_BOXARM_OFF = (1 << 2), ARMED = (1 << 2)
ARMED = (1 << 3)
} armingFlag_e; } armingFlag_e;
extern uint8_t armingFlags; extern uint8_t armingFlags;

View File

@ -41,7 +41,6 @@
#include "rx/rx.h" #include "rx/rx.h"
#include "io/rc_controls.h" #include "io/rc_controls.h"
int16_t rcCommand[4]; // interval [1000;2000] for THROTTLE and [-500;+500] for ROLL/PITCH/YAW int16_t rcCommand[4]; // interval [1000;2000] for THROTTLE and [-500;+500] for ROLL/PITCH/YAW
bool areSticksInApModePosition(uint16_t ap_mode) bool areSticksInApModePosition(uint16_t ap_mode)
@ -85,16 +84,15 @@ void processRcStickPositions(rxConfig_t *rxConfig, throttleStatus_e throttleStat
// perform actions // perform actions
if (activate[BOXARM] > 0) { if (activate[BOXARM] > 0) {
if (rcOptions[BOXARM]) {
// Arming via ARM BOX // Arming via ARM BOX
if (throttleStatus == THROTTLE_LOW) { if (throttleStatus == THROTTLE_LOW) {
if (rcOptions[BOXARM] && ARMING_FLAG(OK_TO_ARM)) { if (ARMING_FLAG(OK_TO_ARM)) {
mwArm(); mwArm();
} }
} }
} else {
// Disarming via ARM BOX // Disarming via ARM BOX
if (!rcOptions[BOXARM]) {
ENABLE_ARMING_FLAG(SEEN_BOXARM_OFF);
if (ARMING_FLAG(ARMED)) { if (ARMING_FLAG(ARMED)) {
mwDisarm(); mwDisarm();
} }

View File

@ -244,7 +244,9 @@ void annexCode(void)
if (ARMING_FLAG(ARMED)) { if (ARMING_FLAG(ARMED)) {
LED0_ON; LED0_ON;
} else { } else {
if (rcOptions[BOXARM] == 0) {
ENABLE_ARMING_FLAG(OK_TO_ARM); ENABLE_ARMING_FLAG(OK_TO_ARM);
}
if (isCalibrating()) { if (isCalibrating()) {
LED0_TOGGLE; LED0_TOGGLE;
@ -255,10 +257,6 @@ void annexCode(void)
DISABLE_ARMING_FLAG(OK_TO_ARM); DISABLE_ARMING_FLAG(OK_TO_ARM);
} }
if (rcOptions[BOXARM] && !ARMING_FLAG(SEEN_BOXARM_OFF)) {
DISABLE_ARMING_FLAG(OK_TO_ARM);
}
if (rcOptions[BOXAUTOTUNE]) { if (rcOptions[BOXAUTOTUNE]) {
DISABLE_ARMING_FLAG(OK_TO_ARM); DISABLE_ARMING_FLAG(OK_TO_ARM);
} }
@ -272,6 +270,10 @@ void annexCode(void)
updateWarningLed(currentTime); updateWarningLed(currentTime);
} }
#if 0
debug[0] = armingFlags;
#endif
#ifdef TELEMETRY #ifdef TELEMETRY
checkTelemetryState(); checkTelemetryState();
#endif #endif