From: Melissa LeBlanc-Williams Date: Thu, 28 Sep 2023 20:59:54 +0000 (-0700) Subject: Add some missing checks to display X-Git-Tag: 1.0.0^2~7 X-Git-Url: https://git.ayoreis.com/hackapet/Adafruit_Blinka_Displayio.git/commitdiff_plain/3ace921d8f91d4d3b83fe6ae27a41beadc25fd46 Add some missing checks to display --- diff --git a/displayio/_display.py b/displayio/_display.py index 7bfe532..2a6ea7b 100644 --- a/displayio/_display.py +++ b/displayio/_display.py @@ -82,7 +82,7 @@ class Display: 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`). @@ -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. """ + + 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 @@ -498,6 +505,8 @@ class Display: @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