Browse Source

Plane: fixed a bug where mode would not revert on geo-fence disable

the mode would not revert if the switch was in position 0
mission-4.1.18
Andrew Tridgell 11 years ago
parent
commit
4f242aedec
  1. 10
      ArduPlane/ArduPlane.pde
  2. 2
      ArduPlane/control_modes.pde
  3. 3
      ArduPlane/geofence.pde

10
ArduPlane/ArduPlane.pde

@ -350,12 +350,14 @@ static bool usb_connected; @@ -350,12 +350,14 @@ static bool usb_connected;
////////////////////////////////////////////////////////////////////////////////
// This is the state of the flight control system
// There are multiple states defined such as MANUAL, FBW-A, AUTO
enum FlightMode control_mode = INITIALISING;
static enum FlightMode control_mode = INITIALISING;
// Used to maintain the state of the previous control switch position
// This is set to -1 when we need to re-read the switch
uint8_t oldSwitchPosition;
// This is set to 254 when we need to re-read the switch
static uint8_t oldSwitchPosition = 254;
// This is used to enable the inverted flight feature
bool inverted_flight = false;
static bool inverted_flight = false;
static struct {
// These are trim values used for elevon control

2
ArduPlane/control_modes.pde

@ -70,7 +70,7 @@ static uint8_t readSwitch(void){ @@ -70,7 +70,7 @@ static uint8_t readSwitch(void){
static void reset_control_switch()
{
oldSwitchPosition = 0;
oldSwitchPosition = 254;
read_control_switch();
}

3
ArduPlane/geofence.pde

@ -87,6 +87,7 @@ static void geofence_load(void) @@ -87,6 +87,7 @@ static void geofence_load(void)
// not much we can do here except disable it
goto failed;
}
geofence_state->old_switch_position = 254;
}
if (g.fence_total <= 0) {
@ -188,7 +189,7 @@ static void geofence_check(bool altitude_check_only) @@ -188,7 +189,7 @@ static void geofence_check(bool altitude_check_only)
geofence_state->old_switch_position == oldSwitchPosition &&
guided_WP.lat == geofence_state->boundary[0].x &&
guided_WP.lng == geofence_state->boundary[0].y) {
geofence_state->old_switch_position = 0;
geofence_state->old_switch_position = 254;
reset_control_switch();
}
return;

Loading…
Cancel
Save