When the lithium battery is inserted into the charger, the lithium battery is in the charging state and current flows through it; you can connect a power resistor of about 0.1 ohm in series in the middle (if a resistor of 0.1 ohm generates a voltage of 100MV when passing a current of 1A), when there is When the current passes, a voltage will be generated at both ends of the resistor; you amplify the voltage on this resistor and compare it with a comparator to find out if lithium is present; the battery is in a state of charge When it is fully charged and the charger is not connected, no current flows!
Just connect a 0.5V diode in series to the two power terminals of the USB. At this point, the voltage supplied by the USB to the battery is 4.5V, so the battery can. be loaded. The saturation voltage of the battery is 4.2 V, but it is not a problem to supply 4.5 V (ifyou are afraid of damaging the battery, connect a 10 ohm resistor in series), so that you can charge the battery and power it. other loads at the same time.