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

Even better Badger wake handling #316

Merged
merged 4 commits into from
Mar 29, 2022

Conversation

MichaelBell
Copy link
Contributor

I love the smell of assembler in the morning! (Well, it was morning when I started).

This change reads the GPIO state and sets the enable 3v3 as early as possible during the boot process. It shaves a couple of milliseconds off when the buttons are read and the power is enabled, because it's done before the external crystal oscillator is started and stable.

Because the initialization is now done in assembler, I've removed the WakeUpInit class the cpp file, so now there are just trivial functions to read the saved state.

I've also removed the access to pressed_to_wake from the Badger2040 object, as it isn't something apps should be using, and removed clear_pressed_to_wake again as it is unnecessary given the launcher waits for all buttons to be released anyway.

@Gadgetoid
Copy link
Member

Wow! And here was me thinking the existing solution was already lightyears ahead of what I could contrive. I wish I'd known about these methods to poke stuff into early boot/init stages.

@Gadgetoid Gadgetoid added this to the v1.18.6 milestone Mar 29, 2022
@Gadgetoid Gadgetoid merged commit 9fc556d into pimoroni:main Mar 29, 2022
@Gadgetoid
Copy link
Member

Works great. Thank you.

It occurs to me that this functionality probably wants copying over to the C++ library at some point, so that C++ project users get some slightly better functionality in this regard. The original intent was to use RP2040s sleep modes, but given this works so well, starts up quickly even when bringing up a whole MicroPython VM, and uses (probably considerably) less power than sleeping it makes sense to include it.

@MichaelBell MichaelBell deleted the earlier-power-init branch March 30, 2022 10:48
@MichaelBell
Copy link
Contributor Author

Yes - we'd want to make this optional for C++ land, as the user might want to do something custom. But having the same default behaviour switchable with a cmake variable would be nice.

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.

2 participants