Code Monkey home page Code Monkey logo

esp_lcd_ili9488's Introduction

esp_lcd driver for ILI9488 displays

This component provides an implementation of the ILI9488 LCD controller using the esp_lcd component APIs.

LCD controller Communication interface Component name Link to datasheet
ILI9488 SPI or Intel 8080 esp_lcd_ili9488 Specification

Note on supported communication interfaces

When using the SPI interface it is required to use 18-bit color depth mode as below:

    const esp_lcd_panel_dev_config_t lcd_config = 
    {
    ...
        .bits_per_pixel = 18,
    ...
    };

When using the Intel 8080 (Parallel) interface the 16-bit color depth mode should be used.

Display Reset pin

If the display requires the usage of a RESET pin during the initialization process be sure to configure it as below:

    const esp_lcd_panel_dev_config_t lcd_config = 
    {
        .reset_gpio_num = CONFIG_TFT_RESET_PIN,
        ....

If the display does not require this pin set this value to GPIO_NUM_NC (-1).

Using this component in your project

This package can be added to your project in two ways:

  1. Using Espressif's component service as:
dependencies:
  atanisoft/esp_lcd_ili9488: "~1.0.0"
  1. Using the git repository directly:
dependencies:
  esp_lcd_ili9488:
    git: https://github.com/atanisoft/esp_lcd_ili9488.git

For more information on the usage of the idf_component.yml file please refer to Espressif's documentation.

Supported platforms

At this time testing is limited to ESP32 and ESP32-S3, other ESP32 variants should work but are not tested.

Required sdkconfig entries

This driver converts the color data from 16-bit to 18-bit as part of the draw_bitmap callback. Therefore it is required to set CONFIG_LV_COLOR_DEPTH_16=y in your sdkconfig. In the future other color depths may be supported.

esp_lcd_ili9488's People

Contributors

atanisoft avatar jacobvc avatar meibao-real avatar nebkat avatar nikhil-robinson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

esp_lcd_ili9488's Issues

Compile

How can I use this? I download this repo and should it compile as it is?

About the horizontal screen display problem

  Hello, your driver successfully drives my LCD screen, but I encountered some problems. The screen will be distorted when switching to landscape mode.The MCU I use is ESP32S3, and the lvgl version is 8.3.

#define EXAMPLE_PIN_NUM_SCLK           14
#define EXAMPLE_PIN_NUM_MOSI           15
#define EXAMPLE_PIN_NUM_MISO           13
#define EXAMPLE_PIN_NUM_LCD_DC         16
#define EXAMPLE_PIN_NUM_LCD_RST        17
#define EXAMPLE_PIN_NUM_LCD_CS         18
#define EXAMPLE_PIN_NUM_BK_LIGHT       2
#define EXAMPLE_PIN_NUM_TOUCH_CS       15

static const int DISPLAY_HORIZONTAL_PIXELS = 320;
static const int DISPLAY_VERTICAL_PIXELS = 480;
static const int DISPLAY_COMMAND_BITS = 8;
static const int DISPLAY_PARAMETER_BITS = 8;
static const unsigned int DISPLAY_REFRESH_HZ = 40000000;
static const int DISPLAY_SPI_QUEUE_LEN = 10;
static const int SPI_MAX_TRANSFER_SIZE = 32768;

static const size_t LV_BUFFER_SIZE = DISPLAY_HORIZONTAL_PIXELS * 25;

static esp_lcd_panel_io_handle_t lcd_io_handle = NULL;
static esp_lcd_panel_handle_t lcd_handle = NULL;
static lv_disp_draw_buf_t lv_disp_buf;
static lv_disp_drv_t lv_disp_drv;
static lv_disp_t *lv_display = NULL;

static const char *TAG = "disp";

static bool notify_lvgl_flush_ready(esp_lcd_panel_io_handle_t panel_io,
    esp_lcd_panel_io_event_data_t *edata, void *user_ctx)
{
    lv_disp_drv_t *disp_driver = (lv_disp_drv_t *)user_ctx;
    lv_disp_flush_ready(disp_driver);
    return false;
}

static void lvgl_flush_cb(lv_disp_drv_t *drv, const lv_area_t *area, lv_color_t *color_map)
{
    esp_lcd_panel_handle_t panel_handle = (esp_lcd_panel_handle_t) drv->user_data;

    int offsetx1 = area->x1;
    int offsetx2 = area->x2;
    int offsety1 = area->y1;
    int offsety2 = area->y2;
    esp_lcd_panel_draw_bitmap(panel_handle, offsetx1, offsety1, offsetx2 + 1, offsety2 + 1, color_map);
}

void disp_init()
{
    ESP_LOGI(TAG, "Initializing SPI bus (MOSI:%d, MISO:%d, CLK:%d)",
             EXAMPLE_PIN_NUM_MOSI, EXAMPLE_PIN_NUM_MISO, EXAMPLE_PIN_NUM_SCLK);
    spi_bus_config_t bus =
    {
        .mosi_io_num = EXAMPLE_PIN_NUM_MOSI,
        .miso_io_num = EXAMPLE_PIN_NUM_MISO,
        .sclk_io_num = EXAMPLE_PIN_NUM_SCLK,
        .quadwp_io_num = GPIO_NUM_NC,
        .quadhd_io_num = GPIO_NUM_NC,
        .data4_io_num = GPIO_NUM_NC,
        .data5_io_num = GPIO_NUM_NC,
        .data6_io_num = GPIO_NUM_NC,
        .data7_io_num = GPIO_NUM_NC,
        .max_transfer_sz = SPI_MAX_TRANSFER_SIZE,
        .flags = SPICOMMON_BUSFLAG_SCLK | SPICOMMON_BUSFLAG_MISO |
                 SPICOMMON_BUSFLAG_MOSI | SPICOMMON_BUSFLAG_MASTER,
        .intr_flags = ESP_INTR_FLAG_LOWMED | ESP_INTR_FLAG_IRAM
    };

    ESP_ERROR_CHECK(spi_bus_initialize(SPI2_HOST, &bus, SPI_DMA_CH_AUTO));

        const esp_lcd_panel_io_spi_config_t io_config = 
    {
        .cs_gpio_num = EXAMPLE_PIN_NUM_LCD_CS,
        .dc_gpio_num = EXAMPLE_PIN_NUM_LCD_DC,
        .spi_mode = 0,
        .pclk_hz = DISPLAY_REFRESH_HZ,
        .trans_queue_depth = DISPLAY_SPI_QUEUE_LEN,
        .on_color_trans_done = notify_lvgl_flush_ready,
        .user_ctx = &lv_disp_drv,
        .lcd_cmd_bits = DISPLAY_COMMAND_BITS,
        .lcd_param_bits = DISPLAY_PARAMETER_BITS,
        .flags =
        {
            .dc_low_on_data = 0,
            .octal_mode = 0,
            .sio_mode = 0,
            .lsb_first = 0,
            .cs_high_active = 0
        }
    };

    const esp_lcd_panel_dev_config_t lcd_config = 
    {
        .reset_gpio_num = EXAMPLE_PIN_NUM_LCD_RST,
        .color_space = LCD_RGB_ELEMENT_ORDER_RGB,
        .bits_per_pixel = 18,
        .flags =
        {
            .reset_active_high = 0
        },
        .vendor_config = NULL
    };

    ESP_ERROR_CHECK(
        esp_lcd_new_panel_io_spi((esp_lcd_spi_bus_handle_t)SPI2_HOST, &io_config, &lcd_io_handle)); 

    ESP_ERROR_CHECK(esp_lcd_new_panel_ili9488(lcd_io_handle, &lcd_config, LV_BUFFER_SIZE, &lcd_handle));

    ESP_ERROR_CHECK(esp_lcd_panel_reset(lcd_handle));
    ESP_ERROR_CHECK(esp_lcd_panel_init(lcd_handle));
    ESP_ERROR_CHECK(esp_lcd_panel_invert_color(lcd_handle, false));
    ESP_ERROR_CHECK(esp_lcd_panel_swap_xy(lcd_handle, false));
    ESP_ERROR_CHECK(esp_lcd_panel_mirror(lcd_handle, false, false));
    ESP_ERROR_CHECK(esp_lcd_panel_set_gap(lcd_handle, 0, 0));

    ESP_ERROR_CHECK(esp_lcd_panel_disp_on_off(lcd_handle, true));
    ESP_LOGI(TAG, "Initializing LVGL");
    lv_init();
    // ESP_LOGI(TAG, "Allocating %zu bytes for LVGL buffer", LV_BUFFER_SIZE * sizeof(lv_color_t));
    // lv_buf_1 = (lv_color_t *)heap_caps_malloc(LV_BUFFER_SIZE * sizeof(lv_color_t), MALLOC_CAP_DMA);
    // ESP_LOGI(TAG, "Creating LVLG display buffer");
    // lv_disp_draw_buf_init(&lv_disp_buf, lv_buf_1, lv_buf_2, LV_BUFFER_SIZE);

    // it's recommended to choose the size of the draw buffer(s) to be at least 1/10 screen sized
    lv_color_t *buf1 = heap_caps_malloc(DISPLAY_HORIZONTAL_PIXELS * 20 * sizeof(lv_color_t), MALLOC_CAP_DMA);
    assert(buf1);
    lv_color_t *buf2 = heap_caps_malloc(DISPLAY_HORIZONTAL_PIXELS * 20 * sizeof(lv_color_t), MALLOC_CAP_DMA);
    assert(buf2);
    // initialize LVGL draw buffers
    lv_disp_draw_buf_init(&lv_disp_buf, buf1, buf2, DISPLAY_HORIZONTAL_PIXELS * 10);

    ESP_LOGI(TAG, "Initializing %dx%d display", DISPLAY_HORIZONTAL_PIXELS, DISPLAY_VERTICAL_PIXELS);
    lv_disp_drv_init(&lv_disp_drv);
    lv_disp_drv.hor_res = DISPLAY_HORIZONTAL_PIXELS;
    lv_disp_drv.ver_res = DISPLAY_VERTICAL_PIXELS;
    lv_disp_drv.flush_cb = lvgl_flush_cb;
    lv_disp_drv.draw_buf = &lv_disp_buf;
    lv_disp_drv.user_data = lcd_handle;
    lv_disp_drv.rotated = LV_DISP_ROT_NONE;
    lv_display = lv_disp_drv_register(&lv_disp_drv);

}

The above is my driver code, which is basically written according to your example。
3D63B1D59FC81D214833042B5C65FE0D
7CF707FBB18128864401E602D4F08FB3

Incorrect pixel data being displayed

I'm currently trying out the esp_lcd_ili9488 driver and it's going quite well. What I have noticed is that sometimes incorrect pixel data is being displayed. If I try out the lvgl example, there are 10 incorrect pixels displayed down the right hand side of the display. This can be seen in the following photo:

ili9488-issue-on-right-of-display

Similar issues can be seen when the display is being updated during the animation when the pointer on the meter moves from 0 to 100 and back to 0. In the following photo, the the pointer on the meter has already moved from 0 to about 10 and there are a few invalid pixels being displayed to the left of the 100 marking on the meter:

ili9488-issue-when-pointer-at-10

By the time the pointer on the meter has moved to about 50, there are more invalid pixels being displayed to the left of the 100 marking on the meter:

ili9488-issue-when-pointer-at-50

By the time the pointer on the meter has moved to about 100, the invalid pixels that were displayed to the left of the 100 marking on the meter are no longer there, but there are new invalid pixels being displayed to the right of the red part of the scale:

ili9488-issue-when-pointer-at-100

Each time the driver sends a block of data to the display, it looks like the data for the last pixel in the block isn't always being sent correctly. What I think is that there's +/- 1 problem somewhere in the code. I have spent some time looking at the code but I can't figure out what the problem is. The results are the same with esp-idf v4.4 and v5.0.

Do you know how to fix this issue?

ESP32-S3 pins issue

The README for the example, mentions that the ESP32-S3 pins are as follows:

pin usage
SPI MISO 13
SPI MOSI 15
SPI CLK 14
TFT CS 3
TFT DC 9
TFT Backlight 12

However in Kconfig.projbuild the defaults for the ESP32-S3 are defined as follows:

pin usage
SPI MISO 13
SPI MOSI 10
SPI CLK 11
TFT CS 3
TFT RESET 46
TFT DC 9
TFT Backlight 12

SPI MOSI and SPI CLK don't match in the tables and there is no mention of TFT_RESET in the documentation.

When tyring out esp_lcd_ili9488, I built a circuit and connected everything up as described in the documentation and it didn't work. It took a while to figure out what was going wrong. Maybe it would be a good idea to fix the documentation so that it matched what's in Kconfig.projbuild.

Multiple displays support

Hello. Thanks for your work. It compiles and runs successfully with esp-idf@esp32s3. But i need to support 8 same displays simultaneously. They are ordered and inder way to me from aliexpress . Is it possible? Any help appreciated. Thanks.

about use i8080 display ili9488

hello ,i have esp32s3 boare i use esp-idf example [lcd/lvgl] by ESP-IDF V4.4.4, Then I incloud "esp_lcd_ili9488.h" and changed 136 lines,
ESP_ERROR_CHECK(esp_lcd_new_panel_ili9488(io_handle, &panel_config, LCD_H_RES * 20 * sizeof(lv_color_t), true, &panel_handle));
The pins are modified in the code based on the actual connection,

   ESP Board                      LCD Screen
┌─────────────┐              ┌────────────────┐
│             │              │                │
│         3V3 ├─────────────►│ VCC            │
│             │              │                │
│         GND ├──────────────┤ GND            │
│             │              │                │
│  DATA[0..7] │◄────────────►│ DATA[0..7]     │
│             │              │                │
│        IO12 ├─────────────►│ PCLK           │
│             │              │                │
│        IO10 ├─────────────►│ CS             │
│             │              │                │
│        IO14 ├─────────────►│ D/C            │
│             │              │                │
│         IO9 ├─────────────►│ RST            │
│             │              │                │
│        IO46 ├─────────────►│ BCKL           │
│             │              │                │
└─────────────┘              └────────────────┘
#define EXAMPLE_PIN_NUM_DATA0          4
#define EXAMPLE_PIN_NUM_DATA1          5
#define EXAMPLE_PIN_NUM_DATA2          6
#define EXAMPLE_PIN_NUM_DATA3          7
#define EXAMPLE_PIN_NUM_DATA4          15
#define EXAMPLE_PIN_NUM_DATA5          16
#define EXAMPLE_PIN_NUM_DATA6          18
#define EXAMPLE_PIN_NUM_DATA7          18

but when Build and Flash project, the lcd notwork, , except the backlight is on, and nothing else happens, I mean it looks like it's just the IO46 pin because the high level turns on the backlight,
So how to use it in the I8080 interface ?
Please give me some Pointers if you can, thank u very much

Code review

Hello,
I checked this component and tested it with Intel 8080 Parallel 16bit interface. It is working but I have some notes for code:

  1. Why do you use malloc and color data recalculation in panel_ili9488_draw_bitmap? It is wasting of memory, it is working properly, when changed init to { LCD_CMD_COLMOD, { ILI9488_COLOR_MODE_16BIT }, 1 } and put whole color data esp_lcd_panel_io_tx_color(io, LCD_CMD_RAMWR, color_data, color_data_len * 2);
  2. Use this ili9488->bits_per_pixel / 8 instead of the constant color size. You can initialize right by this and do not need allocate another buffer (again).

I didn't checked all code line by line but these things are important to change. Please, could you fix it. Or should I make PR?
If you have any questions, feel free to contact me.

error: comparison between 'lcd_color_rgb_endian_t' and 'enum <anonymous>' [-Werror=enum-compare]

idf.py build或者CLion构建,相同错误:

esp_lcd_ili9488.c: In function 'esp_lcd_new_panel_ili9488':
~/Workspace/Projects/CLionProjects/VisualInfo/managed_components/atanisoft__esp_lcd_ili9488/esp_lcd_ili9488.c:349:39: error: comparison between 'lcd_color_rgb_endian_t' and 'enum ' [-Werror=enum-compare]
349 | if (panel_dev_config->color_space == ESP_LCD_COLOR_SPACE_RGB)
| ^~
cc1: some warnings being treated as errors
[866/1054] Building C object esp-idf/wifi_provisioning/CMakeFiles/__idf_wifi_provisioning.dir/src/manager.c.obj
ninja: build stopped: subcommand failed.

image

spi_mode configured incorrectly

In the example, spi_mode is configured as a pin number like this:

        .spi_mode = CONFIG_TFT_DC_PIN,

spi_mode should be configured to a traditional SPI mode (0~3). The correct mode on the display that I have is 0.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.