Skip to content

Added readinto() method to be more consistant with busdevice.spi. #10

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

Merged
merged 2 commits into from
Nov 5, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions adafruit_bus_device/i2c_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class I2CDevice:
device = I2CDevice(i2c, 0x70)
bytes_read = bytearray(4)
with device:
device.read_into(bytes_read)
device.readinto(bytes_read)
# A second transaction
with device:
device.write(bytes_read)
Expand All @@ -62,7 +62,7 @@ def __init__(self, i2c, device_address):
self.i2c = i2c
self.device_address = device_address

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

def read_into(self, buf, **kwargs):
"""
Warning: This method will be deprecated some time in the future.
Please start using readinto() instead. readinto() is functionally
Copy link
Member

Choose a reason for hiding this comment

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

Please use backticks around readinto so that sphinx makes it clickable. You can also use .. warning:: to make it called out in a box. http://www.sphinx-doc.org/en/stable/rest.html#directives

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed

equivalent to read_into(), same parameters and same actions.
"""
self.i2c.readfrom_into(self.device_address, buf, **kwargs)

def write(self, buf, **kwargs):
"""
Write the bytes from ``buffer`` to the device. Transmits a stop bit if
Expand Down