Fix ILI9488 init function | Fix little ILI9488 display artifacts | auto-dma by default for all esp devices | ESP32-S3 support added | updated to be compatible with esp-idf =< 4 and >= 5 versions
This commit is contained in:
parent
26fe6e7703
commit
0b55ade07e
23 changed files with 160 additions and 87 deletions
|
@ -52,15 +52,16 @@ static void ili9488_send_color(void * data, uint16_t length);
|
|||
**********************/
|
||||
// From github.com/jeremyjh/ESP32_TFT_library
|
||||
// From github.com/mvturnho/ILI9488-lvgl-ESP32-WROVER-B
|
||||
// From https://github.com/lvgl/lvgl_esp32_drivers/issues/133 -> correction about displaying collors
|
||||
void ili9488_init(void)
|
||||
{
|
||||
lcd_init_cmd_t ili_init_cmds[]={
|
||||
{ILI9488_CMD_SLEEP_OUT, {0x00}, 0x80},
|
||||
{ILI9488_CMD_POSITIVE_GAMMA_CORRECTION, {0x00, 0x03, 0x09, 0x08, 0x16, 0x0A, 0x3F, 0x78, 0x4C, 0x09, 0x0A, 0x08, 0x16, 0x1A, 0x0F}, 15},
|
||||
{ILI9488_CMD_NEGATIVE_GAMMA_CORRECTION, {0x00, 0x16, 0x19, 0x03, 0x0F, 0x05, 0x32, 0x45, 0x46, 0x04, 0x0E, 0x0D, 0x35, 0x37, 0x0F}, 15},
|
||||
{ILI9488_CMD_POSITIVE_GAMMA_CORRECTION, {0x0F, 0x1F, 0x1C, 0x0C, 0x0F, 0x08, 0x48, 0x98, 0x37, 0x0A, 0x13, 0x04, 0x11, 0x0D, 0x00}, 15},
|
||||
{ILI9488_CMD_NEGATIVE_GAMMA_CORRECTION, {0x0F, 0x32, 0x2E, 0x0B, 0x0D, 0x05, 0x47, 0x75, 0x37, 0x06, 0x10, 0x03, 0x24, 0x20, 0x00}, 15}
|
||||
{ILI9488_CMD_POWER_CONTROL_1, {0x17, 0x15}, 2},
|
||||
{ILI9488_CMD_POWER_CONTROL_2, {0x41}, 1},
|
||||
{ILI9488_CMD_VCOM_CONTROL_1, {0x00, 0x12, 0x80}, 3},
|
||||
{ILI9488_CMD_POWER_CONTROL_NORMAL_3, {0x44}, 1},
|
||||
{ILI9488_CMD_MEMORY_ACCESS_CONTROL, {(0x20 | 0x08)}, 1},
|
||||
{ILI9488_CMD_COLMOD_PIXEL_FORMAT_SET, {0x66}, 1},
|
||||
{ILI9488_CMD_INTERFACE_MODE_CONTROL, {0x00}, 1},
|
||||
|
@ -68,6 +69,7 @@ void ili9488_init(void)
|
|||
{ILI9488_CMD_DISPLAY_INVERSION_CONTROL, {0x02}, 1},
|
||||
{ILI9488_CMD_DISPLAY_FUNCTION_CONTROL, {0x02, 0x02}, 2},
|
||||
{ILI9488_CMD_SET_IMAGE_FUNCTION, {0x00}, 1},
|
||||
{ILI9488_CMD_DISP_INVERSION_OFF, {0}, 0},
|
||||
{ILI9488_CMD_WRITE_CTRL_DISPLAY, {0x28}, 1},
|
||||
{ILI9488_CMD_WRITE_DISPLAY_BRIGHTNESS, {0x7F}, 1},
|
||||
{ILI9488_CMD_ADJUST_CONTROL_3, {0xA9, 0x51, 0x2C, 0x02}, 4},
|
||||
|
@ -76,25 +78,33 @@ void ili9488_init(void)
|
|||
};
|
||||
|
||||
//Initialize non-SPI GPIOs
|
||||
gpio_pad_select_gpio(ILI9488_DC);
|
||||
#ifdef ESP_IDF_VERSION_MAJOR >= 5
|
||||
esp_rom_gpio_pad_select_gpio(ILI9488_DC);
|
||||
#else
|
||||
gpio_pad_select_gpio(ILI9488_DC);
|
||||
#endif
|
||||
gpio_set_direction(ILI9488_DC, GPIO_MODE_OUTPUT);
|
||||
|
||||
#if ILI9488_USE_RST
|
||||
gpio_pad_select_gpio(ILI9488_RST);
|
||||
#ifdef ESP_IDF_VERSION_MAJOR >= 5
|
||||
esp_rom_gpio_pad_select_gpio(ILI9488_RST);
|
||||
#else
|
||||
gpio_pad_select_gpio(ILI9488_RST);
|
||||
#endif
|
||||
gpio_set_direction(ILI9488_RST, GPIO_MODE_OUTPUT);
|
||||
|
||||
//Reset the display
|
||||
gpio_set_level(ILI9488_RST, 0);
|
||||
vTaskDelay(100 / portTICK_RATE_MS);
|
||||
vTaskDelay(100 / portTICK_DELAY_MS);
|
||||
gpio_set_level(ILI9488_RST, 1);
|
||||
vTaskDelay(100 / portTICK_RATE_MS);
|
||||
vTaskDelay(100 / portTICK_DELAY_MS);
|
||||
#endif
|
||||
|
||||
ESP_LOGI(TAG, "ILI9488 initialization.");
|
||||
|
||||
// Exit sleep
|
||||
ili9488_send_cmd(0x01); /* Software reset */
|
||||
vTaskDelay(100 / portTICK_RATE_MS);
|
||||
vTaskDelay(100 / portTICK_DELAY_MS);
|
||||
|
||||
//Send all the commands
|
||||
uint16_t cmd = 0;
|
||||
|
@ -102,7 +112,7 @@ void ili9488_init(void)
|
|||
ili9488_send_cmd(ili_init_cmds[cmd].cmd);
|
||||
ili9488_send_data(ili_init_cmds[cmd].data, ili_init_cmds[cmd].databytes&0x1F);
|
||||
if (ili_init_cmds[cmd].databytes & 0x80) {
|
||||
vTaskDelay(100 / portTICK_RATE_MS);
|
||||
vTaskDelay(100 / portTICK_DELAY_MS);
|
||||
}
|
||||
cmd++;
|
||||
}
|
||||
|
@ -111,6 +121,7 @@ void ili9488_init(void)
|
|||
}
|
||||
|
||||
// Flush function based on mvturnho repo
|
||||
// https://github.com/lvgl/lvgl_esp32_drivers/issues/116 -> heap +3 to avoid display artifacts
|
||||
void ili9488_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * color_map)
|
||||
{
|
||||
uint32_t size = lv_area_get_width(area) * lv_area_get_height(area);
|
||||
|
@ -118,7 +129,7 @@ void ili9488_flush(lv_disp_drv_t * drv, const lv_area_t * area, lv_color_t * col
|
|||
lv_color16_t *buffer_16bit = (lv_color16_t *) color_map;
|
||||
uint8_t *mybuf;
|
||||
do {
|
||||
mybuf = (uint8_t *) heap_caps_malloc(3 * size * sizeof(uint8_t), MALLOC_CAP_DMA);
|
||||
mybuf = (uint8_t *) heap_caps_malloc(3 * size * sizeof(uint8_t) + 3, MALLOC_CAP_DMA);
|
||||
if (mybuf == NULL) ESP_LOGW(TAG, "Could not allocate enough DMA memory!");
|
||||
} while (mybuf == NULL);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue