Skip to content

Commit c10f1a0

Browse files
committed
Merge branch 'bugfix/lcd_esp_video_bugfix_v2.0' into 'release/v2.0'
bugfix(p4): Fixed ST77922 init parameters and improved video_lcd_display example (v2.0) See merge request ae_group/esp-iot-solution!1148
2 parents d0314e7 + 02731d2 commit c10f1a0

File tree

12 files changed

+69
-19
lines changed

12 files changed

+69
-19
lines changed

components/display/lcd/esp_lcd_ek79007/esp_lcd_ek79007.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
*/
66

77
#include "soc/soc_caps.h"
8+
9+
#if SOC_MIPI_DSI_SUPPORTED
810
#include "freertos/FreeRTOS.h"
911
#include "freertos/task.h"
1012
#include "driver/gpio.h"
@@ -274,3 +276,4 @@ static esp_err_t panel_ek79007_invert_color(esp_lcd_panel_t *panel, bool invert_
274276

275277
return ESP_OK;
276278
}
279+
#endif

components/display/lcd/esp_lcd_st77922/esp_lcd_st77922_mipi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ static const st77922_lcd_init_cmd_t vendor_specific_init_default[] = {
178178
{0xB4, (uint8_t []){0x10, 0x09, 0x0B, 0x02, 0x00, 0x19, 0x18, 0x13, 0x1E, 0x1D, 0x1C, 0x1E}, 12, 0},
179179
{0xB5, (uint8_t []){0x08, 0x12, 0x03, 0x0A, 0x19, 0x01, 0x11, 0x18, 0x1D, 0x1E, 0x1E, 0x1C}, 12, 0},
180180
{0xB6, (uint8_t []){0xFF, 0xFF, 0x00, 0x07, 0xFF, 0x0B, 0xFF}, 7, 0},
181-
{0x29, (uint8_t []){0xB7, 0x00, 0x0B, 0x12, 0x0A, 0x0B, 0x06, 0x37, 0x00, 0x02, 0x4D, 0x08, 0x14, 0x14, 0x30, 0x36, 0x0F}, 17, 0},
181+
{0xB7, (uint8_t []){0x00, 0x0B, 0x12, 0x0A, 0x0B, 0x06, 0x37, 0x00, 0x02, 0x4D, 0x08, 0x14, 0x14, 0x30, 0x36, 0x0F}, 17, 0},
182182
{0xB8, (uint8_t []){0x00, 0x0B, 0x11, 0x09, 0x09, 0x06, 0x37, 0x06, 0x05, 0x4D, 0x08, 0x13, 0x13, 0x2F, 0x36, 0x0F}, 16, 0},
183183
{0xB9, (uint8_t []){0x23, 0x23}, 2, 0},
184184
{0xBB, (uint8_t []){0x00, 0x00}, 2, 0},

components/display/lcd/esp_lcd_st77922/include/esp_lcd_st77922.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,9 @@ esp_err_t esp_lcd_new_panel_st77922(const esp_lcd_panel_io_handle_t io, const es
240240
.hsync_back_porch = 40, \
241241
.hsync_pulse_width = 2, \
242242
.hsync_front_porch = 40, \
243-
.vsync_back_porch = 5, \
243+
.vsync_back_porch = 6, \
244244
.vsync_pulse_width = 2, \
245-
.vsync_front_porch = 82, \
245+
.vsync_front_porch = 117, \
246246
}, \
247247
.flags.use_dma2d = true, \
248248
}

