circuitpython/shared-bindings
Jeff Epler a9425cd928 digitalio: Improve DigitalInOut constructor, add finaliser
Now it's possible to construct outputs or enable pulls immediately:

```py
>>> d = digitalio.DigitalInOut(board.A0, pull=digitalio.Pull.UP)
>>> d.pull
digitalio.Pull.UP
```

```py
>>> d = digitalio.DigitalInOut(board.A0, value=True)
>>> d.direction
digitalio.Direction.OUTPUT
>>> d.value
True
```

```py
>>> d = digitalio.DigitalInOut(board.A0, value=False, drive_mode=digitalio.DriveMode.OPEN_DRAIN)
>>> d.drive_mode
digitalio.DriveMode.OPEN_DRAIN
```

The finaliser means that if a pin object is allowed to go out of scope,
then it will be deinitialized automatically when GC runs. **this is a
potential incompatibility**: some hypothetical code that intentionally
leaked a pin might function differently, i.e.
```py
digitalio.DigitalInOut(board.A0).switch_to_output(True)
```
as a way to stick a pin in output mode indefinitely will no longer work
(but may still appear to work "for awhile" because gc doesn't run right
away).

I made this change in part because it simplifies error handling in the
constructor: An incorrect argument would otherwise have left the pin
stuck in allocated state until the interpreter was reset; with this
change, it's available again though not until the GC runs so it would
remain perplexing in interactive situations:
```py
>>> d = digitalio.DigitalInOut(board.A0, pull=7)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: pull must be of type Pull or None, not int
>>> d = digitalio.DigitalInOut(board.A0)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: A0 in use
>>> gc.collect()
>>> d = digitalio.DigitalInOut(board.A0)
>>> d
<DigitalInOut>
```
2024-11-07 10:24:18 -06:00
..
__future__ clean up some include files 2024-07-26 18:38:13 -04:00
_bleio document different kinds of _bleio 2024-10-24 16:02:24 -04:00
_eve Correct method name in docstring 2024-09-06 12:59:40 -07:00
_pew CircuitPython files: replace STATIC with static 2024-05-20 11:02:17 -04:00
_pixelmap clean up some include files 2024-07-26 18:38:13 -04:00
_stage CircuitPython files: replace STATIC with static 2024-05-20 11:02:17 -04:00
adafruit_bus_device clean up some include files 2024-07-26 18:38:13 -04:00
adafruit_pixelbuf clean up some include files 2024-07-26 18:38:13 -04:00
aesio CircuitPython files: replace STATIC with static 2024-05-20 11:02:17 -04:00
alarm Avoid crashing when printing DeepSleepRequest objects 2024-10-07 08:43:42 -05:00
analogbufio working on compilation errors 2024-09-06 23:10:41 -04:00
analogio clean up some include files 2024-07-26 18:38:13 -04:00
atexit CircuitPython files: replace STATIC with static 2024-05-20 11:02:17 -04:00
audiobusio working on compilation errors 2024-09-06 23:10:41 -04:00
audiocore merge from main 2024-07-29 17:41:46 -04:00
audiodelays Added frequency shift on echo option from @dcooperdalrymple 2024-10-14 10:00:08 -05:00
audiofilters Add Optional to synthio.Biquad in documentation to allow for None value. 2024-10-22 21:41:37 -05:00
audioio working on compilation errors 2024-09-06 23:10:41 -04:00
audiomixer working on compilation errors 2024-09-06 23:10:41 -04:00
audiomp3 working on compilation errors 2024-09-06 23:10:41 -04:00
audiopwmio working on compilation errors 2024-09-06 23:10:41 -04:00
aurora_epaper change remaining STATIC to static 2024-09-03 17:40:07 -04:00
bitbangio espressif: get new I2C driver working 2024-09-20 17:48:17 -04:00
bitmapfilter fix some doc-comments 2024-08-23 23:00:56 +02:00
bitmaptools CircuitPython files: replace STATIC with static 2024-05-20 11:02:17 -04:00
bitops CircuitPython files: replace STATIC with static 2024-05-20 11:02:17 -04:00
board CircuitPython files: replace STATIC with static 2024-05-20 11:02:17 -04:00
busdisplay CircuitPython files: replace STATIC with static 2024-05-20 11:02:17 -04:00
busio add __del__() to busio.I2C, which now has a finaliser 2024-10-09 20:54:18 -04:00
camera CircuitPython files: replace STATIC with static 2024-05-20 11:02:17 -04:00
canio CircuitPython files: replace STATIC with static 2024-05-20 11:02:17 -04:00
codeop use types.CodeType, as per jepler finding 2024-08-25 14:28:39 +02:00
countio working on compilation errors 2024-09-06 23:10:41 -04:00
digitalio digitalio: Improve DigitalInOut constructor, add finaliser 2024-11-07 10:24:18 -06:00
displayio fix formatting 2024-10-04 11:14:46 +08:00
dotclockframebuffer fix some doc-comments 2024-08-23 23:00:56 +02:00
dualbank CircuitPython files: replace STATIC with static 2024-05-20 11:02:17 -04:00
epaperdisplay Make time_to_refresh return 0 correctly 2024-06-03 15:33:11 -07:00
floppyio fix doc markup problem 2024-09-24 12:11:15 -05:00
fontio clean up some include files 2024-07-26 18:38:13 -04:00
fourwire CircuitPython files: replace STATIC with static 2024-05-20 11:02:17 -04:00
framebufferio CircuitPython files: replace STATIC with static 2024-05-20 11:02:17 -04:00
frequencyio working on compilation errors 2024-09-06 23:10:41 -04:00
getpass CircuitPython files: replace STATIC with static 2024-05-20 11:02:17 -04:00
gifio CircuitPython files: replace STATIC with static 2024-05-20 11:02:17 -04:00
gnss change remaining STATIC to static 2024-09-03 17:40:07 -04:00
hashlib CircuitPython files: replace STATIC with static 2024-05-20 11:02:17 -04:00
i2cdisplaybus CircuitPython files: replace STATIC with static 2024-05-20 11:02:17 -04:00
i2ctarget CircuitPython files: replace STATIC with static 2024-05-20 11:02:17 -04:00
imagecapture CircuitPython files: replace STATIC with static 2024-05-20 11:02:17 -04:00
ipaddress CircuitPython files: replace STATIC with static 2024-05-20 11:02:17 -04:00
is31fl3741 CircuitPython files: replace STATIC with static 2024-05-20 11:02:17 -04:00
jpegio CircuitPython files: replace STATIC with static 2024-05-20 11:02:17 -04:00
keypad Merge pull request #9717 from aseanwatson/fix_issue9714 2024-10-17 10:25:11 -04:00
keypad_demux CircuitPython files: replace STATIC with static 2024-05-20 11:02:17 -04:00
locale CircuitPython files: replace STATIC with static 2024-05-20 11:02:17 -04:00
math implement math.dist 2024-08-11 09:45:33 -05:00
max3421e working on compilation errors 2024-09-06 23:10:41 -04:00
mdns working on compilation errors 2024-09-06 23:10:41 -04:00
memorymap fix a problem with the addressrange example 2024-09-17 13:40:36 -05:00
memorymonitor CircuitPython files: replace STATIC with static 2024-05-20 11:02:17 -04:00
microcontroller update docs 2024-06-26 13:35:05 +00:00
msgpack CircuitPython files: replace STATIC with static 2024-05-20 11:02:17 -04:00
neopixel_write CircuitPython files: replace STATIC with static 2024-05-20 11:02:17 -04:00
nvm clean up some include files 2024-07-26 18:38:13 -04:00
onewireio clean up some include files 2024-07-26 18:38:13 -04:00
os CircuitPython files: replace STATIC with static 2024-05-20 11:02:17 -04:00
paralleldisplaybus CircuitPython files: replace STATIC with static 2024-05-20 11:02:17 -04:00
ps2io clean up some include files 2024-07-26 18:38:13 -04:00
pulseio working on compilation errors 2024-09-06 23:10:41 -04:00
pwmio working on compilation errors 2024-09-06 23:10:41 -04:00
qrio CircuitPython files: replace STATIC with static 2024-05-20 11:02:17 -04:00
rainbowio address review comments 2024-08-21 16:50:19 -04:00
random CircuitPython files: replace STATIC with static 2024-05-20 11:02:17 -04:00
rgbmatrix CircuitPython files: replace STATIC with static 2024-05-20 11:02:17 -04:00
rotaryio merge from main 2024-09-10 16:36:32 -04:00
rtc CircuitPython files: replace STATIC with static 2024-05-20 11:02:17 -04:00
sdcardio CircuitPython files: replace STATIC with static 2024-05-20 11:02:17 -04:00
sdioio sdioio DOC update: DATA pins pass in Set 2024-07-08 16:43:55 -04:00
sharpdisplay CircuitPython files: replace STATIC with static 2024-05-20 11:02:17 -04:00
socketpool fix compilation issues; remove more uctypes mentions 2024-09-10 16:04:47 -04:00
ssl ensure variable is initialized 2024-06-13 11:41:24 -05:00
storage CircuitPython files: replace STATIC with static 2024-05-20 11:02:17 -04:00
struct CircuitPython files: replace STATIC with static 2024-05-20 11:02:17 -04:00
supervisor CircuitPython files: replace STATIC with static 2024-05-20 11:02:17 -04:00
synthio Update loop docstrings to demonstrate BlockInput implementation. 2024-11-04 11:25:51 -06:00
terminalio clean up some include files 2024-07-26 18:38:13 -04:00
time CircuitPython files: replace STATIC with static 2024-05-20 11:02:17 -04:00
touchio document RP2350-E9 limitations 2024-09-13 17:54:24 -04:00
traceback CircuitPython files: replace STATIC with static 2024-05-20 11:02:17 -04:00
uheap CircuitPython files: replace STATIC with static 2024-05-20 11:02:17 -04:00
usb fix some doc-comments 2024-08-23 23:00:56 +02:00
usb_cdc CircuitPython files: replace STATIC with static 2024-05-20 11:02:17 -04:00
usb_hid CircuitPython files: replace STATIC with static 2024-05-20 11:02:17 -04:00
usb_host CircuitPython files: replace STATIC with static 2024-05-20 11:02:17 -04:00
usb_midi CircuitPython files: replace STATIC with static 2024-05-20 11:02:17 -04:00
usb_video Update USBFramebuffer: __new__ -> __init__ 2024-08-27 23:11:13 +02:00
ustack CircuitPython files: replace STATIC with static 2024-05-20 11:02:17 -04:00
vectorio unix: enable vectorio in coverage build 2024-10-28 08:07:35 -05:00
warnings CircuitPython files: replace STATIC with static 2024-05-20 11:02:17 -04:00
watchdog CircuitPython files: replace STATIC with static 2024-05-20 11:02:17 -04:00
wifi shared-bindings/wifi/Radio.c: fix default values for start_dhcp_client args 2024-10-23 09:25:54 -04:00
zlib CircuitPython files: replace STATIC with static 2024-05-20 11:02:17 -04:00
help.rst update headers of most CircuitPython-only files 2024-05-17 14:56:28 -04:00
index.rst docs: Improve 5.0.x <-> main branch doc linkrot 2020-06-14 11:12:35 -05:00
support_matrix.rst Fix docs build by splitting out support matrix 2023-10-24 16:20:51 -07:00
util.c update headers of most CircuitPython-only files 2024-05-17 14:56:28 -04:00
util.h update headers of most CircuitPython-only files 2024-05-17 14:56:28 -04:00