How to detect remaining capacity in a Lithium-ion battery?
The term you're looking for is "gas gauging." This is usually done with dedicated ICs, measuring voltage and current. TI and Linear Tech are couple of the big players.