]> Repositories - hackapet/Adafruit_Blinka_Displayio.git/blobdiff - displayio/_epaperdisplay.py
add missing return value in _begin_transaction
[hackapet/Adafruit_Blinka_Displayio.git] / displayio / _epaperdisplay.py
index 1f0731c26633e4e84bd5645b83767326cf8382fe..6ce0664be468bd123db42251e7a76fcf23f52f69 100644 (file)
@@ -248,13 +248,22 @@ class EPaperDisplay:
 
     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)
 
+    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:
@@ -298,6 +307,7 @@ class EPaperDisplay:
             self._finish_refresh()
             while self._refreshing:
                 # TODO: Add something here that can change self._refreshing
+                # or add something in _background()
                 pass
 
         self._start_refresh()
@@ -371,10 +381,6 @@ class EPaperDisplay:
         # If there is no overlap then we're done.
         if not self._core.clip_area(area, clipped):
             return True
-        print("---------------")
-        print(area.x1, area.y1, area.x2, area.y2)
-        print(clipped.x1, clipped.y1, clipped.x2, clipped.y2)
-        print("---------------")
         subrectangles = 1
         rows_per_buffer = clipped.height()
         pixels_per_word = 32 // self._core.colorspace.depth
@@ -450,7 +456,7 @@ class EPaperDisplay:
                 if (pass_index == 1 and self._color_bits_inverted) or (
                     pass_index == 0 and self._black_bits_inverted
                 ):
-                    for i, _ in enumerate(buffer):
+                    for i in range(buffer_size):
                         buffer[i] = ~buffer[i]
 
                 if not self._core.begin_transaction():
@@ -595,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.
         """
-        return self._core.root_group
+        return self._core.current_group
 
     @root_group.setter
     def root_group(self, new_group: Group) -> None:
-        self._core.root_group = new_group
+        self._set_root_group(new_group)