Arduino library for TFT displays based on the Sitronix ST7789 controller.
| Interface | Status | Notes |
|---|---|---|
| SPI, 4-Wires, Buffered | ✔️ | Works with local RGB565 buffer for fast rendering. |
- Local framebuffer for efficient rendering
- RGB565 color format (16-bit color)
- Full Adafruit GFX compatibility
- SPI interface with configurable speed
- Rotation support
- Display brightness control
- Display inversion control
#include <st7789.h>
#include <SPI.h>
// Display dimensions
#define WIDTH 240
#define HEIGHT 320
// Pin definitions
#define PIN_CS 10
#define PIN_DC 9
#define PIN_RES 8
// SPI speed (Hz)
#define SPI_SPEED 40000000
// Buffer for framebuffer (RGB565: 2 bytes per pixel)
uint8_t display_buffer[WIDTH * HEIGHT * 2];
// Create display object
st7789 display(WIDTH, HEIGHT);
void setup() {
// Initialize SPI
SPI.begin();
// Setup display
display.setup(SPI, SPI_SPEED, PIN_CS, PIN_DC, PIN_RES, display_buffer);
// Clear display
display.clear();
// Draw something
display.fillScreen(ST77XX_BLACK);
display.setTextColor(ST77XX_WHITE);
display.setTextSize(2);
display.setCursor(10, 10);
display.print("Hello, ST7789!");
// Send buffer to display
display.display();
}
void loop() {
// Your code here
}