]> Repositories - hackapet/Adafruit_Blinka_Displayio.git/blobdiff - displayio/_display.py
Bug fixes
[hackapet/Adafruit_Blinka_Displayio.git] / displayio / _display.py
index d8b49c7031cd3e6492dc1474c0f8a5f8ef310255..9e720541fb9787093b56bf0a024e6655ccec7bb1 100644 (file)
@@ -212,7 +212,7 @@ class Display:
                 # 100Hz looks decent and doesn't keep the CPU too busy
                 self._backlight = PWMOut(backlight_pin, frequency=100, duty_cycle=0)
                 self._backlight_type = BACKLIGHT_PWM
-            except ImportError:
+            except (ImportError, NotImplementedError):
                 # PWMOut not implemented on this platform
                 pass
             if self._backlight_type is None:
@@ -243,8 +243,14 @@ class Display:
         self._core.send(DISPLAY_DATA, CHIP_SELECT_UNTOUCHED, pixels)
 
     def show(self, group: Group) -> None:
-        """Switches to displaying the given group of layers. When group is None, the
+        """
+        .. note:: `show()` is deprecated and will be removed when CircuitPython 9.0.0
+          is released. Use ``.root_group = group`` instead.
+
+        Switches to displaying the given group of layers. When group is None, the
         default CircuitPython terminal will be shown.
+
+        :param Group group: The group to show.
         """
         if group is None:
             group = circuitpython_splash
@@ -401,7 +407,7 @@ class Display:
                 )
 
             buffer = memoryview(bytearray([0] * (buffer_size * 4))).cast("I")
-            mask = memoryview(bytearray([0] * mask_length)).cast("I")
+            mask = memoryview(bytearray([0] * (mask_length * 4))).cast("I")
             self._core.fill_area(subrectangle, mask, buffer)
 
             # Can't acquire display bus; skip the rest of the data.
@@ -525,3 +531,17 @@ class Display:
     def bus(self) -> _DisplayBus:
         """Current Display Bus"""
         return self._core.get_bus()
+
+    @property
+    def root_group(self) -> Group:
+        """
+        The root group on the display.
+        If the root group is set to `displayio.CIRCUITPYTHON_TERMINAL`, the default
+        CircuitPython terminal will be shown.
+        If the root group is set to ``None``, no output will be shown.
+        """
+        return self._core.current_group
+
+    @root_group.setter
+    def root_group(self, new_group: Group) -> None:
+        self._set_root_group(new_group)