# ESP LCD ST7121
Implementation of the ST7121 LCD controller with the ESP-IDF `esp_lcd` component.
| LCD controller | Communication interface | Component name |
| :------------: | :---------------------: | :------------: |
| ST7121 | MIPI-DSI | esp_lcd_st7121 |
**Note**: MIPI-DSI interface requires an ESP-IDF target with MIPI-DSI support, such as ESP32-P4.
## Add to project
```bash
idf.py add-dependency "m5stack/esp_lcd_st7121^1.0.0"
```
Alternatively, add this dependency to `idf_component.yml`:
```yaml
dependencies:
m5stack/esp_lcd_st7121: ^1.0.0
```
## Example use
```c
esp_lcd_dsi_bus_handle_t mipi_dsi_bus = NULL;
esp_lcd_dsi_bus_config_t bus_config = ST7121_PANEL_BUS_DSI_2CH_CONFIG();
ESP_ERROR_CHECK(esp_lcd_new_dsi_bus(&bus_config, &mipi_dsi_bus));
esp_lcd_panel_io_handle_t mipi_dbi_io = NULL;
esp_lcd_dbi_io_config_t dbi_config = ST7121_PANEL_IO_DBI_CONFIG();
ESP_ERROR_CHECK(esp_lcd_new_panel_io_dbi(mipi_dsi_bus, &dbi_config, &mipi_dbi_io));
esp_lcd_dpi_panel_config_t dpi_config = ST7121_1560_720_PANEL_60HZ_DPI_CONFIG(LCD_COLOR_PIXEL_FORMAT_RGB565);
st7121_vendor_config_t vendor_config = {
.mipi_config = {
.dsi_bus = mipi_dsi_bus,
.dpi_config = &dpi_config,
},
};
esp_lcd_panel_dev_config_t panel_config = {
.reset_gpio_num = -1,
.rgb_ele_order = LCD_RGB_ELEMENT_ORDER_RGB,
.bits_per_pixel = 16,
.vendor_config = &vendor_config,
};
esp_lcd_panel_handle_t panel_handle = NULL;
ESP_ERROR_CHECK(esp_lcd_new_panel_st7121(mipi_dbi_io, &panel_config, &panel_handle));
ESP_ERROR_CHECK(esp_lcd_panel_reset(panel_handle));
ESP_ERROR_CHECK(esp_lcd_panel_init(panel_handle));
```
ede55e9284668d0b0c541a973c83ef90438a6199
idf.py add-dependency "m5stack/esp_lcd_st7121^1.0.0"