Fix and consolidate discharge rate and remaining time calculation
This fixes several issues in the current code:
- Instead of averaging the remaining time it averages the discharge rate, and uses the rate and remaining energy to calculate the time.
- It gets rid of the history array, an autoregressive filter only needs one history value, no point recalculating it again and again.
- It keeps the averaged discharge rate over plug/unplug events. This reduces the error after replugging, as the first few reported rate values are often too small, while there is no intrinsic reason the old rate estimate becomes invalid.
- It brings the legacy remaining time calculation in line with the one based on the DisplayDevice UPower object, i.e. always uses rate and remaining energy to full/empty to calculate the time.
For more details, see !118 (merged).
Edited by Stefan Brüns