Skip to content

Commit 5af44e2

Browse files
committed
Merge branch 'docs/add_usb_extern_lcd_docs' into 'master'
docs(usb_extern_lcd): add introduce for the usb extern lcd example See merge request ae_group/esp-iot-solution!1122
2 parents 282ff11 + 801372e commit 5af44e2

File tree

5 files changed

+90
-2
lines changed

5 files changed

+90
-2
lines changed

docs/en/usb/usb_overview/usb_device_solutions.rst

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,3 +119,31 @@ Links:
119119

120120
* `Read/Write NVS with USB Flash Drive <https://github.com/espressif/esp-iot-solution/tree/master/examples/usb/device/usb_uf2_nvs>`_
121121
* `Virtual USB Flash Drive UF2 OTA Upgrade <https://github.com/espressif/esp-iot-solution/tree/master/examples/usb/device/usb_uf2_ota>`_
122+
123+
USB Extended Screen Solution
124+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
125+
126+
The USB extended screen solution allows a device to function as an additional display through a USB connection. It supports data transmission over a single USB cable, including audio, touch information, and video. This solution can be applied in various scenarios such as computer monitors, signature pads, and extended display setups.
127+
128+
Host-side Driver
129+
~~~~~~~~~~~~~~~~~~~~~~~
130+
131+
Since USB 2.0 does not support HDMI transmission, the host must transmit image data to the device. Currently, this solution only supports the Windows platform, utilizing the Windows driver model, [`IDD (Indirect Display Driver)`](https://learn.microsoft.com/en-us/windows-hardware/drivers/display/indirect-display-driver-model-overview). This driver captures the desktop image from Windows. Due to USB's speed limitations, the image is first compressed into formats like JPEG, and then transmitted through the USB vendor interface. Each image frame is prepended with a 16-byte header containing details such as image width, height, format, length, and compression type.
132+
133+
Features
134+
~~~~~~~~~~~~~~~~~
135+
136+
- Supports image transmission via USB
137+
- Supports audio transmission via USB
138+
- Supports touch data transmission via USB
139+
140+
Hardware
141+
~~~~~~~~~~~~~~
142+
143+
- Chips: ESP32-S2, ESP32-S3, ESP32-P4
144+
- Peripheral: USB-OTG
145+
146+
Links
147+
~~~~~~~~~~
148+
149+
- [P4 USB Extended Screen Example](https://github.com/espressif/esp-iot-solution/tree/master/examples/usb/device/usb_extend_screen)

docs/zh_CN/usb/usb_overview/usb_device_solutions.rst

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,31 @@ U 盘拖拽升级
122122

123123
* `U 盘读写 NVS <https://github.com/espressif/esp-iot-solution/tree/master/examples/usb/device/usb_uf2_nvs>`_
124124
* `虚拟 U 盘 UF2 升级 <https://github.com/espressif/esp-iot-solution/tree/master/examples/usb/device/usb_uf2_ota>`_
125+
126+
USB 扩展屏方案
127+
^^^^^^^^^^^^^^^^^
128+
129+
USB 扩展屏方案通过 USB 总线将设备作为一块扩展副屏使用。支持通过一根 USB 数据线传输音频,触摸信息,视频图像等数据。可以应用在电脑屏幕,签字屏,扩展屏等应用场景。
130+
131+
上位机驱动
132+
~~~~~~~~~~~~
133+
134+
USB2.0 驱动不支持 HDMI 传输,因此需要上位机将图像数据传输给设备,本应用方案暂时仅支持 Windows 平台,采用 Windows 驱动 `IDD <https://learn.microsoft.com/en-us/windows-hardware/drivers/display/indirect-display-driver-model-overview>`_,通过驱动可以拿到 Windows 的桌面图像,因为 USB 速率限制,在驱动中会先将图像处理成 JEPG 等格式,然后通过 USB vendor 接口将图像传输到设备。每一帧图像添加 16 字节的头,包含图像的宽高,图像的格式,图像的长度,图像的压缩类型等。
135+
136+
特性:
137+
~~~~~~
138+
139+
* 支持通过 USB 传输图像
140+
* 支持通过 USB 传输音频
141+
* 支持通过 USB 传输触摸信息
142+
143+
硬件:
144+
~~~~~~
145+
146+
* 芯片:ESP32-S2,ESP32-S3,ESP32-P4
147+
* 外设:USB-OTG
148+
149+
链接:
150+
~~~~~~
151+
152+
* `P4 USB 扩展屏 <https://github.com/espressif/esp-iot-solution/tree/master/examples/usb/device/usb_extend_screen>`_

examples/usb/device/usb_extend_screen/README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,10 @@ For preparation, refer to the [windows_driver](./windows_driver/README.md)
5151

5252
### Adjusting JPEG Image Quality
5353

54-
* Modify the `string_desc_arr` vendor interface string in the `usb_descriptor.c` file. Change `Ejpg4` to the desired image quality level; the higher the number, the better the quality, but it will use more memory for the same frame.
54+
* Modify the `string_desc_arr` vendor interface string in the `usb_descriptor.c` file. Change `Ejpg4` to the desired image quality level; the higher the number, the better the quality, but it will use more memory for the same frame.
55+
56+
### Modify Screen Resolution
57+
58+
- Update the `usb_descriptor.c` file by changing the `string_desc_arr` vendor interface string. Modify `R1024x600` to the desired screen resolution.
59+
60+
**Note**: Currently, the driver does not support portrait mode screens. Please use hardware that is designed for landscape orientation.

examples/usb/device/usb_extend_screen/README_cn.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,9 @@ USB 扩展屏示例可以将 P4 开发板作为一块 windows 的副屏。支持
5858
### 调高/调低 JPEG 的图片质量
5959

6060
* 修改 `usb_descriptor.c` 文件中的 `string_desc_arr` Vendor 接口字符串,将 `Ejpg4` 修改为所需的图片质量,数字越大质量越高,同样的一帧图像占用内存更多。
61+
62+
### 修改屏幕分辨率
63+
64+
* 修改 `usb_descriptor.c` 文件中的 `string_desc_arr` Vendor 接口字符串,将 `R1024x600` 修改为所需的屏幕大小
65+
66+
Note: 目前驱动不支持竖屏的屏幕,请使用硬件上为横屏的屏幕。

examples/usb/device/usb_extend_screen/main/app_vendor.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,15 @@ void transfer_task(void *pvParameter)
4848
}
4949
}
5050

