]> Repositories - hackapet/Adafruit_Blinka_Displayio.git/blobdiff - displayio/_i2cdisplay.py
Remove debug code + add bus free
[hackapet/Adafruit_Blinka_Displayio.git] / displayio / _i2cdisplay.py
index 7ec9467e8479865f2af63e4ab9c9fc60c1389369..9611fb09187a687351c308a3cbb07097997b8eca 100644 (file)
@@ -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()