AP_BattMonitor: correct Maxell capacity

This commit is contained in:
Randy Mackay 2020-06-03 09:23:45 +09:00 committed by WickedShell
parent 3de2dff6e3
commit 268c67d12d
3 changed files with 10 additions and 2 deletions

View File

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

View File

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

View File

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