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:
Julian Oes
2020-04-06 15:56:54 +02:00
parent 641612468b
commit f650b91718
13 changed files with 55 additions and 61 deletions
+5 -1
View File
@@ -10,7 +10,11 @@ float32 scale # Power scaling factor, >= 1, or -1 if unknown
float32 temperature # temperature of the battery. NaN if unknown
int32 cell_count # Number of cells
bool connected # Whether or not a battery is connected, based on a voltage threshold
bool system_source # Whether or not a this battery is the active power source for VDD_5V_IN
uint8 BATTERY_SOURCE_POWER_MODULE = 0
uint8 BATTERY_SOURCE_EXTERNAL = 0
uint8 BATTERY_SOURCE_ESCS = 0
uint8 source # Battery source
uint8 priority # Zero based priority is the connection on the Power Controller V1..Vn AKA BrickN-1
uint16 capacity # actual capacity of the battery
uint16 cycle_count # number of discharge cycles the battery has experienced