Battery lavel indicator

Battery capacity can be estimated by completely discharging the battery using a fixed load, measuring the time and summing the current to get Ampere hours. The capacity will drop as the battery ages, or the load increases.

Once you have an estimate of the capacity, measure and sum the load current as a function of time, then subtract from the capacity to estimate remaining charge level.