mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-22 10:23:34 +08:00
battery: check source param inside battery lib
This moves the handling of the BAT%d_SOURCE param inside of the battery library. Users of the library now pass the source instead of the flag whether to publish. The battery library then checks if the source is selected using the param and publishes accordingly. Since we removed the strange system_source flag, we now need to look at all batteries in commander. For current estimation - I think - it makes sense to sum them up.
This commit is contained in:
@@ -41,7 +41,7 @@ AnalogBattery::AnalogBattery(int index, ModuleParams *parent) :
|
||||
|
||||
void
|
||||
AnalogBattery::updateBatteryStatusADC(hrt_abstime timestamp, float voltage_raw, float current_raw,
|
||||
bool selected_source, int priority, float throttle_normalized)
|
||||
int source, int priority, float throttle_normalized)
|
||||
{
|
||||
float voltage_v = voltage_raw * _analog_params.v_div;
|
||||
float current_a = (current_raw - _analog_params.v_offs_cur) * _analog_params.a_per_v;
|
||||
@@ -51,7 +51,7 @@ AnalogBattery::updateBatteryStatusADC(hrt_abstime timestamp, float voltage_raw,
|
||||
|
||||
|
||||
Battery::updateBatteryStatus(timestamp, voltage_v, current_a, connected,
|
||||
selected_source, priority, throttle_normalized, _params.source == 0);
|
||||
source, priority, throttle_normalized);
|
||||
}
|
||||
|
||||
bool AnalogBattery::is_valid()
|
||||
|
||||
Reference in New Issue
Block a user