Skip to content

Improve battery percentage calculation and reporting#719

Merged
JF002 merged 2 commits intoInfiniTimeOrg:developfrom
Riksu9000:improve_battery_reporting
Oct 9, 2021
Merged

Improve battery percentage calculation and reporting#719
JF002 merged 2 commits intoInfiniTimeOrg:developfrom
Riksu9000:improve_battery_reporting

Conversation

@Riksu9000
Copy link
Copy Markdown
Contributor

@Riksu9000 Riksu9000 commented Oct 4, 2021

While charging, percentage should only go up, and while discharging, percentage should only go down.

This is simpler than a proper filter and achieves practically the same thing. Should reduce, or even eliminate the noise that's visible in Gadgetbridge battery graph.

Also notify the battery level over ble only when it has changed. This should make the graph smoother.

While charging, percentage should only go up, and while discharging,
percentage should only go down.
@geekbozu
Copy link
Copy Markdown
Member

geekbozu commented Oct 4, 2021

I can test this later tonight with my devkit, I have an external Power supply that i can change the voltage on so no need to wait for a battery.

@geekbozu geekbozu self-assigned this Oct 4, 2021
@geekbozu geekbozu added the enhancement Enhancement to an existing app/feature label Oct 4, 2021
@Riksu9000
Copy link
Copy Markdown
Contributor Author

Here's a screenshot. Compare this to for example #609 (comment)

In this screenshot you can see that the same percentage is only reported twice on reconnects. This allows Gadgetbridge to create smoother lines instead of hard steps. I guess this could've been fixed in Gadgetbridge too if they ignored duplicate percentages.

During the night for example it can take many hours for the percentage to drop. Because the percentage isn't updated, Gadgetbridge will show the last point being the one from many hours ago. Basically if at 1am the percentage is 50% and at 8am it is still 50%, the graph stops at 1am, but this should probably be considered an issue with Gadgetbridge.

Is there a standard on how the percentage should be notified? If not, then it is more efficient to only report changes instead of reporting periodically.

Screenshot_20211007-120022_Gadgetbridge

@geekbozu
Copy link
Copy Markdown
Member

geekbozu commented Oct 7, 2021

This has been working well for me on a dev build...I have not yet actually paced it with the power supply. This mixed with #711 makes a really clean graph now with expected numbers instead of the jitter/spikes which is great!

@JF002 JF002 added this to the 1.7.0 milestone Oct 9, 2021
@JF002
Copy link
Copy Markdown
Collaborator

JF002 commented Oct 9, 2021

I agree with @geekbozu, the battery level measurement and graph are getting better and better thanks to you, @Riksu9000, thanks!

@JF002 JF002 merged commit b969272 into InfiniTimeOrg:develop Oct 9, 2021
@Riksu9000 Riksu9000 deleted the improve_battery_reporting branch July 25, 2022 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Enhancement to an existing app/feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants