From cf3201dd2f22300c517a9fc55c1becff6d28ef89 Mon Sep 17 00:00:00 2001 From: LiHuashen <854410664@qq.com> Date: Wed, 23 Jan 2019 10:54:28 +0800 Subject: [PATCH] add USB docs ( english version ) --- docs/en/module/usb.md | 85 +++++++++++++++++++++++++++++++++++++++++++ docs/en/unit/gps.md | 6 +-- docs/index.md | 4 +- 3 files changed, 89 insertions(+), 6 deletions(-) diff --git a/docs/en/module/usb.md b/docs/en/module/usb.md index e69de29b..f534ff28 100644 --- a/docs/en/module/usb.md +++ b/docs/en/module/usb.md @@ -0,0 +1,85 @@ +# USB + + + +*** + +: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 + +USB模块是一款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 +#include +#include +#include +#include +#include +#include "M5Mouse.h" + +// new objects +USB Usb; +USBHub Hub(&Usb); +HIDBoot 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); +} +``` + + + +## Schematic + + \ No newline at end of file diff --git a/docs/en/unit/gps.md b/docs/en/unit/gps.md index d619dc03..9bef7c9a 100644 --- a/docs/en/unit/gps.md +++ b/docs/en/unit/gps.md @@ -22,14 +22,14 @@ - 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/)** diff --git a/docs/index.md b/docs/index.md index fe983e5a..04c587e6 100644 --- a/docs/index.md +++ b/docs/index.md @@ -47,9 +47,7 @@ **Expansion Modules** -[![battery_01.jpg](http://m5-docs.oss-cn-shenzhen.aliyuncs.com/assets/img/product_pics/homepage_picture/module/module_battery_01.png)](en/module/battery)         [![proto_01.jpg](http://m5-docs.oss-cn-shenzhen.aliyuncs.com/assets/img/product_pics/homepage_picture/module/module_proto_01.png)](en/module/proto)         [![plus_1.png](http://m5-docs.oss-cn-shenzhen.aliyuncs.com/assets/img/product_pics/homepage_picture/module/module_plus_01.png)](en/module/plus) - - +[![battery_01.jpg](http://m5-docs.oss-cn-shenzhen.aliyuncs.com/assets/img/product_pics/homepage_picture/module/module_battery_01.png)](en/module/battery)         [![proto_01.jpg](http://m5-docs.oss-cn-shenzhen.aliyuncs.com/assets/img/product_pics/homepage_picture/module/module_proto_01.png)](en/module/proto)         [![plus_1.png](http://m5-docs.oss-cn-shenzhen.aliyuncs.com/assets/img/product_pics/homepage_picture/module/module_plus_01.png)](en/module/plus)         [![module_usb.jpg](http://m5-docs.oss-cn-shenzhen.aliyuncs.com/assets/img/product_pics/homepage_picture/module/module_usb_01.png)](en/module/usb)