displaydev.sdldisplay

displaydev.sdldisplay — SDL2 desktop display driver.

displaydev.sdldisplay.poll_event()[source]

Poll for one pending event.

Returns:

Optional[events] – One events event, or None.

displaydev.sdldisplay.get_events()[source]

Drain all pending events from the SDL queue.

Returns:

list | None – A list of events, or None if the queue was empty.

class displaydev.sdldisplay.SDLDisplay(width=320, height=240, rotation=0, color_depth=16, title='SDL2 Display', scale=1.0, window_flags=4, render_flags=6, x=805240832, y=805240832, *, quiet=False)[source]

Bases: FrameRecorderMixin, DesktopDisplay

Emulate an LCD window with SDL2 (via usdl2).

Provides scrolling and rotation similar to a panel driver. The SDL texture acts as the LCD’s internal memory. Scale is reduced automatically when the window would not fit the desktop work area.

Parameters:
  • width (int, optional) – Panel width in pixels. Defaults to 320.

  • height (int, optional) – Panel height in pixels. Defaults to 240.

  • rotation (int, optional) – Rotation in degrees. Defaults to 0.

  • color_depth (int, optional) – Bits per pixel (16/24/32). Defaults to 16.

  • title (str, optional) – Window title. Defaults to "SDL2 Display".

  • scale (float, optional) – Window scale factor. Defaults to 1.0.

  • window_flags (int, optional) – SDL_WINDOW_* flags.

  • render_flags (int, optional) – SDL_RENDERER_* flags.

  • x (int, optional) – Window X (default centered).

  • y (int, optional) – Window Y (default centered).

  • quiet (bool) – Suppress init chatter when True.

needs_refresh

True — appdev.App drives periodic show().

Type:

bool

init()[source]

Initializes the display instance. Called by __init__ and rotation setter.

blit_rect(buffer, x, y, w, h)[source]

Blit a buffer into the display texture. Compositing is deferred until show().

fill_rect(x, y, w, h, c)[source]

Fill a rectangle in the display texture. Compositing is deferred until show().

pixel(x, y, c)[source]

Set a pixel on the display.

Parameters:
  • x (int) – The x-coordinate of the pixel.

  • y (int) – The y-coordinate of the pixel.

  • c (int) – The color of the pixel.

Returns:

(tuple) – A tuple containing the x, y values.

render(renderRect=None)[source]

Composite the logical framebuffer to the window. Called from show() when draws are pending.

show(_timer=None)[source]

Show the display.

capture_rgb()[source]

Return the visible window as (RGB24 bytes, width, height).

quit(code=0, force=False)[source]

Release SDL resources (REPL-safe unless force=True).

force_quit(code=0)[source]

Release SDL resources then hard-exit the process.

On MicroPython and CircuitPython, SDL_Quit during subprocess shutdown can SIGSEGV; skip SDL teardown and _exit immediately after restoring the TTY (kit harnesses and other short-lived desktop runs).