]> Repositories - hackapet/Adafruit_Blinka_Displayio.git/commitdiff
Add root_group property to display
authorMelissa LeBlanc-Williams <melissa@adafruit.com>
Mon, 2 Oct 2023 20:05:55 +0000 (13:05 -0700)
committerMelissa LeBlanc-Williams <melissa@adafruit.com>
Mon, 2 Oct 2023 20:05:55 +0000 (13:05 -0700)
displayio/_display.py
displayio/_epaperdisplay.py

index ba6ea9e4baf8590870e59eb16643ac1f9c807feb..a3da5c5a031a83729806dc7f3a0f6365e9d4d0a4 100644 (file)
@@ -243,8 +243,14 @@ class Display:
         self._core.send(DISPLAY_DATA, CHIP_SELECT_UNTOUCHED, pixels)
 
     def show(self, group: Group) -> None:
         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.
         default CircuitPython terminal will be shown.
+
+        :param Group group: The group to show.
         """
         if group is None:
             group = circuitpython_splash
         """
         if group is None:
             group = circuitpython_splash
@@ -525,3 +531,15 @@ class Display:
     def bus(self) -> _DisplayBus:
         """Current Display Bus"""
         return self._core.get_bus()
     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)
index 59ed690e191099ee903e33a78761f6bd591e3ff3..6ea80f70fc8353ff0c1a48b3cfdee9b3bcf0abd2 100644 (file)
@@ -248,13 +248,22 @@ class EPaperDisplay:
 
     def show(self, group: Group) -> None:
         # pylint: disable=unnecessary-pass
 
     def show(self, group: Group) -> None:
         # pylint: disable=unnecessary-pass
-        """Switches to displaying the given group of layers. When group is None, the default
+        """
+        .. 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 (eventually).
         """
         if group is None:
             group = circuitpython_splash
         self._core.set_root_group(group)
 
         CircuitPython terminal will be shown (eventually).
         """
         if group is None:
             group = circuitpython_splash
         self._core.set_root_group(group)
 
+    def _set_root_group(self, root_group: Group) -> None:
+        ok = self._core.set_root_group(root_group)
+        if not ok:
+            raise ValueError("Group already used")
+
     def update_refresh_mode(
         self, start_sequence: ReadableBuffer, seconds_per_frame: float
     ) -> None:
     def update_refresh_mode(
         self, start_sequence: ReadableBuffer, seconds_per_frame: float
     ) -> None:
@@ -592,8 +601,8 @@ class EPaperDisplay:
         """The root group on the epaper display.
         If the root group is set to ``None``, no output will be shown.
         """
         """The root group on the epaper display.
         If the root group is set to ``None``, no output will be shown.
         """
-        return self._core.root_group
+        return self._core.current_group
 
     @root_group.setter
     def root_group(self, new_group: Group) -> None:
 
     @root_group.setter
     def root_group(self, new_group: Group) -> None:
-        self._core.root_group = new_group
+        self._set_root_group(new_group)