Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ArduCopter/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ enum aux_sw_func {
AUXSW_USER_FUNC1 = 47, // user function #1
AUXSW_USER_FUNC2 = 48, // user function #2
AUXSW_USER_FUNC3 = 49, // user function #3
AUXSW_GPS1_DISABLE = 90, // kill GPS1
AUXSW_GPS2_DISABLE = 91, // kill GPS2
AUXSW_SWITCH_MAX,
};

Expand Down
10 changes: 10 additions & 0 deletions ArduCopter/switches.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ void Copter::init_aux_switch_function(int8_t ch_option, uint8_t ch_flag)
case AUXSW_INVERTED:
case AUXSW_WINCH_ENABLE:
case AUXSW_RC_OVERRIDE_ENABLE:
case AUXSW_GPS1_DISABLE:
case AUXSW_GPS2_DISABLE:
do_aux_switch_function(ch_option, ch_flag);
break;
}
Expand Down Expand Up @@ -775,6 +777,14 @@ void Copter::do_aux_switch_function(int8_t ch_function, uint8_t ch_flag)
userhook_auxSwitch3(ch_flag);
break;
#endif

case AUXSW_GPS1_DISABLE:
gps.force_disable(0, ch_flag==AUX_SWITCH_HIGH);
break;

case AUXSW_GPS2_DISABLE:
gps.force_disable(1, ch_flag==AUX_SWITCH_HIGH);
break;
}
}

Expand Down
13 changes: 13 additions & 0 deletions libraries/AP_GPS/AP_GPS.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,9 @@ class AP_GPS

/// Query GPS status
GPS_Status status(uint8_t instance) const {
if ((1U<<instance) & disable_mask) {
return NO_FIX;
}
return state[instance].status;
}
GPS_Status status(void) const {
Expand Down Expand Up @@ -423,6 +426,14 @@ class AP_GPS
return get_pre_arm_pos_change(primary_instance, pos_change, alt_change);
}

void force_disable(uint8_t instance, bool disable) {
if (disable) {
disable_mask |= (1U<<instance);
} else {
disable_mask &= ~(1U<<instance);
}
}

protected:

// configuration parameters
Expand Down Expand Up @@ -481,6 +492,8 @@ class AP_GPS
// which ports are locked
uint8_t locked_ports:2;

uint8_t disable_mask;

// state of auto-detection process, per instance
struct detect_state {
uint32_t last_baud_change_ms;
Expand Down