Repository navigation
modmachine: Add machine.wake_pins. - #17542
Merged
Merged
Conversation
projectgus
reviewed
Nov 20, 2025
projectgus
left a comment
Contributor
There was a problem hiding this comment.
This looks like a useful function to me, and a good abstraction to eventually support on other ports as well. Thanks @meirarmon!
meirarmon
force-pushed
the
machine-wake-pins
branch
from
November 29, 2025 19:43
34aa6c8 to
a0f3d8b
Compare
projectgus
self-requested a review
January 28, 2026 23:41
projectgus
approved these changes
Apr 30, 2026
projectgus
left a comment
Contributor
There was a problem hiding this comment.
Hey @meirarmon, thanks for being so patient while I got back to this.
I have one very nitpicky optional suggestion, but this looks good to me and I think we should merge it either way. Thank you for contributing it!
| // Only a few (~8) pins might cause wakeup. | ||
| // Therefore, we calculate the required space in a first pass. | ||
| for (index = 0, len = 0; index < 64; index++) { | ||
| len += (status & ((uint64_t)1 << index)) ? 1 : 0; |
Contributor
There was a problem hiding this comment.
Suggested change
| len += (status & ((uint64_t)1 << index)) ? 1 : 0; | |
| len += (status & (1ULL << index)) ? 1 : 0; |
(This is nitpicky, but it's easier to read.)
| mp_obj_tuple_t *tuple = MP_OBJ_TO_PTR(mp_obj_new_tuple(len, NULL)); | ||
|
|
||
| for (index = 0, len = 0; index < 64; index++) { | ||
| if (status & ((uint64_t)1 << index)) { |
Contributor
There was a problem hiding this comment.
Suggested change
| if (status & ((uint64_t)1 << index)) { | |
| if (status & (1ULL << index)) { |
When waking from deep sleep, it could be helpful to know what pins triggered the wake up since the wake pins could be configured to multiple pins. Signed-off-by: Meir Armon <[email protected]>
dpgeorge
force-pushed
the
machine-wake-pins
branch
from
May 8, 2026 12:46
a0f3d8b to
f563d3c
Compare
|
Code size report: |
Member
|
Now merged! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When waking from deep sleep, it could be helpful to know what pins triggered the wake up since the wake pins could be configured to multiple pins.
Based on work that @m-cas did in this PR - #15498.
Testing
Tested ESP32_GENERIC_C3 with:
After wakeup checked that
machine.wake_pins()returned the correct pin that trigerred the wake.Trade-offs and Alternatives
I decided to place the method in
machinetogether withwake_reason, since it is feasible that other portswill want the exact same interface.