ESP32-P4 Setup
The 8-DSI-TOUCH-A connects to ESP32-P4 via MIPI DSI 2-lane interface. This guide covers driver installation, backlight control, and basic configuration.
Prerequisites
Section titled “Prerequisites”- ESP-IDF v5.0 or newer installed
- ESP32-P4 development board (e.g., ESP32-P4-NANO)
- MIPI DSI cable (included with display)
Driver Installation
Section titled “Driver Installation”The display driver is available from the ESP Component Registry.
Add Component
Section titled “Add Component”idf.py add-dependency "waveshare/esp_lcd_jd9365_8"This adds the JD9365 LCD controller driver to your project’s dependencies.
Manual Installation
Section titled “Manual Installation”If you prefer manual installation:
- Clone the component repository
- Copy to your project’s
components/directory - Run
idf.py reconfigure
Display Initialization
Section titled “Display Initialization”Basic Setup
Section titled “Basic Setup”#include "esp_lcd_jd9365.h"#include "driver/i2c.h"
// Initialize the MIPI DSI busesp_lcd_dsi_bus_config_t bus_config = { .bus_id = 0, .num_data_lanes = 2, // 2-lane MIPI .phy_clk_src = LCD_CLK_SRC_DEFAULT, .lane_bit_rate_mbps = 500,};
esp_lcd_new_dsi_bus(&bus_config, &dsi_bus);With ESP32-P4-NANO BSP
Section titled “With ESP32-P4-NANO BSP”The BSP simplifies initialization:
#include "bsp/esp32_p4_nano.h"
void app_main(void){ // Initialize display with default settings bsp_display_start();
// Get LVGL display handle lv_disp_t *disp = bsp_display_get();}Backlight Control
Section titled “Backlight Control”The display backlight is controlled via I2C. The backlight controller is at address 0x45, with brightness register 0x86.
Direct I2C Control
Section titled “Direct I2C Control”#include "driver/i2c.h"
#define BACKLIGHT_I2C_ADDR 0x45#define BACKLIGHT_REG 0x86
void set_backlight(uint8_t brightness){ uint8_t data[2] = {BACKLIGHT_REG, brightness}; i2c_master_write_to_device(I2C_NUM_0, BACKLIGHT_I2C_ADDR, data, sizeof(data), pdMS_TO_TICKS(100));}
// Usageset_backlight(0xFF); // Maximum brightnessset_backlight(0x80); // 50% brightnessset_backlight(0x00); // OffBSP Functions
Section titled “BSP Functions”With the ESP32-P4-NANO BSP:
#include "bsp/esp32_p4_nano.h"
void configure_backlight(void){ // Initialize backlight subsystem bsp_display_brightness_init();
// Turn on at full brightness bsp_display_backlight_on();
// Set specific level (0-100) bsp_display_brightness_set(75);
// Turn off bsp_display_backlight_off();}Touch Configuration
Section titled “Touch Configuration”The GT9271 touch controller connects via I2C. The BSP handles touch initialization automatically.
Manual Touch Setup
Section titled “Manual Touch Setup”#include "esp_lcd_touch_gt911.h"
esp_lcd_touch_config_t touch_config = { .x_max = 800, .y_max = 1280, .rst_gpio_num = GPIO_NUM_NC, .int_gpio_num = TOUCH_INT_GPIO, .levels = { .reset = 0, .interrupt = 0, }, .flags = { .swap_xy = 0, .mirror_x = 0, .mirror_y = 0, },};
esp_lcd_touch_new_i2c_gt911(touch_io_handle, &touch_config, &touch_handle);Reading Touch Data
Section titled “Reading Touch Data”esp_lcd_touch_handle_t touch_handle;uint16_t x[10], y[10];uint8_t touch_cnt = 0;
esp_lcd_touch_read_data(touch_handle);esp_lcd_touch_get_coordinates(touch_handle, x, y, NULL, &touch_cnt, 10);
for (int i = 0; i < touch_cnt; i++) { printf("Touch %d: (%d, %d)\n", i, x[i], y[i]);}LVGL Integration
Section titled “LVGL Integration”Most ESP32-P4 projects use LVGL for graphics. The BSP integrates LVGL automatically.
Basic LVGL Example
Section titled “Basic LVGL Example”#include "lvgl.h"#include "bsp/esp32_p4_nano.h"
void app_main(void){ bsp_display_start();
// Create a simple label lv_obj_t *label = lv_label_create(lv_scr_act()); lv_label_set_text(label, "8-DSI-TOUCH-A\nESP32-P4"); lv_obj_center(label);}Display Specifications (ESP32-P4 Mode)
Section titled “Display Specifications (ESP32-P4 Mode)”| Parameter | Value |
|---|---|
| Interface | MIPI DSI 2-lane |
| Resolution | 800 × 1280 |
| Refresh Rate | Up to 60Hz |
| Color Depth | 24-bit RGB |
| Touch Points | 10 simultaneous |
Troubleshooting
Section titled “Troubleshooting”Display Not Initializing
Section titled “Display Not Initializing”- Verify
num_data_lanes = 2in bus config - Check MIPI cable seating
- Confirm 5V power to display
Backlight Not Responding
Section titled “Backlight Not Responding”- Verify I2C bus is initialized before backlight calls
- Check I2C address (0x45) and pull-up resistors
- Try direct I2C write to confirm communication
Touch Offset or Inverted
Section titled “Touch Offset or Inverted”Adjust touch configuration flags:
.flags = { .swap_xy = 1, // Swap X/Y if rotated 90° .mirror_x = 1, // Mirror if touch is horizontally flipped .mirror_y = 1, // Mirror if touch is vertically flipped},Resources
Section titled “Resources”- ESP32-P4-NANO Wiki - Board-specific documentation
- ESP Component Registry - Official component repository
- LVGL Documentation - Graphics library reference