esp-idf-ssd1306/MouseMoveDemo/README.md

73 lines
2.6 KiB
Markdown
Raw Normal View History

2024-08-21 04:41:49 -04:00
# MouseMoveDemo for SSD1306
2024-08-21 01:51:03 -04:00
Demo of moving a circle using the mouse.
2024-08-21 02:42:43 -04:00
The circle moves when you move the mouse.
2024-08-21 08:51:17 -04:00
I used [this](https://github.com/espressif/esp-idf/tree/master/examples/peripherals/usb/host/hid) as a reference.
2024-08-21 01:51:03 -04:00
# Hardware requirements
2024-08-21 01:52:47 -04:00
- ESP32S2/S3
These have USB-HOST functionality.
2024-08-21 01:51:03 -04:00
2024-08-21 01:52:47 -04:00
- USB Connector
2024-08-21 03:06:43 -04:00
I used this:
2024-08-21 21:26:25 -04:00
![usb-conector-3](https://github.com/user-attachments/assets/05f3f79d-00d1-4d65-ad46-67d2e987bc88)
2024-08-21 01:51:03 -04:00
2024-08-21 01:55:40 -04:00
- USB mouse
2024-08-21 01:56:34 -04:00
2-button or 3-button usb mouse.
2024-08-21 01:55:40 -04:00
Button 3 is not used in this project.
2024-08-21 01:51:03 -04:00
2024-08-21 03:02:31 -04:00
# USB wiring
2024-08-21 19:14:16 -04:00
To stabilize the power supply, I placed a 100uF electrolytic capacitor between 5V and GND.
2024-08-21 03:02:31 -04:00
```
2024-08-21 19:14:16 -04:00
ESP32-S2/S3 BOARD USB CONNECTOR
+--+
[ 5V ] +---------> | || VCC
[GPIO 19] |---------> | || D-
[GPIO 20] |---------> | || D+
[ GND ] |--------+> | || GND
| | +--+
+---||---+
100uF
2024-08-21 03:02:31 -04:00
```
2024-08-21 03:01:22 -04:00
# How to Use
2024-08-21 01:51:03 -04:00
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)
2024-08-21 03:45:22 -04:00
# 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.
2024-08-21 01:51:03 -04:00
2024-08-22 00:11:55 -04:00
# Transfer failed error
2024-08-22 00:10:05 -04:00
For some reason, the following error may occur in rare cases.
2024-08-22 00:45:29 -04:00
This error occurs within [this](https://components.espressif.com/components/espressif/usb_host_hid) component.
2024-08-22 00:27:56 -04:00
It is unclear whether it is a component bug or an effect of electrical noise.
2024-08-22 00:37:09 -04:00
Some kind of stabilization circuitry may be required.
2024-08-22 00:08:47 -04:00
It may come back to life if you unplugging the mouse and plugging it again.
2024-08-22 00:40:17 -04:00
I would like to hear the opinion of someone who is familiar with USB electrical circuits.
2024-08-21 23:59:57 -04:00
```
E (12287696) hid-host: Transfer failed, status 1
E (12287696) usb_hid: HID Device, protocol 'MOUSE' TRANSFER_ERROR
E (15953516) USBH: Device 1 gone
```
2024-08-22 00:55:43 -04:00
# Keyboard with mouse function
I have a keyboard with mouse functionality, but the keyboard with mouse functionality does not work as a mouse.
See [here](https://github.com/espressif/esp-idf/issues/12667).