Skip to content

Commit

Permalink
Advertise NAV modes through MSP even when mag is powered off (MR)
Browse files Browse the repository at this point in the history
  • Loading branch information
shellixyz committed Mar 29, 2018
1 parent 3a5e34e commit 413cb2e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/main/fc/fc_msp_box.c
Expand Up @@ -30,6 +30,7 @@
#include "fc/fc_msp_box.h"
#include "fc/runtime_config.h"

#include "sensors/compass.h"
#include "sensors/diagnostics.h"
#include "sensors/sensors.h"

Expand Down Expand Up @@ -179,7 +180,7 @@ void initActiveBoxIds(void)
activeBoxIds[activeBoxIdCount++] = BOXSURFACE;
}

if ((feature(FEATURE_GPS) && sensors(SENSOR_MAG) && sensors(SENSOR_ACC)) || (STATE(FIXED_WING) && sensors(SENSOR_ACC) && feature(FEATURE_GPS))) {
if ((feature(FEATURE_GPS) && compassIsConfigured() && sensors(SENSOR_ACC)) || (STATE(FIXED_WING) && sensors(SENSOR_ACC) && feature(FEATURE_GPS))) {
activeBoxIds[activeBoxIdCount++] = BOXNAVPOSHOLD;
activeBoxIds[activeBoxIdCount++] = BOXNAVRTH;
activeBoxIds[activeBoxIdCount++] = BOXNAVWP;
Expand Down
4 changes: 3 additions & 1 deletion src/main/navigation/navigation.c
Expand Up @@ -51,7 +51,9 @@

#include "sensors/sensors.h"
#include "sensors/acceleration.h"
#include "sensors/compass.h"
#include "sensors/boardalignment.h"
#include "sensors/diagnostics.h"


// Multirotors:
Expand Down Expand Up @@ -2485,7 +2487,7 @@ bool navigationBlockArming(void)
return false;

// Apply extra arming safety only if pilot has any of GPS modes configured
if ((isUsingNavigationModes() || failsafeMayRequireNavigationMode()) && !((posControl.flags.estPosStatue >= EST_USABLE) && STATE(GPS_FIX_HOME))) {
if ((isUsingNavigationModes() || failsafeMayRequireNavigationMode()) && !(((STATE(FIXED_WING) && !compassIsConfigured()) || (getHwCompassStatus() == HW_SENSOR_OK)) && (posControl.flags.estPosStatue >= EST_USABLE) && STATE(GPS_FIX_HOME))) {
shouldBlockArming = true;
}

Expand Down
5 changes: 5 additions & 0 deletions src/main/sensors/compass.c
Expand Up @@ -82,6 +82,11 @@ PG_RESET_TEMPLATE(compassConfig_t, compassConfig,

static uint8_t magUpdatedAtLeastOnce = 0;

bool compassIsConfigured()
{
return ((compassConfig()->mag_hardware != MAG_NONE) && (compassConfig()->mag_hardware != MAG_AUTODETECT));
}

bool compassDetect(magDev_t *dev, magSensor_e magHardwareToUse)
{
magSensor_e magHardware = MAG_NONE;
Expand Down
1 change: 1 addition & 0 deletions src/main/sensors/compass.h
Expand Up @@ -65,6 +65,7 @@ typedef struct compassConfig_s {

PG_DECLARE(compassConfig_t, compassConfig);

bool compassIsConfigured();
bool compassDetect(magDev_t *dev, magSensor_e magHardwareToUse);
bool compassInit(void);
void compassUpdate(timeUs_t currentTimeUs);
Expand Down

0 comments on commit 413cb2e

Please sign in to comment.