From: Cefn Hoile Date: Tue, 20 Feb 2018 17:57:16 +0000 (+0000) Subject: Workaround for (bug in?) Micropython import logic. Frequency a keyword not positional... X-Git-Tag: 0.1.0~4^2~56 X-Git-Url: https://git.ayoreis.com/Adafruit_Blinka-hackapet.git/commitdiff_plain/c094be01bd8a4ff7288a426a0d26e9f7fbb76bf2 Workaround for (bug in?) Micropython import logic. Frequency a keyword not positional arg. Stop a positional arg not a keyword arg. --- diff --git a/python/bitbangio/__init__.py b/python/bitbangio/__init__.py index 3634f44..31350bf 100644 --- a/python/bitbangio/__init__.py +++ b/python/bitbangio/__init__.py @@ -1,13 +1,15 @@ -from machine import Pin, I2C as _I2C +from machine import I2C as _I2C +from machine import Pin class I2C: def __init__(self, scl, sda, frequency=400000): + self._locked = False self.init(scl, sda, frequency) def init(self, scl, sda, frequency): self.deinit() id = -1 # force bitbanging implementation - in future introspect platform if SDA/SCL matches hardware I2C - self._i2c = _I2C(id, Pin(scl.id), Pin(sda.id), frequency) + self._i2c = _I2C(id, Pin(scl.id), Pin(sda.id), freq=frequency) def deinit(self): try: @@ -42,9 +44,10 @@ class I2C: if end is None: end = len(buffer) buffer = memoryview(buffer)[start:end] - return self._i2c.readfrom_into(address, buffer, stop=False) + stop = True # remove for efficiency later + return self._i2c.readfrom_into(address, buffer, stop) - def writeto(self, address, buffer, start=0, end=None, stop=True): + def writeto(self, address, buffer, start=0, end=None, stop=True, *a, **k): if start is not 0 or end is not None: if end is None: end = len(buffer)