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

Reimplement battery voltage read and display for Badger 2040 W #29

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

GMMan
Copy link

@GMMan GMMan commented Jun 22, 2023

This measures VSYS ADC on Pi Pico W, which should be OK accuracy since the 3.3V reference is provided from the Pico W's buck regulator. Battery display is only enabled for Badger 2040 W because I didn't reimplement the battery measuring logic for Badger 2040.

Nothing special needs to be done to restore pin 29 back to output because the driver in Pico SDK automatically sets it on starting SPI comms.

Resolves #26

@Gadgetoid
Copy link
Member

Thank you-

However I am still very much of the opinion that it's MicroPython / Pico SDK's responsibility to implement the correct way of accomplishing this, taking into account any thread locks and other edge cases that we might otherwise encounter and smoothing over the implementation differences between Pico and Pico W.

This issue in particular touches upon that idea - micropython/micropython#11185

And this reference implementation uses specific cyw43_thread_enter()/_exit() locks to ensure there are no WiFi hiccups while reading battery - micropython/micropython#11185

Right now I don't think we can do this correctly in just Python?

@GMMan
Copy link
Author

GMMan commented Jun 22, 2023

That's a good point. I did end up with some issues with the pin not reading correctly in a previous iteration perhaps due to this. Where would be a good place to insert new code? In a Badger-specific board module, or patching the rp2 module?

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.

Reading battery level with Badger 2040W
2 participants