components/display/lcd/esp_lcd_st77922/test_apps/main/test_esp_lcd_st77922_general.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ static void test_draw_color_bar(esp_lcd_panel_handle_t panel_handle, uint16_t h_
7171
for (int j = 0; j < byte_per_pixel * 8; j++) {
7272
for (int i = 0; i < row_line * h_res; i++) {
7373
for (int k = 0; k < byte_per_pixel; k++) {
74-
color[i * byte_per_pixel + k] = (BIT(j) >> (k * 8)) & 0xff;
74+
color[i * byte_per_pixel + k] = (SPI_SWAP_DATA_TX(BIT(j), TEST_LCD_BIT_PER_PIXEL) >> (k * 8)) & 0xff;
7575
}
7676
}
7777
TEST_ESP_OK(esp_lcd_panel_draw_bitmap(panel_handle, 0, j * row_line, h_res, (j + 1) * row_line, color));

docs/en/display/lcd/lcd_development_guide.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ Driver and Examples
8888
* - I80
8989
- `axs15231b <https://components.espressif.com/components/espressif/esp_lcd_axs15231b>`_, `st7789 <https://github.com/espressif/esp-idf/blob/master/components/esp_lcd/src/esp_lcd_panel_st7789.c>`_, `nt35510 <https://github.com/espressif/esp-idf/blob/master/components/esp_lcd/src/esp_lcd_panel_nt35510.c>`_, `ra8875 <https://components.espressif.com/components/espressif/esp_lcd_ra8875>`_, `st7796 <https://components.espressif.com/components/espressif/esp_lcd_st7796>`_
9090
* - MIPI-DSI
91-
- `ek79007 <https://components.espressif.com/components/espressif/esp_lcd_ek79007>`_, `jd9165 <https://components.espressif.com/components/espressif/esp_lcd_jd9165>`_, `jd9365 <https://components.espressif.com/components/espressif/esp_lcd_jd9365>`_, `st7701 <https://components.espressif.com/components/espressif/esp_lcd_st7701>`_, `ili9881c <https://components.espressif.com/components/espressif/esp_lcd_ili9881c>`_
91+
- `ek79007 <https://components.espressif.com/components/espressif/esp_lcd_ek79007>`_, `jd9165 <https://components.espressif.com/components/espressif/esp_lcd_jd9165>`_, `jd9365 <https://components.espressif.com/components/espressif/esp_lcd_jd9365>`_, `st7701 <https://components.espressif.com/components/espressif/esp_lcd_st7701>`_, `st7703 <https://components.espressif.com/components/espressif/esp_lcd_st7703>`_, `st77922 <https://components.espressif.com/components/espressif/esp_lcd_st77922>`_, `ili9881c <https://components.espressif.com/components/espressif/esp_lcd_ili9881c>`_, `hx8399 <https://components.espressif.com/components/espressif/esp_lcd_hx8399>`_
9292
* - 3-wire SPI + RGB
9393
- `st7701 <https://components.espressif.com/components/espressif/esp_lcd_st7701>`_, `st77903_rgb <https://components.espressif.com/components/espressif/esp_lcd_st77903_rgb>`_, `st77922 <https://components.espressif.com/components/espressif/esp_lcd_st77922>`_, `gc9503 <https://components.espressif.com/components/espressif/esp_lcd_gc9503>`_
9494

docs/en/display/lcd/lcd_guide.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,3 +356,6 @@ Display
356356
Display refers to the process in which the LCD driver IC displays the received image data on the screen. The speed of this process can be measured by the **screen refresh rate**.
357357

358358
For LCDs with SPI/I80 interfaces, the screen refresh rate is determined by the LCD driver IC and can typically be set by sending specific commands, such as the *ST7789* command ``FRCTRL2 (C6h)``. For LCDs with RGB interfaces, the screen refresh rate is determined by the main controller and is equivalent to the interface frame rate.
359+
360+
.. note::
361+
- If development needs to proceed without an LCD, the `esp_lcd_usb_display component <https://components.espressif.com/components/espressif/esp_lcd_usb_display>`_ can be used to simulate the LCD display on a PC monitor via USB UVC, enabling application debugging. The corresponding example is available at `usb_lcd_display <https://github.com/espressif/esp-iot-solution/tree/master/examples/usb/device/usb_lcd_display>`_.

docs/zh_CN/display/lcd/lcd_development_guide.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ LCD 开发指南
8888
* - I80
8989
- `axs15231b <https://components.espressif.com/components/espressif/esp_lcd_axs15231b>`_, `st7789 <https://github.com/espressif/esp-idf/blob/master/components/esp_lcd/src/esp_lcd_panel_st7789.c>`_, `nt35510 <https://github.com/espressif/esp-idf/blob/master/components/esp_lcd/src/esp_lcd_panel_nt35510.c>`_, `ra8875 <https://components.espressif.com/components/espressif/esp_lcd_ra8875>`_, `st7796 <https://components.espressif.com/components/espressif/esp_lcd_st7796>`_
9090
* - MIPI-DSI
91-
- `ek79007 <https://components.espressif.com/components/espressif/esp_lcd_ek79007>`_, `jd9165 <https://components.espressif.com/components/espressif/esp_lcd_jd9165>`_, `jd9365 <https://components.espressif.com/components/espressif/esp_lcd_jd9365>`_, `st7701 <https://components.espressif.com/components/espressif/esp_lcd_st7701>`_, `ili9881c <https://components.espressif.com/components/espressif/esp_lcd_ili9881c>`_
91+
- `ek79007 <https://components.espressif.com/components/espressif/esp_lcd_ek79007>`_, `jd9165 <https://components.espressif.com/components/espressif/esp_lcd_jd9165>`_, `jd9365 <https://components.espressif.com/components/espressif/esp_lcd_jd9365>`_, `st7701 <https://components.espressif.com/components/espressif/esp_lcd_st7701>`_, `st7703 <https://components.espressif.com/components/espressif/esp_lcd_st7703>`_, `st77922 <https://components.espressif.com/components/espressif/esp_lcd_st77922>`_, `ili9881c <https://components.espressif.com/components/espressif/esp_lcd_ili9881c>`_, `hx8399 <https://components.espressif.com/components/espressif/esp_lcd_hx8399>`_
9292
* - 3-wire SPI + RGB
9393
- `st7701 <https://components.espressif.com/components/espressif/esp_lcd_st7701>`_, `st77903_rgb <https://components.espressif.com/components/espressif/esp_lcd_st77903_rgb>`_, `st77922 <https://components.espressif.com/components/espressif/esp_lcd_st77922>`_, `gc9503 <https://components.espressif.com/components/espressif/esp_lcd_gc9503>`_
9494

docs/zh_CN/display/lcd/lcd_guide.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,3 +356,7 @@ RGB 接口
356356
显示是指 LCD 的驱动 IC 将接收到的图像数据显示到屏幕上的过程,其快慢可以用 **屏幕刷新率** 来衡量。
357357

358358
对于 SPI/I80 接口的 LCD,屏幕刷新率是由 LCD 驱动 IC 决定的,一般可以通过发送特定的命令来设置,如 *ST7789* 的 ``FRCTRL2(C6h)`` 命令;对于 RGB 接口的 LCD,屏幕刷新率是由主控决定的,其等价于接口帧率。
359+
360+
.. note::
361+
362+
- 若需要在无 LCD 的情况下开发,可以通过 `esp_lcd_usb_display 组件 <https://components.espressif.com/components/espressif/esp_lcd_usb_display>`_ 通过 USB UVC 在 PC 显示器上模拟 LCD 的显示效果,从而调试应用程序。其对应示例为 `usb_lcd_display <https://github.com/espressif/esp-iot-solution/tree/master/examples/usb/device/usb_lcd_display>`_

examples/camera/video_lcd_display/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ This example is based on the [esp_video](https://github.com/espressif/esp-video-
99

1010
## ESP-IDF Required
1111

12-
- Currently, this example only supports compilation and use on the ESP-IDF master branch. The recommended commit for testing is: ac6c54c997f68662ed2c0b6cb07edd3736175c16.
12+
- This example supports ESP-IDF release/v5.4 and later branches. By default, it runs on ESP-IDF release/v5.4.
1313
- Please follow the [ESP-IDF Programming Guide](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/index.html) to set up the development environment. **We highly recommend** you [Build Your First Project](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/get-started/index.html#build-your-first-project) to get familiar with ESP-IDF and make sure the environment is set up correctly.
1414

1515
### Prerequisites

examples/camera/video_lcd_display/main/app_video.c

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,16 @@ static const char *TAG = "app_video";
2828
typedef struct {
2929
uint8_t *camera_buffer[MAX_BUFFER_COUNT];
3030
size_t camera_buf_size;
31+
uint8_t camera_buf_count;
3132
uint32_t camera_buf_hes;
3233
uint32_t camera_buf_ves;
3334
struct v4l2_buffer v4l2_buf;
3435
uint8_t camera_mem_mode;
3536
app_video_frame_operation_cb_t user_camera_video_frame_operation_cb;
3637
TaskHandle_t video_stream_task_handle;
38+
uint8_t video_task_core_id;
39+
bool video_task_delete;
40+
void *video_task_user_data;
3741
} app_video_t;
3842

3943
static app_video_t app_camera_video;
@@ -170,6 +174,7 @@ esp_err_t app_video_set_bufs(int video_fd, uint32_t fb_num, const void **fb)
170174

171175
memset(&req, 0, sizeof(req));
172176
req.count = fb_num;
177+
app_camera_video.camera_buf_count = fb_num;
173178
req.type = type;
174179

175180
app_camera_video.camera_mem_mode = req.memory = fb ? V4L2_MEMORY_USERPTR : V4L2_MEMORY_MMAP;
@@ -279,7 +284,8 @@ static inline void video_operation_video_frame(int video_fd)
279284
buf_index,
280285
app_camera_video.camera_buf_hes,
281286
app_camera_video.camera_buf_ves,
282-
app_camera_video.camera_buf_size
287+
app_camera_video.camera_buf_size,
288+
app_camera_video.video_task_user_data
283289
);
284290
}
285291

@@ -345,12 +351,21 @@ static void video_stream_task(void *arg)
345351
video_operation_video_frame(video_fd);
346352

347353
ESP_ERROR_CHECK(video_free_video_frame(video_fd));
354+
355+
if (app_camera_video.video_task_delete) {
356+
app_camera_video.video_task_delete = false;
357+
ESP_ERROR_CHECK(video_stream_stop(video_fd));
358+
vTaskDelete(NULL);
359+
}
348360
}
349361
vTaskDelete(NULL);
350362
}
351363

