How to draw in the EK79007 for the esp32-p4 dev kit

andres-st
Posts: 5
Joined: Sat Nov 16, 2024 7:50 pm
Location: Madrid

How to draw in the EK79007 for the esp32-p4 dev kit

Postby andres-st » Sat Nov 16, 2024 8:01 pm

Hi! :D I want to make a simple code where the screen goes to red, green and blue in a loop to practice.

But I don't find how to make it work.

Code: Select all

static void test_draw_color_pattern (esp_lcd_panel_handle_t * panel_handle, uint16_t h_res, uint16_t v_res)
{
    uint16_t *color = (uint16_t *) heap_caps_calloc (1, h_res * v_res, MALLOC_CAP_DMA);

    if (color == NULL)
    {
        ESP_LOGE(TAG, "Color not initialized");
        return;
    }

    ESP_LOGI(TAG, "Vamos a entrar en el bucle");

    while (true)
    {
        // Draw Red
        memset (color, RED, h_res * v_res); // Fill with red

        esp_lcd_panel_draw_bitmap (panel_handle, 10, 0, h_res + 10, v_res, color);
        xSemaphoreTake (refresh_finish, portMAX_DELAY);

        memset (color, GREEN, h_res * v_res); // Fill with green

        esp_lcd_panel_draw_bitmap (panel_handle, 10, 0, h_res + 10, v_res, color);
        xSemaphoreTake (refresh_finish, portMAX_DELAY);

        memset (color, BLUE, h_res * v_res); // Fill with blue

        esp_lcd_panel_draw_bitmap (panel_handle, 10, 0, h_res + 10, v_res, color);
        xSemaphoreTake (refresh_finish, portMAX_DELAY);

        vTaskDelay(1);
    }
    
    free(color);
}
This is my function where I make all the changes


And this is my code to initialize the EK79007. (I am using the GPIOs used in the examples, 26 for the PWM and the 27 for the RST_LCD.

Code: Select all

void ek79007_initialize(gpio_num_t reset_pin) {
    // Encender la fuente de alimentación de MIPI DSI PHY
    esp_ldo_channel_handle_t ldo_mipi_phy = NULL;
    esp_ldo_channel_config_t ldo_mipi_phy_config = {
        .chan_id = 3,
        .voltage_mv = 2500,
    };
    ESP_ERROR_CHECK(esp_ldo_acquire_channel(&ldo_mipi_phy_config, &ldo_mipi_phy));
    ESP_LOGI(TAG, "MIPI DSI PHY Powered on");

    // Crear el bus MIPI DSI
    esp_lcd_dsi_bus_handle_t mipi_dsi_bus;
    esp_lcd_dsi_bus_config_t bus_config = {
        .bus_id = 0,
        .num_data_lanes = PANEL_MIPI_DSI_LANE_NUM,
        .phy_clk_src = MIPI_DSI_PHY_CLK_SRC_DEFAULT,
        .lane_bit_rate_mbps = PANEL_MIPI_DSI_LANE_BITRATE_MBPS,
    };
    ESP_ERROR_CHECK(esp_lcd_new_dsi_bus(&bus_config, &mipi_dsi_bus));

    // Configurar y crear el IO de control del panel
    esp_lcd_panel_io_handle_t mipi_dbi_io;
    esp_lcd_dbi_io_config_t dbi_config = {
        .virtual_channel = 0,
        .lcd_cmd_bits = 8,   // according to the LCD spec
        .lcd_param_bits = 8, // according to the LCD spec
    };
    ESP_ERROR_CHECK(esp_lcd_new_panel_io_dbi(mipi_dsi_bus, &dbi_config, &mipi_dbi_io));

    // Configurar y crear el panel MIPI DSI
    esp_lcd_dpi_panel_config_t dpi_config = {
        .virtual_channel = 0,
        .dpi_clk_src = MIPI_DSI_DPI_CLK_SRC_DEFAULT,
        .dpi_clock_freq_mhz = PANEL_MIPI_DSI_DPI_CLK_MHZ,
        .pixel_format = LCD_COLOR_PIXEL_FORMAT_RGB888,
        .video_timing = {
            .h_size = PANEL_MIPI_DSI_LCD_H_RES,
            .v_size = PANEL_MIPI_DSI_LCD_V_RES,
            .hsync_back_porch = PANEL_MIPI_DSI_LCD_HBP,
            .hsync_pulse_width = PANEL_MIPI_DSI_LCD_HSYNC,
            .hsync_front_porch = PANEL_MIPI_DSI_LCD_HFP,
            .vsync_back_porch = PANEL_MIPI_DSI_LCD_VBP,
            .vsync_pulse_width = PANEL_MIPI_DSI_LCD_VSYNC,
            .vsync_front_porch = PANEL_MIPI_DSI_LCD_VFP,
        },
        .flags.use_dma2d = true,
    };

    ek79007_vendor_config_t vendor_config = {
        .mipi_config = {
            .dsi_bus = mipi_dsi_bus,
            .dpi_config = &dpi_config,
        },
    };
    esp_lcd_panel_dev_config_t lcd_dev_config = {
        .reset_gpio_num = reset_pin,
        .rgb_ele_order = LCD_RGB_ELEMENT_ORDER_RGB,
        .bits_per_pixel = 24,
        .vendor_config = &vendor_config,
    };
    ESP_ERROR_CHECK(esp_lcd_new_panel_ek79007(mipi_dbi_io, &lcd_dev_config, &mipi_dpi_panel));

    // Resetear e inicializar el panel
    ESP_ERROR_CHECK(esp_lcd_panel_reset(mipi_dpi_panel));
    ESP_ERROR_CHECK(esp_lcd_panel_init(mipi_dpi_panel));

    // Activar la retroiluminación y encender la pantalla
    ek79007_backlight_on(mipi_dbi_io);
    // ESP_ERROR_CHECK(esp_lcd_panel_disp_on_off(mipi_dpi_panel, true));

    // Registrar el evento de actualización del panel
    // refresh_finish = xSemaphoreCreateBinary();
    // if (refresh_finish == NULL) {
    //     ESP_LOGE(TAG, "Failed to create semaphore for refresh");
    //     return;
    // }
    
    // esp_lcd_dpi_panel_event_callbacks_t cbs = {
    //     .on_color_trans_done = test_notify_refresh_ready,
    // };
    // ESP_ERROR_CHECK(esp_lcd_dpi_panel_register_event_callbacks(mipi_dpi_panel, &cbs, refresh_finish));
}
Can please someone help me! :)

