From 76020dfb237c42d1b1e4e110bde24958c3b878f7 Mon Sep 17 00:00:00 2001 From: Andy Piper Date: Sat, 13 Jan 2024 20:20:24 +0000 Subject: [PATCH] AC_Fence: convert old FENCE_ENABLE to bitmask of values --- libraries/AC_Fence/AC_Fence.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/libraries/AC_Fence/AC_Fence.cpp b/libraries/AC_Fence/AC_Fence.cpp index 1dd416e7ab542c..2f1067c30ffcc8 100644 --- a/libraries/AC_Fence/AC_Fence.cpp +++ b/libraries/AC_Fence/AC_Fence.cpp @@ -42,13 +42,16 @@ extern const AP_HAL::HAL& hal; const AP_Param::GroupInfo AC_Fence::var_info[] = { + + // 0 - deprecated enable flag + // @Param: ENABLE // @DisplayName: Fence enable/disable // @Description: Enabled fence types held as bitmask // @Bitmask{Rover}: 1:Circle Centered on Home,2:Inclusion/Exclusion Circles+Polygons // @Bitmask{Copter, Plane, Sub}: 0:Max altitude,1:Circle Centered on Home,2:Inclusion/Exclusion Circles+Polygons,3:Min altitude // @User: Standard - AP_GROUPINFO("ENABLE", 0, AC_Fence, _enabled_fences, 0), + AP_GROUPINFO("ENABLE", 12, AC_Fence, _enabled_fences, 0), // @Param: TYPE // @DisplayName: Fence Type @@ -144,6 +147,8 @@ const AP_Param::GroupInfo AC_Fence::var_info[] = { // @User: Standard AP_GROUPINFO_FRAME("OPTIONS", 11, AC_Fence, _options, static_cast(OPTIONS::DISABLE_MODE_CHANGE), AP_PARAM_FRAME_PLANE), + // 12 - new enabled flag + AP_GROUPEND }; @@ -157,6 +162,13 @@ AC_Fence::AC_Fence() #endif _singleton = this; AP_Param::setup_object_defaults(this, var_info); + + // convert old enable parameter + uint8_t enable_type = 0; + if (AP_Param::get_param_by_index(this, 0, AP_PARAM_INT8, &enable_type) && enable_type) { + _enabled_fences = _present_fences; + _enabled_fences.save(true); + } } /// enable the Fence code generally; a master switch for all fences