AP_BattMonitor: add has_cell_voltages method

This commit is contained in:
Randy Mackay 2017-05-31 12:31:18 +09:00
parent 6d8dc0fccf
commit 7a2d8fd5fd
4 changed files with 17 additions and 2 deletions

View File

@ -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
{

View File

@ -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

View File

@ -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;

View File

@ -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: