8 #if defined(HAL_BATT_VOLT_PIN) 10 # define AP_BATT_VOLT_PIN HAL_BATT_VOLT_PIN 11 # define AP_BATT_CURR_PIN HAL_BATT_CURR_PIN 12 # define AP_BATT_VOLTDIVIDER_DEFAULT HAL_BATT_VOLT_SCALE 13 # define AP_BATT_CURR_AMP_PERVOLT_DEFAULT HAL_BATT_CURR_SCALE 14 #elif CONFIG_HAL_BOARD == HAL_BOARD_PX4 && defined(CONFIG_ARCH_BOARD_PX4FMU_V1) 16 # define AP_BATT_VOLT_PIN 100 17 # define AP_BATT_CURR_PIN 101 18 # define AP_BATT_VOLTDIVIDER_DEFAULT 1.1f 19 # define AP_BATT_CURR_AMP_PERVOLT_DEFAULT 17.0f 20 #elif CONFIG_HAL_BOARD == HAL_BOARD_PX4 && (defined(CONFIG_ARCH_BOARD_PX4FMU_V2) || defined(CONFIG_ARCH_BOARD_PX4FMU_V4) || defined(CONFIG_ARCH_BOARD_PX4FMU_V4PRO)) 22 # define AP_BATT_VOLT_PIN 2 23 # define AP_BATT_CURR_PIN 3 24 # define AP_BATT_VOLTDIVIDER_DEFAULT 10.1f 25 # define AP_BATT_CURR_AMP_PERVOLT_DEFAULT 17.0f 26 #elif CONFIG_HAL_BOARD == HAL_BOARD_CHIBIOS 27 # define AP_BATT_VOLT_PIN 4 28 # define AP_BATT_CURR_PIN 3 29 # define AP_BATT_VOLTDIVIDER_DEFAULT 10.1f 30 # define AP_BATT_CURR_AMP_PERVOLT_DEFAULT 17.0f 31 #elif CONFIG_HAL_BOARD == HAL_BOARD_SITL 32 # define AP_BATT_VOLT_PIN 13 33 # define AP_BATT_CURR_PIN 12 34 # define AP_BATT_VOLTDIVIDER_DEFAULT 10.1f 35 # define AP_BATT_CURR_AMP_PERVOLT_DEFAULT 17.0f 37 #elif CONFIG_HAL_BOARD == HAL_BOARD_VRBRAIN && (defined(CONFIG_ARCH_BOARD_VRBRAIN_V45) || defined(CONFIG_ARCH_BOARD_VRBRAIN_V51) || defined(CONFIG_ARCH_BOARD_VRBRAIN_V52) || defined(CONFIG_ARCH_BOARD_VRBRAIN_V52E) || defined(CONFIG_ARCH_BOARD_VRCORE_V10) || defined(CONFIG_ARCH_BOARD_VRBRAIN_V54)) 38 # define AP_BATT_VOLT_PIN 10 39 # define AP_BATT_CURR_PIN 11 40 # define AP_BATT_VOLTDIVIDER_DEFAULT 10.1f 41 # define AP_BATT_CURR_AMP_PERVOLT_DEFAULT 17.0f 42 #elif CONFIG_HAL_BOARD == HAL_BOARD_VRBRAIN && defined(CONFIG_ARCH_BOARD_VRUBRAIN_V51) 43 # define AP_BATT_VOLT_PIN 10 44 # define AP_BATT_CURR_PIN -1 45 # define AP_BATT_VOLTDIVIDER_DEFAULT 10.1f 46 # define AP_BATT_CURR_AMP_PERVOLT_DEFAULT 17.0f 47 #elif CONFIG_HAL_BOARD == HAL_BOARD_VRBRAIN && defined(CONFIG_ARCH_BOARD_VRUBRAIN_V52) 48 # define AP_BATT_VOLT_PIN 10 49 # define AP_BATT_CURR_PIN 1 50 # define AP_BATT_VOLTDIVIDER_DEFAULT 10.1f 51 # define AP_BATT_CURR_AMP_PERVOLT_DEFAULT 17.0f 52 # define AP_BATT_CURR_AMP_PERVOLT_DEFAULT 17.0f 54 #elif CONFIG_HAL_BOARD == HAL_BOARD_LINUX && (CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_ERLEBOARD || CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_PXF) 55 # define AP_BATT_VOLT_PIN 5 56 # define AP_BATT_CURR_PIN 6 57 # define AP_BATT_VOLTDIVIDER_DEFAULT 10.1f 58 # define AP_BATT_CURR_AMP_PERVOLT_DEFAULT 17.0f 60 #elif CONFIG_HAL_BOARD == HAL_BOARD_LINUX && CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BBBMINI 61 # define AP_BATT_VOLT_PIN 0 62 # define AP_BATT_CURR_PIN 1 63 # define AP_BATT_VOLTDIVIDER_DEFAULT 10.1f 64 # define AP_BATT_CURR_AMP_PERVOLT_DEFAULT 17.0f 66 #elif CONFIG_HAL_BOARD == HAL_BOARD_LINUX && CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BLUE 67 # define AP_BATT_VOLT_PIN 0 68 # define AP_BATT_CURR_PIN 1 69 # define AP_BATT_VOLTDIVIDER_DEFAULT 10.1f 70 # define AP_BATT_CURR_AMP_PERVOLT_DEFAULT 17.0f 72 #elif CONFIG_HAL_BOARD == HAL_BOARD_LINUX && CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_POCKET 73 # define AP_BATT_VOLT_PIN 1 74 # define AP_BATT_CURR_PIN 0 75 # define AP_BATT_VOLTDIVIDER_DEFAULT 10.1f 76 # define AP_BATT_CURR_AMP_PERVOLT_DEFAULT 17.0f 78 #elif CONFIG_HAL_BOARD == HAL_BOARD_LINUX && CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_MINLURE 79 # define AP_BATT_VOLT_PIN 2 80 # define AP_BATT_CURR_PIN 3 81 # define AP_BATT_VOLTDIVIDER_DEFAULT 10.1f 82 # define AP_BATT_CURR_AMP_PERVOLT_DEFAULT 17.0f 84 #elif CONFIG_HAL_BOARD == HAL_BOARD_LINUX && (CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIO || CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIO2) 85 # define AP_BATT_VOLT_PIN 2 86 # define AP_BATT_CURR_PIN 3 87 # define AP_BATT_VOLTDIVIDER_DEFAULT 11.3f 88 # define AP_BATT_CURR_AMP_PERVOLT_DEFAULT 17.0f 90 #elif CONFIG_HAL_BOARD == HAL_BOARD_LINUX && (CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_EDGE) 91 # define AP_BATT_VOLT_PIN 3 92 # define AP_BATT_CURR_PIN 2 93 # define AP_BATT_VOLTDIVIDER_DEFAULT 18.62 94 # define AP_BATT_CURR_AMP_PERVOLT_DEFAULT 62.98f 96 # define AP_BATT2_VOLT_PIN 5 97 # define AP_BATT2_CURR_PIN 4 98 # define AP_BATT2_VOLTDIVIDER_DEFAULT 18.62 99 # define AP_BATT2_CURR_AMP_PERVOLT_DEFAULT 62.98f 102 # define AP_BATT_VOLT_PIN -1 103 # define AP_BATT_CURR_PIN -1 104 # define AP_BATT_VOLTDIVIDER_DEFAULT 10.1f 105 # define AP_BATT_CURR_AMP_PERVOLT_DEFAULT 17.0f
bool has_current() const override
returns true if battery monitor provides current info
bool has_consumed_energy() const override
returns true if battery monitor provides consumed energy info
AP_BattMonitor_Analog(AP_BattMonitor &mon, AP_BattMonitor::BattMonitor_State &mon_state, AP_BattMonitor_Params ¶ms)
Constructor.
AP_HAL::AnalogSource * _volt_pin_analog_source
void read()
Read the battery voltage and current. Should be called at 10hz.
AP_HAL::AnalogSource * _curr_pin_analog_source