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
This commit is contained in:
Andrew Tridgell 2013-12-17 14:13:32 +11:00
parent dcfed13c87
commit 4f242aedec
3 changed files with 9 additions and 6 deletions

View File

@ -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

View File

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

View File

@ -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)
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;