AP_Battery: fixed bug in SUI driver

fixed bug in total voltage
This commit is contained in:
Andrew Tridgell 2020-03-02 08:18:12 +11:00
parent d96c7049ca
commit ff112a726b

View File

@ -139,10 +139,11 @@ void AP_BattMonitor_SMBus_SUI::read_cell_voltages()
pack_voltage_mv = total_mv;
} else {
// we can't get total pack voltage. Use average of cells we have so far
const uint16_t cell_mv = pack_voltage_mv / SUI_MAX_CELL_READ;
for (uint8_t i = SUI_MAX_CELL_READ; i < cell_count; i++) {
_state.cell_voltages.cells[i] = pack_voltage_mv / SUI_MAX_CELL_READ;
pack_voltage_mv += _state.cell_voltages.cells[i];
_state.cell_voltages.cells[i] = cell_mv;
}
pack_voltage_mv += cell_mv * (cell_count - SUI_MAX_CELL_READ);
}
}