mirror of
https://github.com/m5stack/m5-docs.git
synced 2026-05-20 10:23:01 -07:00
add USB docs ( english version )
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
# USB
|
||||
|
||||
<img src="assets/img/product_pics/module/module_usb_01.png" width="30%" height="30%"> <img src="assets/img/product_pics/module/module_usb_02.png" width="30%" height="30%">
|
||||
|
||||
***
|
||||
|
||||
:memo:**[Description](#Description)** :octocat:**[Example](#Example)** :electric_plug:**[Schematic](#Schematic)** 🛒**[Purchase](https://www.aliexpress.com/store/product/M5Stack-New-USB-Module-USB-HOST-HID-with-MAX3421E-SPI-Interface-Output-5-Input-5-Compatible/3226069_32961627365.html?spm=2114.12010615.8148356.4.6c042548sAUbGi)**
|
||||
|
||||
## Description
|
||||
|
||||
<mark>USB模块</mark>是一款USB控制器,内置了USB芯片MAX3421E。堆叠了M5Core之后,通过通信速率可高达26MHz的SPI接口与M5Core连接,即可作USB外设又可作USB主机。
|
||||
|
||||
## Feature
|
||||
|
||||
- 高达26MHz的SPI接口
|
||||
- 8路GPIO输入输出
|
||||
- 内置锂电池接口
|
||||
|
||||
## Including
|
||||
|
||||
- 1x USB模块
|
||||
|
||||
## Application
|
||||
|
||||
- USB键盘记录器
|
||||
- M5Core读写U盘
|
||||
|
||||
## Related Link
|
||||
|
||||
- **[Offical Video](https://www.youtube.com/channel/UCozgFVglWYQXbvTmGyS739w)**
|
||||
|
||||
- **[Forum](http://forum.m5stack.com/)**
|
||||
|
||||
- **[Datasheet]** - [MAX3421E](https://www.sparkfun.com/datasheets/DevTools/Arduino/MAX3421E.pdf)
|
||||
|
||||
## Example
|
||||
|
||||
*以下仅为用法示意,并不完整。如果需要完整例程请点击[这里](https://github.com/m5stack/M5-ProductExampleCodes/tree/master/Module/USB/Arduino)。*
|
||||
|
||||
烧录例程`usb_mouse.ino`,USB鼠标接入模块之后,按住左键并拖动鼠标描绘白色线条;按住右键,描述绿色线条;按下中间滚轮键,清屏。
|
||||
|
||||
```arduino
|
||||
#include <M5Stack.h>
|
||||
#include <SPI.h>
|
||||
#include <Usb.h>
|
||||
#include <hiduniversal.h>
|
||||
#include <hidboot.h>
|
||||
#include <usbhub.h>
|
||||
#include "M5Mouse.h"
|
||||
|
||||
// new objects
|
||||
USB Usb;
|
||||
USBHub Hub(&Usb);
|
||||
HIDBoot<USB_HID_PROTOCOL_MOUSE> HidMouse(&Usb);
|
||||
MouseRptParser Prs;
|
||||
|
||||
// initialization
|
||||
M5.begin();
|
||||
Usb.Init();
|
||||
HidMouse.SetReportParser(0,(HIDReportParser*)&Prs);
|
||||
|
||||
// handle event coming from usb device
|
||||
Usb.Task();
|
||||
if(Usb.getUsbTaskState() == USB_STATE_RUNNING)
|
||||
{
|
||||
Mouse_Pointer(mou_px, mou_py);
|
||||
mou_px = 0;
|
||||
mou_py = 0;
|
||||
/* left button pressed: draw white point */
|
||||
if (mou_button == 1)
|
||||
M5.Lcd.drawCircle(StaPotX, StaPotY, 1, WHITE);
|
||||
/* right button pressed: draw green point */
|
||||
if (mou_button == 2)
|
||||
M5.Lcd.drawCircle(StaPotX, StaPotY, 1, GREEN);
|
||||
/* middle button pressed: clear screen */
|
||||
if (mou_button == 4)
|
||||
M5.Lcd.fillScreen(BLACK);
|
||||
}
|
||||
```
|
||||
|
||||
<img src="assets/img/product_pics/module/module_example/USB/example_module_usb_01.png">
|
||||
|
||||
## Schematic
|
||||
|
||||
<img src="assets/img/product_pics/module/usb_sch.png">
|
||||
+3
-3
@@ -22,14 +22,14 @@
|
||||
<!-- - GROVE接口,支持[UiFlow](http://flow.m5stack.com)编程,[Arduino](http://www.arduino.cc)编程 -->
|
||||
- With two Lego plugin holes on the Unit, it could be more easier to compatable with Lego mountings
|
||||
|
||||
## 应用
|
||||
## Application
|
||||
|
||||
- Vehicle location
|
||||
- Intelligent Law enforcement location
|
||||
|
||||
## 相关链接
|
||||
## Related Link
|
||||
|
||||
- **[Offical Video](https://i.youku.com/i/UNjE1ODA2MzE0OA==?spm=a2hzp.8253869.0.0)**
|
||||
- **[Offical Video](https://www.youtube.com/channel/UCozgFVglWYQXbvTmGyS739w)**
|
||||
|
||||
- **[Forum](http://forum.m5stack.com/)**
|
||||
|
||||
|
||||
+1
-3
@@ -47,9 +47,7 @@
|
||||
|
||||
**Expansion Modules**
|
||||
|
||||
[](en/module/battery) [](en/module/proto) [](en/module/plus)
|
||||
|
||||
<!-- [](en/module/usb) -->
|
||||
[](en/module/battery) [](en/module/proto) [](en/module/plus) [](en/module/usb)
|
||||
|
||||
<!-- |[BATTERY]()|[PROTO]()| -->
|
||||
|
||||
|
||||
Reference in New Issue
Block a user