Skip to content

Commit 8a662c5

Browse files
mrmcwethytannewt
authored andcommitted
Added readinto() method to be more consistant with busdevice.spi. (#10)
Added warning on read_into() saying it will be deprecated in the future
1 parent 39f28ed commit 8a662c5

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

adafruit_bus_device/i2c_device.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class I2CDevice:
4343
device = I2CDevice(i2c, 0x70)
4444
bytes_read = bytearray(4)
4545
with device:
46-
device.read_into(bytes_read)
46+
device.readinto(bytes_read)
4747
# A second transaction
4848
with device:
4949
device.write(bytes_read)
@@ -62,7 +62,7 @@ def __init__(self, i2c, device_address):
6262
self.i2c = i2c
6363
self.device_address = device_address
6464

65-
def read_into(self, buf, **kwargs):
65+
def readinto(self, buf, **kwargs):
6666
"""
6767
Read into ``buf`` from the device. The number of bytes read will be the
6868
length of ``buf``.
@@ -77,6 +77,14 @@ def read_into(self, buf, **kwargs):
7777
"""
7878
self.i2c.readfrom_into(self.device_address, buf, **kwargs)
7979

80+
def read_into(self, buf, **kwargs):
81+
"""
82+
.. warning:: This method will be deprecated at some time in the future.
83+
Please use `readinto`() instead. `readinto`() is functionally
84+
equivalent to read_into(), same parameters and same actions.
85+
"""
86+
self.i2c.readfrom_into(self.device_address, buf, **kwargs)
87+
8088
def write(self, buf, **kwargs):
8189
"""
8290
Write the bytes from ``buffer`` to the device. Transmits a stop bit if

0 commit comments

Comments
 (0)