-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Make ResetReason and RunReason available #3797
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
Make ResetReason and RunReason available #3797
Conversation
hihi fyi on some chips the reset-reason register can have multiple bits set. so you can have "power on reset" bit and "reset pin" bits both set. |
theres' no particular reason youd want it but i know that some chips are like that. just an FYI that may be better to do |
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.
Replicating Dan's tests on ESP32-S2, looks good:
Adafruit CircuitPython 6.1.0-beta.2-5-gacbc5fc7a on 2020-12-06; FeatherS2 with ESP32S2
>>>
>>> import microcontroller
>>> microcontroller.cpu.reset_reason
microcontroller.ResetReason.POWER_ON
>>> microcontroller.cpu.reset_reason is microcontroller.cpu.reset_reason.POWER_ON
True
>>> microcontroller.cpu.reset_reason is microcontroller.ResetReason.POWER_ON
True
>>> microcontroller.cpu.reset_reason is microcontroller.ResetReason.UNKNOWN
False
>>>
>>> import supervisor
>>> supervisor.runtime.run_reason
supervisor.RunReason.REPL_RELOAD
>>> supervisor.runtime.run_reason is supervisor.runtime.run_reason.REPL_RELOAD
True
>>> supervisor.runtime.run_reason is supervisor.RunReason.REPL_RELOAD
True
>>> supervisor.runtime.run_reason is supervisor.RunReason.STARTUP
False
I can re-test if / when there are changes.
Yes, good point. we could make it |
My preference would be a set or tuple if we want to support multiple reasons. I'm not sure we do though. I think we can simplify to one reason. For chips that are cumulative we can clear the state or prioritize the reason. |
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.
Looks good to me!
This is OK with me. I think we can prioritize the reasons: I think there will be an overriding one that the user will really care about. |
microcontroller.ResetReason
andsupervisor.RunReason
were missing from the corresponding module dictionaries, making them unavailable.ResetReason
mistakenly was saying it was part ofalarm
.Testing: