diff --git a/libraries/AP_RangeFinder/AP_RangeFinder_BBB_PRU.h b/libraries/AP_RangeFinder/AP_RangeFinder_BBB_PRU.h index ddff67dda2..c8027d4d14 100644 --- a/libraries/AP_RangeFinder/AP_RangeFinder_BBB_PRU.h +++ b/libraries/AP_RangeFinder/AP_RangeFinder_BBB_PRU.h @@ -1,19 +1,11 @@ #pragma once -#include "AP_RangeFinder.h" -#include "AP_RangeFinder_Backend.h" - -#include - -#ifndef AP_RANGEFINDER_BBB_PRU_ENABLED -#define AP_RANGEFINDER_BBB_PRU_ENABLED ( \ - AP_RANGEFINDER_BACKEND_DEFAULT_ENABLED && \ - CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BBBMINI \ - ) -#endif +#include "AP_RangeFinder_config.h" #if AP_RANGEFINDER_BBB_PRU_ENABLED +#include "AP_RangeFinder_Backend.h" + #define PRU0_CTRL_BASE 0x4a322000 #define PRU0_IRAM_BASE 0x4a334000 @@ -54,4 +46,4 @@ private: }; -#endif +#endif // AP_RANGEFINDER_BBB_PRU_ENABLED diff --git a/libraries/AP_RangeFinder/AP_RangeFinder_BLPing.h b/libraries/AP_RangeFinder/AP_RangeFinder_BLPing.h index 63be4121cc..3a64e8f0b1 100644 --- a/libraries/AP_RangeFinder/AP_RangeFinder_BLPing.h +++ b/libraries/AP_RangeFinder/AP_RangeFinder_BLPing.h @@ -1,10 +1,6 @@ #pragma once -#include "AP_RangeFinder.h" - -#ifndef AP_RANGEFINDER_BLPING_ENABLED -#define AP_RANGEFINDER_BLPING_ENABLED AP_RANGEFINDER_BACKEND_DEFAULT_ENABLED -#endif +#include "AP_RangeFinder_config.h" #if AP_RANGEFINDER_BLPING_ENABLED diff --git a/libraries/AP_RangeFinder/AP_RangeFinder_Bebop.h b/libraries/AP_RangeFinder/AP_RangeFinder_Bebop.h index fa1c062203..e32be0ebe8 100644 --- a/libraries/AP_RangeFinder/AP_RangeFinder_Bebop.h +++ b/libraries/AP_RangeFinder/AP_RangeFinder_Bebop.h @@ -14,19 +14,7 @@ */ #pragma once -#include "AP_RangeFinder.h" -#include "AP_RangeFinder_Backend.h" - -#include -#include - -#ifndef AP_RANGEFINDER_BEBOP_ENABLED -#define AP_RANGEFINDER_BEBOP_ENABLED \ - AP_RANGEFINDER_BACKEND_DEFAULT_ENABLED && \ - (CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BEBOP || \ - CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_DISCO) && \ - defined(HAVE_LIBIIO) -#endif +#include "AP_RangeFinder_config.h" #if AP_RANGEFINDER_BEBOP_ENABLED @@ -158,4 +146,4 @@ private: }; -#endif +#endif // AP_RANGEFINDER_BEBOP_ENABLED diff --git a/libraries/AP_RangeFinder/AP_RangeFinder_Lua.h b/libraries/AP_RangeFinder/AP_RangeFinder_Lua.h index e412a398b8..12e5fad367 100644 --- a/libraries/AP_RangeFinder/AP_RangeFinder_Lua.h +++ b/libraries/AP_RangeFinder/AP_RangeFinder_Lua.h @@ -1,9 +1,10 @@ #pragma once -#include "AP_RangeFinder.h" -#include "AP_RangeFinder_Backend.h" +#include "AP_RangeFinder_config.h" -#if AP_SCRIPTING_ENABLED +#if AP_RANGEFINDER_LUA_ENABLED + +#include "AP_RangeFinder_Backend.h" // Data timeout #define AP_RANGEFINDER_LUA_TIMEOUT_MS 500 @@ -30,4 +31,4 @@ private: float _distance_m; // stored data from lua script: }; -#endif +#endif // AP_RANGEFINDER_LUA_ENABLED diff --git a/libraries/AP_RangeFinder/AP_RangeFinder_SITL.h b/libraries/AP_RangeFinder/AP_RangeFinder_SITL.h index 7ae23b0df6..c9f7466373 100644 --- a/libraries/AP_RangeFinder/AP_RangeFinder_SITL.h +++ b/libraries/AP_RangeFinder/AP_RangeFinder_SITL.h @@ -14,16 +14,12 @@ */ #pragma once -#include - -#include "AP_RangeFinder_Backend.h" - -#ifndef AP_RANGEFINDER_SIM_ENABLED -#define AP_RANGEFINDER_SIM_ENABLED (CONFIG_HAL_BOARD == HAL_BOARD_SITL && AP_RANGEFINDER_BACKEND_DEFAULT_ENABLED) -#endif +#include "AP_RangeFinder_config.h" #if AP_RANGEFINDER_SIM_ENABLED +#include "AP_RangeFinder_Backend.h" + class AP_RangeFinder_SITL : public AP_RangeFinder_Backend { public: // constructor. This incorporates initialisation as well. diff --git a/libraries/AP_RangeFinder/AP_RangeFinder_analog.h b/libraries/AP_RangeFinder/AP_RangeFinder_analog.h index 052782a0dd..d27ad72a00 100644 --- a/libraries/AP_RangeFinder/AP_RangeFinder_analog.h +++ b/libraries/AP_RangeFinder/AP_RangeFinder_analog.h @@ -1,15 +1,13 @@ #pragma once +#include "AP_RangeFinder_config.h" + +#if AP_RANGEFINDER_ANALOG_ENABLED + #include "AP_RangeFinder.h" #include "AP_RangeFinder_Backend.h" #include "AP_RangeFinder_Params.h" -#ifndef AP_RANGEFINDER_ANALOG_ENABLED -#define AP_RANGEFINDER_ANALOG_ENABLED AP_RANGEFINDER_BACKEND_DEFAULT_ENABLED -#endif - -#if AP_RANGEFINDER_ANALOG_ENABLED - class AP_RangeFinder_analog : public AP_RangeFinder_Backend { public: @@ -35,4 +33,4 @@ private: AP_HAL::AnalogSource *source; }; -#endif +#endif // AP_RANGEFINDER_ANALOG_ENABLED diff --git a/libraries/AP_RangeFinder/AP_RangeFinder_config.h b/libraries/AP_RangeFinder/AP_RangeFinder_config.h index c3fdf94cde..bb51ee21bf 100644 --- a/libraries/AP_RangeFinder/AP_RangeFinder_config.h +++ b/libraries/AP_RangeFinder/AP_RangeFinder_config.h @@ -1,6 +1,7 @@ #pragma once #include +#include #ifndef AP_RANGEFINDER_ENABLED #define AP_RANGEFINDER_ENABLED 1 @@ -9,3 +10,34 @@ #ifndef AP_RANGEFINDER_BACKEND_DEFAULT_ENABLED #define AP_RANGEFINDER_BACKEND_DEFAULT_ENABLED AP_RANGEFINDER_ENABLED #endif + +#ifndef AP_RANGEFINDER_ANALOG_ENABLED +#define AP_RANGEFINDER_ANALOG_ENABLED AP_RANGEFINDER_BACKEND_DEFAULT_ENABLED +#endif + +#ifndef AP_RANGEFINDER_BBB_PRU_ENABLED +#define AP_RANGEFINDER_BBB_PRU_ENABLED ( \ + AP_RANGEFINDER_BACKEND_DEFAULT_ENABLED && \ + CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BBBMINI \ + ) +#endif + +#ifndef AP_RANGEFINDER_BLPING_ENABLED +#define AP_RANGEFINDER_BLPING_ENABLED AP_RANGEFINDER_BACKEND_DEFAULT_ENABLED +#endif + +#ifndef AP_RANGEFINDER_BEBOP_ENABLED +#define AP_RANGEFINDER_BEBOP_ENABLED \ + AP_RANGEFINDER_BACKEND_DEFAULT_ENABLED && \ + (CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BEBOP || \ + CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_DISCO) && \ + defined(HAVE_LIBIIO) +#endif + +#ifndef AP_RANGEFINDER_LUA_ENABLED +#define AP_RANGEFINDER_LUA_ENABLED AP_SCRIPTING_ENABLED +#endif + +#ifndef AP_RANGEFINDER_SIM_ENABLED +#define AP_RANGEFINDER_SIM_ENABLED (CONFIG_HAL_BOARD == HAL_BOARD_SITL && AP_RANGEFINDER_BACKEND_DEFAULT_ENABLED) +#endif