|
ST7789V3 1.47 Inch LCD Driver
Public API reference for the ST7789V3 display driver
|
Public interface for the ST7789V3 display driver. More...
Data Structures | |
| struct | ST7789V3_Config |
| Runtime configuration and hardware binding for one display instance. More... | |
Enums and Types | |
Public state, mode, and callback types used by the driver. | |
| enum | GPIO_Pinstate { HIGH = 1 , LOW = 0 } |
| Logical output level used by GPIO control callbacks. More... | |
| enum | Trans_State { DATA = 1 , CMD = 0 } |
| Select whether the current SPI byte stream is command or pixel/data content. More... | |
| enum | Color_Mode { bit_12 = 0x03U , bit_16 = 0x05U , bit_18 = 0x06U } |
| Pixel format written to the display controller. More... | |
| enum | Inversion_Mode { INVON = 1 , INVOFF = 0 } |
| Display inversion mode selection. More... | |
| enum | Sleep_State { Asleep = 0 , Awake = 1 } |
| Sleep state selection for the display. More... | |
| enum | Orientation { Portrait = 0 , Landscape = 1 , Portrait_Inverted = 2 , Landscape_Inverted = 3 } |
| Logical display orientation used by SetRotation. More... | |
| enum | ST7789V3_State { ST7789_STATE_READY = 0 , ST7789_STATE_BUSY = 1 , ST7789_STATE_ERROR = 2 } |
| Driver transfer state used for DMA operations. More... | |
| typedef struct ST7789V3_Config | ST7789V3_Config |
| Forward declaration of the driver configuration structure. | |
| typedef void(* | ST7789V3_Callback) (ST7789V3_Config *config, void *user_data) |
| Callback signature used for DMA completion and error notifications. | |
Core Control API | |
Functions for initialization and controller-level display control. | |
| void | ST7789V3_init (ST7789V3_Config *config) |
| Initialize the display and apply the default startup sequence. | |
| int8_t | SetWindow (ST7789V3_Config *config, uint16_t X_Start, uint16_t X_End, uint16_t Y_Start, uint16_t Y_End) |
| Set the active drawing window on the display. | |
| int8_t | SetColorMode (ST7789V3_Config *config, Color_Mode bitdepth) |
| Set the controller pixel format. | |
| void | DISPLAYON (ST7789V3_Config *config) |
| Enable display output. | |
| void | DISPLAYOFF (ST7789V3_Config *config) |
| Disable display output. | |
| void | HardReset (ST7789V3_Config *config) |
| Toggle the hardware reset line using the driver's reset sequence. | |
| void | InvertDisplay (ST7789V3_Config *config, Inversion_Mode Inversion) |
| Enable or disable display inversion. | |
| void | SleepMode (ST7789V3_Config *config, Sleep_State sleepstate) |
| Put the display into sleep mode or wake it up. | |
Drawing API | |
Functions for rendering pixels, text, and basic shapes. | |
| int8_t | DrawPixel (ST7789V3_Config *config, uint16_t x, uint16_t y, uint32_t hexcolor) |
| Draw a single pixel using a 24-bit RGB888 input color. | |
| void | DrawChar (ST7789V3_Config *config, uint16_t x, uint16_t y, char user_char, uint32_t hexcolor, const FontDef *font) |
| Draw a single printable ASCII character. | |
| void | FillScreen (ST7789V3_Config *config, uint32_t hexcolor) |
| Fill the entire display with a single color. | |
| void | SetRotation (ST7789V3_Config *config, Orientation orientation) |
| Change the logical display rotation. | |
| void | DrawString (ST7789V3_Config *config, uint16_t x, uint16_t y, const char *str, uint32_t hexcolor, const FontDef *font) |
| Draw a null-terminated string. | |
| void | DrawLine (ST7789V3_Config *config, uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint32_t hexcolor) |
| Draw a line between two points using Bresenham's algorithm. | |
| void | DrawRectangle (ST7789V3_Config *config, uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint32_t hexcolor) |
| Draw an unfilled rectangle outline. | |
| void | DrawFilledRectangle (ST7789V3_Config *config, uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint32_t hexcolor) |
| Draw a filled rectangle. | |
| void | DrawCircle (ST7789V3_Config *config, uint16_t x_center, uint16_t y_center, uint16_t radius, uint32_t hexcolor) |
| Draw a circle outline using the midpoint circle algorithm. | |
| void | DrawFilledCircle (ST7789V3_Config *config, uint16_t x_center, uint16_t y_center, uint16_t radius, uint32_t hexcolor) |
| Draw a filled circle using the midpoint circle algorithm. | |
DMA API | |
Optional non-blocking transfer helpers. | |
| int8_t | ST7789V3_WriteBuffer_DMA (ST7789V3_Config *config, const uint8_t *buf, uint16_t len) |
| Start a non-blocking DMA write of pixel data to the display. | |
| void | ST7789V3_DMA_Complete (ST7789V3_Config *config) |
| Finish a successful DMA transfer and run the completion callback. | |
| void | ST7789V3_DMA_Error (ST7789V3_Config *config) |
| Finish a failed DMA transfer and run the error callback. | |
Controller Command Macros | |
Controller command values used by the ST7789V3 display. | |
| #define | ST7789V3_rst |
| #define | ST7789V3_backlight |
| #define | Sleep_Out 0x11U |
| #define | Sleep_In 0x10U |
| #define | Display_On_Register 0x29U |
| #define | Display_Off_Register 0x28U |
| #define | CASET 0x2AU |
| #define | RASET 0x2BU |
| #define | RAMWR 0x2CU |
| #define | COLMODE 0x3AU |
| #define | MADCTL 0x36U |
| #define | INVOFF_REG 0x20U |
| #define | INVON_REG 0x21U |
Color Constants | |
Predefined 24-bit RGB888 colors in 0xRRGGBB format. | |
| #define | BLACK 0x000000U |
| #define | WHITE 0xFFFFFFU |
| #define | RED 0xFF0000U |
| #define | GREEN 0x00FF00U |
| #define | BLUE 0x0000FFU |
| #define | YELLOW 0xFFFF00U |
| #define | CYAN 0x00FFFFU |
| #define | MAGENTA 0xFF00FFU |
| #define | ORANGE 0xFF6A00U |
| #define | PINK 0xFF69B4U |
| #define | PURPLE 0x800080U |
| #define | LIME 0x32FF00U |
| #define | NAVY 0x000080U |
| #define | DARK_GREEN 0x006400U |
| #define | MAROON 0x800000U |
| #define | OLIVE 0x808000U |
| #define | TEAL 0x008080U |
| #define | SILVER 0xC0C0C0U |
| #define | GRAY 0x808080U |
| #define | DARK_GRAY 0x404040U |
| #define | LIGHT_GRAY 0xD3D3D3U |
| #define | GOLD 0xFFD700U |
| #define | SKY_BLUE 0x87CEEBU |
Public interface for the ST7789V3 display driver.
| #define BLACK 0x000000U |
Black in RGB888 format.
| #define BLUE 0x0000FFU |
Blue in RGB888 format.
| #define CASET 0x2AU |
Column address set command.
| #define COLMODE 0x3AU |
Interface pixel format command.
| #define CYAN 0x00FFFFU |
Cyan in RGB888 format.
| #define DARK_GRAY 0x404040U |
Dark gray in RGB888 format.
| #define DARK_GREEN 0x006400U |
Dark green in RGB888 format.
| #define Display_Off_Register 0x28U |
Turn the display output off.
| #define Display_On_Register 0x29U |
Turn the display output on.
| #define GOLD 0xFFD700U |
Gold in RGB888 format.
| #define GRAY 0x808080U |
Gray in RGB888 format.
| #define GREEN 0x00FF00U |
Green in RGB888 format.
| #define INVOFF_REG 0x20U |
Disable display color inversion.
| #define INVON_REG 0x21U |
Enable display color inversion.
| #define LIGHT_GRAY 0xD3D3D3U |
Light gray in RGB888 format.
| #define LIME 0x32FF00U |
Lime in RGB888 format.
| #define MADCTL 0x36U |
Memory data access control command.
| #define MAGENTA 0xFF00FFU |
Magenta in RGB888 format.
| #define MAROON 0x800000U |
Maroon in RGB888 format.
| #define NAVY 0x000080U |
Navy in RGB888 format.
| #define OLIVE 0x808000U |
Olive in RGB888 format.
| #define ORANGE 0xFF6A00U |
Orange in RGB888 format.
| #define PINK 0xFF69B4U |
Pink in RGB888 format.
| #define PURPLE 0x800080U |
Purple in RGB888 format.
| #define RAMWR 0x2CU |
Memory write command.
| #define RASET 0x2BU |
Row address set command.
| #define RED 0xFF0000U |
Red in RGB888 format.
| #define SILVER 0xC0C0C0U |
Silver in RGB888 format.
| #define SKY_BLUE 0x87CEEBU |
Sky blue in RGB888 format.
| #define Sleep_In 0x10U |
Enter sleep mode command.
| #define Sleep_Out 0x11U |
Exit sleep mode command.
| #define ST7789V3_backlight |
Reserved placeholder for board-specific backlight mapping.
| #define ST7789V3_rst |
Reserved placeholder for board-specific reset mapping.
| #define TEAL 0x008080U |
Teal in RGB888 format.
| #define WHITE 0xFFFFFFU |
White in RGB888 format.
| #define YELLOW 0xFFFF00U |
Yellow in RGB888 format.
| typedef void(* ST7789V3_Callback) (ST7789V3_Config *config, void *user_data) |
Callback signature used for DMA completion and error notifications.
| config | Pointer to the active driver configuration. |
| user_data | Application-defined context pointer from ST7789V3_Config::callback_user_data. |
| enum Color_Mode |
| enum GPIO_Pinstate |
| enum Inversion_Mode |
| enum Orientation |
Logical display orientation used by SetRotation.
| Enumerator | |
|---|---|
| Portrait | Upright portrait orientation. |
| Landscape | 90-degree landscape orientation. |
| Portrait_Inverted | 180-degree portrait orientation. |
| Landscape_Inverted | 270-degree landscape orientation. |
| enum Sleep_State |
| enum ST7789V3_State |
| enum Trans_State |
| void DISPLAYOFF | ( | ST7789V3_Config * | config | ) |
Disable display output.
| config | Pointer to the active driver configuration. |
References Display_Off_Register.
| void DISPLAYON | ( | ST7789V3_Config * | config | ) |
Enable display output.
| config | Pointer to the active driver configuration. |
References Display_On_Register.
Referenced by ST7789V3_init().
| void DrawChar | ( | ST7789V3_Config * | config, |
| uint16_t | x, | ||
| uint16_t | y, | ||
| char | user_char, | ||
| uint32_t | hexcolor, | ||
| const FontDef * | font | ||
| ) |
Draw a single printable ASCII character.
| config | Pointer to the active driver configuration. |
| x | Leftmost X position of the character. |
| y | Topmost Y position of the character. |
| user_char | Printable ASCII character to draw. |
| hexcolor | Foreground color in 0xRRGGBB RGB888 format. |
| font | Pointer to the font definition used for rendering. |
References FontDef::bytes_per_row, FontDef::data, DrawPixel(), FontDef::height, and FontDef::width.
Referenced by DrawString().
| void DrawCircle | ( | ST7789V3_Config * | config, |
| uint16_t | x_center, | ||
| uint16_t | y_center, | ||
| uint16_t | radius, | ||
| uint32_t | hexcolor | ||
| ) |
Draw a circle outline using the midpoint circle algorithm.
| config | Pointer to the active driver configuration. |
| x_center | Center X coordinate. |
| y_center | Center Y coordinate. |
| radius | Circle radius in pixels. |
| hexcolor | Outline color in 0xRRGGBB RGB888 format. |
References DrawPixel().
| void DrawFilledCircle | ( | ST7789V3_Config * | config, |
| uint16_t | x_center, | ||
| uint16_t | y_center, | ||
| uint16_t | radius, | ||
| uint32_t | hexcolor | ||
| ) |
Draw a filled circle using the midpoint circle algorithm.
| config | Pointer to the active driver configuration. |
| x_center | Center X coordinate. |
| y_center | Center Y coordinate. |
| radius | Circle radius in pixels. |
| hexcolor | Fill color in 0xRRGGBB RGB888 format. |
| void DrawFilledRectangle | ( | ST7789V3_Config * | config, |
| uint16_t | x, | ||
| uint16_t | y, | ||
| uint16_t | width, | ||
| uint16_t | height, | ||
| uint32_t | hexcolor | ||
| ) |
Draw a filled rectangle.
| config | Pointer to the active driver configuration. |
| x | Top-left X coordinate. |
| y | Top-left Y coordinate. |
| width | Rectangle width in pixels. |
| height | Rectangle height in pixels. |
| hexcolor | Fill color in 0xRRGGBB RGB888 format. |
References ST7789V3_Config::LCD_Height, and ST7789V3_Config::LCD_Width.
| void DrawLine | ( | ST7789V3_Config * | config, |
| uint16_t | x0, | ||
| uint16_t | y0, | ||
| uint16_t | x1, | ||
| uint16_t | y1, | ||
| uint32_t | hexcolor | ||
| ) |
Draw a line between two points using Bresenham's algorithm.
| config | Pointer to the active driver configuration. |
| x0 | Starting X coordinate. |
| y0 | Starting Y coordinate. |
| x1 | Ending X coordinate. |
| y1 | Ending Y coordinate. |
| hexcolor | Line color in 0xRRGGBB RGB888 format. |
References DrawPixel().
Referenced by DrawRectangle().
| int8_t DrawPixel | ( | ST7789V3_Config * | config, |
| uint16_t | x, | ||
| uint16_t | y, | ||
| uint32_t | hexcolor | ||
| ) |
Draw a single pixel using a 24-bit RGB888 input color.
| config | Pointer to the active driver configuration. |
| x | Pixel X coordinate. |
| y | Pixel Y coordinate. |
| hexcolor | Color in 0xRRGGBB RGB888 format. |
0 on success, or -1 if the coordinates are outside the current logical display bounds. References DATA, HIGH, ST7789V3_Config::LCD_Height, ST7789V3_Config::LCD_Width, LOW, ST7789V3_Config::set_cs, ST7789V3_Config::set_dc, SetWindow(), and ST7789V3_Config::spi_write.
Referenced by DrawChar(), DrawCircle(), and DrawLine().
| void DrawRectangle | ( | ST7789V3_Config * | config, |
| uint16_t | x, | ||
| uint16_t | y, | ||
| uint16_t | width, | ||
| uint16_t | height, | ||
| uint32_t | hexcolor | ||
| ) |
Draw an unfilled rectangle outline.
| config | Pointer to the active driver configuration. |
| x | Top-left X coordinate. |
| y | Top-left Y coordinate. |
| width | Rectangle width in pixels. |
| height | Rectangle height in pixels. |
| hexcolor | Outline color in 0xRRGGBB RGB888 format. |
References DrawLine(), ST7789V3_Config::LCD_Height, and ST7789V3_Config::LCD_Width.
| void DrawString | ( | ST7789V3_Config * | config, |
| uint16_t | x, | ||
| uint16_t | y, | ||
| const char * | str, | ||
| uint32_t | hexcolor, | ||
| const FontDef * | font | ||
| ) |
Draw a null-terminated string.
| config | Pointer to the active driver configuration. |
| x | Starting X position of the first character. |
| y | Starting Y position of the first character. |
| str | Null-terminated string to draw. |
| hexcolor | Text color in 0xRRGGBB RGB888 format. |
| font | Pointer to the font definition used for rendering. |
\n for newline, \r for carriage return, and simple line wrapping when the next character would exceed the display width. References DrawChar(), FontDef::height, ST7789V3_Config::LCD_Width, and FontDef::width.
| void FillScreen | ( | ST7789V3_Config * | config, |
| uint32_t | hexcolor | ||
| ) |
Fill the entire display with a single color.
| config | Pointer to the active driver configuration. |
| hexcolor | Fill color in 0xRRGGBB RGB888 format. |
Fill the entire display with a single color.
References ST7789V3_Config::LCD_Height, ST7789V3_Config::LCD_Width, and SetWindow().
| void HardReset | ( | ST7789V3_Config * | config | ) |
Toggle the hardware reset line using the driver's reset sequence.
| config | Pointer to the active driver configuration. |
Toggle the hardware reset line using the driver's reset sequence.
References ST7789V3_Config::delay_ms, HIGH, LOW, and ST7789V3_Config::set_rst.
| void InvertDisplay | ( | ST7789V3_Config * | config, |
| Inversion_Mode | Inversion | ||
| ) |
Enable or disable display inversion.
| config | Pointer to the active driver configuration. |
| Inversion | Requested inversion mode. |
References ST7789V3_Config::Inversion_Mode, INVOFF_REG, INVON, and INVON_REG.
Referenced by ST7789V3_init().
| int8_t SetColorMode | ( | ST7789V3_Config * | config, |
| Color_Mode | bitdepth | ||
| ) |
Set the controller pixel format.
| config | Pointer to the active driver configuration. |
| bitdepth | Requested color mode. |
0 on success.References ST7789V3_Config::Bit_Depth, and COLMODE.
Referenced by ST7789V3_init().
| void SetRotation | ( | ST7789V3_Config * | config, |
| Orientation | orientation | ||
| ) |
Change the logical display rotation.
| config | Pointer to the active driver configuration. |
| orientation | Requested orientation. |
References ST7789V3_Config::Col_Offset, Landscape, Landscape_Inverted, ST7789V3_Config::LCD_Height, ST7789V3_Config::LCD_Width, MADCTL, Portrait, Portrait_Inverted, and ST7789V3_Config::Row_Offset.
| int8_t SetWindow | ( | ST7789V3_Config * | config, |
| uint16_t | X_Start, | ||
| uint16_t | X_End, | ||
| uint16_t | Y_Start, | ||
| uint16_t | Y_End | ||
| ) |
Set the active drawing window on the display.
| config | Pointer to the active driver configuration. |
| X_Start | Inclusive starting column in logical display coordinates. |
| X_End | Inclusive ending column in logical display coordinates. |
| Y_Start | Inclusive starting row in logical display coordinates. |
| Y_End | Inclusive ending row in logical display coordinates. |
0 on success.References CASET, CMD, ST7789V3_Config::Col_Offset, DATA, HIGH, LOW, RAMWR, RASET, ST7789V3_Config::Row_Offset, ST7789V3_Config::set_cs, ST7789V3_Config::set_dc, and ST7789V3_Config::spi_write.
Referenced by DrawPixel(), and FillScreen().
| void SleepMode | ( | ST7789V3_Config * | config, |
| Sleep_State | sleepstate | ||
| ) |
| void ST7789V3_DMA_Complete | ( | ST7789V3_Config * | config | ) |
Finish a successful DMA transfer and run the completion callback.
| config | Pointer to the active driver configuration. |
References ST7789V3_Config::callback_user_data, HIGH, ST7789V3_Config::set_cs, ST7789_STATE_READY, ST7789V3_Config::State, and ST7789V3_Config::tx_complete_callback.
| void ST7789V3_DMA_Error | ( | ST7789V3_Config * | config | ) |
Finish a failed DMA transfer and run the error callback.
| config | Pointer to the active driver configuration. |
References ST7789V3_Config::callback_user_data, HIGH, ST7789V3_Config::set_cs, ST7789_STATE_ERROR, ST7789V3_Config::State, and ST7789V3_Config::tx_error_callback.
| void ST7789V3_init | ( | ST7789V3_Config * | config | ) |
Initialize the display and apply the default startup sequence.
| config | Pointer to a configured driver instance. |
References bit_16, ST7789V3_Config::Col_Offset, ST7789V3_Config::delay_ms, DISPLAYON(), HIGH, ST7789V3_Config::Inversion_Mode, InvertDisplay(), INVON, ST7789V3_Config::LCD_Height, ST7789V3_Config::LCD_Width, LOW, ST7789V3_Config::Row_Offset, ST7789V3_Config::set_rst, SetColorMode(), and Sleep_Out.
| int8_t ST7789V3_WriteBuffer_DMA | ( | ST7789V3_Config * | config, |
| const uint8_t * | buf, | ||
| uint16_t | len | ||
| ) |
Start a non-blocking DMA write of pixel data to the display.
| config | Pointer to the active driver configuration. |
| buf | Pointer to the pixel data buffer. |
| len | Number of bytes to transfer. |
0 on success, -1 if DMA support is unavailable or the driver is not ready, or another negative value from the platform DMA callback.References DATA, HIGH, LOW, ST7789V3_Config::set_cs, ST7789V3_Config::set_dc, ST7789V3_Config::spi_write_dma, ST7789_STATE_BUSY, ST7789_STATE_ERROR, ST7789_STATE_READY, and ST7789V3_Config::State.