+
+ # Go through groups and and add each to buffer
+ #for group in self._groups:
+
+
+ # Eventually calculate dirty rectangles here
+ self._subrectangles.append(Rectangle(0, 0, self._width, self._height))
+
+ for area in self._subrectangles:
+ self._refresh_display_area(area)
+
+ if self._auto_refresh:
+ self.refresh()
+
+ def _refresh_display_area(self, rectangle):
+ """Loop through dirty rectangles and redraw that area."""
+ """Read or write a block of data."""
+ data = numpy.array(self._buffer.crop(rectangle).convert("RGB")).astype("uint16")
+ color = (
+ ((data[:, :, 0] & 0xF8) << 8)
+ | ((data[:, :, 1] & 0xFC) << 3)
+ | (data[:, :, 2] >> 3)
+ )
+
+ pixels = list(numpy.dstack(((color >> 8) & 0xFF, color & 0xFF)).flatten().tolist())
+
+ self._write(
+ self._set_column_command,
+ self._encode_pos(rectangle.x1 + self._colstart, rectangle.x2 + self._colstart)
+ )
+ self._write(
+ self._set_row_command,
+ self._encode_pos(rectangle.y1 + self._rowstart, rectangle.y2 + self._rowstart)
+ )
+ self._write(self._write_ram_command, pixels)
+
+ def _encode_pos(self, x, y):
+ """Encode a postion into bytes."""
+ return struct.pack(self._bounds_encoding, x, y)