How to draw in the EK79007 for the esp32-p4 dev kit
Posted: Sat Nov 16, 2024 8:01 pm
Hi! 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.
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.
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:
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);
}
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));
}
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;
}