352-
esp_err_t app_video_stream_task_start(int video_fd, int core_id)
364+
esp_err_t app_video_stream_task_start(int video_fd, int core_id, void *user_data)
353365
{
366+
app_camera_video.video_task_core_id = core_id;
367+
app_camera_video.video_task_user_data = user_data;
368+
354369
video_stream_start(video_fd);
355370

356371
BaseType_t result = xTaskCreatePinnedToCore(video_stream_task, "video stream task", VIDEO_TASK_STACK_SIZE, &video_fd, VIDEO_TASK_PRIORITY, &app_camera_video.video_stream_task_handle, core_id);
@@ -367,14 +382,25 @@ esp_err_t app_video_stream_task_start(int video_fd, int core_id)
367382
return ESP_FAIL;
368383
}
369384

370-
esp_err_t app_video_stream_task_stop(int video_fd)
385+
esp_err_t app_video_stream_task_restart(int video_fd)
371386
{
372-
if (app_camera_video.video_stream_task_handle != NULL) {
373-
vTaskDelete(app_camera_video.video_stream_task_handle);
374-
app_camera_video.video_stream_task_handle = NULL;
387+
app_video_set_bufs(video_fd, app_camera_video.camera_buf_count, (const void **)app_camera_video.camera_buffer);
388+
389+
esp_err_t ret = app_video_stream_task_start(video_fd, app_camera_video.video_task_core_id, app_camera_video.video_task_user_data);
390+
if (ret != ESP_OK) {
391+
ESP_LOGE(TAG, "failed to restart video stream task");
392+
goto errout;
375393
}
376394

377-
ESP_ERROR_CHECK(video_stream_stop(video_fd));
395+
return ESP_OK;
396+
397+
errout:
398+
return ESP_FAIL;
399+
}
400+
401+
esp_err_t app_video_stream_task_stop(int video_fd)
402+
{
403+
app_camera_video.video_task_delete = true;
378404

379405
return ESP_OK;
380406
}

0 commit comments

Comments
 (0)