# driver_ST7789 C++ driver for the **ST7789 SPI LCD panel** (320×240, RGB565) on ESP32, designed for the [ESP-IDF Component Registry](https://components.espressif.com/). Inherits from [`andresragot/driver_lcd`](https://github.com/andresragot/driver_lcd). ## Features - SPI interface at 80 MHz pixel clock - Asynchronous frame transfer with DMA and completion callback - Vsync-synchronized rendering with FreeRTOS semaphore - Automatic display orientation (swap XY, mirror Y, color inversion) ## Requirements - ESP-IDF **>= 5.4.1** - Target: **ESP32, ESP32-S2, ESP32-S3, ESP32-C3, ESP32-P4** ## Installation Add the dependency to your project's `idf_component.yml`: ```yaml dependencies: andresragot/driver_ST7789: "^1.0.0" ``` Then run `idf.py build` — the component manager will download it and its dependency (`driver_lcd`) automatically. ## Usage ```cpp #include "Driver_ST7789.hpp" // Default constructor initializes with GPIO1 (reset) and GPIO15 (backlight) Ragot::Driver_ST7789 display; // Or initialize manually with custom pins Ragot::Driver_ST7789 display; display.init(GPIO_NUM_1, GPIO_NUM_15); // Send a frame buffer to the panel display.send_frame_buffer(my_frame_buffer); // Clean up display.deinit(); ``` ## API | Method | Description | |---|---| | `Driver_ST7789()` | Constructor — calls `init()` with default pins | | `init(reset_pin, bk_pin)` | Initialize SPI bus, panel IO, and transfer callback | | `deinit()` | Release panel handle and semaphore | | `send_frame_buffer(buf)` | Wait for transfer done, then draw the frame buffer | | `set_pixel(x, y, color)` | Not implemented — returns `ESP_FAIL` | ## Panel Specifications | Parameter | Value | |---|---| | Resolution | 320 × 240 | | Color format | RGB565 (16-bit) | | Interface | SPI (SPI3_HOST) | | SPI clock | 80 MHz | | Transfer queue | 10 deep | | Orientation | Landscape (XY swapped, Y mirrored) | ## Default Pin Mapping | Signal | GPIO | |---|---| | MOSI | 4 | | SCLK | 5 | | CS | 3 | | DC | 2 | | Reset | 1 | ## Dependencies - [`andresragot/driver_lcd`](https://github.com/andresragot/driver_lcd) — Base LCD driver class ## License MIT — see [LICENSE](LICENSE) for details. MIT — see [LICENSE](LICENSE) for details.
idf.py add-dependency "andresragot/driver_st7789^1.0.0"