From b07021730897ac53ad1d091c31d3a2e681e53cef Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Mon, 27 Feb 2023 16:06:56 +1100 Subject: [PATCH] AP_Generator: add defines for generator backends --- libraries/AP_Generator/AP_Generator.cpp | 12 +++++++---- libraries/AP_Generator/AP_Generator.h | 6 ++++++ .../AP_Generator/AP_Generator_IE_2400.cpp | 4 ++-- libraries/AP_Generator/AP_Generator_IE_2400.h | 5 +++-- .../AP_Generator/AP_Generator_IE_650_800.cpp | 5 +++-- .../AP_Generator/AP_Generator_IE_650_800.h | 4 ++-- .../AP_Generator/AP_Generator_IE_FuelCell.cpp | 4 ++-- .../AP_Generator/AP_Generator_IE_FuelCell.h | 4 ++-- .../AP_Generator/AP_Generator_RichenPower.h | 4 ---- libraries/AP_Generator/AP_Generator_config.h | 20 +++++++++++++++++++ 10 files changed, 48 insertions(+), 20 deletions(-) diff --git a/libraries/AP_Generator/AP_Generator.cpp b/libraries/AP_Generator/AP_Generator.cpp index 2e9fba8372..f531c05ec7 100644 --- a/libraries/AP_Generator/AP_Generator.cpp +++ b/libraries/AP_Generator/AP_Generator.cpp @@ -65,19 +65,23 @@ void AP_Generator::init() // Not using a generator return; +#if AP_GENERATOR_IE650_800_ENABLED case Type::IE_650_800: _driver_ptr = new AP_Generator_IE_650_800(*this); break; +#endif +#if AP_GENERATOR_IE2400_ENABLED case Type::IE_2400: _driver_ptr = new AP_Generator_IE_2400(*this); break; - - case Type::RICHENPOWER: -#if AP_GENERATOR_RICHENPOWER_ENABLED - _driver_ptr = new AP_Generator_RichenPower(*this); #endif + +#if AP_GENERATOR_RICHENPOWER_ENABLED + case Type::RICHENPOWER: + _driver_ptr = new AP_Generator_RichenPower(*this); break; +#endif } if (_driver_ptr != nullptr) { diff --git a/libraries/AP_Generator/AP_Generator.h b/libraries/AP_Generator/AP_Generator.h index 86afb9d57a..3a393b0268 100644 --- a/libraries/AP_Generator/AP_Generator.h +++ b/libraries/AP_Generator/AP_Generator.h @@ -81,9 +81,15 @@ private: enum class Type { GEN_DISABLED = 0, +#if AP_GENERATOR_IE650_800_ENABLED IE_650_800 = 1, +#endif +#if AP_GENERATOR_IE2400_ENABLED IE_2400 = 2, +#endif +#if AP_GENERATOR_RICHENPOWER_ENABLED RICHENPOWER = 3, +#endif // LOWEHEISER = 4, }; diff --git a/libraries/AP_Generator/AP_Generator_IE_2400.cpp b/libraries/AP_Generator/AP_Generator_IE_2400.cpp index 8124d15559..991661c579 100644 --- a/libraries/AP_Generator/AP_Generator_IE_2400.cpp +++ b/libraries/AP_Generator/AP_Generator_IE_2400.cpp @@ -15,7 +15,7 @@ #include "AP_Generator_IE_2400.h" -#if HAL_GENERATOR_ENABLED +#if AP_GENERATOR_IE2400_ENABLED #include @@ -203,4 +203,4 @@ void AP_Generator_IE_2400::log_write() _err_code ); } -#endif +#endif // AP_GENERATOR_IE2400_ENABLED diff --git a/libraries/AP_Generator/AP_Generator_IE_2400.h b/libraries/AP_Generator/AP_Generator_IE_2400.h index 5bace66713..178e0d69fc 100644 --- a/libraries/AP_Generator/AP_Generator_IE_2400.h +++ b/libraries/AP_Generator/AP_Generator_IE_2400.h @@ -2,7 +2,7 @@ #include "AP_Generator_IE_FuelCell.h" -#if HAL_GENERATOR_ENABLED +#if AP_GENERATOR_IE2400_ENABLED class AP_Generator_IE_2400 : public AP_Generator_IE_FuelCell { @@ -53,4 +53,5 @@ private: uint16_t _spm_pwr; // Stack Power Module (SPM) power draw (Watts) }; -#endif +#endif // AP_GENERATOR_IE2400_ENABLED + diff --git a/libraries/AP_Generator/AP_Generator_IE_650_800.cpp b/libraries/AP_Generator/AP_Generator_IE_650_800.cpp index f1ccaa571a..e6939a1833 100644 --- a/libraries/AP_Generator/AP_Generator_IE_650_800.cpp +++ b/libraries/AP_Generator/AP_Generator_IE_650_800.cpp @@ -15,7 +15,7 @@ #include "AP_Generator_IE_650_800.h" -#if HAL_GENERATOR_ENABLED +#if AP_GENERATOR_IE650_800_ENABLED extern const AP_HAL::HAL& hal; @@ -122,4 +122,5 @@ AP_BattMonitor::Failsafe AP_Generator_IE_650_800::update_failsafes() const return AP_BattMonitor::Failsafe::None; } -#endif +#endif // AP_GENERATOR_IE650_800_ENABLED + diff --git a/libraries/AP_Generator/AP_Generator_IE_650_800.h b/libraries/AP_Generator/AP_Generator_IE_650_800.h index 9f3e48786b..545e3e244a 100644 --- a/libraries/AP_Generator/AP_Generator_IE_650_800.h +++ b/libraries/AP_Generator/AP_Generator_IE_650_800.h @@ -2,7 +2,7 @@ #include "AP_Generator_IE_FuelCell.h" -#if HAL_GENERATOR_ENABLED +#if AP_GENERATOR_IE650_800_ENABLED class AP_Generator_IE_650_800 : public AP_Generator_IE_FuelCell { @@ -95,4 +95,4 @@ private: | ERROR_BAT_UT; // (0x8), Battery undertemperature (<-15 degC) }; -#endif +#endif // AP_GENERATOR_IE650_800_ENABLED diff --git a/libraries/AP_Generator/AP_Generator_IE_FuelCell.cpp b/libraries/AP_Generator/AP_Generator_IE_FuelCell.cpp index b1dfddfdcf..901a583638 100644 --- a/libraries/AP_Generator/AP_Generator_IE_FuelCell.cpp +++ b/libraries/AP_Generator/AP_Generator_IE_FuelCell.cpp @@ -15,7 +15,7 @@ #include "AP_Generator_IE_FuelCell.h" -#if HAL_GENERATOR_ENABLED +#if AP_GENERATOR_IE_ENABLED #include #include @@ -190,4 +190,4 @@ bool AP_Generator_IE_FuelCell::check_for_err_code_if_changed(char* msg_txt, uint return false; } -#endif +#endif // AP_GENERATOR_IE_ENABLED diff --git a/libraries/AP_Generator/AP_Generator_IE_FuelCell.h b/libraries/AP_Generator/AP_Generator_IE_FuelCell.h index a1666adbe2..682d71f350 100644 --- a/libraries/AP_Generator/AP_Generator_IE_FuelCell.h +++ b/libraries/AP_Generator/AP_Generator_IE_FuelCell.h @@ -2,7 +2,7 @@ #include "AP_Generator_Backend.h" -#if HAL_GENERATOR_ENABLED +#if AP_GENERATOR_IE_ENABLED class AP_Generator_IE_FuelCell : public AP_Generator_Backend { @@ -100,4 +100,4 @@ protected: bool check_for_err_code_if_changed(char* msg_txt, uint8_t msg_len); }; -#endif +#endif // AP_GENERATOR_IE_ENABLED diff --git a/libraries/AP_Generator/AP_Generator_RichenPower.h b/libraries/AP_Generator/AP_Generator_RichenPower.h index 1ec7f3e8a9..790f2f7ff3 100644 --- a/libraries/AP_Generator/AP_Generator_RichenPower.h +++ b/libraries/AP_Generator/AP_Generator_RichenPower.h @@ -3,10 +3,6 @@ #include "AP_Generator_Backend.h" -#ifndef AP_GENERATOR_RICHENPOWER_ENABLED -#define AP_GENERATOR_RICHENPOWER_ENABLED 0 -#endif - #if AP_GENERATOR_RICHENPOWER_ENABLED #include diff --git a/libraries/AP_Generator/AP_Generator_config.h b/libraries/AP_Generator/AP_Generator_config.h index 3120b04c68..3c3f701def 100644 --- a/libraries/AP_Generator/AP_Generator_config.h +++ b/libraries/AP_Generator/AP_Generator_config.h @@ -5,3 +5,23 @@ #ifndef HAL_GENERATOR_ENABLED #define HAL_GENERATOR_ENABLED !HAL_MINIMIZE_FEATURES #endif + +#ifndef AP_GENERATOR_BACKEND_DEFAULT_ENABLED +#define AP_GENERATOR_BACKEND_DEFAULT_ENABLED HAL_GENERATOR_ENABLED +#endif + +#ifndef AP_GENERATOR_IE_ENABLED +#define AP_GENERATOR_IE_ENABLED AP_GENERATOR_BACKEND_DEFAULT_ENABLED +#endif + +#ifndef AP_GENERATOR_IE2400_ENABLED +#define AP_GENERATOR_IE2400_ENABLED AP_GENERATOR_IE_ENABLED +#endif + +#ifndef AP_GENERATOR_IE650_800_ENABLED +#define AP_GENERATOR_IE650_800_ENABLED AP_GENERATOR_IE_ENABLED +#endif + +#ifndef AP_GENERATOR_RICHENPOWER_ENABLED +#define AP_GENERATOR_RICHENPOWER_ENABLED 0 +#endif