]> Repositories - hackapet/Adafruit_Blinka_Displayio.git/blobdiff - displayio/_i2cdisplay.py
Speed improvements by making larger buffer
[hackapet/Adafruit_Blinka_Displayio.git] / displayio / _i2cdisplay.py
index b5de381edced2f74620a106204a2ffa6352bdfd8..e37eb8a659be5b584b28e71777f7b7131b571426 100644 (file)
@@ -23,7 +23,7 @@ displayio for Blinka
 import time
 import busio
 import digitalio
 import time
 import busio
 import digitalio
-import circuitpython_typing
+from circuitpython_typing import ReadableBuffer
 from ._constants import CHIP_SELECT_UNTOUCHED, DISPLAY_COMMAND
 
 __version__ = "0.0.0+auto.0"
 from ._constants import CHIP_SELECT_UNTOUCHED, DISPLAY_COMMAND
 
 __version__ = "0.0.0+auto.0"
@@ -58,8 +58,9 @@ class I2CDisplay:
             allocate_display_bus,
         )
 
             allocate_display_bus,
         )
 
-        allocate_display_bus(cls)
-        return super().__new__(cls)
+        display_bus_instance = super().__new__(cls)
+        allocate_display_bus(display_bus_instance)
+        return display_bus_instance
 
     def _release(self):
         self.reset()
 
     def _release(self):
         self.reset()
@@ -84,7 +85,7 @@ class I2CDisplay:
         while not self._i2c.try_lock():
             pass
 
         while not self._i2c.try_lock():
             pass
 
-    def send(self, command: int, data: circuitpython_typing.ReadableBuffer) -> None:
+    def send(self, command: int, data: ReadableBuffer) -> None:
         """
         Sends the given command value followed by the full set of data. Display state,
         such as vertical scroll, set via ``send`` may or may not be reset once the code is
         """
         Sends the given command value followed by the full set of data. Display state,
         such as vertical scroll, set via ``send`` may or may not be reset once the code is
@@ -98,7 +99,7 @@ class I2CDisplay:
         self,
         data_type: int,
         _chip_select: int,  # Chip select behavior
         self,
         data_type: int,
         _chip_select: int,  # Chip select behavior
-        data: circuitpython_typing.ReadableBuffer,
+        data: ReadableBuffer,
     ):
         if data_type == DISPLAY_COMMAND:
             n = len(data)
     ):
         if data_type == DISPLAY_COMMAND:
             n = len(data)