-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
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, ifvalueis set toTrue, settingpulltoTruewill 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
pullisFalseorNone(Nonewould be a new allowed arg), do not enable a pull. - if
pullisTrue, enable apullopposite tovalue, as is currently done. - If
pullis adigitalio.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.)