diff --git a/libraries/AP_BattMonitor/AP_BattMonitor_SMBus.cpp b/libraries/AP_BattMonitor/AP_BattMonitor_SMBus.cpp index 667815beaf..7f4b8a63d2 100644 --- a/libraries/AP_BattMonitor/AP_BattMonitor_SMBus.cpp +++ b/libraries/AP_BattMonitor/AP_BattMonitor_SMBus.cpp @@ -54,7 +54,7 @@ bool AP_BattMonitor_SMBus::read_full_charge_capacity(void) if (_full_charge_capacity != 0) { return true; } else if (read_word(BATTMONITOR_SMBUS_FULL_CHARGE_CAPACITY, data)) { - _full_charge_capacity = data; + _full_charge_capacity = data * get_capacity_scaler(); return true; } return false; @@ -70,7 +70,7 @@ bool AP_BattMonitor_SMBus::read_remaining_capacity(void) if (capacity > 0) { uint16_t data; if (read_word(BATTMONITOR_SMBUS_REMAINING_CAPACITY, data)) { - _state.consumed_mah = MAX(0, capacity - data); + _state.consumed_mah = MAX(0, capacity - (data * get_capacity_scaler())); return true; } } diff --git a/libraries/AP_BattMonitor/AP_BattMonitor_SMBus.h b/libraries/AP_BattMonitor/AP_BattMonitor_SMBus.h index ad262099e6..9fc91fdd09 100644 --- a/libraries/AP_BattMonitor/AP_BattMonitor_SMBus.h +++ b/libraries/AP_BattMonitor/AP_BattMonitor_SMBus.h @@ -65,6 +65,9 @@ protected: // we know the full charge capacity bool read_remaining_capacity(void); + // return a scaler that should be multiplied by the battery's reported capacity numbers to arrive at the actual capacity in mAh + virtual uint16_t get_capacity_scaler() const { return 1; } + // reads the temperature word from the battery // returns true if the read was successful bool read_temp(void); diff --git a/libraries/AP_BattMonitor/AP_BattMonitor_SMBus_Maxell.h b/libraries/AP_BattMonitor/AP_BattMonitor_SMBus_Maxell.h index 3df29dd402..a70fb07f47 100644 --- a/libraries/AP_BattMonitor/AP_BattMonitor_SMBus_Maxell.h +++ b/libraries/AP_BattMonitor/AP_BattMonitor_SMBus_Maxell.h @@ -6,4 +6,9 @@ class AP_BattMonitor_SMBus_Maxell : public AP_BattMonitor_SMBus_Generic { using AP_BattMonitor_SMBus_Generic::AP_BattMonitor_SMBus_Generic; +private: + + // return a scaler that should be multiplied by the battery's reported capacity numbers to arrive at the actual capacity in mAh + uint16_t get_capacity_scaler() const override { return 2; } + };