mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-03 06:28:27 -04:00
AP_BattMonitor: add has_cell_voltages method
This commit is contained in:
parent
6d8dc0fccf
commit
7a2d8fd5fd
@ -384,6 +384,15 @@ bool AP_BattMonitor::overpower_detected(uint8_t instance) const
|
||||
#endif
|
||||
}
|
||||
|
||||
bool AP_BattMonitor::has_cell_voltages(const uint8_t instance) const
|
||||
{
|
||||
if (instance < _num_instances && drivers[instance] != nullptr) {
|
||||
return drivers[instance]->has_cell_voltages();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// return the current cell voltages, returns the first monitor instances cells if the instance is out of range
|
||||
const AP_BattMonitor::cells & AP_BattMonitor::get_cell_voltages(const uint8_t instance) const
|
||||
{
|
||||
|
@ -144,7 +144,9 @@ public:
|
||||
bool overpower_detected(uint8_t instance) const;
|
||||
|
||||
// cell voltages
|
||||
const cells & get_cell_voltages() { return get_cell_voltages(AP_BATT_PRIMARY_INSTANCE); };
|
||||
bool has_cell_voltages() { return has_cell_voltages(AP_BATT_PRIMARY_INSTANCE); }
|
||||
bool has_cell_voltages(const uint8_t instance) const;
|
||||
const cells & get_cell_voltages() const { return get_cell_voltages(AP_BATT_PRIMARY_INSTANCE); }
|
||||
const cells & get_cell_voltages(const uint8_t instance) const;
|
||||
|
||||
// temperature
|
||||
|
@ -37,6 +37,9 @@ public:
|
||||
/// returns true if battery monitor instance provides current info
|
||||
virtual bool has_current() const = 0;
|
||||
|
||||
// returns true if battery monitor provides individual cell voltages
|
||||
virtual bool has_cell_voltages() const { return false; }
|
||||
|
||||
/// capacity_remaining_pct - returns the % battery capacity remaining (0 ~ 100)
|
||||
uint8_t capacity_remaining_pct() const;
|
||||
|
||||
|
@ -23,8 +23,9 @@ public:
|
||||
// virtual destructor to reduce compiler warnings
|
||||
virtual ~AP_BattMonitor_SMBus() {}
|
||||
|
||||
// all smart batteries provide current info
|
||||
// all smart batteries provide current and individual cell voltages
|
||||
bool has_current() const override { return true; }
|
||||
bool has_cell_voltages() const override { return true; }
|
||||
|
||||
protected:
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user