dotclockframebuffer – Native helpers for driving parallel displays — Adafruit CircuitPython 1 documentation (original) (raw)

Adafruit CircuitPython

Available on these boards

dotclockframebuffer.Length

dotclockframebuffer.ioexpander_send_init_sequence(bus: busio.I2C, init_sequence: circuitpython_typing.ReadableBuffer, *, i2c_init_sequence: circuitpython_typing.ReadableBuffer, i2c_address: int, gpio_address: int, gpio_data_len: Length, gpio_data: int, cs_bit: int, mosi_bit: int, clk_bit: int, reset_bit: int | None) → None

Send a displayio-style initialization sequence over an I2C I/O expander

This function is highly generic in order to support various I/O expanders. What’s assumed is that all the GPIO can be updated by writing to a single I2C register. Normal output polarity is assumed (CS and CLK are active low, data is not inverted). Only 8-bit I2C addresses are supported. 8- and 16-bit I2C addresses and data registers are supported. The Data/Command bit is sent as part of the serial data.

Normally this function is used via a convenience library that is specific to the display & I/O expander in use.

If the board has an integrated I/O expander, **board.TFT_IO_EXPANDER expands to the proper arguments starting with gpio_address. Note that this may include the i2c_init_sequence argument which can change the direction & value of I/O expander pins. If this is undesirable, take a copy of TFT_IO_EXPANDER and change or remove the i2c_init_sequence key.

If the board has an integrated display that requires an initialization sequence, board.TFT_INIT_SEQUENCE is the initialization string for the display.

Parameters:

class dotclockframebuffer.DotClockFramebuffer(*, de: microcontroller.Pin, vsync: microcontroller.Pin, hsync: microcontroller.Pin, dclk: microcontroller.Pin, red: Tuple[microcontroller.Pin], green: Tuple[microcontroller.Pin], blue: Tuple[microcontroller.Pin], frequency: int, width: int, height: int, hsync_pulse_width: int, hsync_back_porch: int, hsync_front_porch: int, hsync_idle_low: bool, vsync_back_porch: int, vsync_front_porch: int, vsync_idle_low: bool, de_idle_high: bool, pclk_active_high: bool, pclk_idle_high: bool, overscan_left: int = 0)

Manage updating a ‘dot-clock’ framebuffer in the background while Python code runs. It doesn’t handle display initialization.

Create a DotClockFramebuffer object associated with the given pins.

The pins are then in use by the display until displayio.release_displays()is called even after a reload. (It does this so CircuitPython can use the display after your code is done.) So, the first time you initialize a display bus in code.py you should calldisplayio.release_displays() first, otherwise it will error after the first code.py run.

When a board has dedicated dot clock framebuffer pins and/or timings, they are intended to be used in the constructor with ** dictionary unpacking like so:DotClockFramebuffer(**board.TFT_PINS, **board.TFT_TIMINGS)

On Espressif-family microcontrollers, this driver requires that theCIRCUITPY_RESERVED_PSRAM in settings.toml be large enough to hold the framebuffer. Generally, boards with built-in displays or display connectors will have a default setting that is large enough for typical use. If the constructor raises a MemoryError or an IDFError, this probably indicates the setting is too small and should be increased.

TFT connection parameters:

Parameters:

TFT timing parameters:

Parameters:

refresh() → None

Transmits the color data in the buffer to the pixels so that they are shown.

If this function is not called, the results are unpredictable; updates may be partially shown.

refresh_rate_: float_

The pixel refresh rate of the display, in Hz

frequency_: int_

The pixel frequency of the display, in Hz

width_: int_

The width of the display, in pixels

height_: int_

The height of the display, in pixels

row_stride_: int_

The row_stride of the display, in bytes

Due to overscan or alignment requirements, the memory address for row N+1 may not be exactly 2*width bytes after the memory address for row N. This property gives the stride in bytes.

On Espressif this value is guaranteed to be a multiple of the 2 (i.e., it is a whole number of pixels)

first_pixel_offset_: int_

The first_pixel_offset of the display, in bytes

Due to overscan or alignment requirements, the memory address for row N+1 may not be exactly 2*width bytes after the memory address for row N. This property gives the stride in bytes.

On Espressif this value is guaranteed to be a multiple of the 2 (i.e., it is a whole number of pixels)