Skip to content

Commit ecb4b4f

Browse files
authored
Merge pull request #16 from tannewt/remove_stop
Remove stop kwarg and use write_then_readinto.
2 parents 50b3978 + d14fc34 commit ecb4b4f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

adafruit_mcp230xx/mcp230xx.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ def _read_u16le(self, register):
5252
# register.
5353
with self._device as i2c:
5454
_BUFFER[0] = register & 0xFF
55-
i2c.write(_BUFFER, end=1, stop=False)
56-
i2c.readinto(_BUFFER, end=2)
57-
return (_BUFFER[1] << 8) | _BUFFER[0]
55+
56+
i2c.write_then_readinto(_BUFFER, _BUFFER, out_end=1, in_start=1, in_end=3)
57+
return (_BUFFER[2] << 8) | _BUFFER[1]
5858

5959
def _write_u16le(self, register, val):
6060
# Write an unsigned 16 bit little endian value to the specified 8-bit
@@ -69,9 +69,9 @@ def _read_u8(self, register):
6969
# Read an unsigned 8 bit value from the specified 8-bit register.
7070
with self._device as i2c:
7171
_BUFFER[0] = register & 0xFF
72-
i2c.write(_BUFFER, end=1, stop=False)
73-
i2c.readinto(_BUFFER, end=1)
74-
return _BUFFER[0]
72+
73+
i2c.write_then_readinto(_BUFFER, _BUFFER, out_end=1, in_start=1, in_end=2)
74+
return _BUFFER[1]
7575

7676
def _write_u8(self, register, val):
7777
# Write an 8 bit value to the specified 8-bit register.

0 commit comments

Comments
 (0)