From 72a2962367471c1c0fe7ee6af14b9996bce9ae6b Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Tue, 6 Jun 2023 18:05:06 +1000 Subject: [PATCH] AP_Relay: add option to disable relay and servorelay libraries --- libraries/AP_Relay/AP_Relay.cpp | 5 +++++ libraries/AP_Relay/AP_Relay.h | 6 ++++++ libraries/AP_Relay/AP_Relay_config.h | 7 +++++++ 3 files changed, 18 insertions(+) create mode 100644 libraries/AP_Relay/AP_Relay_config.h diff --git a/libraries/AP_Relay/AP_Relay.cpp b/libraries/AP_Relay/AP_Relay.cpp index 578ab4fdf5..cb74a23040 100644 --- a/libraries/AP_Relay/AP_Relay.cpp +++ b/libraries/AP_Relay/AP_Relay.cpp @@ -7,6 +7,9 @@ #include #include "AP_Relay.h" + +#if AP_RELAY_ENABLED + #include #if CONFIG_HAL_BOARD == HAL_BOARD_SITL @@ -195,3 +198,5 @@ AP_Relay *relay() } } + +#endif // AP_RELAY_ENABLED diff --git a/libraries/AP_Relay/AP_Relay.h b/libraries/AP_Relay/AP_Relay.h index 1baa37a6aa..ef94fe44a7 100644 --- a/libraries/AP_Relay/AP_Relay.h +++ b/libraries/AP_Relay/AP_Relay.h @@ -9,6 +9,10 @@ /// @brief APM relay control class #pragma once +#include "AP_Relay_config.h" + +#if AP_RELAY_ENABLED + #include #define AP_RELAY_NUM_RELAYS 6 @@ -64,3 +68,5 @@ private: namespace AP { AP_Relay *relay(); }; + +#endif // AP_RELAY_ENABLED diff --git a/libraries/AP_Relay/AP_Relay_config.h b/libraries/AP_Relay/AP_Relay_config.h new file mode 100644 index 0000000000..efc3b918f4 --- /dev/null +++ b/libraries/AP_Relay/AP_Relay_config.h @@ -0,0 +1,7 @@ +#pragma once + +#include + +#ifndef AP_RELAY_ENABLED +#define AP_RELAY_ENABLED 1 +#endif