Skip to content

Commit

Permalink
AP_GPS: change GPS_AUTO_SWITCH #define list to enum class
Browse files Browse the repository at this point in the history
enumeration entry had to change to NONE to avoid name conflict with DISABLED
  • Loading branch information
magicrub authored and peterbarker committed Jun 25, 2020
1 parent ff007dd commit 8f6e9ca
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
10 changes: 5 additions & 5 deletions libraries/AP_GPS/AP_GPS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const AP_Param::GroupInfo AP_GPS::var_info[] = {
// @Description: Automatic switchover to GPS reporting best lock
// @Values: 0:Disabled,1:UseBest,2:Blend,3:UseSecond
// @User: Advanced
AP_GROUPINFO("AUTO_SWITCH", 3, AP_GPS, _auto_switch, 1),
AP_GROUPINFO("AUTO_SWITCH", 3, AP_GPS, _auto_switch, (int8_t)GPSAutoSwitch::USE_BEST),
#endif

// @Param: MIN_DGPS
Expand Down Expand Up @@ -276,7 +276,7 @@ const AP_Param::GroupInfo AP_GPS::var_info[] = {
#if defined(GPS_BLENDED_INSTANCE)
// @Param: BLEND_MASK
// @DisplayName: Multi GPS Blending Mask
// @Description: Determines which of the accuracy measures Horizontal position, Vertical Position and Speed are used to calculate the weighting on each GPS receiver when soft switching has been selected by setting GPS_AUTO_SWITCH to 2
// @Description: Determines which of the accuracy measures Horizontal position, Vertical Position and Speed are used to calculate the weighting on each GPS receiver when soft switching has been selected by setting GPS_AUTO_SWITCH to 2(Blend)
// @Bitmask: 0:Horiz Pos,1:Vert Pos,2:Speed
// @User: Advanced
AP_GROUPINFO("BLEND_MASK", 20, AP_GPS, _blend_mask, 5),
Expand Down Expand Up @@ -837,7 +837,7 @@ void AP_GPS::update_primary(void)
{
#if defined(GPS_BLENDED_INSTANCE)
// if blending is requested, attempt to calculate weighting for each GPS
if (_auto_switch == 2) {
if ((GPSAutoSwitch)_auto_switch.get() == GPSAutoSwitch::BLEND) {
_output_is_blended = calc_blend_weights();
// adjust blend health counter
if (!_output_is_blended) {
Expand All @@ -862,13 +862,13 @@ void AP_GPS::update_primary(void)
return;
}

if (_auto_switch == 0) {
if ((GPSAutoSwitch)_auto_switch.get() == GPSAutoSwitch::NONE) {
// AUTO_SWITCH is 0 so no switching of GPSs, always use first instance
primary_instance = 0;
return;
}

if (_auto_switch == 3) {
if ((GPSAutoSwitch)_auto_switch.get() == GPSAutoSwitch::USE_SECOND) {
// always select the second GPS instance
primary_instance = 1;
return;
Expand Down
7 changes: 7 additions & 0 deletions libraries/AP_GPS/AP_GPS.h
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,13 @@ class AP_GPS
GPS_AUTO_CONFIG_ENABLE = 1
};

enum class GPSAutoSwitch {
NONE = 0,
USE_BEST = 1,
BLEND = 2,
USE_SECOND = 3,
};

// used for flight testing with GPS loss
bool _force_disable_gps;

Expand Down

0 comments on commit 8f6e9ca

Please sign in to comment.