mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-22 12:27:34 +08:00
battery: cell voltage fill refactor
This commit is contained in:
committed by
Julian Oes
parent
14a61a6695
commit
49d22edc33
@@ -153,14 +153,10 @@ Battery::updateBatteryStatus(hrt_abstime timestamp, float voltage_v, float curre
|
||||
|
||||
static constexpr int uorb_max_cells = sizeof(_battery_status.voltage_cell_v) / sizeof(
|
||||
_battery_status.voltage_cell_v[0]);
|
||||
int i;
|
||||
|
||||
for (i = 0; i < _params.n_cells && i < uorb_max_cells; i++) {
|
||||
_battery_status.voltage_cell_v[i] = _voltage_filtered_v / _params.n_cells;
|
||||
}
|
||||
|
||||
for (; i < uorb_max_cells; i++) {
|
||||
_battery_status.voltage_cell_v[i] = 0.0f;
|
||||
// Fill cell voltages with average values to work around BATTERY_STATUS message not allowing to report just total voltage
|
||||
for (int i = 0; (i < _battery_status.cell_count) && (i < uorb_max_cells); i++) {
|
||||
_battery_status.voltage_cell_v[i] = _battery_status.voltage_filtered_v / _battery_status.cell_count;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user