-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Battery display and calibration #9426
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
base: develop
Are you sure you want to change the base?
Battery display and calibration #9426
Conversation
|
|
|
Thank you for this useful feature :) This will need also patches to the docs https://github.com/meshtastic/Meshtastic and protobuf repo https://github.com/meshtastic/protobufs Are you familar with the trunk linting tool? We use that to keep our code formatting consistent. |
Sure thing! Protobufs repo has a PR out already, I’ll work on docs this upcoming week. I did add the trunk linting extension to vscode but it wasn’t showing anything. I’ll mess around with it or use the output from the trunk CI test at least. Thanks for the review! |
|
Status for future reviewers: Seems like next steps after review are to get protobufs updates merged so the CI tests can complete |
|
@nwilde1590 If you can please review your PR and investigate the build failures in CI, that would get us several steps closer in reviewing this PR. |
The build failures are due to protobufs updates not being merged yet. I included the updated protobufs previously to allow CI to pass, but was advised to remove any generated content from the PR and allow the submodules to update on their own. |
| screen->runNow(); | ||
| } | ||
| } else if (selected == Reset) { | ||
| if (batteryCalibrationSampler) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we call a batteryCalibrationModule->stopCalibration(); here in order to preempt any issues?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed 356a4e1
| rebootAtMsec = (millis() + DEFAULT_REBOOT_SECONDS * 1000); | ||
| screen->runNow(); | ||
| } else if (selected == Apply) { | ||
| if (batteryCalibrationModule && batteryCalibrationModule->isCalibrationActive()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the node restarted due to low battery / brownout, will isCalibrationActive still be true?
I was trying to trace this in the code but can't confirm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Theres nothing in persistent memory/protobufs right now for saving current state, so brownout/low battery shutdown would reset back to false (See BatteryCalibrationModule.h line 27)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do have future ideas about saving the calibration data to memory periodically to resume after unintentional rebooting though. In testing, its a pain to have to start calibration from scratch if you accidentally hit the reset button several days in with a battery that lasts a week+.
|
Protobuf patch:L meshtastic/protobufs#850 |


This adds a module to Base-UI that displays battery stats and a discharge curve (similar to what can be found in the iOS app. It also adds battery calibration. Users charge their device to full, start calibration, and upon automatic low battery shutdown an updated OCV array is stored to persistent memory. The persistent OCV array is also loaded at boot and used to calculate battery percentage, if present.
First time making a contribution of this scale so very open to feedback. Still need a couple more weeks of charge/discharging my own device for beta testing, but figured I'd get the PR started in case others are available to test/provide feedback.
A couple misc. notes:
I have a branch with protobufs updates, not sure how that works for PRs, but it adds an array to store the actual OCV array under config.proto. Let me know where to make a PR for that and I'll get that set up.
showSimpleBanner - seems to not work in user modules, so added some logic to allow them to display after user/menu interaction.
Will need testers for regression - only tested on Wio Tracker L1 E-Ink
🤝 Attestations
Wio L1 E-ink. Will need assistance with other devices.