displaydev.busdisplay
displaydev.busdisplay
- class displaydev.busdisplay.BusDisplay(display_bus, init_sequence=None, *, width=0, height=0, colstart=0, rowstart=0, rotation=0, mirrored=False, color_depth=16, bgr=False, invert=False, reverse_bytes_in_word=False, brightness=1.0, backlight_pin=None, backlight_on_high=True, reset_pin=None, reset_high=True, power_pin=None, power_on_high=True, set_column_command=42, set_row_command=43, write_ram_command=44, brightness_command=None, data_as_commands=False, single_byte_bounds=False, quiet=False)[source]
Bases:
DisplayDriverBase class for displays connected via a bus.
- Parameters:
display_bus (SPIBus, I80Bus) – The bus the display is connected to.
init_sequence (bytes, list) – The initialization sequence for the display.
width (int) – The width of the display in pixels.
height (int) – The height of the display in pixels.
colstart (int) – The column start address for the display.
rowstart (int) – The row start address for the display.
rotation (int) – The rotation of the display in degrees.
mirrored (bool) – If True, the display is mirrored.
color_depth (int) – The color depth of the display in bits.
bgr (bool) – If True, the display uses BGR color order.
invert (bool) – If True, the display colors are inverted.
reverse_bytes_in_word (bool) – If True, the bytes in 16-bit colors are reversed.
brightness (float) – The brightness of the display as a float between 0.0 and 1.0.
backlight_pin (int, Pin) – The pin the display backlight is connected to.
backlight_on_high (bool) – If True, the backlight is on when the pin is high.
reset_pin (int, Pin) – The pin the display reset is connected to.
reset_high (bool) – If True, the reset pin is high.
power_pin (int, Pin) – The pin the display power is connected to.
power_on_high (bool) – If True, the power pin is high.
set_column_command (int) – The command to set the column address.
set_row_command (int) – The command to set the row address.
write_ram_command (int) – The command to write to the display RAM.
brightness_command (int) – The command to set the display brightness.
data_as_commands (bool) – If True, data is sent as commands.
single_byte_bounds (bool) – If True, single byte bounds are used.
- display_bus
The bus the display is connected to.
- Type:
SPIBus, I80Bus
- init()[source]
Post initialization tasks.
This method may be overridden by subclasses to perform any post initialization. If it is overridden, it must call super().init() or set self._initialized = True.
- blit_rect(buf, x, y, w, h)[source]
Blit a buffer to the display.
This method takes a buffer of pixel data and writes it to a specified rectangular area of the display. The top-left corner of the rectangle is specified by the x and y parameters, and the size of the rectangle is specified by the width and height parameters.
- Parameters:
buf (memoryview) – The buffer containing the pixel data.
x (int) – The x-coordinate of the top-left corner of the rectangle.
y (int) – The y-coordinate of the top-left corner of the rectangle.
w (int) – The width of the rectangle in pixels.
h (int) – The height of the rectangle in pixels.
- Returns:
(tuple) – A tuple containing the x, y, width, and height of the rectangle.
- fill_rect(x, y, w, h, c)[source]
Draw a rectangle at the given location, size and filled with color.
This method draws a filled rectangle on the display. The top-left corner of the rectangle is specified by the x and y parameters, and the size of the rectangle is specified by the width and height parameters. The rectangle is filled with the specified color.
- Parameters:
- Returns:
(tuple) – A tuple containing the x, y, width, and height of the rectangle.
- vscrdef(tfa, vsa, bfa)[source]
Set Vertical Scrolling Definition.
To scroll a 135x240 display these values should be 40, 240, 40. There are 40 lines above the display that are not shown followed by 240 lines that are shown followed by 40 more lines that are not shown. You could write to these areas off display and scroll them into view by changing the TFA, VSA and BFA values.
- vscsad(vssa=None)[source]
Set the vertical scroll start address.
- Parameters:
vssa (int, None) – The vertical scroll start address.
- Returns:
int – The vertical scroll start address.
- property colstart
The offset in pixels to the first column of the visible display.
- property rowstart
The offset in pixels to the first row of the visible display.
- property power
The power state of the display.
- Returns:
bool: The power state of the display.
- property brightness
The brightness of the display.
- invert_colors(value)[source]
Invert the colors of the display.
- Parameters:
value (bool) – If True, invert the colors of the display.