AP_Battery: fixed bug in SUI driver
fixed bug in total voltage
This commit is contained in:
parent
9c16e30178
commit
160839f0e1
@ -139,10 +139,11 @@ void AP_BattMonitor_SMBus_SUI::read_cell_voltages()
|
|||||||
pack_voltage_mv = total_mv;
|
pack_voltage_mv = total_mv;
|
||||||
} else {
|
} else {
|
||||||
// we can't get total pack voltage. Use average of cells we have so far
|
// 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++) {
|
for (uint8_t i = SUI_MAX_CELL_READ; i < cell_count; i++) {
|
||||||
_state.cell_voltages.cells[i] = pack_voltage_mv / SUI_MAX_CELL_READ;
|
_state.cell_voltages.cells[i] = cell_mv;
|
||||||
pack_voltage_mv += _state.cell_voltages.cells[i];
|
|
||||||
}
|
}
|
||||||
|
pack_voltage_mv += cell_mv * (cell_count - SUI_MAX_CELL_READ);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user