Skip to content

update to use write_then_readinto for repeated start #3

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 1 commit into from
Aug 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 2 additions & 3 deletions adafruit_mma8451.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,8 @@ def _read_into(self, address, buf, count=None):
if count is None:
count = len(buf)
with self._device as i2c:
buf[0] = address & 0xFF
i2c.write(buf, end=1, stop=False)
i2c.readinto(buf, end=count)
i2c.write_then_readinto(bytes([address & 0xFF]), buf,
Copy link
Contributor

Choose a reason for hiding this comment

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

out_end=1 should be specified, I think.

Copy link
Member Author

Choose a reason for hiding this comment

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

we dont have to because i dont use 'buf' anymore, i just create and pass in a single-byte array. oddly when i used buf, it wasnt working. i just did this instead of in-depth investigation on why i couldnt use buf for both output and input

Copy link
Contributor

Choose a reason for hiding this comment

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

got it, i didn't read carefully enough

Copy link
Member Author

Choose a reason for hiding this comment

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

np its confusing, ive mixed both because you write first, then read. anyways...yay!

in_end=count, stop=False)

def _read_u8(self, address):
# Read an 8-bit unsigned value from the specified 8-bit address.
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Adafruit-Blinka
adafruit-circuitpython-busdevice
adafruit-circuitpython-busdevice>=2.2.5