hey there… sorry, been a while, cause i worked on a cpython driver for mmWave devices
I tried around a bit… what do you need is a P-MOSFET-Switch which changes between charging and measure circuit…
if the charger is connected, the FET need to be deactivated to not read the charging state.
I do not have a circuitdesign-proggi installed currently, but here the general description:
USB->charging controller->battery->P-MOSFET(+V-Divider) where you read the voltage->GND all of the above
The Gate-Pin will be connected (via Voltage-Divider) so that the mosfet will close if the usb-power is connected, the divider for battery-testing can be connected to the out of the p-fet, then you can read the battery if there is no cable connected, without being interrupted but will turned of from the usb-source (cause it’s closed by the p-fet)
hope this helps a little
Greetings