-
-
Notifications
You must be signed in to change notification settings - Fork 58
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
Power off improvements #265
base: master
Are you sure you want to change the base?
Conversation
I tested briefly on City Hub and SPIKE Prime, but this could use some more @BertLindeman level QA testing ™️ 😄
|
Tested movehub at build 3514. Color/distance. Press button and keep pressed. Hub goes off and sensor re-lights again. [EDIT] added Technic hub. Going to test with build 3517 City hub no regression seen on issue 385 Movehub same positive result. Technichub same positive result. A-Oh Regression: from pybricks.hubs import ThisHub
from pybricks.tools import wait
hub = ThisHub()
print(hub.system.reset_reason())
wait(100)
hub.system.shutdown() The hub mimics "I am powered off" but the Color sensor and the Color-distance sensor flip-flop off and on at ~ 1 Hz? |
David as I do not know if you see updated comments, so I add this comment to let you know I finished this tests. Bert {EDIT] movie of Spike prime hub power-off while USB connected to loader: 2024-08-31.23.40.14_480.mp4 |
Hi @BertLindeman, thanks for all the testing!
I'm not able to reproduce this. Here is what I am doing:
I am able to reproduce this issue.
Which error are you referring to here? |
What I referred to was the Spike hub. As you reproduced. Not the city hub. Sorry for the confusion. Issue 365 is not back. |
0ba1f91
to
7d70d95
Compare
This issue should be fixed now (build 3526). |
Ah, I think you were referring to a build from before this pull request. So all good now? |
Test-mode ON
Long press power button if hub is ON and keep pressed and verify color sensor and color-distance sensor stay OFF
OK for me, David. |
7d70d95
to
731ee10
Compare
David, scenario:
Long press to power-off still does put off all lights. No idea how come, Laurens did not implement the light refactor, did he? Bert |
There were some changes to the Bluetooth button merged already, so that is probably a side effect of those changes. So hopefully that will be fixed by one of the other open pull requests. |
Reported on https://github.com/orgs/pybricks/discussions/1801, MoveHub still need work. |
Thanks for the pull request! Is it possible to make a short list of hub/sensor/usb poweroff permutations that this now fixes?
Is this the only issue or does something also stay on permanently when connected to USB? |
USB connected and power button pressed both keep the power on, so there is really no difference between those. If something stays on when USB is connected, then it will also stay on if the power button is pressed.
I don't know all of the sensors that request power on P1 or P2, but these are affected. Before, power on P1 or P2 was left on, now it is turned off. This was only noticeable without a volt meter on the SPIKE color light matrix since it turned on all green because of this. Before this, P4 was powered off when shutdown was requested (it doesn't matter if a device is connected or not). After this change, they don't power off until shutdown is complete. So now, the hub status light and the sensors turn off at the same time. Before, the sensors would turn off, then the hub status light would blink after that. The difference is only noticeable to the user if the sensor has a light. Bug that still needs to be fixed. If Move hub has a sensor attached, all works as expected. But if Move hub doesn't have a sensor attached, it will turn itself back on after the button is released. This bug was most likely introduced by these changes. |
[EDIT] For clarity add a column to the table with the build 3537 result. Power button press patterns.
Tests on movehub at build 3527 and build 3537
ConclusionIf a color-sensor is connected to port-C all is OK, even if a color-distance sensor is on Port.D. Repeat this on the current build, and added to the table. Bert |
Up to now, the VCC power off was done when shutdown was requested. This will cause external sensors to power off. Users may see this and assume that the hub is now off. However, the hub is still busy with the shutdown process, e.g. writing to flash memory. So we don't want the user to release the power button yet. Instead, move the VCC power off to after the hub has finished everything and it is safe to power off. This lets us remove the sys/io_ports.c and sys/io_ports.h files. The function is renamed to pbdrv_ioport_power_off() to be consistent with pbdrv_reset_power_off().
Add a new PBDRV_CONFIG_IOPORT_PUP_QUIRK_SHUTDOWN configuration flag for the ioport_pup driver. This flag is used to indicate that the driver that special handling of the I/O port VCC pin is needed during shutdown. We already had such a quirk in place, but it was enabled at all times on all hubs. This improves the situation by only enabling the quirk on hubs that need it. Also, on hubs that needed it, we now only enable the quirk when the button is not pressed. This has the desired effect of turning off sensors before the user released the button so that it looks like the hub is really off. This way it will be more clear to the user that they can release the button because the hub is "off".
731ee10
to
9727891
Compare
In most cases, pbio_stop_all() was already stopping motors, but it doesn't turn off motor outputs for non-motor devices that need extra power. This was causing the SPIKE Light Matrix to turn on all green LEDs when any hub was turned off. This fix is a bit of a hack since it is going behind the back of the higher-level I/O port stuff, but it works for now.
9727891
to
91c5940
Compare
OK, hopefully I got this working with all combinations now. Also rebased on current master, so other recent status light/bluetooth light changes should be included. Amending my previous summary of changes, the most noticeable differences are:
|
Just to be sure, David. Will test using build 3542 for this PR |
Yup, that should be the latest and greatest. |
No 3x3 light matrix here, so not tested. Maybe Manfred @msw-home can test? Tested cityhub, movehub like the table above. All OK Great David. Bert |
This is an attempt to do a better job shutting off all I/O port devices when powering off the hub.
The last commit fixes the issue identified in https://github.com/orgs/pybricks/discussions/1795#discussioncomment-10507805.
The middle commit fixes sensors like the BOOST Color/Distance sensor staying on while the button is held down at power off.
The first commit is setting up for the second commit.