AP_BattMonitor: add is_powering_off

This commit is contained in:
Jonathan Challinger 2016-01-06 17:11:12 -08:00 committed by Randy Mackay
parent 85b4288990
commit 8fdbb36827
3 changed files with 9 additions and 0 deletions

View File

@ -194,6 +194,10 @@ bool AP_BattMonitor::healthy(uint8_t instance) const {
return instance < AP_BATT_MONITOR_MAX_INSTANCES && _BattMonitor_STATE(instance).healthy;
}
bool AP_BattMonitor::is_powering_off(uint8_t instance) const {
return instance < AP_BATT_MONITOR_MAX_INSTANCES && _BattMonitor_STATE(instance).is_powering_off;
}
/// has_current - returns true if battery monitor instance provides current info
bool AP_BattMonitor::has_current(uint8_t instance) const
{

View File

@ -48,6 +48,7 @@ public:
struct BattMonitor_State {
uint8_t instance; // the instance number of this monitor
bool healthy; // battery monitor is communicating correctly
bool is_powering_off; // true if the battery is about to power off
float voltage; // voltage in volts
float current_amps; // current in amperes
float current_total_mah; // total current draw since start-up
@ -70,6 +71,9 @@ public:
bool healthy(uint8_t instance) const;
bool healthy() const { return healthy(AP_BATT_PRIMARY_INSTANCE); }
bool is_powering_off(uint8_t instance) const;
bool is_powering_off() const { return is_powering_off(AP_BATT_PRIMARY_INSTANCE); }
/// has_current - returns true if battery monitor instance provides current info
bool has_current(uint8_t instance) const;
bool has_current() const { return has_current(AP_BATT_PRIMARY_INSTANCE); }

View File

@ -69,6 +69,7 @@ void AP_BattMonitor_SMBus_PX4::read()
_state.last_time_micros = AP_HAL::micros();
_state.current_total_mah = batt_status.discharged_mah;
_state.healthy = true;
_state.is_powering_off = batt_status.is_powering_off;
// read capacity
if ((_batt_fd >= 0) && !_capacity_updated) {