-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
[Feature] Make reset and reset_reason consistent #379
Comments
pybricks/support#379 Even though these are not the same enums, it makes sense to align the first two entries of both as they can be used complementary.
pybricks/support#379 Even though these are not the same enums, it makes sense to align the first two entries of both as they can be used complementary.
We've already released v3.0, so this would be a breaking change. If we wanted to use the reset function as part of the firmware upgrade process, it would make things more complicated since the value we would have to pass would depend on the current firmware version. |
|
I chose |
Independent of the numbering, here are some suggestions for the docs: Reset: 0: Reboots the hub (hard reset) Reset reason: 0: The hub booted directly to Pybricks firmware from a powered off state. |
And we should be wary of the MicroPython definitions of hard and soft reset. Hard reset != hardware reset (not strictly anyway). Soft reset != software reset. Hard reset == (software [or hardware? - not applicable to Pybricks anyway since we don't have a reset button]) reset of the MCU. Soft reset == reset of the MicroPython runtime without resetting the MCU. |
Given
and,
it sounds like maybe the existing If we do, we can also just keep and document
Since we're not aiming to recreate Whether it's two methods or just one with an argument, I think all we'd need for end users are safe/usable variants of these:
I'm looking at these terms from the end-user perspective, even if they don't truly power off in a technical sense. Hence this wording (as opposed to power off and reset). Shut down is mainly useful for long-running creations that you may want to turn off on some condition. Such as after N hours, on completing a complicated drawing, on reaching the charging-pad, etc. EDIT: We might not even need any form of reboot, especially if it's causing more trouble than it's worth, like #382. Unlike many MicroPython boards, a lot is already cleaned up by just exiting the script anyway. If the user needs to reset other things, like maybe ports or Bluetooth connections, it might be better to use dedicated methods instead of rebooting. |
Reset will not be part of the end-user API. We will only keep it for backwards-compatibility for system updates. There will be a graceful shutdown instead. This adds the placeholder and moves the corresponding TODO note. pybricks/support#379
hub.system.reset(2) is kept in the implementation for backwards-compatibility with system updates, but the other reset variants should not be used, since they can lead to problems like pybricks/support#381 pybricks/support#379
Resolved via Skype. We are going for the implementation as sketched above. tl;dr:
|
Also drop reset() and update reset_reason() after pybricks/support#379
Also drop reset() and update reset_reason() after pybricks/support#379
Is your feature request related to a problem? Please describe.
I'm currently documenting the reset functions, but it is a bit hard to explain.
Right now, reset(1) does not reset, and reset() and reset_reason() are the exact opposites:
reset(0) ---> reset_reason() == 1
reset(1) ---> reset_reason() == 0
Is there a reason for this?
Since we're not introducing enums for these, it would make sense to use the same numbers. And if we have to pick one, I'd say "reset(1)" means "reset", so:
reset(1) ---> reset_reason() == 1 // This is reset
reset(0) ---> reset_reason() == 0 // This is shutdown
EDIT: Pushed proposed change.
The text was updated successfully, but these errors were encountered: