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)¶
framesizeOne of the standard supported resolutions (e.g.display.FWVGA).refreshSets the screen refresh rate in hertz. Valid range is 30 to 120. This controls the DSI LCD clock.display_onEnables the display.triple_bufferAllocates three framebuffers to allow tear-free display updates. Required for vertical flipping inwrite().portraitSwap the framesize width and height.channelThe virtual MIPI DSI channel to use to talk to the display.controllerPass 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.backlightSpecify 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.
- 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
imagewhose top-left corner starts at locationx,y.imagemay be a path string instead of an image object to automatically load the image from disk. E.g.write("test.jpg").x_scalecontrols how much the displayed image is scaled by in the x direction (float). If this value is negative the image will be flipped horizontally. Ify_scaleis not specified then it will matchx_scaleto maintain the aspect ratio.y_scalecontrols 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 requirestriple_buffer=True. Ifx_scaleis not specified then it will matchy_scale.roiis the region-of-interest rectangle tuple (x, y, w, h) of the image to display.rgb_channelis the RGB channel (0=R, 1=G, 2=B) to extract from an RGB565 image and render on the display in grayscale.-1disables extraction. Valid range is -1 to 2.alphacontrols 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_palettemay 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 afterrgb_channelextraction.alpha_palettemay be a 256 pixel grayscale image used as an alpha lookup table that modulatesalphaper input pixel grayscale value. Applied afterrgb_channelextraction.hintis a logical OR of the flags:image.AREA: Use area scaling when downscaling versus the default of nearest neighbor.image.BILINEAR: Use bilinear scaling versus the default of nearest neighbor scaling.image.BICUBIC: Use bicubic scaling versus the default of nearest neighbor scaling.image.CENTER: Center the image being drawn on the display. This is applied after scaling.image.HMIRROR: Horizontally mirror the image.image.VFLIP: Vertically flip the image.image.TRANSPOSE: Transpose the image (swap x/y).image.EXTRACT_RGB_CHANNEL_FIRST: Do rgb_channel extraction before scaling.image.APPLY_COLOR_PALETTE_FIRST: Apply color palette before scaling.image.SCALE_ASPECT_KEEP: Scale the image being drawn to fit inside the display.image.SCALE_ASPECT_EXPAND: Scale the image being drawn to fill the display (results in cropping).image.SCALE_ASPECT_IGNORE: Scale the image being drawn to fill the display (results in stretching).image.ROTATE_90: Rotate the image by 90 degrees (this is just VFLIP | TRANSPOSE).image.ROTATE_180: Rotate the image by 180 degrees (this is just HMIRROR | VFLIP).image.ROTATE_270: Rotate the image by 270 degrees (this is just HMIRROR | TRANSPOSE).
- clear(display_off: bool = False) None¶
Clears the LCD framebuffer to black.
display_offif 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
DACBacklightorPWMBacklightcontroller 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
cmdto the display.argsis an optional integer or buffer containing command parameters.dcsif True sends the command as a DCS (Display Command Set) packet.