From 8a6880711a2b2223c9071dc8afa707fa5593b20b Mon Sep 17 00:00:00 2001 From: Alfie Lockrey <47219621+AlfieLockrey@users.noreply.github.com> Date: Fri, 15 Nov 2024 11:54:35 +0000 Subject: [PATCH] AP_Battery: include OPTIONS parameter on boards with SUM backend Enable battx_options for periphs if useful. Enable the options parameter for the battery monitor on AP_Periph devices if they could be useful - ie, battery summing is enabled and in use on a node with more than one source for battery inputs. Only define options in a single place Single definition for non periph builds or if AP_BATTERY_SUM_ENABLED --- libraries/AP_BattMonitor/AP_BattMonitor_Params.cpp | 4 +++- libraries/AP_BattMonitor/AP_BattMonitor_config.h | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/libraries/AP_BattMonitor/AP_BattMonitor_Params.cpp b/libraries/AP_BattMonitor/AP_BattMonitor_Params.cpp index 285481d38b..aceee7c05b 100644 --- a/libraries/AP_BattMonitor/AP_BattMonitor_Params.cpp +++ b/libraries/AP_BattMonitor/AP_BattMonitor_Params.cpp @@ -150,14 +150,16 @@ const AP_Param::GroupInfo AP_BattMonitor_Params::var_info[] = { AP_GROUPINFO("ARM_MAH", 19, AP_BattMonitor_Params, _arming_minimum_capacity, 0), // 20 was BUS +#endif // HAL_BUILD_AP_PERIPH +#if AP_BATTERY_OPTIONS_PARAM_ENABLED // @Param: OPTIONS // @DisplayName: Battery monitor options // @Description: This sets options to change the behaviour of the battery monitor // @Bitmask: 0:Ignore DroneCAN SoC, 1:MPPT reports input voltage and current, 2:MPPT Powered off when disarmed, 3:MPPT Powered on when armed, 4:MPPT Powered off at boot, 5:MPPT Powered on at boot, 6:Send resistance compensated voltage to GCS, 7:Allow DroneCAN InfoAux to be from a different CAN node, 9:Sum monitor measures minimum voltage instead of average // @User: Advanced AP_GROUPINFO("OPTIONS", 21, AP_BattMonitor_Params, _options, 0), -#endif // HAL_BUILD_AP_PERIPH +#endif // AP_BATTERY_OPTIONS_PARAM_ENABLED #if AP_BATTERY_ESC_TELEM_OUTBOUND_ENABLED // @Param: ESC_INDEX diff --git a/libraries/AP_BattMonitor/AP_BattMonitor_config.h b/libraries/AP_BattMonitor/AP_BattMonitor_config.h index 14a1fa7d28..3159b075d6 100644 --- a/libraries/AP_BattMonitor/AP_BattMonitor_config.h +++ b/libraries/AP_BattMonitor/AP_BattMonitor_config.h @@ -119,3 +119,7 @@ #ifndef AP_BATTERY_SCRIPTING_ENABLED #define AP_BATTERY_SCRIPTING_ENABLED (AP_SCRIPTING_ENABLED && AP_BATTERY_BACKEND_DEFAULT_ENABLED) #endif + +#ifndef AP_BATTERY_OPTIONS_PARAM_ENABLED +#define AP_BATTERY_OPTIONS_PARAM_ENABLED (!defined(HAL_BUILD_AP_PERIPH) || AP_BATTERY_SUM_ENABLED) +#endif