Owie icon indicating copy to clipboard operation
Owie copied to clipboard

Track battery % using consumed mAh instead of voltage.

Open JordanVlieg opened this issue 2 years ago • 1 comments

This PR introduces the concept of battery % (SOC) tracking using mAh instead of a voltage table.

The new system tracks SOC using both voltage and mAh in parallel, and only uses mAh if the following conditions are true

  • The user has set a battery capacity > 0 in the settings
  • The SOC as determined by voltage is > 15% (this prevents sudden nosedives at low voltage if the mAh is misconfigured or bugged).

It converts from mAh % remaining to watt hour % remaining using a set formula derived from the chemical properties of LiPo batteries. Namely that the voltage goes from 4.2V->2.8V. I know the maintainers are not a fan of "magic formulas", but this is a very simple square polynomial that is not an approximation, but rather an exact derivation. The only assumption made is that voltage decay is linear (which is obviously not quite true). However since everyone uses different cells, linear decay is the best choice.

Also adds a new (hidden) diagnostics page that displays more internal variables. Useful for developer debugging and visibility.

Known issues:

  • I expect weird SOC jumps near the 15% cutover. Need to add a fuzzy cutover

JordanVlieg avatar Sep 05 '22 00:09 JordanVlieg

@lolwheel sorry for the delay in response. Absolutely feel free to build on top of it. Though I would encourage the merging and release of a OWIE 2.0 with this as it is, since this changes nothing for users who don't enter a value, but those who want to beta test can access this feature before we measure on their behalf.

We can then follow up with 2.1 which determines capacity on your behalf.

JordanVlieg avatar Nov 04 '22 23:11 JordanVlieg