51+
static bool buffer_skip(frame_info_t *frame_info, uint32_t len)
52+
{
53+
if (frame_info->received + len >= frame_info->total) {
54+
return true;
55+
}
56+
frame_info->received += len;
57+
return false;
58+
}
59+
5160
static bool buffer_fill(frame_t *frame, uint8_t *buf, uint32_t len)
5261
{
5362
if (0 == len) {
@@ -68,11 +77,13 @@ static bool buffer_fill(frame_t *frame, uint8_t *buf, uint32_t len)
6877
void tud_vendor_rx_cb(uint8_t itf)
6978
{
7079
static uint8_t rx_buf[CONFIG_USB_VENDOR_RX_BUFSIZE];
80+
static bool skip_frame = false;
81+
static frame_info_t skip_frame_info = {0};
7182

7283
while (tud_vendor_n_available(itf)) {
7384
int read_res = tud_vendor_n_read(itf, rx_buf, CONFIG_USB_VENDOR_RX_BUFSIZE);
7485
if (read_res > 0) {
75-
if (!current_frame) {
86+
if (!current_frame && !skip_frame) {
7687
udisp_frame_header_t *pblt = (udisp_frame_header_t *)rx_buf;
7788
switch (pblt->type) {
7889
case UDISP_TYPE_RGB565:
@@ -104,6 +115,10 @@ void tud_vendor_rx_cb(uint8_t itf)
104115
current_frame = NULL;
105116
}
106117
} else {
118+
memset(&skip_frame_info, 0, sizeof(skip_frame_info));
119+
skip_frame_info.total = pblt->payload_total;
120+
skip_frame = true;
121+
buffer_skip(&skip_frame_info, read_res - sizeof(udisp_frame_header_t));
107122
ESP_LOGE(TAG, "Get frame is null");
108123
}
109124
break;
@@ -112,6 +127,11 @@ void tud_vendor_rx_cb(uint8_t itf)
112127
ESP_LOGE(TAG, "error cmd");
113128
break;
114129
}
130+
} else if (skip_frame) {
131+
if (buffer_skip(&skip_frame_info, read_res)) {
132+
current_frame = NULL;
133+
skip_frame = false;
134+
}
115135
} else {
116136
if (buffer_fill(current_frame, rx_buf, read_res)) {
117137
current_frame = NULL;

0 commit comments

Comments
 (0)