mirror of
https://github.com/nopnop2002/esp-idf-ssd1306.git
synced 2024-09-20 02:06:31 -04:00
65 lines
2.1 KiB
Markdown
65 lines
2.1 KiB
Markdown
# MouseMoveDemo for SSD1306
|
|
Demo of moving a circle using the mouse.
|
|
The circle moves when you move the mouse.
|
|
I used [this](https://github.com/espressif/esp-idf/tree/master/examples/peripherals/usb/host/hid) as a reference.
|
|
|
|
# Hardware requirements
|
|
|
|
- ESP32S2/S3
|
|
These have USB-HOST functionality.
|
|
|
|
- USB Connector
|
|
I used this:
|
|
![usb-conector-3](https://github.com/user-attachments/assets/05f3f79d-00d1-4d65-ad46-67d2e987bc88)
|
|
|
|
- USB mouse
|
|
2-button or 3-button usb mouse.
|
|
Button 3 is not used in this project.
|
|
|
|
# USB wiring
|
|
To stabilize the power supply, I placed a 100uF electrolytic capacitor between 5V and GND.
|
|
```
|
|
ESP32-S2/S3 BOARD USB CONNECTOR
|
|
+--+
|
|
[ 5V ] +---------> | || VCC
|
|
[GPIO 19] |---------> | || D-
|
|
[GPIO 20] |---------> | || D+
|
|
[ GND ] |--------+> | || GND
|
|
| | +--+
|
|
+---||---+
|
|
100uF
|
|
```
|
|
|
|
# How to Use
|
|
The circle moves when you move the mouse.
|
|
![usb-mouse-3](https://github.com/user-attachments/assets/020e0f71-aff5-4e12-8fad-1dc724336f2e)
|
|
|
|
Invert with left mouse click.
|
|
![usb-mouse-2](https://github.com/user-attachments/assets/28ec7de7-d741-408a-8ed6-6821277129c7)
|
|
|
|
|
|
Right click the mouse to go back.
|
|
![usb-mouse-1](https://github.com/user-attachments/assets/b8d152c5-2aed-450b-9f18-721f051c0b23)
|
|
|
|
# USB hot socket
|
|
There are times when it works correctly and times when it doesn't.
|
|
It works more stably if you connect before starting the firmware.
|
|
When it works correctly, a log like this will be displayed.
|
|
```
|
|
I (1166) usb_hid: hid_host_device_callback
|
|
I (1166) usb_hid: HID Device, protocol 'MOUSE' CONNECTED
|
|
```
|
|
|
|
# Using USB-HUB
|
|
I tried it, but it doesn't work properly via USB-HUB.
|
|
|
|
# Transfer failed
|
|
For some reason, the following errors may occur.
|
|
This error occurs inside the usb_host_hid library.
|
|
The cause is unknown, but it may be resolved by unplugging the mouse.
|
|
```
|
|
E (12287696) hid-host: Transfer failed, status 1
|
|
E (12287696) usb_hid: HID Device, protocol 'MOUSE' TRANSFER_ERROR
|
|
E (15953516) USBH: Device 1 gone
|
|
```
|