From: Melissa LeBlanc-Williams Date: Sat, 30 Sep 2023 05:33:20 +0000 (-0700) Subject: Merge branch main X-Git-Tag: 1.1.0^2~5 X-Git-Url: https://git.ayoreis.com/hackapet/Adafruit_Blinka_Displayio.git/commitdiff_plain/62e0eafb17cffc425e519fd3389ef4ea699e0267?hp=-c Merge branch main --- 62e0eafb17cffc425e519fd3389ef4ea699e0267 diff --combined displayio/_display.py index d8b49c7,9572a81..ba6ea9e --- a/displayio/_display.py +++ b/displayio/_display.py @@@ -18,6 -18,7 +18,6 @@@ displayio for Blink """ import time -from array import array from typing import Optional import digitalio import microcontroller @@@ -377,15 -378,15 +377,15 @@@ class Display buffer_size = pixels_per_buffer // pixels_per_word if pixels_per_buffer % pixels_per_word: buffer_size += 1 - mask_length = (pixels_per_buffer // 8) + 1 # 1 bit per pixel + 1 + mask_length = (pixels_per_buffer // 32) + 1 # 1 bit per pixel + 1 remaining_rows = clipped.height() for subrect_index in range(subrectangles): subrectangle = Area( - clipped.x1, - clipped.y1 + rows_per_buffer * subrect_index, - clipped.x2, - clipped.y1 + rows_per_buffer * (subrect_index + 1), + x1=clipped.x1, + y1=clipped.y1 + rows_per_buffer * subrect_index, + x2=clipped.x2, + y2=clipped.y1 + rows_per_buffer * (subrect_index + 1), ) if remaining_rows < rows_per_buffer: subrectangle.y2 = subrectangle.y1 + remaining_rows @@@ -401,7 -402,7 +401,7 @@@ ) 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. @@@ -409,7 -410,7 +409,7 @@@ return False self._core.begin_transaction() - self._send_pixels(buffer[:subrectangle_size_bytes]) + self._send_pixels(buffer.tobytes()[:subrectangle_size_bytes]) self._core.end_transaction() return True @@@ -425,9 -426,9 +425,9 @@@ if pixels_per_buffer % pixels_per_word: buffer_size += 1 - buffer = bytearray([0] * (buffer_size * 4)) + buffer = memoryview(bytearray([0] * (buffer_size * 4))).cast("I") mask_length = (pixels_per_buffer // 32) + 1 - mask = array("L", [0x00000000] * mask_length) + mask = memoryview(bytearray([0] * (mask_length * 4))).cast("I") self._core.fill_area(area, mask, buffer) return buffer @@@ -511,15 -512,7 +511,15 @@@ def rotation(self, value: int): if value % 90 != 0: raise ValueError("Display rotation must be in 90 degree increments") + transposed = self._core.rotation in (90, 270) + will_transposed = value in (90, 270) + if transposed != will_transposed: + self._core.width, self._core.height = self._core.height, self._core.width self._core.set_rotation(value) + if self._core.current_group is not None: + self._core.current_group._update_transform( # pylint: disable=protected-access + self._core.transform + ) @property def bus(self) -> _DisplayBus: diff --combined displayio/_tilegrid.py index 9287e98,a87860e..87d9a92 --- a/displayio/_tilegrid.py +++ b/displayio/_tilegrid.py @@@ -319,7 -319,7 +319,7 @@@ class TileGrid ) # In Pixels # Check the mask first to see if the pixel has already been set - if mask[offset // 8] & (1 << (offset % 8)): + if mask[offset // 32] & (1 << (offset % 32)): continue local_x = input_pixel.x // self._absolute_transform.scale tile_location = ( @@@ -364,23 -364,22 +364,22 @@@ full_coverage = False else: mask[offset // 32] |= 1 << (offset % 32) - # print("Mask", mask) if colorspace.depth == 16: struct.pack_into( "H", - buffer.cast("H"), - offset, + buffer.cast("B"), + offset * 2, output_pixel.pixel, ) elif colorspace.depth == 32: struct.pack_into( "I", - buffer, - offset, + buffer.cast("B"), + offset * 4, output_pixel.pixel, ) elif colorspace.depth == 8: - buffer[offset] = output_pixel.pixel & 0xFF + buffer.cast("B")[offset] = output_pixel.pixel & 0xFF elif colorspace.depth < 8: # Reorder the offsets to pack multiple rows into # a byte (meaning they share a column). @@@ -399,9 -398,7 +398,9 @@@ if colorspace.reverse_pixels_in_byte: # Reverse the shift by subtracting it from the leftmost shift shift = (pixels_per_byte - 1) * colorspace.depth - shift - buffer[offset // pixels_per_byte] |= output_pixel.pixel << shift + buffer.cast("B")[offset // pixels_per_byte] |= ( + output_pixel.pixel << shift + ) return full_coverage