8000 FramebufferDisplay: Don't set rotation via core_construct · dastels/circuitpython@71c63c2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 71c63c2

Browse files
committed
FramebufferDisplay: Don't set rotation via core_construct
The expectations of displayio.Display and frambufferio.FramebufferDisplay are different when it comes to rotation. In displayio.Display, if you call core_construct with a WxH = 64x32 and rotation=90, you get something that is 32 pixels wide and 64 pixels tall in the LCD's coordinate system. This is fine, as the existing definitions were written to work like this. With framebuffer displays, however, the underlying framebuffer (such as RGBMatrix) says "I am WxH pixels wide in my coordinate system" and the constructor is given a rotation; when the rotation indicates a transpose that means "exchange rows and columns, so that to the Groups displayed on it, there is an effectively HxW pixel region for use". Happily, we already have a set_rotation method. Thus (modulo the time spent debugging things anyway:) the fix is simple: Always request no rotation from core_construct, then immediately fix up the rotation to match what was requested. Testing performed: 32x16 RGBMatrix on Metro M4 Express (but using the Airlift firmware, as this is the configuration the error was reported on): * initially construct display at 0, 90, 180, 270 degrees * later change angle to 0, 90, 180, 270 degrees * no garbled display * no safe mode crashes
1 parent ce603df commit 71c63c2

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

shared-module/framebufferio/FramebufferDisplay.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ void common_hal_framebufferio_framebufferdisplay_construct(framebufferio_framebu
6666
ram_height,
6767
0,
6868
0,
69-
rotation,
69+
0, // rotation
7070
depth,
7171
fb_getter_default(get_grayscale, (depth < 8)),
7272
fb_getter_default(get_pixels_in_byte_share_row, false),
@@ -92,6 +92,10 @@ void common_hal_framebufferio_framebufferdisplay_construct(framebufferio_framebu
9292
self->native_frames_per_second = fb_getter_default(get_native_frames_per_second, 60);
9393
self->native_ms_per_frame = 1000 / self->native_frames_per_second;
9494

95+
if (rotation != 0) {
96+
common_hal_framebufferio_framebufferdisplay_set_rotation(self, rotation);
97+
}
98+
9599
supervisor_start_terminal(self->core.width, self->core.height);
96100

97101
// Set the group after initialization otherwise we may send pixels while we delay in

0 commit comments

Comments
 (0)
0