I have also built the test_app from the dependency https://components.espressif.com/components/espressif/esp_lcd_ek79007
Not even that works.

The only thing that has worked are the examples of the esp-dev-kits.

I am really blocked. :(

PS: I also tried to make this code for only setting a pixel color to try and hasn't worked either:

Code: Select all

esp_err_t panel_ek79007_set_pixel (esp_lcd_panel_t *panel, uint16_t x, uint16_t y, uint16_t color)
{
    ek79007_panel_t *ek79007 = (ek79007_panel_t *) panel->user_data;
    esp_lcd_panel_io_handle_t io = ek79007->io;

    // Set the column address
    uint8_t col_data [] = { (x >> 8) & 0xFF, x & 0xFF, ((x + 1) >> 8) & 0xFF, (x + 1) & 0xFF};
    ESP_RETURN_ON_ERROR ( esp_lcd_panel_io_tx_param(io, LCD_CMD_CASET, col_data, sizeof(col_data)), TAG, "send command failed");

    uint8_t row_data [] = { (y >> 8) & 0xFF, y & 0xFF, ((y + 1) >> 8) & 0xFF, (y + 1) & 0xFF};
    ESP_RETURN_ON_ERROR ( esp_lcd_panel_io_tx_param(io, LCD_CMD_RASET, row_data, sizeof(row_data)), TAG, "send command failed");

    // Write the pixel color
    uint8_t color_data[] = { (color >> 8) & 0xFF, color & 0xFF};
    ESP_RETURN_ON_ERROR ( esp_lcd_panel_io_tx_param(io, LCD_CMD_RAMWR, color_data, sizeof(color_data)), TAG, "send command failed");

    return ESP_OK;
}

chegewara
Posts: 2376
Joined: Wed Jun 14, 2017 9:00 pm

Re: How to draw in the EK79007 for the esp32-p4 dev kit

Postby chegewara » Wed Nov 20, 2024 6:15 am

Code: Select all

    for (size_t i = 0; i < width * height; i++)
    {
        fb_buf[i] = color;
    }

    ESP_ERROR_CHECK(esp_lcd_panel_draw_bitmap(panel, 0, 0, width, height, fb_buf));
    

andres-st
Posts: 5
Joined: Sat Nov 16, 2024 7:50 pm
Location: Madrid

Re: How to draw in the EK79007 for the esp32-p4 dev kit

Postby andres-st » Thu Nov 21, 2024 5:27 pm

Thanks for the response!

I believe I am doing the same that you, mine is a bit different,

Code: Select all

static void test_draw_color (esp_lcd_panel_handle_t * panel_handle, uint16_t h_res, uint16_t v_res)
{
    uint16_t *color = (uint16_t *) heap_caps_calloc (1, h_res * v_res, MALLOC_CAP_DMA);

    if (color == NULL)
    {
        ESP_LOGE(TAG, "Color not initialized");
        return;
    }

    ESP_LOGI(TAG, "We are entering the loop.");

    while (true)
    {
        // Draw Red
        memset (color, RED, h_res * v_res); // Fill with red

        esp_lcd_panel_draw_bitmap (panel_handle, 10, 0, h_res + 10, v_res, color);
        xSemaphoreTake (refresh_finish, portMAX_DELAY);

        memset (color, GREEN, h_res * v_res); // Fill with green

        esp_lcd_panel_draw_bitmap (panel_handle, 10, 0, h_res + 10, v_res, color);
        xSemaphoreTake (refresh_finish, portMAX_DELAY);

        memset (color, BLUE, h_res * v_res); // Fill with blue

        esp_lcd_panel_draw_bitmap (panel_handle, 10, 0, h_res + 10, v_res, color);
        xSemaphoreTake (refresh_finish, portMAX_DELAY);

        vTaskDelay(1);
    }
    
    free(color);
}
None of the colors are represented.

chegewara
Posts: 2376
Joined: Wed Jun 14, 2017 9:00 pm

Re: How to draw in the EK79007 for the esp32-p4 dev kit

Postby chegewara » Fri Nov 22, 2024 4:19 am

Then i dont know. Maybe display is not init correctly?

andres-st
Posts: 5
Joined: Sat Nov 16, 2024 7:50 pm
Location: Madrid

Re: How to draw in the EK79007 for the esp32-p4 dev kit

Postby andres-st » Sat Nov 23, 2024 9:17 pm

This is how I am initializing the display, following the test for the display.

Code: Select all

#define PANEL_MIPI_DSI_DPI_CLK_MHZ  52
#define PANEL_MIPI_DSI_LCD_H_RES    1024
#define PANEL_MIPI_DSI_LCD_V_RES    600
#define PANEL_MIPI_DSI_LCD_HSYNC    10
#define PANEL_MIPI_DSI_LCD_HBP      160
#define PANEL_MIPI_DSI_LCD_HFP      160
#define PANEL_MIPI_DSI_LCD_VSYNC    1
#define PANEL_MIPI_DSI_LCD_VBP      23
#define PANEL_MIPI_DSI_LCD_VFP      12
#define PANEL_MIPI_DSI_LANE_NUM          2    // 2 data lanes
#define PANEL_MIPI_DSI_LANE_BITRATE_MBPS 1000 // 1Gbps

void ek79007_initialize(gpio_num_t reset_pin) {
    // Encender la fuente de alimentación de MIPI DSI PHY
    esp_ldo_channel_handle_t ldo_mipi_phy = NULL;
    esp_ldo_channel_config_t ldo_mipi_phy_config = {
        .chan_id = 3,
        .voltage_mv = 2500,
    };
    ESP_ERROR_CHECK(esp_ldo_acquire_channel(&ldo_mipi_phy_config, &ldo_mipi_phy));
    ESP_LOGI(TAG, "MIPI DSI PHY Powered on");

    // Crear el bus MIPI DSI
    esp_lcd_dsi_bus_handle_t mipi_dsi_bus;
    esp_lcd_dsi_bus_config_t bus_config = {
        .bus_id = 0,
        .num_data_lanes = PANEL_MIPI_DSI_LANE_NUM,
        .phy_clk_src = MIPI_DSI_PHY_CLK_SRC_DEFAULT,
        .lane_bit_rate_mbps = PANEL_MIPI_DSI_LANE_BITRATE_MBPS,
    };
    ESP_ERROR_CHECK(esp_lcd_new_dsi_bus(&bus_config, &mipi_dsi_bus));

    // Configurar y crear el IO de control del panel
    esp_lcd_panel_io_handle_t mipi_dbi_io;
    esp_lcd_dbi_io_config_t dbi_config = {
        .virtual_channel = 0,
        .lcd_cmd_bits = 8,   // according to the LCD spec
        .lcd_param_bits = 8, // according to the LCD spec
    };
    ESP_ERROR_CHECK(esp_lcd_new_panel_io_dbi(mipi_dsi_bus, &dbi_config, &mipi_dbi_io));

    // Configurar y crear el panel MIPI DSI
    esp_lcd_dpi_panel_config_t dpi_config = {
        .virtual_channel = 0,
        .dpi_clk_src = MIPI_DSI_DPI_CLK_SRC_DEFAULT,
        .dpi_clock_freq_mhz = PANEL_MIPI_DSI_DPI_CLK_MHZ,
        .pixel_format = LCD_COLOR_PIXEL_FORMAT_RGB565,
        .video_timing = {
            .h_size = PANEL_MIPI_DSI_LCD_H_RES,
            .v_size = PANEL_MIPI_DSI_LCD_V_RES,
            .hsync_back_porch = PANEL_MIPI_DSI_LCD_HBP,
            .hsync_pulse_width = PANEL_MIPI_DSI_LCD_HSYNC,
            .hsync_front_porch = PANEL_MIPI_DSI_LCD_HFP,
            .vsync_back_porch = PANEL_MIPI_DSI_LCD_VBP,
            .vsync_pulse_width = PANEL_MIPI_DSI_LCD_VSYNC,
            .vsync_front_porch = PANEL_MIPI_DSI_LCD_VFP,
        },
        .flags.use_dma2d = true,
    };

    ek79007_vendor_config_t vendor_config = {
        .mipi_config = {
            .dsi_bus = mipi_dsi_bus,
            .dpi_config = &dpi_config,
        },
    };
    const esp_lcd_panel_dev_config_t lcd_dev_config = {
        .reset_gpio_num = reset_pin,
        .rgb_ele_order = LCD_RGB_ELEMENT_ORDER_RGB,
        .bits_per_pixel = 16,
        .vendor_config = &vendor_config,
    };
    ESP_ERROR_CHECK(esp_lcd_new_panel_ek79007(mipi_dbi_io, &lcd_dev_config, &mipi_dpi_panel));

    // Resetear e inicializar el panel
    ESP_ERROR_CHECK(esp_lcd_panel_reset(mipi_dpi_panel));
    ESP_ERROR_CHECK(esp_lcd_panel_init(mipi_dpi_panel));
  
As for the coloring part, I am now doing this:

Code: Select all

test_draw_color_pattern(mipi_dpi_panel, 1024, 600);

static void test_draw_color_pattern (esp_lcd_panel_handle_t * panel_handle, uint16_t h_res, uint16_t v_res)
{
    size_t total_size = h_res * v_res * sizeof(uint16_t);
    size_t total_pixels = h_res * v_res;
    uint16_t *color = NULL;

    esp_lcd_dpi_panel_get_frame_buffer(panel_handle, 1, &color);

    ESP_LOGI(TAG, "color size %zu", total_size);

    if (color == NULL)
    {
        ESP_LOGE(TAG, "Color not initialized");
        return;
    }

    ESP_LOGI(TAG, "Vamos a entrar en el bucle");

    while (true)
    {
        // Draw Red
        ESP_LOGI(TAG, "Drawing Red");
        for (size_t i = 0; i < total_pixels; i++)
        {
            color[i] = RED;

            if (i % 250 == 0)
                vTaskDelay(pdMS_TO_TICKS(10));
        }

        esp_lcd_panel_draw_bitmap (panel_handle, 0, 0, h_res, v_res, color);
        xSemaphoreTake (refresh_finish, portMAX_DELAY);

        ESP_LOGI(TAG, "Drawing Green");
        for (size_t i = 0; i < total_pixels; i++)
        {
            color[i] = GREEN;

            if (i % 250 == 0)
                vTaskDelay(pdMS_TO_TICKS(10));
        }

        esp_lcd_panel_draw_bitmap (panel_handle, 0, 0, h_res, v_res, color);
        xSemaphoreTake (refresh_finish, portMAX_DELAY);


        ESP_LOGI(TAG, "Drawing Blue");
        for (size_t i = 0; i < total_pixels; i++)
        {
            color[i] = BLUE;

            if (i % 250 == 0)
                vTaskDelay(pdMS_TO_TICKS(10));
        }

        esp_lcd_panel_draw_bitmap (panel_handle, 0, 0, h_res, v_res, color);
        xSemaphoreTake (refresh_finish, portMAX_DELAY);

        vTaskDelay(pdMS_TO_TICKS(1));
    }
    
    free(color);
}
However, for some reason, I am only able to change about 10 rows of pixels—only the upper part—and in that part, it flickers a lot.

PHOTO-2024-11-23-22-12-45.jpg
PHOTO-2024-11-23-22-12-45.jpg (42.34 KiB) Viewed 295 times

Thanks for the help!

ESP_Sprite
Posts: 9764
Joined: Thu Nov 26, 2015 4:08 am

Re: How to draw in the EK79007 for the esp32-p4 dev kit

Postby ESP_Sprite » Sun Nov 24, 2024 5:56 am

THat blue-ish color on the rest of the screen is the mipi peripheral not getting its data fast enough... I'm thinking your PSRAM may be at 20MHz. Can you try running menuconfig, then enabling experimental features (if it's not already), then setting psram speed to 200MHz?

andres-st
Posts: 5
Joined: Sat Nov 16, 2024 7:50 pm
Location: Madrid

Re: How to draw in the EK79007 for the esp32-p4 dev kit

Postby andres-st » Sun Nov 24, 2024 8:49 am

Thanks a lot! It worked!

Now, how can I work at a lower level and only change the value of a single pixel? Instead of sending the whole frame buffer, I want to communicate directly with the controller to send the value of that specific pixel and see it change.

Thanks again for the help!

andres-st
Posts: 5
Joined: Sat Nov 16, 2024 7:50 pm
Location: Madrid

Re: How to draw in the EK79007 for the esp32-p4 dev kit

Postby andres-st » Sun Nov 24, 2024 9:31 am

hi, I have been trying the set_pixel function. Right now I have this:

Code: Select all

esp_err_t panel_ek79007_set_pixel (esp_lcd_panel_t *panel, uint16_t x, uint16_t y, uint16_t color)
{
    ESP_LOGI(TAG, "Setting pixel");
    ek79007_panel_t *ek79007 = (ek79007_panel_t *) panel->user_data;
    esp_lcd_panel_io_handle_t io = ek79007->io;

    // Set the column address
    uint8_t col_data [] = { (x >> 8) & 0xFF, x & 0xFF, ((x + 1) >> 8) & 0xFF, (x + 1) & 0xFF};
    ESP_RETURN_ON_ERROR ( esp_lcd_panel_io_tx_param(io, LCD_CMD_CASET, col_data, sizeof(col_data)), TAG, "send command failed");

    uint8_t row_data [] = { (y >> 8) & 0xFF, y & 0xFF, ((y + 1) >> 8) & 0xFF, (y + 1) & 0xFF};
    ESP_RETURN_ON_ERROR ( esp_lcd_panel_io_tx_param(io, LCD_CMD_RASET, row_data, sizeof(row_data)), TAG, "send command failed");

    // Write the pixel color
    uint8_t color_data[] = { (color >> 8) & 0xFF, color & 0xFF};
    ESP_RETURN_ON_ERROR ( esp_lcd_panel_io_tx_param(io, LCD_CMD_RAMWR, color_data, sizeof(color_data)), TAG, "send command failed");

    return ESP_OK;
}
But it doesn't give me any error, yet it also doesn't change anything, and the screen remains black.

Then I tried this way:

Code: Select all

esp_err_t panel_ek79007_set_pixel (esp_lcd_panel_handle_t *panel, uint16_t x, uint16_t y, uint16_t color)
{
    ESP_LOGI(TAG, "Setting pixel");
    // Set the column address
    uint8_t col_data [] = { (x >> 8) & 0xFF, x & 0xFF, ((x) >> 8) & 0xFF, (x) & 0xFF};
    ESP_RETURN_ON_ERROR ( esp_lcd_panel_io_tx_param(panel, LCD_CMD_CASET, col_data, sizeof(col_data)), TAG, "send command failed");

    uint8_t row_data [] = { (y >> 8) & 0xFF, y & 0xFF, ((y) >> 8) & 0xFF, (y) & 0xFF};
    ESP_RETURN_ON_ERROR ( esp_lcd_panel_io_tx_param(panel, LCD_CMD_RASET, row_data, sizeof(row_data)), TAG, "send command failed");

    // Write the pixel color
    uint8_t color_data[] = { (color >> 8) & 0xFF, color & 0xFF};
    ESP_RETURN_ON_ERROR ( esp_lcd_panel_io_tx_param(panel, LCD_CMD_RAMWR, color_data, sizeof(color_data)), TAG, "send command failed");

    return ESP_OK;
}
It is virtually the same, but this one retains the same blue color from some posts before and gives me this error:

Code: Select all

Guru Meditation Error: Core  0 panic'ed (Store access fault). Exception was unhandled.

Core  0 register dump:
--- Stack dump detected
MEPC    : 0x40022120  RA      : 0x4000c0d0  SP      : 0x4ff166e0  GP      : 0x4ff10d80
--- 0x40022120: dw_gdma_ll_channel_set_link_list_master_port at /Users/andres/esp/esp-idf-53/components/hal/esp32p4/include/hal/dw_gdma_ll.h:833
 (inlined by) dw_gdma_channel_use_link_list at /Users/andres/esp/esp-idf-53/components/esp_hw_support/dma/dw_gdma.c:455
0x4000c0d0: dpi_panel_init at /Users/andres/esp/esp-idf-53/components/esp_lcd/dsi/esp_lcd_panel_dpi.c:403

TP      : 0x4ff16810  T0      : 0x4fc0a778  T1      : 0x48000c54  T2      : 0x00000000
S0/FP   : 0x48000c98  S1      : 0x00000001  A0      : 0x4812cebc  A1      : 0x4812ceec
A2      : 0x48000d58  A3      : 0x00000001  A4      : 0x00000000  A5      : 0x50081000
A6      : 0x00000005  A7      : 0x00000000  S2      : 0x4812ceec  S3      : 0x48000c54
S4      : 0x4812cebc  S5      : 0x00000000  S6      : 0x00000000  S7      : 0x00000000
S8      : 0x00000000  S9      : 0x00000000  S10     : 0x00000000  S11     : 0x00000000
T3      : 0x00000001  T4      : 0x00000000  T5      : 0x000000d0  T6      : 0x000000d0
MSTATUS : 0x00011880  MTVEC   : 0x4ff00003  MCAUSE  : 0x00000007  MTVAL   : 0x50081128
--- 0x4ff00003: _vector_table at ??:?

MHARTID : 0x00000000


--- Backtrace:


0x40022120 in dw_gdma_ll_channel_set_link_list_master_port (port=1, channel=0 '\000', dev=0x0) at /Users/andres/esp/esp-idf-53/components/hal/esp32p4/include/hal/dw_gdma_ll.h:833
833	    dev->ch[channel].llp0.lms = port;
#0  0x40022120 in dw_gdma_ll_channel_set_link_list_master_port (port=1, channel=0 '\000', dev=0x0) at /Users/andres/esp/esp-idf-53/components/hal/esp32p4/include/hal/dw_gdma_ll.h:833
#1  dw_gdma_channel_use_link_list (chan=chan@entry=0x4812cebc, list=0x4812ceec) at /Users/andres/esp/esp-idf-53/components/esp_hw_support/dma/dw_gdma.c:455
#2  0x4000c0d0 in dpi_panel_init (panel=0x48000c98) at /Users/andres/esp/esp-idf-53/components/esp_lcd/dsi/esp_lcd_panel_dpi.c:401
#3  0x4000b04a in panel_ek79007_init (panel=0x48000c98) at /Users/andres/projects/p4-library/managed_components/espressif__esp_lcd_ek79007/esp_lcd_ek79007.c:208
#4  0x4000b49e in esp_lcd_panel_io_tx_param (io=io@entry=0x48000c98, lcd_cmd=lcd_cmd@entry=42, param=param@entry=0x4ff1677c, param_size=param_size@entry=4) at /Users/andres/esp/esp-idf-53/components/esp_lcd/src/esp_lcd_panel_io.c:23
#5  0x4000b3a6 in panel_ek79007_set_pixel (panel=0x48000c98, x=<optimized out>, y=300, color=color@entry=63488) at /Users/andres/projects/p4-library/managed_components/espressif__esp_lcd_ek79007/esp_lcd_ek79007.c:286
#6  0x4000a9f0 in app_main () at /Users/andres/projects/p4-library/main/main.c:341
#7  0x400226c6 in main_task (args=<error reading variable: value has been optimized out>) at /Users/andres/esp/esp-idf-53/components/freertos/app_startup.c:208
#8  0x4ff082e0 in vPortTaskWrapper (pxCode=<optimized out>, pvParameters=<optimized out>) at /Users/andres/esp/esp-idf-53/components/freertos/FreeRTOS-Kernel/portable/riscv/port.c:255



ELF file SHA256: 450ab667a

Rebooting...
ESP-ROM:esp32p4-eco1-20240205
Build:Feb  5 2024
rst:0xc (SW_CPU_RESET),boot:0x20f (SPI_FAST_FLASH_BOOT)
Core0 Saved PC:0x4ff03524
--- 0x4ff03524: cpu_utility_ll_reset_cpu at /Users/andres/esp/esp-idf-53/components/hal/esp32p4/include/hal/cpu_utility_ll.h:23
 (inlined by) esp_cpu_reset at /Users/andres/esp/esp-idf-53/components/esp_hw_support/cpu.c:49

Core1 Saved PC:0x4ff03694
--- 0x4ff03694: esp_cpu_wait_for_intr at /Users/andres/esp/esp-idf-53/components/esp_hw_support/cpu.c:57 (discriminator 1)

SPI mode:DIO, clock div:1
load:0x4ff33ce0,len:0x17d0
load:0x4ff2abd0,len:0xddc
load:0x4ff2cbd0,len:0x37e4
entry 0x4ff2abda
I understand that it is a problem with the DMA.

I have the initial configuration of the display as follows:

Code: Select all

.flags.use_dma2d = true,
Thanks for all the help!

ESP_Sprite
Posts: 9764
Joined: Thu Nov 26, 2015 4:08 am

Re: How to draw in the EK79007 for the esp32-p4 dev kit

Postby ESP_Sprite » Mon Nov 25, 2024 2:26 am

andres-st wrote:
Sun Nov 24, 2024 8:49 am
Thanks a lot! It worked!

Now, how can I work at a lower level and only change the value of a single pixel? Instead of sending the whole frame buffer, I want to communicate directly with the controller to send the value of that specific pixel and see it change.

Thanks again for the help!
I think you're making a conceptual mistake here. The EK79007 is not a display driver that has integrated RAM, so you cannot tell it to change one pixel. It works more like an old VGA monitor: you need to send it the full image over and over and over again (ideally >50 times per second) in order to make it display an image. That is what the MIPI peripheral already does: it takes the framebuffer memory (the one you get a pointer to when you call esp_lcd_dpi_panel_get_frame_buffer()) and sends it to the display continuously. In other words: if you want to draw a pixel, all you need to do is change the relevant bytes in the framebuffer and it should be displayed!

Well, technically, there's another gotcha: when you change those bytes, these will be changed in the CPU cache, and they don't necessarily trickle down to the underlying memory (which is read by the MIPI peripheral) any time fast. You need to force a cache flush to make that happen immediately. And that is what

Code: Select all

esp_lcd_panel_draw_bitmap (panel_handle, 0, 0, h_res, v_res, color);
does. Initially this may seem nonsensical, because you draw the framebuffer on the display, which already displays that same framebuffer. If you call it like this, though, you're saying 'hey, I messed with the framebuffer manually, please make sure the changes make it to the actual memory by e.g. flushing the caches'. It doesn't actually copy a bitmap.

Who is online

Users browsing this forum: No registered users and 11 guests