Skip to content

Commit

Permalink
Update doc/getting-started-with-i2c.md
Browse files Browse the repository at this point in the history
It seems like the write_bytes and read methods were renamed (which doesn't make much sense, but hey)

>>> dir(quick2wire.i2c)
[<snip> 'reading', 'reading_into', 'sizeof', 'string_at', 'writing', 'writing_bytes']
  • Loading branch information
omerk committed Aug 1, 2012
1 parent 482a9a1 commit 30abe4a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions doc/getting-started-with-i2c.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,16 @@ single write operation that writes two bytes: the register to
write to and the value of the register.

bus.transaction(
i2c.write_bytes(address, iodir_register, 0xFF))
i2c.writing_bytes(address, iodir_register, 0xFF))

Then we'll read the value of the chip's GPIO register by performing a
transaction containing two operations: a write operation that tells
the chip which register we want to read, and a read operation that
reads a single byte from that register.

read_results = bus.transaction(
i2c.write_bytes(address, gpio_register),
i2c.read(address, 1))
i2c.writing_bytes(address, gpio_register),
i2c.reading(address, 1))

The I2CMaster' transaction method returns a list of byte sequences, one
for each read operation performed. Each result is an array of bytes
Expand All @@ -110,11 +110,11 @@ Putting it all together:

with i2c.I2CMaster() as bus:
bus.transaction(
i2c.write_bytes(address, iodir_register, 0xFF))
i2c.writing_bytes(address, iodir_register, 0xFF))
read_results = bus.transaction(
i2c.write_bytes(address, gpio_register),
i2c.read(address, 1))
i2c.writing_bytes(address, gpio_register),
i2c.reading(address, 1))
gpio_state = read_results[0][0]
Expand Down

0 comments on commit 30abe4a

Please sign in to comment.