class DPI – DPI Interface
The DPI(RGB) class is the DPI(RGB) parallel interface hardware abstract class, which implements some common interfaces of DPI.
Constructors
- class DPI(data: tuple, hsync: Pin, vsync: Pin, de: Pin, pclk_pin: Pin, timings: tuple, disp: Pin = None, backlight: Pin = None, pclk: int = 8000000, width: int = 480, height: int = 480)
Create an DPI hardware abstract class.
These parameters are:
data: Tuple of data bus, currently only supports 16-bit RGB interfacehsync: Pin used for hsync signalvsync: Pin used for vsync signalde: Pin used for DE signal, set to None if it’s not usedpclk_pin: Pin used for PCLK signaltimings: RGB timing parametersdisp: Pin used for display control signal, set to None if it’s not usedbacklight: Pin used for backlight signalpclk: Frequency of pixel clockwidth: Horizontal resolution, i.e. the number of pixels in a lineheight: Vertical resolution, i.e. the number of lines in the frame
The
timingmust be a 6-tuple in the following format:(hsync_pulse_width, hsync_back_porch, hsync_front_porch, vsync_pulse_width, vsync_back_porch, vsync_front_porch)
hsync_pulse_width: Horizontal sync width, unit: PCLK periodhsync_back_porch: Horizontal back porch, number of PCLK between hsync and start of line active datahsync_front_porch: Horizontal front porch, number of PCLK between the end of active data and the next hsyncvsync_pulse_width: Vertical sync width, unit: number of linesvsync_back_porch: Vertical back porch, number of invalid lines between vsync and start of framevsync_front_porch: Vertical front porch, number of invalid lines between the end of frame and the next vsync
Methods
- DPI.reset()
Reset LCD panel.
- DPI.init()
Initialize LCD panel.
Note
Before calling this method, make sure the LCD panel has finished the reset stage by DPI.reset().
- DPI.bitmap(x_start, y_start, x_end, y_end, color_data)
Draw bitmap on LCD panel.
The arguments are:
x_start- Start index on x-axis (x_start included)y_start- Start index on y-axis (y_start included)x_end- End index on x-axis (x_end not included)y_end- End index on y-axis (y_end not included)color_data- RGB color data that will be dumped to the specific window range
- DPI.mirror(mirror_x: bool, mirror_y: bool)
Mirror the LCD panel on specific axis.
The arguments are:
mirror_x- Whether the panel will be mirrored about the x axismirror_y- Whether the panel will be mirrored about the y axis
Note
Combined with DPI.swap_xy(), one can realize screen rotation
- DPI.swap_xy(swap_axes: bool)
Swap/Exchange x and y axis.
swap_axes- Whether to swap the x and y axis
Note
Combined with DPI.mirror(), one can realize screen rotation
- DPI.set_gap(x_gap: int, y_gap: int)
Set extra gap in x and y axis.
The gap is the space (in pixels) between the left/top sides of the LCD panel and the first row/column respectively of the actual contents displayed.
The arguments are:
x_gap- Extra gap on x axis, in pixelsy_gap- Extra gap on y axis, in pixels
Note
Setting a gap is useful when positioning or centering a frame that is smaller than the LCD.
- DPI.invert_color(invert_color_data: bool)
Invert the color (bit-wise invert the color data line)
invert_color_data- Whether to invert the color data
- DPI.disp_off(off: bool)
Turn off the display.
off- Whether to turn off the screen
- DPI.backlight_on()
Turn on the backlight.
- DPI.backlight_off()
turn off the backlight.
- DPI.deint()
Deinitialize the LCD panel.