]> Repositories - hackapet/Adafruit_Blinka_Displayio.git/blobdiff - displayio/_displaycore.py
Bug fixes for SSD1306
[hackapet/Adafruit_Blinka_Displayio.git] / displayio / _displaycore.py
index 3126b8732da7df9a27a42ed36371513ad5ed7266..42218ec7baa5bb9d32b9251038fdcf442ca43a71 100644 (file)
@@ -24,7 +24,7 @@ __repo__ = "https://github.com/adafruit/Adafruit_Blinka_Displayio.git"
 
 import time
 import struct
-import circuitpython_typing
+from circuitpython_typing import WriteableBuffer, ReadableBuffer
 from paralleldisplay import ParallelBus
 from ._fourwire import FourWire
 from ._group import Group
@@ -178,25 +178,14 @@ class _DisplayCore:
         if self.current_group is not None:
             self.current_group._update_transform(self.transform)
 
-    def show(self, root_group: Group) -> bool:
-        # pylint: disable=protected-access
-
+    def set_root_group(self, root_group: Group) -> bool:
         """
         Switches to displaying the given group of layers. When group is `None`, the
         default CircuitPython terminal will be shown.
 
         :param Optional[displayio.Group] root_group: The group to show.
         """
-
-        """
-        # TODO: Implement Supervisor
-        if root_group is None:
-            circuitpython_splash = _Supervisor().circuitpython_splash
-            if not circuitpython_splash._in_group:
-                root_group = circuitpython_splash
-            elif self.current_group == circuitpython_splash:
-                return True
-        """
+        # pylint: disable=protected-access
 
         if root_group == self.current_group:
             return True
@@ -248,8 +237,8 @@ class _DisplayCore:
     def fill_area(
         self,
         area: Area,
-        mask: circuitpython_typing.WriteableBuffer,
-        buffer: circuitpython_typing.WriteableBuffer,
+        mask: WriteableBuffer,
+        buffer: WriteableBuffer,
     ) -> bool:
         """Call the current group's fill area function"""
         if self.current_group is not None:
@@ -258,21 +247,6 @@ class _DisplayCore:
             )
         return False
 
-    """
-    def _clip(self, rectangle):
-        if self._core.rotation in (90, 270):
-            width, height = self._core.height, self._core.width
-        else:
-            width, height = self._core.width, self._core.height
-
-        rectangle.x1 = max(rectangle.x1, 0)
-        rectangle.y1 = max(rectangle.y1, 0)
-        rectangle.x2 = min(rectangle.x2, width)
-        rectangle.y2 = min(rectangle.y2, height)
-
-        return rectangle
-    """
-
     def clip_area(self, area: Area, clipped: Area) -> bool:
         """Shrink the area to the region shared by the two areas"""
 
@@ -280,7 +254,8 @@ class _DisplayCore:
         if not overlaps:
             return False
 
-        # Expand the area if we have multiple pixels per byte and we need to byte align the bounds
+        # Expand the area if we have multiple pixels per byte and we need to byte
+        # align the bounds
         if self.colorspace.depth < 8:
             pixels_per_byte = (
                 8 // self.colorspace.depth * self.colorspace.bytes_per_cell
@@ -308,11 +283,11 @@ class _DisplayCore:
         if self.colorspace.depth < 8:
             pixels_per_byte = 8 // self.colorspace.depth
             if self.colorspace.pixels_in_byte_share_row:
-                region_x1 /= pixels_per_byte * self.colorspace.bytes_per_cell
-                region_x2 /= pixels_per_byte * self.colorspace.bytes_per_cell
+                region_x1 //= pixels_per_byte * self.colorspace.bytes_per_cell
+                region_x2 //= pixels_per_byte * self.colorspace.bytes_per_cell
             else:
-                region_y1 /= pixels_per_byte * self.colorspace.bytes_per_cell
-                region_y2 /= pixels_per_byte * self.colorspace.bytes_per_cell
+                region_y1 //= pixels_per_byte * self.colorspace.bytes_per_cell
+                region_y2 //= pixels_per_byte * self.colorspace.bytes_per_cell
 
         region_x2 -= 1
         region_y2 -= 1
@@ -330,12 +305,6 @@ class _DisplayCore:
             )
         else:
             data_type = DISPLAY_COMMAND
-            """
-            self._core.send(
-                DISPLAY_COMMAND, CHIP_SELECT_TOGGLE_EVERY_BYTE, bytes([command]) + data
-            )
-            self._core.send(DISPLAY_DATA, CHIP_SELECT_UNTOUCHED, data)
-            """
 
         if self.ram_width < 0x100:  # Single Byte Bounds
             data = struct.pack(">BB", region_x1, region_x2)
@@ -421,7 +390,7 @@ class _DisplayCore:
         self,
         data_type: int,
         chip_select: int,
-        data: circuitpython_typing.ReadableBuffer,
+        data: ReadableBuffer,
     ) -> None:
         """
         Send the data to the current bus