Skip to content

Commit

Permalink
AC_Fence: convert old FENCE_ENABLE to bitmask of values
Browse files Browse the repository at this point in the history
  • Loading branch information
andyp1per committed Jan 13, 2024
1 parent 26a2f2d commit 76020df
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion libraries/AC_Fence/AC_Fence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -144,6 +147,8 @@ const AP_Param::GroupInfo AC_Fence::var_info[] = {
// @User: Standard
AP_GROUPINFO_FRAME("OPTIONS", 11, AC_Fence, _options, static_cast<uint16_t>(OPTIONS::DISABLE_MODE_CHANGE), AP_PARAM_FRAME_PLANE),

// 12 - new enabled flag

AP_GROUPEND
};

Expand All @@ -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
Expand Down

0 comments on commit 76020df

Please sign in to comment.