Skip to content

Commit

Permalink
Merge pull request #47 from makermelissa/master
Browse files Browse the repository at this point in the history
Increase read delay to fix occasional bad reads
  • Loading branch information
makermelissa authored Feb 13, 2020
2 parents dc01285 + 5f9a2b1 commit 617151c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions adafruit_seesaw/seesaw.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,18 +204,18 @@ def digital_read(self, pin):
return self.digital_read_bulk_b((1 << (pin - 32))) != 0
return self.digital_read_bulk((1 << pin)) != 0

def digital_read_bulk(self, pins):
def digital_read_bulk(self, pins, delay=0.008):
"""Get the values of all the pins on the 'A' port as a bitmask"""
buf = bytearray(4)
self.read(_GPIO_BASE, _GPIO_BULK, buf)
self.read(_GPIO_BASE, _GPIO_BULK, buf, delay=delay)
buf[0] = buf[0] & 0x3F
ret = struct.unpack(">I", buf)[0]
return ret & pins

def digital_read_bulk_b(self, pins):
def digital_read_bulk_b(self, pins, delay=0.008):
"""Get the values of all the pins on the 'B' port as a bitmask"""
buf = bytearray(8)
self.read(_GPIO_BASE, _GPIO_BULK, buf)
self.read(_GPIO_BASE, _GPIO_BULK, buf, delay=delay)
ret = struct.unpack(">I", buf[4:])[0]
return ret & pins

Expand Down Expand Up @@ -405,7 +405,7 @@ def read8(self, reg_base, reg):
self.read(reg_base, reg, ret)
return ret[0]

def read(self, reg_base, reg, buf, delay=.005):
def read(self, reg_base, reg, buf, delay=.008):
"""Read an arbitrary I2C register range on the device"""
self.write(reg_base, reg)
if self._drdy is not None:
Expand Down

0 comments on commit 617151c

Please sign in to comment.