Skip to content

Commit

Permalink
Fix for new I2CDevice API.
Browse files Browse the repository at this point in the history
  • Loading branch information
tannewt committed Apr 11, 2017
1 parent 2ed8676 commit 0b18ae6
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -119,19 +119,19 @@ we must implement ``__get__`` and ``__set__``.
def __get__(self, obj, objtype=None):
with obj.i2c_device:
obj.i2c_device.writeto(self.buffer, end=1, stop=False)
obj.i2c_device.write(self.buffer, end=1, stop=False)
obj.i2c_device.read_into(self.buffer, start=1)
return bool(self.buffer[1] & self.bit_mask)
def __set__(self, obj, value):
with obj.i2c_device:
obj.i2c_device.writeto(self.buffer, end=1, stop=False)
obj.i2c_device.write(self.buffer, end=1, stop=False)
obj.i2c_device.read_into(self.buffer, start=1)
if value:
self.buffer[1] |= self.bit_mask
else:
self.buffer[1] &= ~self.bit_mask
obj.i2c_device.writeto(self.buffer)
obj.i2c_device.write(self.buffer)
As you can see, we have two places to get state from. First, ``self`` stores the
register class members which locate the register within the device memory map.
Expand Down

0 comments on commit 0b18ae6

Please sign in to comment.