Skip to content

Conversation

gglockner
Copy link

With a MagTag 2025 Edition, MagTag.exit_and_deep_sleep() can fail to restart the board if it is called while the display is still updating. I documented this in issue 10639 for CircuitPython.

As a workaround, I added a while loop to test board.DISPLAY.busy, which enters light sleep while waiting for the display to finish updating. I also added a try/except block around the call to super().exit_and_deep_sleep() since the updated sleep_time value could be negative. Finally, in the exception handling, I call supervisor.reload() instead of microcontroller.reset() because the latter flashes the neopixels, unlike the original behavior of MagTag.exit_and_deep_sleep().

@dhalbert
Copy link
Contributor

This is really a core bug: alarm.exit_and_deep_sleep_until_alarms() should not be prevented from sleeping by the display updating. #10639.

@gglockner
Copy link
Author

@dhalbert : If you're saying that this is an upstream bug with hardware libraries, feel free to fix the problem with the hardware libraries and reject this pull request. However, if you're saying that the developer needs to check whether the display has finished updating before calling exit_and_deep_sleep(), I believe that is an unreasonable burden for a developer who expects code to restart at the end of deep sleep.

@dhalbert
Copy link
Contributor

If you're saying that this is an upstream bug with hardware libraries, feel free to fix the problem with the hardware libraries

Yup, that is what I'm saying: you as a user should not have to check for the display update being finished. The CircuitPython core should take care of that, since otherwise deep sleep will not work as expected.

@gglockner
Copy link
Author

After the comment from @bablokb in adafruit/circuitpython#10639, I refactored this so that the waiting is done in MagTag.refresh(), which lacks the side-effects from my prior commit fef40c2. I think this is a much cleaner implementation.

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