class DSIDisplay – DSI Display Driver

The DSIDisplay class is used for driving MIPI LCDs.

Example usage for driving the 800x480 MIPI LCD:

import sensor, display

# Setup camera.
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.LCD)
sensor.skip_frames()
lcd = display.DSIDisplay(controller=display.ST7701())

# Show image.
def loop():
    lcd.write(sensor.snapshot())

构造函数

class display.DSIDisplay([framesize=display.FWVGA[, refresh=60[, portrait=False[, channel=0[, controller[, backlight]]]]]])

framesize 是一个支持的标准的分辨率

refresh 设置屏幕的水平刷新率。控制DSI LCD的时钟

portrait 交换显示帧的宽度和高度

channel 用于显示的虚拟MIPI DSI通道。

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.

方法

DSIDisplay.deinit()

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

DSIDisplay.width()

Returns the width of the screen.

DSIDisplay.height()

Returns the height of the screen.

DSIDisplay.refresh()

Returns the refresh rate.

DSIDisplay.write(image, [x=0, [y=0, [x_scale=1.0, [y_scale=1.0, [roi=None, [rgb_channel=-1, [alpha=256, [color_palette=None, [alpha_palette=None]]]]]]]]]])

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

You may also pass a path instead of an image object for this method to automatically load the image from disk and draw it in one step. E.g. write("test.jpg").

x_scale 控制在水平方向显示图像的缩放参数(浮点数)。如果是负值则进行水平镜像。注意如果没有指定``y_scale`` 则使用 x_scale 来保持纵横比。

y_scale 控制在垂直方向显示图像的缩放参数(浮点数)。如果是负值则进行垂直翻转。注意如果没有指定``x_scale`` 则使用 y_scale 来保持纵横比。

roi 是需要显示的感兴趣区域的元组(x, y, w, h)。这能够允许你只对ROI区域进行做法。

rgb_channel 是从RGB图像中抽取的RGB通道 (0=R, G=1, B=2) 并显示。例如,如果传 rgb_channel=1 ,将抽取图像的绿通道,并以灰度图进行显示。

alpha 控制图像的透明度。 如果使用256将显示一个透明膜图像。当小于256则产生一个半透明的图像。0则为黑色图像。

color_palette if not -1 can be image.PALETTE_RAINBOW, image.PALETTE_IRONBOW, or a 256 pixel in total RGB565 image to use as a color lookup table on the grayscale value of whatever the input image is. This is applied after rgb_channel extraction if used.

alpha_palette if not -1 can be a 256 pixel in total GRAYSCALE image to use as a alpha palette which modulates the alpha value of the input image being displayed at a pixel pixel level allowing you to precisely control the alpha value of pixels based on their grayscale value. A pixel value of 255 in the alpha lookup table is opaque which anything less than 255 becomes more transparent until 0. This is applied after rgb_channel extraction if used.

hint 为一个逻辑或标志:

DSIDisplay.clear([display_off=False])

将LCD屏清为黑色。

display_off 如果设置为True则关闭显示并清屏的缓存为黑。应该同时关闭背光,以保证黑屏,因为部分屏关闭显示后会显示为白屏。

DSIDisplay.backlight([value])

设置LCD的背光。0(关)到100(全开)

注意除非你使用 DACBacklightPWMBacklight 作为背光,使用GPIO控制管脚将只有0关闭和非0打开。

无参数将获取背光值。

DSIDisplay.dsi_write(cmd[, args=None[, dcs=False]])

发送DSI显示 cmd 参数 args

DSIDisplay.dsi_read(cmd[, len[, args=None[, dcs=False]]])

用``cmd`` 参数 args 读取DSI显示的 len