ST7789 TFT LCD display driver interface for color displays. More...
![]() |
Data Structures | |
struct | driver_st7789_rect_t |
ST7789 display rectangle for window operations. More... | |
struct | driver_st7789_t |
ST7789 display driver structure. More... | |
Typedefs | |
typedef struct driver_st7789_t | driver_st7789_t |
ST7789 display driver structure. More... | |
Enumerations | |
enum | driver_st7789_rotation_t { DRIVER_ST7789_ROTATION_0 = 0, DRIVER_ST7789_ROTATION_90 = 1, DRIVER_ST7789_ROTATION_180 = 2, DRIVER_ST7789_ROTATION_270 = 3 } |
ST7789 rotation modes. More... | |
enum | driver_st7789_interface_t { DRIVER_ST7789_INTERFACE_SPI = 0, DRIVER_ST7789_INTERFACE_PARALLEL = 1 } |
ST7789 interface type. More... | |
Functions | |
driver_st7789_t | driver_st7789_init (hw_spi_t *spi, uint8_t dc_pin, uint8_t reset_pin, uint8_t backlight_pin, uint16_t width, uint16_t height, bool round) |
Initialize a ST7789 display driver using the SPI interface. More... | |
void | driver_st7789_finalize (driver_st7789_t *st7789) |
Finalize and release a ST7789 display driver. More... | |
bool | driver_st7789_valid (const driver_st7789_t *st7789) |
Check if a ST7789 driver structure is valid. More... | |
bool | driver_st7789_set_rotation (driver_st7789_t *st7789, driver_st7789_rotation_t rotation) |
Set the rotation of the ST7789 display. More... | |
bool | driver_st7789_set_backlight (driver_st7789_t *st7789, uint8_t brightness) |
Set the backlight brightness of the ST7789 display. More... | |
void | driver_st7789_reset (driver_st7789_t *st7789) |
Reset the ST7789 display. More... | |
bool | driver_st7789_set_window (driver_st7789_t *st7789, driver_st7789_rect_t rect) |
Set the display window for subsequent pixel data. More... | |
bool | driver_st7789_write_pixels (driver_st7789_t *st7789, const uint8_t *data, size_t size) |
Send pixel data to the ST7789 display. More... | |
bool | driver_st7789_fill (driver_st7789_t *st7789, uint16_t color) |
Fill the entire display with a single color. More... | |
bool | driver_st7789_update_rect (driver_st7789_t *st7789, driver_st7789_rect_t rect, const uint8_t *data, size_t size) |
Update a rectangular region of the ST7789 display. More... | |
ST7789 TFT LCD display driver interface for color displays.
The ST7789 is a popular TFT LCD controller supporting 16-bit color with SPI and parallel interfaces.
typedef struct driver_st7789_t driver_st7789_t |
ST7789 display driver structure.
This structure contains the configuration and state information for a ST7789 TFT LCD display controller instance. The ST7789 supports both SPI and parallel interfaces with 16-bit color depth.
ST7789 interface type.
Enumerator | |
---|---|
DRIVER_ST7789_INTERFACE_SPI | SPI interface. |
DRIVER_ST7789_INTERFACE_PARALLEL | Parallel interface. |
Definition at line 34 of file drivers_st7789.h.
ST7789 rotation modes.
Enumerator | |
---|---|
DRIVER_ST7789_ROTATION_0 | No rotation. |
DRIVER_ST7789_ROTATION_90 | 90-degree rotation |
DRIVER_ST7789_ROTATION_180 | 180-degree rotation |
DRIVER_ST7789_ROTATION_270 | 270-degree rotation |
Definition at line 23 of file drivers_st7789.h.
bool driver_st7789_fill | ( | driver_st7789_t * | st7789, |
uint16_t | color | ||
) |
Fill the entire display with a single color.
st7789 | Pointer to the ST7789 driver structure. |
color | RGB565 color value to fill the display with. |
This function efficiently fills the entire display with a single color by setting the full display window and writing the color data.
void driver_st7789_finalize | ( | driver_st7789_t * | st7789 | ) |
Finalize and release a ST7789 display driver.
st7789 | Pointer to the ST7789 driver structure to finalize. |
This function properly shuts down the ST7789 display driver, turning off the backlight, releasing GPIO resources, and clearing the driver structure. After calling this function, the driver structure should not be used.
driver_st7789_t driver_st7789_init | ( | hw_spi_t * | spi, |
uint8_t | dc_pin, | ||
uint8_t | reset_pin, | ||
uint8_t | backlight_pin, | ||
uint16_t | width, | ||
uint16_t | height, | ||
bool | round | ||
) |
Initialize a ST7789 display driver using the SPI interface.
spi | Pointer to an initialized SPI interface for display communication. |
dc_pin | GPIO pin number for Data/Command control. |
reset_pin | GPIO pin number for display reset (optional, use HW_GPIO_INVALID if not used). |
backlight_pin | GPIO pin number for backlight control (optional, use HW_GPIO_INVALID if not used). |
width | Display width in pixels. |
height | Display height in pixels. |
round | Whether the display is round (affects drawing operations). |
This function initializes a ST7789 TFT LCD display driver for communication over SPI. The display requires DC and CS control pins, with optional reset and backlight control.
void driver_st7789_reset | ( | driver_st7789_t * | st7789 | ) |
Reset the ST7789 display.
st7789 | Pointer to the ST7789 driver structure. |
This function performs a hardware reset of the display if a reset pin is configured, or issues a software reset command.
bool driver_st7789_set_backlight | ( | driver_st7789_t * | st7789, |
uint8_t | brightness | ||
) |
Set the backlight brightness of the ST7789 display.
st7789 | Pointer to the ST7789 driver structure. |
brightness | Brightness level (0-255, where 0 is off and 255 is full brightness). |
This function controls the display backlight using PWM if a backlight pin was configured during initialization.
bool driver_st7789_set_rotation | ( | driver_st7789_t * | st7789, |
driver_st7789_rotation_t | rotation | ||
) |
Set the rotation of the ST7789 display.
st7789 | Pointer to the ST7789 driver structure. |
rotation | The rotation mode to set. |
This function configures the display rotation by setting the appropriate MADCTL register values. The rotation affects how pixel data is interpreted and displayed.
bool driver_st7789_set_window | ( | driver_st7789_t * | st7789, |
driver_st7789_rect_t | rect | ||
) |
Set the display window for subsequent pixel data.
st7789 | Pointer to the ST7789 driver structure. |
rect | Rectangle defining the window area. |
This function configures the display controller's column and row address windows for subsequent pixel data writes. All pixel data sent after this command will be written to the specified rectangular area.
bool driver_st7789_update_rect | ( | driver_st7789_t * | st7789, |
driver_st7789_rect_t | rect, | ||
const uint8_t * | data, | ||
size_t | size | ||
) |
Update a rectangular region of the ST7789 display.
st7789 | Pointer to the ST7789 driver structure. |
rect | Rectangle defining the update area. |
data | Pointer to the pixel data buffer. |
size | Size of the pixel data in bytes. |
This function updates a specific rectangular region of the display with new pixel data. It combines setting the window and writing pixels in a single operation.
bool driver_st7789_valid | ( | const driver_st7789_t * | st7789 | ) |
Check if a ST7789 driver structure is valid.
st7789 | Pointer to the ST7789 driver structure to validate. |
This function performs basic validation of the ST7789 driver structure to ensure it has been properly initialized and contains valid configuration.
bool driver_st7789_write_pixels | ( | driver_st7789_t * | st7789, |
const uint8_t * | data, | ||
size_t | size | ||
) |
Send pixel data to the ST7789 display.
st7789 | Pointer to the ST7789 driver structure. |
data | Pointer to the pixel data buffer. |
size | Size of the pixel data in bytes. |
This function sends raw pixel data to the display. The data should be 16-bit RGB565 format pixels. The display window should be set before calling this function using driver_st7789_set_window().