AP_Compass: add and use AP_SIM_COMPASS_ENABLED

This commit is contained in:
Peter Barker 2021-10-30 12:15:48 +11:00 committed by Peter Barker
parent 48abb57a8a
commit ed608d37f6
4 changed files with 13 additions and 6 deletions

View File

@ -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

View File

@ -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;

View File

@ -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()
drain_accumulated_samples(_compass_instance[i], nullptr);
}
}
#endif
#endif // AP_SIM_COMPASS_ENABLED

View File

@ -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:
Vector3f _last_odi;
Vector3f _last_data[MAX_SITL_COMPASSES];
};
#endif // CONFIG_HAL_BOARD
#endif // AP_SIM_COMPASS_ENABLED