class DSIDisplay – DSI Display Driver

The DSIDisplay class is used for driving MIPI DSI LCDs.

Constructors

class display.DSIDisplay(framesize: int = FWVGA, *, refresh: int = 60, display_on: bool = True, triple_buffer: bool = True, portrait: bool = False, channel: int = 0, controller: Any | None = None, backlight: Any | None = None)

framesize One of the standard supported resolutions (e.g. display.FWVGA).

refresh Sets the screen refresh rate in hertz. Valid range is 30 to 120. This controls the DSI LCD clock.

display_on Enables the display.

triple_buffer Allocates three framebuffers to allow tear-free display updates. Required for vertical flipping in write().

portrait Swap the framesize width and height.

channel The virtual MIPI DSI channel to use to talk to the display.

controller Pass the controller chip class here to initialize it along with the display. E.g. display.ST7701() which is a standard display controller for MIPI DSI displays.

backlight Specify a backlight controller module to use. By default the backlight will be controlled via a GPIO pin.

deinit() None

Releases the I/O pins and RAM used by the class. This is called automatically on destruction.

width() int

Returns the width of the screen.

height() int

Returns the height of the screen.

triple_buffer() int

Returns whether triple buffering is enabled.

bgr() int

Returns whether the display expects BGR ordered pixels.

byte_swap() int

Returns whether the display expects byte-swapped pixels.

framesize() int

Returns the framesize constant the display was initialized with.

refresh() int

Returns the refresh rate in hertz.

write(image: image.Image, x: int = 0, y: int = 0, x_scale: float = 1.0, y_scale: float = 1.0, roi: Tuple[int, int, int, int] | None = None, rgb_channel: int = -1, alpha: int = 255, color_palette: image.Image | None = None, alpha_palette: image.Image | None = None, hint: int = 0) None

Displays an image whose top-left corner starts at location x, y.

image may be a path string instead of an image object to automatically load the image from disk. E.g. write("test.jpg").

x_scale controls how much the displayed image is scaled by in the x direction (float). If this value is negative the image will be flipped horizontally. If y_scale is not specified then it will match x_scale to maintain the aspect ratio.

y_scale controls how much the displayed image is scaled by in the y direction (float). If this value is negative the image will be flipped vertically. Vertical flip requires triple_buffer=True. If x_scale is not specified then it will match y_scale.

roi is the region-of-interest rectangle tuple (x, y, w, h) of the image to display.

rgb_channel is the RGB channel (0=R, 1=G, 2=B) to extract from an RGB565 image and render on the display in grayscale. -1 disables extraction. Valid range is -1 to 2.

alpha controls how opaque the image is. 255 displays an opaque image, lower values blend toward black, and 0 produces a fully black image. Valid range is 0 to 255.

color_palette may be a color palette enum or a 256 pixel RGB565 image to use as a color lookup table on the grayscale value of the input image. Applied after rgb_channel extraction.

alpha_palette may be a 256 pixel grayscale image used as an alpha lookup table that modulates alpha per input pixel grayscale value. Applied after rgb_channel extraction.

hint is a logical OR of the flags:

clear(display_off: bool = False) None

Clears the LCD framebuffer to black.

display_off if True turns off the display logic instead of clearing the framebuffer.

backlight(value: int | None = None) int

Sets the LCD backlight dimming value, 0 (off) to 100 (on). Pass no arguments to get the current backlight value.

Unless a DACBacklight or PWMBacklight controller is passed to the constructor, the backlight is controlled as a GPIO pin and will only go from 0 (off) to non-zero (on).

bus_write(cmd: int, args: int | bytes | None = None, *, dcs: bool = False) None

Send DSI command cmd to the display.

args is an optional integer or buffer containing command parameters.

dcs if True sends the command as a DCS (Display Command Set) packet.

bus_read(cmd: int, len: int, args: int | bytes | None = None, *, dcs: bool = False) bytes

Read len bytes from the display using DSI command cmd.

args is an optional integer or buffer containing command parameters.

dcs if True sends the command as a DCS (Display Command Set) packet.

ioctl(cmd: int, arg: Any | None = None) Any

Send a driver-specific ioctl cmd with optional arg to the display. Raises ValueError if the display does not support ioctl.