Skip to content

Deep Sleep support on CPY #3467

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

Closed
wants to merge 15 commits into from
Closed

Deep Sleep support on CPY #3467

wants to merge 15 commits into from

Conversation

microdev1
Copy link
Collaborator

@microdev1 microdev1 commented Sep 24, 2020

This PR implements deep sleep support in CircuitPython!

Port(s) supported: (as of this PR)

  • esp32s2

To-do:

  • Get wakeup reason to work
  • Implement custom wake stub
  • Implement method to enter deep sleep when code.py finishes

@tannewt tannewt self-requested a review September 25, 2020 20:19
@tannewt tannewt added advanced api enhancement espressif applies to multiple Espressif chips power labels Sep 25, 2020
Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What feedback would you like from me? It looks like you intend on changing things to be closer to what I want already. (By entering deep sleep at exit for example.)

@tannewt
Copy link
Member

tannewt commented Sep 28, 2020

FYI, I'll make changes to the Python side of this in the next few days.

@microdev1
Copy link
Collaborator Author

@tannewt I was considering the following to be the final form of the api.

import alarm
import alarm_io
import alarm_time
import alarm_touch

alarm_io.enable(board.IO6, level=1, pull=True)
alarm_time.enable(2.5)
alarm_touch.enable(board.IO8)

alarm.disable             //Disable all alarms
alarm_io.disable          //Disable all io alarms, similar for time & touch alarm.

//Go to light/deep sleep on code.py exit based on usb connection check.        
  • In alarm_io a new call with same pin will override the previous parameters.
  • Similarly in alarm_touch a new call will override the previous duration.
  • Still need to figure out in what form to get the wakeup alarm so that it can be compared with other alarms.

@tannewt
Copy link
Member

tannewt commented Oct 1, 2020

I'd prefer each alarm type to be it's own object rather than just enable. There is no need to disable because alarms should be reset after one of them wakes up the cpu. (The code.py will reset it if desired.)

I likely won't have time until next week to help with this. #2796 is really what I'd like to see.

@microdev1
Copy link
Collaborator Author

microdev1 commented Oct 1, 2020

  • alarm.disable is there just to demonstrate the function call.
  • With enable I am aiming for a more generalized approach.

@microdev1
Copy link
Collaborator Author

I would like to point anyone looking for updates regarding deep sleep api to issue #2796, where the api is being actively discussed

@dhalbert
Copy link
Collaborator

@microdev1 I will close this in favor of the PR I will be submitting, if that's OK with you.

@dhalbert dhalbert closed this Nov 18, 2020
@microdev1
Copy link
Collaborator Author

@dhalbert As discussed earlier on discord, there is still some work left to be done on the alarm modules... I have already got changes on my local branch. I am waiting for the api changes before pushing them.

@dhalbert
Copy link
Collaborator

dhalbert commented Nov 19, 2020

@microdev1 It went out of my head that you were still working on these. I am working in https://github.com/dhalbert/circuitpython/tree/sleep, but it does not even compile yet and has rough edges. I push regularly for backup purposes and just merged from upstream.

The API implied in the #2796 is still a moving target, and my branch is the latest, though the API hasn't been re-reviewed completely by @tannewt yet.

I am very focused at first on the narrow path of getting DurationAlarm to work, because that opens up many MagTag projects to practicality. I will probably prepare a WIP PR when that works.

@microdev1 microdev1 deleted the sleepCPY branch September 3, 2022 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
advanced api enhancement espressif applies to multiple Espressif chips power
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants