X-Git-Url: https://git.ayoreis.com/hackapet/Adafruit_Blinka_Displayio.git/blobdiff_plain/11e8cc62b210c761fd42e6cca723835654811776..b6c1453b93053cbf2fb6aae6f09fdb8f9b9e4345:/displayio/_i2cdisplay.py diff --git a/displayio/_i2cdisplay.py b/displayio/_i2cdisplay.py index 7ec9467..9611fb0 100644 --- a/displayio/_i2cdisplay.py +++ b/displayio/_i2cdisplay.py @@ -80,10 +80,6 @@ class I2CDisplay: time.sleep(0.0001) self._reset.value = True - def _begin_transaction(self) -> bool: - """Lock the bus before sending data.""" - return self._i2c.try_lock() - def send(self, command: int, data: ReadableBuffer) -> None: """ Sends the given command value followed by the full set of data. Display state, @@ -129,6 +125,17 @@ class I2CDisplay: ) from error raise error + def _free(self) -> bool: + """Attempt to free the bus and return False if busy""" + if not self._i2c.try_lock(): + return False + self._i2c.unlock() + return True + + def _begin_transaction(self) -> bool: + """Lock the bus before sending data.""" + return self._i2c.try_lock() + def _end_transaction(self) -> None: """Release the bus after sending data.""" self._i2c.unlock()