AP_Periph: add param BATT_HIDE_MASK
This commit is contained in:
parent
86aad6f6bf
commit
6fb94828fe
@ -43,6 +43,10 @@ extern const AP_HAL::HAL &hal;
|
||||
#define AP_PERIPH_BARO_ENABLE_DEFAULT 1
|
||||
#endif
|
||||
|
||||
#ifndef HAL_PERIPH_BATT_HIDE_MASK_DEFAULT
|
||||
#define HAL_PERIPH_BATT_HIDE_MASK_DEFAULT 0
|
||||
#endif
|
||||
|
||||
#ifndef AP_PERIPH_EFI_PORT_DEFAULT
|
||||
#define AP_PERIPH_EFI_PORT_DEFAULT 3
|
||||
#endif
|
||||
@ -224,6 +228,13 @@ const AP_Param::Info AP_Periph_FW::var_info[] = {
|
||||
// @Group: BATT
|
||||
// @Path: ../libraries/AP_BattMonitor/AP_BattMonitor.cpp
|
||||
GOBJECT(battery_lib, "BATT", AP_BattMonitor),
|
||||
|
||||
// @Param: BATT_HIDE_MASK
|
||||
// @DisplayName: Battery hide mask
|
||||
// @Description: Instance mask of battery index(es) to not transmit their status over CAN. This is useful for hiding a "battery" instance that is used by other libraries but don't want to be treated as a battery source to the autopilot. For example, an AP_Periph based motor controller (ESC) that is reporting as an ESC. It should not be reporting "batteries", only ESC telemetry type data which includes voltage and current.
|
||||
// @Bitmask: 0:BATT, 1:BATT2, 2:BATT3, 3:BATT4, 4:BATT5, 5:BATT6, 6:BATT7, 7:BATT8, 8:BATT9, 9:BATTA, 10:BATTB, 11:BATTC, 12:BATTD, 13:BATTE, 14:BATTF, 15:BATTG
|
||||
// @User: Advanced
|
||||
GSCALAR(battery_hide_mask, "BATT_HIDE_MASK", HAL_PERIPH_BATT_HIDE_MASK_DEFAULT),
|
||||
#endif
|
||||
|
||||
#ifdef HAL_PERIPH_ENABLE_MAG
|
||||
|
@ -82,6 +82,7 @@ public:
|
||||
k_param_sitl,
|
||||
k_param_ahrs,
|
||||
k_param_battery_balance,
|
||||
k_param_battery_hide_mask,
|
||||
};
|
||||
|
||||
AP_Int16 format_version;
|
||||
@ -183,6 +184,10 @@ public:
|
||||
AP_Int16 sysid_this_mav;
|
||||
#endif
|
||||
|
||||
#ifdef HAL_PERIPH_ENABLE_BATTERY
|
||||
AP_Int32 battery_hide_mask;
|
||||
#endif
|
||||
|
||||
#ifdef HAL_PERIPH_ENABLE_EFI
|
||||
AP_Int32 efi_baudrate;
|
||||
AP_Int8 efi_port;
|
||||
|
@ -27,6 +27,10 @@ void AP_Periph_FW::can_battery_update(void)
|
||||
|
||||
const uint8_t battery_instances = battery_lib.num_instances();
|
||||
for (uint8_t i=0; i<battery_instances; i++) {
|
||||
if (BIT_IS_SET(g.battery_hide_mask, i)) {
|
||||
// do not transmit this battery
|
||||
continue;
|
||||
}
|
||||
if (!battery_lib.healthy(i)) {
|
||||
continue;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user