Browse Source

AP_Compass: add and use AP_SIM_COMPASS_ENABLED

gps-1.3.1
Peter Barker 3 years ago committed by Peter Barker
parent
commit
ed608d37f6
  1. 2
      libraries/AP_Compass/AP_Compass.cpp
  2. 4
      libraries/AP_Compass/AP_Compass.h
  3. 5
      libraries/AP_Compass/AP_Compass_SITL.cpp
  4. 8
      libraries/AP_Compass/AP_Compass_SITL.h

2
libraries/AP_Compass/AP_Compass.cpp

@ -1227,7 +1227,7 @@ void Compass::_detect_backends(void) @@ -1227,7 +1227,7 @@ void Compass::_detect_backends(void)
}
#endif
#if CONFIG_HAL_BOARD == HAL_BOARD_SITL
#if AP_SIM_COMPASS_ENABLED
ADD_BACKEND(DRIVER_SITL, new AP_Compass_SITL());
#endif

4
libraries/AP_Compass/AP_Compass.h

@ -70,6 +70,10 @@ @@ -70,6 +70,10 @@
#define MAX_CONNECTED_MAGS (COMPASS_MAX_UNREG_DEV+COMPASS_MAX_INSTANCES)
#ifndef AP_SIM_COMPASS_ENABLED
#define AP_SIM_COMPASS_ENABLED (CONFIG_HAL_BOARD == HAL_BOARD_SITL)
#endif
#include "CompassCalibrator.h"
class CompassLearn;

5
libraries/AP_Compass/AP_Compass_SITL.cpp

@ -1,8 +1,9 @@ @@ -1,8 +1,9 @@
#include "AP_Compass_SITL.h"
#if AP_SIM_COMPASS_ENABLED
#include <AP_HAL/AP_HAL.h>
#if CONFIG_HAL_BOARD == HAL_BOARD_SITL
extern const AP_HAL::HAL& hal;
AP_Compass_SITL::AP_Compass_SITL()
@ -158,4 +159,4 @@ void AP_Compass_SITL::read() @@ -158,4 +159,4 @@ void AP_Compass_SITL::read()
drain_accumulated_samples(_compass_instance[i], nullptr);
}
}
#endif
#endif // AP_SIM_COMPASS_ENABLED

8
libraries/AP_Compass/AP_Compass_SITL.h

@ -1,13 +1,15 @@ @@ -1,13 +1,15 @@
#pragma once
#include "AP_Compass.h"
#if AP_SIM_COMPASS_ENABLED
#include "AP_Compass_Backend.h"
#if CONFIG_HAL_BOARD == HAL_BOARD_SITL
#include <SITL/SITL.h>
#include <AP_Math/vectorN.h>
#include <AP_Math/AP_Math.h>
#include <AP_Declination/AP_Declination.h>
#include <SITL/SITL.h>
#define MAX_SITL_COMPASSES 3
@ -42,4 +44,4 @@ private: @@ -42,4 +44,4 @@ private:
Vector3f _last_odi;
Vector3f _last_data[MAX_SITL_COMPASSES];
};
#endif // CONFIG_HAL_BOARD
#endif // AP_SIM_COMPASS_ENABLED

Loading…
Cancel
Save