Powering over battery?

Rock5b allready has saradc input connected to the vbus supply voltage with a voltage divider, you can check here Realtime power usage on how this works and read the saradc data with any scripting language and convert it to the actual voltage of the battery.

When you have the voltage, you have enough input to model the percantage of the charge status.