From f361d9b0d07aa249420b36861b7fcfaf2c7ebab8 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Fri, 24 Dec 2021 19:17:50 +1100 Subject: [PATCH] AP_OpticalFlow: create and use AP_OPTICALFLOW_ENABLED --- libraries/AP_OpticalFlow/AP_OpticalFlow.cpp | 12 +++++++++++- libraries/AP_OpticalFlow/AP_OpticalFlow_Onboard.h | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/libraries/AP_OpticalFlow/AP_OpticalFlow.cpp b/libraries/AP_OpticalFlow/AP_OpticalFlow.cpp index 2cc0f158be..f9c266ea53 100644 --- a/libraries/AP_OpticalFlow/AP_OpticalFlow.cpp +++ b/libraries/AP_OpticalFlow/AP_OpticalFlow.cpp @@ -116,13 +116,17 @@ void OpticalFlow::init(uint32_t log_bit) case OpticalFlowType::NONE: break; case OpticalFlowType::PX4FLOW: +#if AP_OPTICALFLOW_PX4FLOW_ENABLED backend = AP_OpticalFlow_PX4Flow::detect(*this); +#endif break; case OpticalFlowType::PIXART: +#if AP_OPTICALFLOW_PIXART_ENABLED backend = AP_OpticalFlow_Pixart::detect("pixartflow", *this); if (backend == nullptr) { backend = AP_OpticalFlow_Pixart::detect("pixartPC15", *this); } +#endif break; case OpticalFlowType::BEBOP: #if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BEBOP @@ -130,13 +134,17 @@ void OpticalFlow::init(uint32_t log_bit) #endif break; case OpticalFlowType::CXOF: +#if AP_OPTICALFLOW_CXOF_ENABLED backend = AP_OpticalFlow_CXOF::detect(*this); +#endif break; case OpticalFlowType::MAVLINK: +#if AP_OPTICALFLOW_MAV_ENABLED backend = AP_OpticalFlow_MAV::detect(*this); +#endif break; case OpticalFlowType::UAVCAN: -#if HAL_ENABLE_LIBUAVCAN_DRIVERS +#if AP_OPTICALFLOW_HEREFLOW_ENABLED backend = new AP_OpticalFlow_HereFlow(*this); #endif break; @@ -146,7 +154,9 @@ void OpticalFlow::init(uint32_t log_bit) #endif break; case OpticalFlowType::UPFLOW: +#if AP_OPTICALFLOW_UPFLOW_ENABLED backend = AP_OpticalFlow_UPFLOW::detect(*this); +#endif break; case OpticalFlowType::SITL: #if CONFIG_HAL_BOARD == HAL_BOARD_SITL diff --git a/libraries/AP_OpticalFlow/AP_OpticalFlow_Onboard.h b/libraries/AP_OpticalFlow/AP_OpticalFlow_Onboard.h index b152741ddf..46dc74094f 100644 --- a/libraries/AP_OpticalFlow/AP_OpticalFlow_Onboard.h +++ b/libraries/AP_OpticalFlow/AP_OpticalFlow_Onboard.h @@ -14,7 +14,7 @@ */ #pragma once -#include +#include #ifndef AP_OPTICALFLOW_ONBOARD_ENABLED #define AP_OPTICALFLOW_ONBOARD_ENABLED AP_OPTICALFLOW_ENABLED