AP_BattMonitor: add is_powering_off
This commit is contained in:
parent
85b4288990
commit
8fdbb36827
@ -194,6 +194,10 @@ bool AP_BattMonitor::healthy(uint8_t instance) const {
|
|||||||
return instance < AP_BATT_MONITOR_MAX_INSTANCES && _BattMonitor_STATE(instance).healthy;
|
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
|
/// has_current - returns true if battery monitor instance provides current info
|
||||||
bool AP_BattMonitor::has_current(uint8_t instance) const
|
bool AP_BattMonitor::has_current(uint8_t instance) const
|
||||||
{
|
{
|
||||||
|
@ -48,6 +48,7 @@ public:
|
|||||||
struct BattMonitor_State {
|
struct BattMonitor_State {
|
||||||
uint8_t instance; // the instance number of this monitor
|
uint8_t instance; // the instance number of this monitor
|
||||||
bool healthy; // battery monitor is communicating correctly
|
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 voltage; // voltage in volts
|
||||||
float current_amps; // current in amperes
|
float current_amps; // current in amperes
|
||||||
float current_total_mah; // total current draw since start-up
|
float current_total_mah; // total current draw since start-up
|
||||||
@ -70,6 +71,9 @@ public:
|
|||||||
bool healthy(uint8_t instance) const;
|
bool healthy(uint8_t instance) const;
|
||||||
bool healthy() const { return healthy(AP_BATT_PRIMARY_INSTANCE); }
|
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
|
/// has_current - returns true if battery monitor instance provides current info
|
||||||
bool has_current(uint8_t instance) const;
|
bool has_current(uint8_t instance) const;
|
||||||
bool has_current() const { return has_current(AP_BATT_PRIMARY_INSTANCE); }
|
bool has_current() const { return has_current(AP_BATT_PRIMARY_INSTANCE); }
|
||||||
|
@ -69,6 +69,7 @@ void AP_BattMonitor_SMBus_PX4::read()
|
|||||||
_state.last_time_micros = AP_HAL::micros();
|
_state.last_time_micros = AP_HAL::micros();
|
||||||
_state.current_total_mah = batt_status.discharged_mah;
|
_state.current_total_mah = batt_status.discharged_mah;
|
||||||
_state.healthy = true;
|
_state.healthy = true;
|
||||||
|
_state.is_powering_off = batt_status.is_powering_off;
|
||||||
|
|
||||||
// read capacity
|
// read capacity
|
||||||
if ((_batt_fd >= 0) && !_capacity_updated) {
|
if ((_batt_fd >= 0) && !_capacity_updated) {
|
||||||
|
Loading…
Reference in New Issue
Block a user