Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix round to 0 or 1 in capacity computation with given full-at #680

Merged
merged 1 commit into from
Apr 27, 2020

Conversation

akobel
Copy link
Contributor

@akobel akobel commented Apr 20, 2020

Fixes #666: static_cast<float>(capacity / full_at) is either 0.0 or 1.0 for most sane values of full_at.

I'm not 100% sure of the logic, though: clamping capacity to 0 .. full_at might be reasonable for defective batteries, if and only if full_at is well-known and can never be exceeded, and capacity readings are error-prone and could be misleading if higher than full_at.
I'd prefer the interpretation that capacity should not be clamped, but that I simply consider my battery to be charged at, say, full_at 80. In fact, that's what I set as a regular charging threshold to conserve battery lifetime, unless I prepare for extended offline periods and manually request 100%-charging. But my battery is nevertheless perfectly able to charge up to 100%, and I'd prefer this to be reflected by showing the actual capacity... But that's a matter of taste.

Why not leave full_at at the default 100 and just change the "good" threshold then? Well, reason is that my battery (again, usually) won't charge beyond 80%, and the "time-to-full" should reflect the fact that "full" is 80% in this context. Of course, this is not taken into account (yet), so I can just as well do without full_at.
In full generality, it's even more complicated: e.g., modern Thinkpads have a hysteresis function that sets lower and upper charging thresholds: target 80% as full, but don't even bother to start charging unless the battery drops below 75%. Hence, time to full would be time to 80%, if coming from less than 75%, or NaN/inf/undef if the cable has been plugged in between 75 and 80%...

If that's something you'd consider worth to add in the long run, I might investigate.

@Alexays
Copy link
Owner

Alexays commented Apr 27, 2020

Thanks!

@Alexays Alexays merged commit 44ed61b into Alexays:master Apr 27, 2020
@akobel
Copy link
Contributor Author

akobel commented Apr 27, 2020

My pleasure, thank you. Any opinions regarding my comment for the full_at logic? As mentioned, I might give it a shot, but only if there's upstream interest. It's already well-usable as-is, so not one of my priorities...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Battery full-at sometimes displays zero
2 participants