RGBDisplay类 – RGB显示驱动¶
RGBDisplay 类使用24bit的驱动并口LCD。
800x480 24bit并口LCD的使用例子:
import sensor, display
# Setup camera.
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.LCD)
sensor.skip_frames()
lcd = display.RGBDisplay()
# Show image.
def loop():
lcd.write(sensor.snapshot())
构造函数¶
- class display.RGBDisplay([framesize=display.FWVGA[, refresh=60[, display_on=True[, portrait=False[, controller[, backlight]]]]]])¶
framesize是一个支持的标准的分辨率refresh设置屏的刷新率,控制RGB屏的时钟。display_on使能显示。当24比特的并口屏输出共享多个设备的,需要使用False。对于HDMI显示当驱动数据总线,并位置驱动屏关闭。portrait交换显示帧的宽度和高度controller控制初始化显示的芯片类backlightspecify a backlight controller module to use. By default the backlight will be controlled via a GPIO pin.
方法¶
- RGBDisplay.deinit()¶
Releases the I/O pins and RAM used by the class. This is called automatically on destruction.
- RGBDisplay.width()¶
Returns the width of the screen.
- RGBDisplay.height()¶
Returns the height of the screen.
- RGBDisplay.refresh()¶
Returns the refresh rate.
- RGBDisplay.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[, hint=0]]]]]]]]]])¶
Displays an
imagewhose 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_paletteif not-1can beimage.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 afterrgb_channelextraction if used.alpha_paletteif not-1can be a 256 pixel in total GRAYSCALE image to use as a alpha palette which modulates thealphavalue 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 afterrgb_channelextraction if used.hint为一个逻辑或标志:image.AREA: 近邻插值缩小使用的面积参数image.BILINEAR: 近邻插值的线性缩放。image.BICUBIC:近邻插值的双立方缩放image.CENTER: 显示图像置中,在缩放后使用。image.HMIRROR:水平镜像图像image.VFLIP: 垂直翻转图像image.TRANSPOSE: 旋转图像(交换x/y)image.EXTRACT_RGB_CHANNEL_FIRST: 在缩放前抽取RGB通道。image.APPLY_COLOR_PALETTE_FIRST: 做法前 使用调色板。image.SCALE_ASPECT_KEEP: 缩放图像以使用显示。image.SCALE_ASPECT_EXPAND: 缩放图像以适应显示(剪切)image.SCALE_ASPECT_IGNORE: 缩放图像以适应显示(伸展)image.ROTATE_90: 图像旋转90度(即 VFLIP | TRANSPOSE)image.ROTATE_180: 图像180度旋转(即 HMIRROR | VFLIP)image.ROTATE_270: 图像旋转270度(即 HMIRROR | TRANSPOSE)
- RGBDisplay.clear([display_off=False])¶
将LCD屏清为黑色。
display_off如果设置为True则关闭显示并清屏的缓存为黑。应该同时关闭背光,以保证黑屏,因为部分屏关闭显示后会显示为白屏。
- RGBDisplay.backlight([value])¶
设置LCD的背光。0(关)到100(全开)
注意除非你使用
DACBacklight或PWMBacklight作为背光,使用GPIO控制管脚将只有0关闭和非0打开。无参数将获取背光值。