objc

Data Structures | Typedefs | Enumerations | Functions

ST7789 TFT LCD display driver interface for color displays. More...

Collaboration diagram for ST7789:

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...
 

Detailed Description

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 Documentation

◆ 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.

Enumeration Type Documentation

◆ driver_st7789_interface_t

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.

34  {
driver_st7789_interface_t
ST7789 interface type.

◆ driver_st7789_rotation_t

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.

23  {
driver_st7789_rotation_t
ST7789 rotation modes.
180-degree rotation
270-degree rotation
90-degree rotation

Function Documentation

◆ driver_st7789_fill()

bool driver_st7789_fill ( driver_st7789_t st7789,
uint16_t  color 
)

Fill the entire display with a single color.

Parameters
st7789Pointer to the ST7789 driver structure.
colorRGB565 color value to fill the display with.
Returns
True if successful, false otherwise.

This function efficiently fills the entire display with a single color by setting the full display window and writing the color data.

◆ driver_st7789_finalize()

void driver_st7789_finalize ( driver_st7789_t st7789)

Finalize and release a ST7789 display driver.

Parameters
st7789Pointer 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.

Note
This function is safe to call multiple times on the same driver.
See also
driver_st7789_init() for initialization.

◆ driver_st7789_init()

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.

Parameters
spiPointer to an initialized SPI interface for display communication.
dc_pinGPIO pin number for Data/Command control.
reset_pinGPIO pin number for display reset (optional, use HW_GPIO_INVALID if not used).
backlight_pinGPIO pin number for backlight control (optional, use HW_GPIO_INVALID if not used).
widthDisplay width in pixels.
heightDisplay height in pixels.
roundWhether the display is round (affects drawing operations).
Returns
A ST7789 driver structure representing the initialized display.

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.

Note
The spi pointer must be valid and the SPI interface must be properly initialized with appropriate speed and mode for ST7789, including CS pin.
See also
hw_spi_init() for SPI interface initialization.
driver_st7789_finalize() for cleanup and resource release.

◆ driver_st7789_reset()

void driver_st7789_reset ( driver_st7789_t st7789)

Reset the ST7789 display.

Parameters
st7789Pointer 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.

◆ driver_st7789_set_backlight()

bool driver_st7789_set_backlight ( driver_st7789_t st7789,
uint8_t  brightness 
)

Set the backlight brightness of the ST7789 display.

Parameters
st7789Pointer to the ST7789 driver structure.
brightnessBrightness level (0-255, where 0 is off and 255 is full brightness).
Returns
True if successful, false if backlight control is not available.

This function controls the display backlight using PWM if a backlight pin was configured during initialization.

◆ driver_st7789_set_rotation()

bool driver_st7789_set_rotation ( driver_st7789_t st7789,
driver_st7789_rotation_t  rotation 
)

Set the rotation of the ST7789 display.

Parameters
st7789Pointer to the ST7789 driver structure.
rotationThe rotation mode to set.
Returns
True if successful, false otherwise.

This function configures the display rotation by setting the appropriate MADCTL register values. The rotation affects how pixel data is interpreted and displayed.

◆ driver_st7789_set_window()

bool driver_st7789_set_window ( driver_st7789_t st7789,
driver_st7789_rect_t  rect 
)

Set the display window for subsequent pixel data.

Parameters
st7789Pointer to the ST7789 driver structure.
rectRectangle defining the window area.
Returns
True if successful, false otherwise.

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.

◆ driver_st7789_update_rect()

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.

Parameters
st7789Pointer to the ST7789 driver structure.
rectRectangle defining the update area.
dataPointer to the pixel data buffer.
sizeSize of the pixel data in bytes.
Returns
True if successful, false otherwise.

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.

◆ driver_st7789_valid()

bool driver_st7789_valid ( const driver_st7789_t st7789)

Check if a ST7789 driver structure is valid.

Parameters
st7789Pointer to the ST7789 driver structure to validate.
Returns
True if the driver structure is valid, false otherwise.

This function performs basic validation of the ST7789 driver structure to ensure it has been properly initialized and contains valid configuration.

◆ driver_st7789_write_pixels()

bool driver_st7789_write_pixels ( driver_st7789_t st7789,
const uint8_t *  data,
size_t  size 
)

Send pixel data to the ST7789 display.

Parameters
st7789Pointer to the ST7789 driver structure.
dataPointer to the pixel data buffer.
sizeSize of the pixel data in bytes.
Returns
True if successful, false otherwise.

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().