From 93fdbf15732284450b9f63cf8320a74ca0994448 Mon Sep 17 00:00:00 2001 From: khancyr Date: Thu, 20 Jul 2017 18:42:28 +0200 Subject: [PATCH] AC_Fence: reset fences breach on disable Also rename enable function parameter --- libraries/AC_Fence/AC_Fence.cpp | 8 ++++++++ libraries/AC_Fence/AC_Fence.h | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/libraries/AC_Fence/AC_Fence.cpp b/libraries/AC_Fence/AC_Fence.cpp index 283f03a53b..4ce2e3da3e 100644 --- a/libraries/AC_Fence/AC_Fence.cpp +++ b/libraries/AC_Fence/AC_Fence.cpp @@ -97,6 +97,14 @@ AC_Fence::AC_Fence(const AP_AHRS& ahrs, const AP_InertialNav& inav) : } } +void AC_Fence::enable(bool value) +{ + _enabled = value; + if (!value) { + clear_breach(AC_FENCE_TYPE_ALT_MAX | AC_FENCE_TYPE_CIRCLE | AC_FENCE_TYPE_POLYGON); + } +} + /// get_enabled_fences - returns bitmask of enabled fences uint8_t AC_Fence::get_enabled_fences() const { diff --git a/libraries/AC_Fence/AC_Fence.h b/libraries/AC_Fence/AC_Fence.h index c6cf0bb120..bdd414eb78 100644 --- a/libraries/AC_Fence/AC_Fence.h +++ b/libraries/AC_Fence/AC_Fence.h @@ -40,7 +40,7 @@ public: AC_Fence(const AP_AHRS& ahrs, const AP_InertialNav& inav); /// enable - allows fence to be enabled/disabled. Note: this does not update the eeprom saved value - void enable(bool true_false) { _enabled = true_false; } + void enable(bool value); /// enabled - returns true if fence is enabled bool enabled() const { return _enabled; }