Skip to content
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

Add explicit pull choice for PinAlarm #9823

Open
dhalbert opened this issue Nov 22, 2024 · 0 comments
Open

Add explicit pull choice for PinAlarm #9823

dhalbert opened this issue Nov 22, 2024 · 0 comments

Comments

@dhalbert
Copy link
Collaborator

See https://forums.adafruit.com/viewtopic.php?t=215000 for motivation.

Currently, if pull=True when creating a PinAlarm, the pull chosen is the opposite from the value argument. From the doc:

pull (bool) – Enable a pull-up or pull-down which pulls the pin to the level opposite that of value. For instance, if value is set to True, setting pull to True will enable a pull-down, to hold the pin low normally until an outside signal pulls it high.

A user is using a normally-closed switch, connected to a PinAlarm pin. (In this case, the switch is closed when a box lid is closed.) The switch is attached to ground at the far end. So, in the sleeping case (lid closed, switch closed) the alarm pin would be low. When the switch opens, the user wants a wake-up.

I didn't consider normally-closed switches when designing the API. If I had, I might have made pull take either None or digitalio.Pull.UP or digitalio.Pull.DOWN. However, an upward-compatible addition to the API would be:

  • If pull is False or None (None would be a new allowed arg), do not enable a pull.
  • if pull is True, enable a pull opposite to value, as is currently done.
  • If pull is a digitalio.Pull, enable that specific pull.

(The same thing might be done with keypad, but we haven't had a call for that yet, and that complicates thinking about "pressed" and "released". So I'm not going there for keypad.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant