mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-03 20:54:32 +02:00
lcd: support model NT35510 in example
This commit is contained in:
@@ -19,7 +19,7 @@ This example uses the [esp_timer](https://docs.espressif.com/projects/esp-idf/en
|
||||
### Hardware Required
|
||||
|
||||
* An ESP development board
|
||||
* An Intel 8080 interfaced (so called MCU interface or parallel interface) LCD
|
||||
* An Intel 8080 interfaced (so called MCU interface or parallel interface) LCD (this example can use ST7789 or NT35510)
|
||||
* An USB cable for power supply and programming
|
||||
|
||||
### Hardware Connection
|
||||
@@ -58,6 +58,8 @@ Run `idf.py set-target <target-name>` to select one supported target that can ru
|
||||
|
||||
Run `idf.py menuconfig` to open a terminal UI where you can tune specific configuration for this example in the `Example Configuration` menu.
|
||||
|
||||
* `i80 LCD controller model`: Choose the LCD model to use by the example. If you choose `NT35510`, there will be another relevant configuration `NT35510 Data Width`, to choose the data line width for your NT35510 LCD module.
|
||||
|
||||
* `Allocate color data from PSRAM`: Select this option if you want to allocate the LVGL draw buffers from PSRAM.
|
||||
|
||||
Run `idf.py -p PORT build flash monitor` to build, flash and monitor the project. A fancy animation will show up on the LCD as expected.
|
||||
|
@@ -8,4 +8,38 @@ menu "Example Configuration"
|
||||
Enable this option if you wish to allocate the color buffer used by LVGL from PSRAM.
|
||||
Unmatched PSRAM band width with LCD requirement can lead to blurred image display.
|
||||
|
||||
choice EXAMPLE_LCD_I80_CONTROLLER_MODEL
|
||||
prompt "i80 LCD controller model"
|
||||
default EXAMPLE_LCD_I80_CONTROLLER_ST7789
|
||||
help
|
||||
Select LCD controller model
|
||||
|
||||
config EXAMPLE_LCD_I80_CONTROLLER_ST7789
|
||||
bool "ST7789"
|
||||
|
||||
config EXAMPLE_LCD_I80_CONTROLLER_NT35510
|
||||
bool "NT35510"
|
||||
endchoice
|
||||
|
||||
if EXAMPLE_LCD_I80_CONTROLLER_NT35510
|
||||
choice EXAMPLE_LCD_NT35510_DATA_WIDTH
|
||||
prompt "NT35510 Data Width"
|
||||
default EXAMPLE_LCD_NT35510_DATA_WIDTH_8
|
||||
help
|
||||
Select NT35510 Data Width (8 or 16), a.k.a, the number of data lines.
|
||||
|
||||
config EXAMPLE_LCD_NT35510_DATA_WIDTH_8
|
||||
bool "8"
|
||||
|
||||
config EXAMPLE_LCD_NT35510_DATA_WIDTH_16
|
||||
bool "16"
|
||||
endchoice
|
||||
|
||||
endif
|
||||
|
||||
config EXAMPLE_LCD_I80_BUS_WIDTH
|
||||
int
|
||||
default 16 if EXAMPLE_LCD_NT35510_DATA_WIDTH_16
|
||||
default 8
|
||||
|
||||
endmenu
|
||||
|
@@ -38,6 +38,16 @@ static const char *TAG = "example";
|
||||
#define EXAMPLE_PIN_NUM_DATA5 11
|
||||
#define EXAMPLE_PIN_NUM_DATA6 12
|
||||
#define EXAMPLE_PIN_NUM_DATA7 13
|
||||
#if CONFIG_EXAMPLE_LCD_I80_BUS_WIDTH > 8
|
||||
#define EXAMPLE_PIN_NUM_DATA8 14
|
||||
#define EXAMPLE_PIN_NUM_DATA9 15
|
||||
#define EXAMPLE_PIN_NUM_DATA10 16
|
||||
#define EXAMPLE_PIN_NUM_DATA11 17
|
||||
#define EXAMPLE_PIN_NUM_DATA12 18
|
||||
#define EXAMPLE_PIN_NUM_DATA13 19
|
||||
#define EXAMPLE_PIN_NUM_DATA14 20
|
||||
#define EXAMPLE_PIN_NUM_DATA15 21
|
||||
#endif
|
||||
#define EXAMPLE_PIN_NUM_PCLK 5
|
||||
#define EXAMPLE_PIN_NUM_CS 3
|
||||
#define EXAMPLE_PIN_NUM_DC 4
|
||||
@@ -48,8 +58,13 @@ static const char *TAG = "example";
|
||||
#define EXAMPLE_LCD_H_RES 240
|
||||
#define EXAMPLE_LCD_V_RES 280
|
||||
// Bit number used to represent command and parameter
|
||||
#if CONFIG_EXAMPLE_LCD_I80_CONTROLLER_ST7789
|
||||
#define EXAMPLE_LCD_CMD_BITS 8
|
||||
#define EXAMPLE_LCD_PARAM_BITS 8
|
||||
#elif CONFIG_EXAMPLE_LCD_I80_CONTROLLER_NT35510
|
||||
#define EXAMPLE_LCD_CMD_BITS 16
|
||||
#define EXAMPLE_LCD_PARAM_BITS 16
|
||||
#endif
|
||||
|
||||
#define EXAMPLE_LVGL_TICK_PERIOD_MS 2
|
||||
|
||||
@@ -110,8 +125,18 @@ void app_main(void)
|
||||
EXAMPLE_PIN_NUM_DATA5,
|
||||
EXAMPLE_PIN_NUM_DATA6,
|
||||
EXAMPLE_PIN_NUM_DATA7,
|
||||
#if CONFIG_EXAMPLE_LCD_I80_BUS_WIDTH > 8
|
||||
EXAMPLE_PIN_NUM_DATA8,
|
||||
EXAMPLE_PIN_NUM_DATA9,
|
||||
EXAMPLE_PIN_NUM_DATA10,
|
||||
EXAMPLE_PIN_NUM_DATA11,
|
||||
EXAMPLE_PIN_NUM_DATA12,
|
||||
EXAMPLE_PIN_NUM_DATA13,
|
||||
EXAMPLE_PIN_NUM_DATA14,
|
||||
EXAMPLE_PIN_NUM_DATA15,
|
||||
#endif
|
||||
},
|
||||
.bus_width = 8,
|
||||
.bus_width = CONFIG_EXAMPLE_LCD_I80_BUS_WIDTH,
|
||||
.max_transfer_bytes = EXAMPLE_LCD_H_RES * 100 * sizeof(uint16_t),
|
||||
.psram_trans_align = EXAMPLE_PSRAM_DATA_ALIGNMENT,
|
||||
.sram_trans_align = 4,
|
||||
@@ -135,18 +160,34 @@ void app_main(void)
|
||||
};
|
||||
ESP_ERROR_CHECK(esp_lcd_new_panel_io_i80(i80_bus, &io_config, &io_handle));
|
||||
|
||||
ESP_LOGI(TAG, "Install LCD driver of st7789");
|
||||
esp_lcd_panel_handle_t panel_handle = NULL;
|
||||
#if CONFIG_EXAMPLE_LCD_I80_CONTROLLER_ST7789
|
||||
ESP_LOGI(TAG, "Install LCD driver of st7789");
|
||||
esp_lcd_panel_dev_config_t panel_config = {
|
||||
.reset_gpio_num = EXAMPLE_PIN_NUM_RST,
|
||||
.color_space = ESP_LCD_COLOR_SPACE_RGB,
|
||||
.bits_per_pixel = 16,
|
||||
};
|
||||
ESP_ERROR_CHECK(esp_lcd_new_panel_st7789(io_handle, &panel_config, &panel_handle));
|
||||
#elif CONFIG_EXAMPLE_LCD_I80_CONTROLLER_NT35510
|
||||
ESP_LOGI(TAG, "Install LCD driver of nt35510");
|
||||
esp_lcd_panel_dev_config_t panel_config = {
|
||||
.reset_gpio_num = EXAMPLE_PIN_NUM_RST,
|
||||
.color_space = ESP_LCD_COLOR_SPACE_BGR,
|
||||
.bits_per_pixel = 16,
|
||||
};
|
||||
ESP_ERROR_CHECK(esp_lcd_new_panel_nt35510(io_handle, &panel_config, &panel_handle));
|
||||
#endif
|
||||
|
||||
esp_lcd_panel_reset(panel_handle);
|
||||
esp_lcd_panel_init(panel_handle);
|
||||
// Set inversion, x/y coordinate order, x/y mirror according to your LCD module spec
|
||||
#if CONFIG_EXAMPLE_LCD_I80_CONTROLLER_ST7789
|
||||
esp_lcd_panel_invert_color(panel_handle, true);
|
||||
#elif CONFIG_EXAMPLE_LCD_I80_CONTROLLER_NT35510
|
||||
esp_lcd_panel_swap_xy(panel_handle, true);
|
||||
esp_lcd_panel_mirror(panel_handle, true, false);
|
||||
#endif
|
||||
// the gap is LCD panel specific, even panels with the same driver IC, can have different gap value
|
||||
esp_lcd_panel_set_gap(panel_handle, 0, 20);
|
||||
|
||||
|
Reference in New Issue
Block a user