Skip to content

Commit 6dadb45

Browse files
authored
Ignore last 2 bits of digital input, only on boards without long ints
For compatibility on boards that don't support arbitrary integers. Bit 31 and 32 are scrubbed on these boards instead of throwing OverflowError, while builds with long ints retain this extra functionality.
1 parent 198f2aa commit 6dadb45

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

adafruit_seesaw/seesaw.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,11 @@ def digital_read_bulk(self, pins, delay=0.008):
214214
"""Get the values of all the pins on the 'A' port as a bitmask"""
215215
buf = bytearray(4)
216216
self.read(_GPIO_BASE, _GPIO_BULK, buf, delay=delay)
217-
ret = struct.unpack(">I", buf)[0]
217+
try:
218+
ret = struct.unpack(">I", buf)[0]
219+
except OverflowError:
220+
buf[0] = buf[0] & 0x3F
221+
ret = struct.unpack(">I", buf)[0]
218222
return ret & pins
219223

220224
def digital_read_bulk_b(self, pins, delay=0.008):

0 commit comments

Comments
 (0)