API Documentation←
The main entrypoint for the library is the DispmanX class as described below.
DispmanX ←
DispmanX(
layer: int = 0,
display: Union[None, int, Display] = None,
pixel_format: Literal["RGB", "ARGB", "RGBA", "RGBX", "XRGB", "RGBA16", "RGB565"] = "RGBA",
buffer_type: Literal["auto", "numpy", "ctypes"] = "auto",
)
The DispmanX Class
You can use this class via the following,
Parameters:
Name | Type | Description | Default |
---|---|---|---|
layer |
int
|
What layer to choose. For example, the default layer of
Raspberry Pi OS Lite's terminal is |
0
|
display |
Union[None, int, Display]
|
Which display to use. Choices:
|
None
|
pixel_format |
Literal['RGB', 'ARGB', 'RGBA', 'RGBX', 'XRGB', 'RGBA16', 'RGB565']
|
Pixel format for the object. Choices:
|
'RGBA'
|
buffer_type |
Literal['auto', 'numpy', 'ctypes']
|
Type of buffer to write to the display from. Choices:
|
'auto'
|
Raises:
Type | Description |
---|---|
DispmanXError
|
A user error occured by specifying an incorrect argument. |
DispmanXRuntimeError
|
A serious error occured with the underlying DispmanX layer on your PI. |
Attributes:
Name | Type | Description |
---|---|---|
buffer |
A buffer representing underlying raw pixel data. It will be
a NumPy array or ctypes Array
of c_char depending on the value of the
|
|
buffer_type |
str
|
Whether the buffer is a NumPy array
or a ctypes Array. (Either |
display |
Display
|
The display for which this object is attached to |
pixel_format |
str
|
The pixel format for this object. (One of |
size |
Size
|
The Size object representing the dimensions of the current display. |
width |
int
|
The width of the current display. |
height |
int
|
The height of the current display. |
layer |
int
|
The layer of this object. |
destroyed |
bool
|
Whether or not this object has been destroyed, is currently unusable, and no longer is available to display. |
destroy ←
Destroy this DispmanX object
If the object is already destroyed, the operation will do nothing.
Raises:
Type | Description |
---|---|
DispmanXRuntimeError
|
Raised if there's an error destroying any of the underlying resources for the object |
get_default_display
classmethod
←
list_displays
classmethod
←
Get a list of available Displays.
Returns:
Type | Description |
---|---|
list[Display]
|
List of available Displays. |
Raises:
Type | Description |
---|---|
DispmanXRuntimeError
|
Raised if no devices are found, or there's an error while getting the list of displays. |
update ←
Update the pixels based on what's in the buffer
Raises:
Type | Description |
---|---|
DispmanXRuntimeError
|
Raises if there's an error writing to the video memory |
Other Classes←
Display
←
Bases: NamedTuple
Returned by various interactions with the DispmanX class.
Not instantiated directly.
Attributes:
Name | Type | Description |
---|---|---|
device_id |
int
|
The numeric ID associated with this display. You can use this to instantiate a DispmanX for this display. |
name |
str
|
The string representation of this display, for example
|
size |
Size
|
The size of this display. |
Size
←
Bases: NamedTuple
Returned by various interactions with the DismpanX and Display classes.
Not instantiated directly.
Attributes:
Name | Type | Description |
---|---|---|
width |
int
|
The width component |
height |
int
|
The height component |
Exceptions←
DispmanXError
←
Bases: Exception
Raised when a recoverable error occurs with the underlying DispmanX library.
Likely a programmer error. You can try whatever you were doing again and correcting the offending behavior.
DispmanXRuntimeError
←
Bases: RuntimeError
Raised when an irrecoverable error occurs with the underlying DispmanX library.
Under normal circumstances, you should destroy any DispmanX objects you've instantiated when one of these exceptions gets raises. Or, your program should cleanly exit.