diff --git a/libraries/AP_OpticalFlow/AP_OpticalFlow.h b/libraries/AP_OpticalFlow/AP_OpticalFlow.h index b5751d7351..d071436f8c 100644 --- a/libraries/AP_OpticalFlow/AP_OpticalFlow.h +++ b/libraries/AP_OpticalFlow/AP_OpticalFlow.h @@ -14,19 +14,7 @@ */ #pragma once -#include - -#ifndef AP_OPTICALFLOW_ENABLED -#define AP_OPTICALFLOW_ENABLED 1 -#endif - -#ifndef HAL_MSP_OPTICALFLOW_ENABLED -#define HAL_MSP_OPTICALFLOW_ENABLED (AP_OPTICALFLOW_ENABLED && (HAL_MSP_ENABLED && !HAL_MINIMIZE_FEATURES)) -#endif - -#ifndef AP_OPTICALFLOW_SITL_ENABLED -#define AP_OPTICALFLOW_SITL_ENABLED AP_SIM_ENABLED -#endif +#include "AP_OpticalFlow_config.h" #if AP_OPTICALFLOW_ENABLED diff --git a/libraries/AP_OpticalFlow/AP_OpticalFlow_Backend.h b/libraries/AP_OpticalFlow/AP_OpticalFlow_Backend.h index 059e5b92d1..f0c5b3096e 100644 --- a/libraries/AP_OpticalFlow/AP_OpticalFlow_Backend.h +++ b/libraries/AP_OpticalFlow/AP_OpticalFlow_Backend.h @@ -20,6 +20,8 @@ #include "AP_OpticalFlow.h" +#include + class OpticalFlow_backend { friend class AP_OpticalFlow; diff --git a/libraries/AP_OpticalFlow/AP_OpticalFlow_CXOF.h b/libraries/AP_OpticalFlow/AP_OpticalFlow_CXOF.h index 2cb8716bf8..d76205f46c 100644 --- a/libraries/AP_OpticalFlow/AP_OpticalFlow_CXOF.h +++ b/libraries/AP_OpticalFlow/AP_OpticalFlow_CXOF.h @@ -1,14 +1,10 @@ #pragma once -#include "AP_OpticalFlow.h" - -#ifndef AP_OPTICALFLOW_CXOF_ENABLED -#define AP_OPTICALFLOW_CXOF_ENABLED AP_OPTICALFLOW_ENABLED -#endif +#include "AP_OpticalFlow_config.h" #if AP_OPTICALFLOW_CXOF_ENABLED -#include +#include "AP_OpticalFlow_Backend.h" class AP_OpticalFlow_CXOF : public OpticalFlow_backend { diff --git a/libraries/AP_OpticalFlow/AP_OpticalFlow_HereFlow.h b/libraries/AP_OpticalFlow/AP_OpticalFlow_HereFlow.h index fa340584ff..8b61a87bf7 100644 --- a/libraries/AP_OpticalFlow/AP_OpticalFlow_HereFlow.h +++ b/libraries/AP_OpticalFlow/AP_OpticalFlow_HereFlow.h @@ -1,13 +1,10 @@ #pragma once -#include "AP_OpticalFlow.h" - -#ifndef AP_OPTICALFLOW_HEREFLOW_ENABLED -#define AP_OPTICALFLOW_HEREFLOW_ENABLED (AP_OPTICALFLOW_ENABLED && HAL_ENABLE_DRONECAN_DRIVERS) -#endif +#include "AP_OpticalFlow_config.h" #if AP_OPTICALFLOW_HEREFLOW_ENABLED +#include "AP_OpticalFlow_Backend.h" #include class AP_OpticalFlow_HereFlow : public OpticalFlow_backend { diff --git a/libraries/AP_OpticalFlow/AP_OpticalFlow_MAV.h b/libraries/AP_OpticalFlow/AP_OpticalFlow_MAV.h index 3784e4dc76..b9f0f6e9ad 100644 --- a/libraries/AP_OpticalFlow/AP_OpticalFlow_MAV.h +++ b/libraries/AP_OpticalFlow/AP_OpticalFlow_MAV.h @@ -1,13 +1,10 @@ #pragma once -#include "AP_OpticalFlow.h" - -#ifndef AP_OPTICALFLOW_MAV_ENABLED -#define AP_OPTICALFLOW_MAV_ENABLED AP_OPTICALFLOW_ENABLED -#endif +#include "AP_OpticalFlow_config.h" #if AP_OPTICALFLOW_MAV_ENABLED +#include "AP_OpticalFlow_Backend.h" #include class AP_OpticalFlow_MAV : public OpticalFlow_backend diff --git a/libraries/AP_OpticalFlow/AP_OpticalFlow_Onboard.cpp b/libraries/AP_OpticalFlow/AP_OpticalFlow_Onboard.cpp index a6e46b928e..00cf389b23 100644 --- a/libraries/AP_OpticalFlow/AP_OpticalFlow_Onboard.cpp +++ b/libraries/AP_OpticalFlow/AP_OpticalFlow_Onboard.cpp @@ -12,17 +12,15 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#include "AP_OpticalFlow_Onboard.h" + +#include "AP_OpticalFlow_config.h" #if AP_OPTICALFLOW_ONBOARD_ENABLED +#include "AP_OpticalFlow_Onboard.h" + #include -#include "AP_OpticalFlow.h" - -#if CONFIG_HAL_BOARD == HAL_BOARD_LINUX &&\ - CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BEBOP - #ifndef OPTICALFLOW_ONBOARD_DEBUG #define OPTICALFLOW_ONBOARD_DEBUG 0 #endif @@ -95,6 +93,4 @@ void AP_OpticalFlow_Onboard::update() #endif } -#endif - #endif // AP_OPTICALFLOW_ONBOARD_ENABLED diff --git a/libraries/AP_OpticalFlow/AP_OpticalFlow_Onboard.h b/libraries/AP_OpticalFlow/AP_OpticalFlow_Onboard.h index 3d21d82ed2..2950062d93 100644 --- a/libraries/AP_OpticalFlow/AP_OpticalFlow_Onboard.h +++ b/libraries/AP_OpticalFlow/AP_OpticalFlow_Onboard.h @@ -14,18 +14,11 @@ */ #pragma once -#include - -#ifndef AP_OPTICALFLOW_ONBOARD_ENABLED -#define AP_OPTICALFLOW_ONBOARD_ENABLED AP_OPTICALFLOW_ENABLED -#endif +#include "AP_OpticalFlow_config.h" #if AP_OPTICALFLOW_ONBOARD_ENABLED -#include -#include -#include -#include +#include #include "AP_OpticalFlow.h" diff --git a/libraries/AP_OpticalFlow/AP_OpticalFlow_PX4Flow.cpp b/libraries/AP_OpticalFlow/AP_OpticalFlow_PX4Flow.cpp index 4b051250af..0f72760d02 100644 --- a/libraries/AP_OpticalFlow/AP_OpticalFlow_PX4Flow.cpp +++ b/libraries/AP_OpticalFlow/AP_OpticalFlow_PX4Flow.cpp @@ -16,10 +16,12 @@ driver for PX4Flow optical flow sensor */ -#include "AP_OpticalFlow_PX4Flow.h" +#include "AP_OpticalFlow_config.h" #if AP_OPTICALFLOW_PX4FLOW_ENABLED +#include "AP_OpticalFlow_PX4Flow.h" + #include #include #include diff --git a/libraries/AP_OpticalFlow/AP_OpticalFlow_PX4Flow.h b/libraries/AP_OpticalFlow/AP_OpticalFlow_PX4Flow.h index c5c22b6de2..98e579b3e1 100644 --- a/libraries/AP_OpticalFlow/AP_OpticalFlow_PX4Flow.h +++ b/libraries/AP_OpticalFlow/AP_OpticalFlow_PX4Flow.h @@ -1,13 +1,10 @@ #pragma once -#include "AP_OpticalFlow.h" - -#ifndef AP_OPTICALFLOW_PX4FLOW_ENABLED -#define AP_OPTICALFLOW_PX4FLOW_ENABLED AP_OPTICALFLOW_ENABLED -#endif +#include "AP_OpticalFlow_config.h" #if AP_OPTICALFLOW_PX4FLOW_ENABLED +#include "AP_OpticalFlow_Backend.h" #include class AP_OpticalFlow_PX4Flow : public OpticalFlow_backend diff --git a/libraries/AP_OpticalFlow/AP_OpticalFlow_Pixart.cpp b/libraries/AP_OpticalFlow/AP_OpticalFlow_Pixart.cpp index 96ca4f9425..1095e44227 100644 --- a/libraries/AP_OpticalFlow/AP_OpticalFlow_Pixart.cpp +++ b/libraries/AP_OpticalFlow/AP_OpticalFlow_Pixart.cpp @@ -20,10 +20,12 @@ timing for register reads and writes is critical */ -#include "AP_OpticalFlow_Pixart.h" +#include "AP_OpticalFlow_config.h" #if AP_OPTICALFLOW_PIXART_ENABLED +#include "AP_OpticalFlow_Pixart.h" + #include #include #include diff --git a/libraries/AP_OpticalFlow/AP_OpticalFlow_Pixart.h b/libraries/AP_OpticalFlow/AP_OpticalFlow_Pixart.h index d1720eea72..2aeb5dd8e8 100644 --- a/libraries/AP_OpticalFlow/AP_OpticalFlow_Pixart.h +++ b/libraries/AP_OpticalFlow/AP_OpticalFlow_Pixart.h @@ -1,13 +1,11 @@ #pragma once -#include "AP_OpticalFlow.h" - -#ifndef AP_OPTICALFLOW_PIXART_ENABLED -#define AP_OPTICALFLOW_PIXART_ENABLED AP_OPTICALFLOW_ENABLED -#endif +#include "AP_OpticalFlow_config.h" #if AP_OPTICALFLOW_PIXART_ENABLED +#include "AP_OpticalFlow_Backend.h" + #include class AP_OpticalFlow_Pixart : public OpticalFlow_backend diff --git a/libraries/AP_OpticalFlow/AP_OpticalFlow_SITL.h b/libraries/AP_OpticalFlow/AP_OpticalFlow_SITL.h index e54cdc8e9c..a9e816aaac 100644 --- a/libraries/AP_OpticalFlow/AP_OpticalFlow_SITL.h +++ b/libraries/AP_OpticalFlow/AP_OpticalFlow_SITL.h @@ -1,9 +1,11 @@ #pragma once -#include "AP_OpticalFlow.h" +#include "AP_OpticalFlow_config.h" #if AP_OPTICALFLOW_SITL_ENABLED +#include "AP_OpticalFlow.h" + class AP_OpticalFlow_SITL : public OpticalFlow_backend { public: diff --git a/libraries/AP_OpticalFlow/AP_OpticalFlow_UPFLOW.h b/libraries/AP_OpticalFlow/AP_OpticalFlow_UPFLOW.h index 64bec165ee..c39e14359e 100644 --- a/libraries/AP_OpticalFlow/AP_OpticalFlow_UPFLOW.h +++ b/libraries/AP_OpticalFlow/AP_OpticalFlow_UPFLOW.h @@ -1,13 +1,10 @@ #pragma once -#include "AP_OpticalFlow.h" - -#ifndef AP_OPTICALFLOW_UPFLOW_ENABLED -#define AP_OPTICALFLOW_UPFLOW_ENABLED AP_OPTICALFLOW_ENABLED -#endif +#include "AP_OpticalFlow_config.h" #if AP_OPTICALFLOW_UPFLOW_ENABLED +#include "AP_OpticalFlow_Backend.h" #include class AP_OpticalFlow_UPFLOW : public OpticalFlow_backend diff --git a/libraries/AP_OpticalFlow/AP_OpticalFlow_config.h b/libraries/AP_OpticalFlow/AP_OpticalFlow_config.h new file mode 100644 index 0000000000..1d2eb4cf99 --- /dev/null +++ b/libraries/AP_OpticalFlow/AP_OpticalFlow_config.h @@ -0,0 +1,49 @@ +#pragma once + +#include +#include +#include + +#ifndef AP_OPTICALFLOW_ENABLED +#define AP_OPTICALFLOW_ENABLED 1 +#endif + +#ifndef AP_OPTICALFLOW_BACKEND_DEFAULT_ENABLED +#define AP_OPTICALFLOW_BACKEND_DEFAULT_ENABLED AP_OPTICALFLOW_ENABLED +#endif + +#ifndef AP_OPTICALFLOW_CXOF_ENABLED +#define AP_OPTICALFLOW_CXOF_ENABLED AP_OPTICALFLOW_BACKEND_DEFAULT_ENABLED +#endif + +#ifndef AP_OPTICALFLOW_HEREFLOW_ENABLED +#define AP_OPTICALFLOW_HEREFLOW_ENABLED (AP_OPTICALFLOW_BACKEND_DEFAULT_ENABLED && HAL_ENABLE_DRONECAN_DRIVERS) +#endif + +#ifndef AP_OPTICALFLOW_MAV_ENABLED +#define AP_OPTICALFLOW_MAV_ENABLED (AP_OPTICALFLOW_BACKEND_DEFAULT_ENABLED && HAL_GCS_ENABLED) +#endif + +#ifndef HAL_MSP_OPTICALFLOW_ENABLED +#define HAL_MSP_OPTICALFLOW_ENABLED (AP_OPTICALFLOW_BACKEND_DEFAULT_ENABLED && (HAL_MSP_ENABLED && !HAL_MINIMIZE_FEATURES)) +#endif + +#ifndef AP_OPTICALFLOW_ONBOARD_ENABLED +#define AP_OPTICALFLOW_ONBOARD_ENABLED (AP_OPTICALFLOW_BACKEND_DEFAULT_ENABLED && CONFIG_HAL_BOARD == HAL_BOARD_LINUX && CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BEBOP) +#endif + +#ifndef AP_OPTICALFLOW_PIXART_ENABLED +#define AP_OPTICALFLOW_PIXART_ENABLED AP_OPTICALFLOW_BACKEND_DEFAULT_ENABLED +#endif + +#ifndef AP_OPTICALFLOW_PX4FLOW_ENABLED +#define AP_OPTICALFLOW_PX4FLOW_ENABLED AP_OPTICALFLOW_BACKEND_DEFAULT_ENABLED +#endif + +#ifndef AP_OPTICALFLOW_SITL_ENABLED +#define AP_OPTICALFLOW_SITL_ENABLED (AP_OPTICALFLOW_BACKEND_DEFAULT_ENABLED && AP_SIM_ENABLED) +#endif + +#ifndef AP_OPTICALFLOW_UPFLOW_ENABLED +#define AP_OPTICALFLOW_UPFLOW_ENABLED AP_OPTICALFLOW_BACKEND_DEFAULT_ENABLED +#endif