]> Repositories - hackapet/Adafruit_Blinka_Displayio.git/blobdiff - displayio/_display.py
Make some internal functions protected
[hackapet/Adafruit_Blinka_Displayio.git] / displayio / _display.py
index 7bfe532b4d0f2c6b55ab26b40f1baeca937da762..f2d02cfd4cadf90746aca796def6be7f44bba76d 100644 (file)
@@ -82,7 +82,7 @@ class Display:
         backlight_on_high: bool = True,
         SH1107_addressing: bool = False,
     ):
         backlight_on_high: bool = True,
         SH1107_addressing: bool = False,
     ):
-        # pylint: disable=too-many-locals,invalid-name
+        # pylint: disable=too-many-locals,invalid-name, too-many-branches
         """Create a Display object on the given display bus (`displayio.FourWire` or
         `paralleldisplay.ParallelBus`).
 
         """Create a Display object on the given display bus (`displayio.FourWire` or
         `paralleldisplay.ParallelBus`).
 
@@ -112,6 +112,13 @@ class Display:
         The initialization sequence should always leave the display memory access inline with
         the scan of the display to minimize tearing artifacts.
         """
         The initialization sequence should always leave the display memory access inline with
         the scan of the display to minimize tearing artifacts.
         """
+
+        if rotation % 90 != 0:
+            raise ValueError("Display rotation must be in 90 degree increments")
+
+        if SH1107_addressing and color_depth != 1:
+            raise ValueError("color_depth must be 1 when SH1107_addressing is True")
+
         # Turn off auto-refresh as we init
         self._auto_refresh = False
         ram_width = 0x100
         # Turn off auto-refresh as we init
         self._auto_refresh = False
         ram_width = 0x100
@@ -320,7 +327,7 @@ class Display:
             )
         return areas
 
             )
         return areas
 
-    def background(self):
+    def _background(self):
         """Run background refresh tasks. Do not call directly"""
         if (
             self._auto_refresh
         """Run background refresh tasks. Do not call directly"""
         if (
             self._auto_refresh
@@ -420,12 +427,12 @@ class Display:
         self._core.fill_area(area, mask, buffer)
         return buffer
 
         self._core.fill_area(area, mask, buffer)
         return buffer
 
-    def release(self) -> None:
+    def _release(self) -> None:
         """Release the display and free its resources"""
         self.auto_refresh = False
         self._core.release_display_core()
 
         """Release the display and free its resources"""
         self.auto_refresh = False
         self._core.release_display_core()
 
-    def reset(self) -> None:
+    def _reset(self) -> None:
         """Reset the display"""
         self.auto_refresh = True
         circuitpython_splash.x = 0
         """Reset the display"""
         self.auto_refresh = True
         circuitpython_splash.x = 0
@@ -498,6 +505,8 @@ class Display:
 
     @rotation.setter
     def rotation(self, value: int):
 
     @rotation.setter
     def rotation(self, value: int):
+        if value % 90 != 0:
+            raise ValueError("Display rotation must be in 90 degree increments")
         self._core.set_rotation(value)
 
     @property
         self._core.set_rotation(value)
 
     @property