diff --git a/ArduPlane/AP_Arming.cpp b/ArduPlane/AP_Arming.cpp index 28d24e64fa..f90d2c023c 100644 --- a/ArduPlane/AP_Arming.cpp +++ b/ArduPlane/AP_Arming.cpp @@ -151,7 +151,7 @@ bool AP_Arming_Plane::arm_checks(AP_Arming::Method method) } #if GEOFENCE_ENABLED == ENABLED - if (plane.g.fence_autoenable == 3) { + if (plane.g.fence_autoenable == FenceAutoEnable::WhenArmed) { if (!plane.geofence_set_enabled(true)) { gcs().send_text(MAV_SEVERITY_WARNING, "Fence: cannot enable for arming"); return false; @@ -239,7 +239,7 @@ bool AP_Arming_Plane::disarm(const AP_Arming::Method method) gcs().send_text(MAV_SEVERITY_INFO, "Throttle disarmed"); #if GEOFENCE_ENABLED == ENABLED - if (plane.g.fence_autoenable == 3) { + if (plane.g.fence_autoenable == FenceAutoEnable::AutoDisableFloorOnly) { plane.geofence_set_enabled(false); } #endif diff --git a/ArduPlane/Parameters.h b/ArduPlane/Parameters.h index cf6d9ca776..dca38ab706 100644 --- a/ArduPlane/Parameters.h +++ b/ArduPlane/Parameters.h @@ -401,7 +401,7 @@ public: AP_Int16 fence_minalt; // meters AP_Int16 fence_maxalt; // meters AP_Int16 fence_retalt; // meters - AP_Int8 fence_autoenable; + AP_Enum fence_autoenable; AP_Int8 fence_ret_rally; #endif diff --git a/ArduPlane/commands_logic.cpp b/ArduPlane/commands_logic.cpp index 5c73f28404..58bd0f2729 100644 --- a/ArduPlane/commands_logic.cpp +++ b/ArduPlane/commands_logic.cpp @@ -386,13 +386,13 @@ void Plane::do_land(const AP_Mission::Mission_Command& cmd) } #if GEOFENCE_ENABLED == ENABLED - if (g.fence_autoenable == 1) { + if (g.fence_autoenable == FenceAutoEnable::Auto) { if (! geofence_set_enabled(false)) { gcs().send_text(MAV_SEVERITY_NOTICE, "Disable fence failed (autodisable)"); } else { gcs().send_text(MAV_SEVERITY_NOTICE, "Fence disabled (autodisable)"); } - } else if (g.fence_autoenable == 2) { + } else if (g.fence_autoenable == FenceAutoEnable::AutoDisableFloorOnly) { if (! geofence_set_floor_enabled(false)) { gcs().send_text(MAV_SEVERITY_NOTICE, "Disable fence floor failed (autodisable)"); } else { diff --git a/ArduPlane/defines.h b/ArduPlane/defines.h index 112b0c7145..9de96adc9d 100644 --- a/ArduPlane/defines.h +++ b/ArduPlane/defines.h @@ -172,3 +172,10 @@ enum class AirMode { OFF, ON, }; + +enum class FenceAutoEnable : uint8_t { + OFF=0, + Auto=1, + AutoDisableFloorOnly=2, + WhenArmed=3 +}; diff --git a/ArduPlane/takeoff.cpp b/ArduPlane/takeoff.cpp index 33cc24e8f7..10ccdac594 100644 --- a/ArduPlane/takeoff.cpp +++ b/ArduPlane/takeoff.cpp @@ -272,7 +272,7 @@ return_zero: void Plane::complete_auto_takeoff(void) { #if GEOFENCE_ENABLED == ENABLED - if (g.fence_autoenable > 0) { + if (g.fence_autoenable != FenceAutoEnable::OFF) { if (! geofence_set_enabled(true)) { gcs().send_text(MAV_SEVERITY_NOTICE, "Enable fence failed (cannot autoenable"); } else {