From 8074a86810ddc5cf363dbdc9a5dc46e1fea9e6e5 Mon Sep 17 00:00:00 2001 From: LiHuashen <854410664@qq.com> Date: Sun, 2 Dec 2018 23:17:25 +0800 Subject: [PATCH 1/2] translate docs to chinese --- docs/zh_CN/api_reference.md | 2 + docs/zh_CN/product_documents.md | 20 +++---- .../applications/application_bala.md | 56 ++++++------------- .../applications/application_lidarbot.md | 2 +- .../tools/tool_usb_downloader.md | 4 +- .../quick_start/bala/bala_quick_start.md | 2 +- .../m5camera/m5camera_quick_start.md | 18 +++--- .../how_to_install_git_and_arduino.md | 16 +++--- .../related_documents/upgrade_m5stack_lib.md | 12 ++-- 9 files changed, 56 insertions(+), 76 deletions(-) diff --git a/docs/zh_CN/api_reference.md b/docs/zh_CN/api_reference.md index a0655df4..aadc19ee 100644 --- a/docs/zh_CN/api_reference.md +++ b/docs/zh_CN/api_reference.md @@ -2,6 +2,8 @@ 中文 | [English](/en/api_reference) | [日本語](/ja/api_reference) +*这是MicroPython的编程API* + ## [LCD](zh_CN/api_reference/api_lcd) ## [Peripherals](zh_CN/api_reference/peripherals/api_gpio) ### 1. [GPIO](zh_CN/api_reference/peripherals/api_gpio) diff --git a/docs/zh_CN/product_documents.md b/docs/zh_CN/product_documents.md index fef8b17f..a39938fc 100644 --- a/docs/zh_CN/product_documents.md +++ b/docs/zh_CN/product_documents.md @@ -1,6 +1,6 @@ # 产品列表 -中文 | [English](/en/product_documents) | [日本語](ja/product_documents) +中文 | [English](en/product_documents) | [日本語](ja/product_documents) ?> 每个产品的`快速上手(Quick Start)`部分都放置在了该产品的介绍文档里。 @@ -12,17 +12,17 @@ | [GRAY](zh_CN/product_documents/m5stack-core/m5core_gray) | / | | [FIRE](zh_CN/product_documents/m5stack-core/m5core_fire) | / | | [FACE Kit](zh_CN/product_documents/m5stack-core/face_kit) | / | -| [M5GO IOT Kit](/zh_CN/product_documents/m5stack-core/m5go_iot_starter_kit) | / | +| [M5GO IOT Kit](zh_CN/product_documents/m5stack-core/m5go_iot_starter_kit) | / | | 无线通信模块 | 配件模块 | 控制模块 | | :------------------: |:------------------:| :--------------------:| -| [GPS](/zh_CN/product_documents/modules/module_gps) | [PROTO](/zh_CN/product_documents/modules/module_proto) | [STEPMOTOR](/zh_CN/product_documents/modules/module_stepmotor)| -| [LORA](/zh_CN/product_documents/modules/module_lora) | [BATTERY](/zh_CN/product_documents/modules/module_battery) | [SERVO](/zh_CN/product_documents/modules/module_servo) | -| [SIM800/GPRS/GSM](/zh_CN/product_documents/modules/module_sim800) | [BTC](/zh_CN/product_documents/modules/module_btc) | [COMMU](/zh_CN/product_documents/modules/module_commu) | -| [LoRaWAN](/zh_CN/product_documents/modules/module_lorawan) | [PLUS](/zh_CN/product_documents/modules/module_plus) | / | +| [GPS](zh_CN/product_documents/modules/module_gps) | [PROTO](zh_CN/product_documents/modules/module_proto) | [STEPMOTOR](zh_CN/product_documents/modules/module_stepmotor)| +| [LORA](zh_CN/product_documents/modules/module_lora) | [BATTERY](zh_CN/product_documents/modules/module_battery) | [SERVO](zh_CN/product_documents/modules/module_servo) | +| [SIM800/GPRS/GSM](zh_CN/product_documents/modules/module_sim800) | [BTC](zh_CN/product_documents/modules/module_btc) | [COMMU](zh_CN/product_documents/modules/module_commu) | +| [LoRaWAN](zh_CN/product_documents/modules/module_lorawan) | [PLUS](zh_CN/product_documents/modules/module_plus) | / | | / | / | / | | / | / | / | | / | / | / | @@ -33,9 +33,9 @@ | | | | | :------------------: |:------------------:| :--------------------:| -| [M5GO底座](/zh_CN/product_documents/bases/m5go_base) | [PLC底座](/zh_CN/product_documents/modules/module_plc) | [FACE底座](/zh_CN/product_documents/bases/face_base) | -| [LAN底座](/zh_CN/product_documents/bases/lan_base) | / | / | -| [Node底座](/zh_CN/product_documents/bases/node_base) | / | / | +| [M5GO底座](zh_CN/product_documents/bases/m5go_base) | [PLC底座](zh_CN/product_documents/modules/module_plc) | [FACE底座](zh_CN/product_documents/bases/face_base) | +| [LAN底座](zh_CN/product_documents/bases/lan_base) | / | / | +| [Node底座](zh_CN/product_documents/bases/node_base) | / | / | @@ -72,7 +72,7 @@ | | | | | :------------------: |:------------------:| :--------------------:| -| [BALA](/zh_CN/product_documents/applications/application_bala) | [LidarBot](/zh_CN/product_documents/applications/application_lidarbot) | / | +| [BALA](zh_CN/product_documents/applications/application_bala) | [LidarBot](zh_CN/product_documents/applications/application_lidarbot) | / | diff --git a/docs/zh_CN/product_documents/applications/application_bala.md b/docs/zh_CN/product_documents/applications/application_bala.md index d7f0c574..b5f79385 100644 --- a/docs/zh_CN/product_documents/applications/application_bala.md +++ b/docs/zh_CN/product_documents/applications/application_bala.md @@ -1,53 +1,31 @@ -# M5Stack BALA +# BALA -中文 | [English](/en/product_documents/applications/application_bala) | [日本語](ja/product_documents/applications/application_bala) +中文 | [English](en/product_documents/applications/application_bala) | [日本語](ja/product_documents/applications/application_bala) -## DESCRIPTION +## 描述 -The M5Stack BALA is a balance bot based on M5Stack FIRE, including a 2 DC driver module based on Mega328p which is a core chip on Arduino UNO -You can even program The M5Stack BALA through Arduino or MicroPython with few code +BALA是堆叠了M5Fire,以[M5Fire](https://m5stack.github.io/m5-docs/#/zh_CN/product_documents/m5stack-core/m5core_fire)做主控的平衡车应用,还包括了MEGA328为主控的2路直流电机驱动模块和两个轮子。你可以Arduino或MicroPython编程它。 -The 2 DC driver module communicates with M5Stack FIRE through I2C bus. It's default I2C address is **0x56** +2路直流电机模块与M5Fire之间通过IIC通信,它的IIC地址是**0x56**。 -## FEATURES +## 特性 -- Programming Support - + Python -- Compatible LEGO -- POGO Pin -- TF Card Support +- 支持Arduino编程和Python编程 +- 兼容LEGO +- M5Fire支持插入TF卡 -## PARAMETER - -Model | M5Stack FIRE ----|--- -ESP32 | 240MHz dual core, 600 DMIPS, 520KB SRAM, Wi-Fi, dual mode Bluetooth -Flash | 16MB Flash + 4MB pSRAM -Input | 5V @ 500mA -Interface | TypeC x 1, GROVE(I2C+I/0+UART), Pogo Pin x 1 -LCD | 2 inch, 320x240 Colorful TFT LCD, ILI9342 -Speaker | 1W-0928 -Microphone | MEMS Analog BSE3729 Microphone -LED | SK6812 3535 RGB LED x 10 -MEMS | MPU9250 (MPU6500 + AK8963) -Battery | 550mAh @ 3.7V, inside -Op.Temp. | 32°F to 104°F ( 0°C to 40°C ) -Size | 54 x 54 x 21 mm -C.A.S.E | Plastic ( PC ) -Weight | 56g - -## INCLUDES +## 包括 - 1x M5Stack BALA -- 1x Motor Driver -- 2x N20(Encoder included) -- Type-C USB Cable +- 1x 电机驱动 +- 2x 带编码器的N20电机 +- Type-C USB线 -## DOCUMENTS -- **Example** - [Arduino](https://github.com/m5stack/M5Bala/tree/master/examples) - [MicroPython](https://github.com/m5stack/M5Bala/tree/master/mpy) -- **[QuickStart](https://github.com/m5stack/M5Bala)** -- **[Purchase](https://www.aliexpress.com/store/product/M5Satck-New-BALA-Car-ESP32-Development-Mini-Electric-Self-balancing-Car-2DC-Motor-with-Encoder-PSRAM/3226069_32904033658.html?spm=2114.12010615.8148356.40.1fd3724dW3O2Bu.html)** +## 相关链接 +- **例程** - [Arduino](https://github.com/m5stack/M5Bala/tree/master/examples) - [MicroPython](https://github.com/m5stack/M5Bala/tree/master/mpy) +- **[上手指南](https://github.com/m5stack/M5Bala)** +- **[购买链接](https://www.aliexpress.com/store/product/M5Satck-New-BALA-Car-ESP32-Development-Mini-Electric-Self-balancing-Car-2DC-Motor-with-Encoder-PSRAM/3226069_32904033658.html?spm=2114.12010615.8148356.40.1fd3724dW3O2Bu.html)**
diff --git a/docs/zh_CN/product_documents/applications/application_lidarbot.md b/docs/zh_CN/product_documents/applications/application_lidarbot.md index 86706ff3..a83b4810 100644 --- a/docs/zh_CN/product_documents/applications/application_lidarbot.md +++ b/docs/zh_CN/product_documents/applications/application_lidarbot.md @@ -1,6 +1,6 @@ # LidarBot -中文 | [English](/en/product_documents/applications/application_lidarbot) | [日本語](ja/product_documents/applications/application_lidarbot) +中文 | [English](en/product_documents/applications/application_lidarbot) | [日本語](ja/product_documents/applications/application_lidarbot) ## 描述 diff --git a/docs/zh_CN/product_documents/tools/tool_usb_downloader.md b/docs/zh_CN/product_documents/tools/tool_usb_downloader.md index b3132936..b3b6a6b8 100644 --- a/docs/zh_CN/product_documents/tools/tool_usb_downloader.md +++ b/docs/zh_CN/product_documents/tools/tool_usb_downloader.md @@ -1,13 +1,11 @@ # M5Stack USB Downloader -中文 | [English](/en/product_documents/tools/tool_usb_downloader) | [日本語](ja/product_documents/tools/tool_usb_downloader) +中文 | [English](en/product_documents/tools/tool_usb_downloader) | [日本語](ja/product_documents/tools/tool_usb_downloader) ## 描述 内置CP2104芯片的串口转USB烧录工具,使用这款工具,能自动烧录固件。 -TXD led, RXD led, Power led and 6pin @ 2.54mm bus sockets. - ## 参数 | 管脚号 | 管脚名字 | diff --git a/docs/zh_CN/quick_start/bala/bala_quick_start.md b/docs/zh_CN/quick_start/bala/bala_quick_start.md index ab35a773..b051280c 100644 --- a/docs/zh_CN/quick_start/bala/bala_quick_start.md +++ b/docs/zh_CN/quick_start/bala/bala_quick_start.md @@ -2,4 +2,4 @@ 中文 | [English](en/quick_start/bala/bala_quick_start) | [日本語](ja/quick_start/bala/bala_quick_start) -## (coming soon...) \ No newline at end of file +## (在编辑中...) \ No newline at end of file diff --git a/docs/zh_CN/quick_start/m5camera/m5camera_quick_start.md b/docs/zh_CN/quick_start/m5camera/m5camera_quick_start.md index dc025d8f..cdd75db2 100644 --- a/docs/zh_CN/quick_start/m5camera/m5camera_quick_start.md +++ b/docs/zh_CN/quick_start/m5camera/m5camera_quick_start.md @@ -2,32 +2,32 @@ 中文 | [English](en/quick_start/m5camera/m5camera_quick_start) | [日本語](ja/quick_start/m5camera/m5camera_quick_start) -## 1. Out-of-the-box Demo +## 1. 开箱即用的Demo -It is really really out of the box. Your ESP32Cam/M5Camera will immediately run without any code after you power it. +*这是一个开箱即用的例程,摄像头模块预置了这个例程。* -1. plug usb cable into ESP32Cam/M5Camera and open the serial terminal on your computer. +*如果你拿到摄像头模块之后,不需要写任何代码即可能看到摄像头拍摄的图像。* + +1. 向ESP32Cam/M5Camera插入USB线以供电,然后打开电脑的串口终端。
-2. Then waitting a few seconds, you connect to a AP named "`M5CAM`" with your computer(or mobile phone). +2. 等待几秒之后,用电脑连接名为`M5CAM`的热点。
-3. And you open the browser on the computer(or mobile phone), enter a URL `http://192.168.4.1`. At the moment, your can see the real-time transmission of video by ESP32Cam/M5Camera on the browser. +3. 打开浏览器,访问网址`http://192.168.4.1`。 此时,即可看到ESP32Cam/M5Camera实时传输的图像。
-Now, A WebCam you achieved successfully ! +*注意:* -*Note:* - -ESP32CAM AP only can connect with one device at a time. +ESP32CAM的热点一次只能连接一台电脑 \ No newline at end of file diff --git a/docs/zh_CN/related_documents/how_to_install_git_and_arduino.md b/docs/zh_CN/related_documents/how_to_install_git_and_arduino.md index 3ff41dd8..1b0c2704 100644 --- a/docs/zh_CN/related_documents/how_to_install_git_and_arduino.md +++ b/docs/zh_CN/related_documents/how_to_install_git_and_arduino.md @@ -1,20 +1,22 @@ -# How to install Git and Arduino IDE (Windows) +# 安装Git和Arduino IDE (Windows) -中文 | [English](/en/related_documents/how_to_install_git_and_arduino) | [日本語](ja/related_documents/how_to_install_git_and_arduino) +中文 | [English](en/related_documents/how_to_install_git_and_arduino) | [日本語](ja/related_documents/how_to_install_git_and_arduino) -## 1. Install `Git` -If you has installed `Git`, please following next setp 2 straight.Otherwise, download the client of [Git](https://git-scm.com/download/win) and install it. +## 1. 安装`Git` +如果你已经安装了`Git`,请直接从第2步开始。 -## 2. Install `Arduino IDE` +否则点击这里下载[Git](https://git-scm.com/download/win)并安装它 -*download address* +## 2. 安装`Arduino IDE` + +*下载地址* https://www.arduino.cc/en/Main/Software
-Double click to install Arduino IDE +双击安装Arduino IDE,全程保持默认的选择,包括安装路径也是默认。
diff --git a/docs/zh_CN/related_documents/upgrade_m5stack_lib.md b/docs/zh_CN/related_documents/upgrade_m5stack_lib.md index 17af843e..81d30340 100644 --- a/docs/zh_CN/related_documents/upgrade_m5stack_lib.md +++ b/docs/zh_CN/related_documents/upgrade_m5stack_lib.md @@ -1,18 +1,18 @@ -# Upgrade M5Stack Lib +# 升级M5Stack库(Arduino IDE Library) -中文 | [English](/en/related_documents/upgrade_m5stack_lib) | [日本語](ja/related_documents/upgrade_m5stack_lib) +中文 | [English](en/related_documents/upgrade_m5stack_lib) | [日本語](ja/related_documents/upgrade_m5stack_lib) -### 1. Start up Arduino IDE, then Select `Sketch`->`Include Library`->`Manage Libraries...` +### 1. 打开Arduino IDE,然后点击`Sketch`->`Include Library`->`Manage Libraries...` -### 2. Type `M5Stack` into the search box, search it. +### 2. 在搜索框输入`M5Stack`,并搜索
Screenshot of coverpage
-### 3. If it shows as below figure, click `Update`. +### 3. 如果显示如下,则点击`Update`. -**But if it shows `Install`, it means you has not installed M5Stack Lib. So, you need click `Install` for installing lib.** +**但是如果显示`Install`,这意味着你之前还没安装M5Stack库,所以点击`Install`进行安装。**
Screenshot of coverpage From b53d3c15166a6711db25269caa0885c93622a84b Mon Sep 17 00:00:00 2001 From: LiHuashen <854410664@qq.com> Date: Mon, 3 Dec 2018 00:21:57 +0800 Subject: [PATCH 2/2] modified api_lcd.md --- docs/en/api_reference.md | 4 +- docs/en/api_reference/api_lcd.md | 228 ++++++++++++++++++++++------ docs/ja/api_reference.md | 4 +- docs/zh_CN/api_reference.md | 4 +- docs/zh_CN/api_reference/api_lcd.md | 228 ++++++++++++++++++++++------ 5 files changed, 368 insertions(+), 100 deletions(-) diff --git a/docs/en/api_reference.md b/docs/en/api_reference.md index d954243b..42ae2f42 100644 --- a/docs/en/api_reference.md +++ b/docs/en/api_reference.md @@ -3,6 +3,6 @@ [中文](/zh_CN/api_reference) | English | [日本語](/ja/api_reference) ## [LCD](en/api_reference/api_lcd) -## [Peripherals](en/api_reference/peripherals/api_gpio) + diff --git a/docs/en/api_reference/api_lcd.md b/docs/en/api_reference/api_lcd.md index dd9f15c7..0ad4325b 100644 --- a/docs/en/api_reference/api_lcd.md +++ b/docs/en/api_reference/api_lcd.md @@ -1,73 +1,207 @@ # LCD -### setbrightness -> M5.Lcd.setbrightness(uint8_t brightness); +[中文](https://m5stack.github.io/m5-docs/#/zh_CN/api_reference/api_lcd) | English -Set the brightness of LCD. - -| Param | Type | Description | -| --- | --- | --- | -| brightness | uint8_t | brightness(0-254) | +### lcd.setRotation(degree) **Example** -```c++ -M5.Lcd.setbrightness(100); +```python +lcd.setRotation(90) ``` +**Set the angle of rotation of the entire screen.** + +| Param | Description | +| --- | --- | +| degree | the angle of setRotation | + + + * * * -### fillScreen -> M5.Lcd.fillScreen(uint16_t color); - -Set the color to display of the whole LCD. - -| Param | Type | Description | -| --- | --- | --- | -| color | uint16_t | color value | +### lcd.setColor(color [, background_color]) **Example** -```c++ -M5.Lcd.fillScreen(RED); -delay(500); -M5.Lcd.fillScreen(WHITE); -delay(500); +```python +lcd.setColor(lcd.RED) +lcd.setColor(lcd.ORANGE, LCD.DARKCYAN) ``` +**Set the default foreground/background color of text.** + +| Param | Description | +| --- | --- | +| color | the color of text | +| background_color| the fill color of text | + * * * -### fillRect -> M5.Lcd.fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color); - -Draw a filled rectangle. - -| Param | Type | Description | -| --- | --- | --- | -| x, y | int16_t | offset of x, y direction | -| w, h | int16_t | width and height of graphics | -| color | uint16_t | color to fill | - +### lcd.fillScreen(color) **Example** -```c++ -M5.Lcd.fillRect(50,50,60,150,WHITE); +```python +lcd.fillScreen(lcd.RED) ``` +**Fill the entire screen with the given color.** + +| Param | Description | +| --- | --- | +| color | color value | + + * * * -### fillRoundRect -> M5.Lcd.fillRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color); +### lcd.drawPixel(x, y [,color]) +**Example** +```python +lcd.drawPixel(22,22,lcd.RED) +``` +**Draw the pixel at position (x,y)** -Draw a filled round rectangle. +*If color is not given, current foreground color is used* -| Param | Type | Description | -| --- | --- | --- | -| x, y | int16_t | offset of x, y direction | -| w, h | int16_t | width and height of graphics | -| radius | int16_t | fillet radius | -| color | uint16_t | color to fill | +| Param | Description | +| --- | --- | +| color | color value | + + + +* * * + +### lcd.drawLine(x, y, x1, y1 [,color]) +**Example** +```python +lcd.drawLine(0,0,12,12,lcd.WHITE) +``` +**Draw the line from point (x,y) to point (x1,y1)** + +*If color is not given, current foreground color is used* + +| Param | Description | +| --- | --- | +| color | color value | + + +* * * + +### lcd.drawTriangle(x, y, x1, y1, x2, y2 [,color]) **Example** -```c++ -M5.Lcd.fillRoundRect(50,50,60,150,4,WHITE); +```python +lcd.drawTriangle(22,22,69,98,51,22,lcd.RED) ``` -* * * \ No newline at end of file +**Draw the triangel between points (x,y), (x1,y1) and (x2,y2).** + +*If color is not given, current foreground color is used* + +| Param | Description | +| --- | --- | +| color | color value | + +* * * + +### lcd.fillTriangle(x, y, x1, y1, x2, y2 [,color]) + +**Example** +```python +lcd.fillTriangle(122, 122, 169, 198, 151, 182, lcd.RED) +``` +**Fill the triangel between points (x,y), (x1,y1) and (x2,y2).** + +*If color is not given, current foreground color is used* + +| Param | Description | +| --- | --- | +| color | color value | + + +* * * +### lcd.drawRect(x, y, w, h, [,color]) +**Example** +```python +lcd.drawRect(180, 12, 122, 10, lcd.BLUE) +``` +**Draw the rectangle from the upper left point at (x,y) and width and height.** + +*If color is not given, current foreground color is used* + +| Param | Description | +| --- | --- | +| w | display phisical width in pixels (display’s smaller dimension) | +| h | display phisical height in pixels (display’s larger dimension) | +| color | color value | + + + + +* * * + +### lcd.drawRoundRect(x, y, w, h, r [,color]) +**Example** +```python +lcd.fillRoundRect(180,70,122,10,4,lcd.BLUE) +``` +**Draw the rectangle with rounded corners from the upper left point at (x,y) and width and height. Corner radius is given by r argument.** + +*If color is not given, current foreground color is used* + +| Param | Description | +| --- | --- | +| w | display phisical width in pixels (display’s smaller dimension) | +| h | display phisical height in pixels (display’s larger dimension) | +| r | the radius of circle | +| color | color value | + + + + +* * * +### lcd.print(‘text’, [x, y]) +**Example** +```python +lcd.print('this is a print text function', 80, 80) +``` +**Print the text at position (x,y).** + +| Param | Description | +| --- | --- | +| text | the string need to print | + + +* * * + +### lcd.clear([color]) + +**Example** +```python +lcd.clear() +``` + +**Clear the screen with default background color orspecific color if given.** + + +* * * + +### Usage + +```python +from machine import SPI, Pin +from display import LCD + +spi = SPI(1, baudrate=32000000, mosi=Pin(23), miso=Pin(19), sck=Pin(18)) + +lcd = LCD(spi = spi) #lcd init +lcd.fillScreen(lcd.BLACK) #set the default background color + +lcd.drawLine(0, 0, lcd.WHITE) +lcd.drawTriangle(22, 22, 69, 98, 51, 22, lcd.RED) +lcd.fillTriangle(122, 122, 169, 198, 151, 182, lcd.RED) +lcd.drawCircle(180, 180, 10, lcd.BLUE) +lcd.fillcircle(100, 100, 10, lcd.BLUE) +lcd.drawRect(180, 12, 122, 10, lcd.BLUE) +lcd.fillRect(180, 30, 122, 10, lcd.BLUE) +lcd.drawRoundRect(180, 50, 122, 10, 4, lcd.BLUE) +lcd.fillRoundRect(180, 70, 122, 10, 4, lcd.BLUE) +lcd.print('this is a print text function', 80, 80) +``` diff --git a/docs/ja/api_reference.md b/docs/ja/api_reference.md index b4dba569..b816d576 100644 --- a/docs/ja/api_reference.md +++ b/docs/ja/api_reference.md @@ -2,7 +2,7 @@ [中文](/zh_CN/api_reference) | [English](/en/api_reference) | 日本語 -## [LCD](ja/api_reference/api_lcd) + \ No newline at end of file diff --git a/docs/zh_CN/api_reference.md b/docs/zh_CN/api_reference.md index aadc19ee..9cd540ee 100644 --- a/docs/zh_CN/api_reference.md +++ b/docs/zh_CN/api_reference.md @@ -5,6 +5,6 @@ *这是MicroPython的编程API* ## [LCD](zh_CN/api_reference/api_lcd) -## [Peripherals](zh_CN/api_reference/peripherals/api_gpio) + diff --git a/docs/zh_CN/api_reference/api_lcd.md b/docs/zh_CN/api_reference/api_lcd.md index a186603a..cf78ccd7 100644 --- a/docs/zh_CN/api_reference/api_lcd.md +++ b/docs/zh_CN/api_reference/api_lcd.md @@ -1,73 +1,207 @@ # LCD -### setbrightness -> M5.Lcd.setbrightness(uint8_t brightness); +中文 | [English](https://m5stack.github.io/m5-docs/#/en/api_reference/api_lcd) -设置LCD屏幕的亮度 - -| Param | Type | Description | -| --- | --- | --- | -| brightness | uint8_t | 亮度值(0-254) | +### lcd.setRotation(degree) **例程** -```c++ -M5.Lcd.setbrightness(100); +```python +lcd.setRotation(90) ``` +**设置整个屏幕显示的旋转角度。** + +| 参数 | 描述 | +| --- | --- | +| degree | 旋转的角度 | + + + * * * -### fillScreen -> M5.Lcd.fillScreen(uint16_t color); - -设置全屏颜色 - -| Param | Type | Description | -| --- | --- | --- | -| color | uint16_t | 颜色值 | +### lcd.setColor(color [, background_color]) **例程** -```c++ -M5.Lcd.fillScreen(RED); -delay(500); -M5.Lcd.fillScreen(WHITE); -delay(500); +```python +lcd.setColor(lcd.RED) +lcd.setColor(lcd.ORANGE, LCD.DARKCYAN) ``` +**设置显示文本的前景颜色和背景颜色。** + +| 参数 | 描述 | +| --- | --- | +| color | 文本的前景颜色 | +| background_color| 文本的背景颜色 | + * * * -### fillRect -> M5.Lcd.fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color); - -画填充形式的矩形图形 - -| Param | Type | Description | -| --- | --- | --- | -| x, y | int16_t | x和y方向的偏移量 | -| w, h | int16_t | 图形宽和高 | -| color | uint16_t | 填充的颜色 | - +### lcd.fillScreen(color) **例程** -```c++ -M5.Lcd.fillRect(50,50,60,150,WHITE); +```python +lcd.fillScreen(lcd.RED) ``` +**以指定的颜色填充整个屏幕。** + +| 参数 | 描述 | +| --- | --- | +| color | 颜色值 | + + * * * -### fillRoundRect -> M5.Lcd.fillRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color); +### lcd.drawPixel(x, y [,color]) +**例程** +```python +lcd.drawPixel(22,22,lcd.RED) +``` +**在位置(x,y)处画点。** -画填充形式的圆角矩形图形 +*如果函数的color值没给出,则使用当前的背景颜色。* -| Param | Type | Description | -| --- | --- | --- | -| x, y | int16_t | x和y方向的偏移量 | -| w, h | int16_t | 图形宽和高 | -| radius | int16_t | 圆角半径 | -| color | uint16_t | 填充的颜色 | +| 参数 | 描述 | +| --- | --- | +| color | 颜色值 | + + + +* * * + +### lcd.drawLine(x, y, x1, y1 [,color]) +**例程** +```python +lcd.drawLine(0,0,12,12,lcd.WHITE) +``` +**以指定的颜色从点(x,y)到点(x1,y1)画直线。** + +*如果函数的color值没给出,则使用当前的背景颜色。* + +| 参数 | 描述 | +| --- | --- | +| color | 颜色值 | + + +* * * + +### lcd.drawTriangle(x, y, x1, y1, x2, y2 [,color]) **例程** -```c++ -M5.Lcd.fillRoundRect(50,50,60,150,4,WHITE); +```python +lcd.drawTriangle(22,22,69,98,51,22,lcd.RED) ``` -* * * \ No newline at end of file +**以指定颜色画三角形,顶点分别为(x,y),(x1,y1)和(x2,y2)。** + +*如果函数的color值没给出,则使用当前的背景颜色。* + +| 参数 | 描述 | +| --- | --- | +| color | 颜色值 | + +* * * + +### lcd.fillTriangle(x, y, x1, y1, x2, y2 [,color]) + +**例程** +```python +lcd.fillTriangle(122, 122, 169, 198, 151, 182, lcd.RED) +``` +**以指定颜色画填充形式的三角形,顶点分别为(x,y),(x1,y1)和(x2,y2)。** + +*如果函数的color值没给出,则使用当前的背景颜色。* + +| 参数 | 描述 | +| --- | --- | +| color | 颜色值 | + + +* * * +### lcd.drawRect(x, y, w, h, [,color]) +**例程** +```python +lcd.drawRect(180, 12, 122, 10, lcd.BLUE) +``` +**以指定颜色画矩形,其中矩形左上角坐标为(x,y),宽高分别为width和height。** + +*如果函数的color值没给出,则使用当前的背景颜色。* + +| 参数 | 描述 | +| --- | --- | +| w | 图形宽(单位: 像素) | +| h | 图形高(单位: 像素) | +| color | 颜色值 | + + + + +* * * + +### lcd.drawRoundRect(x, y, w, h, r [,color]) +**例程** +```python +lcd.fillRoundRect(180,70,122,10,4,lcd.BLUE) +``` +**以指定颜色画圆角矩形,其中矩形左上角坐标为(x,y),宽高分别为width和height,圆角半径为r。** + +*如果函数的color值没给出,则使用当前的背景颜色。* + +| 参数 | 描述 | +| --- | --- | +| w | 图形宽(单位: 像素) | +| h | 图形高(单位: 像素) | +| r | 圆角半径 | +| color | 颜色值 | + + + + +* * * +### lcd.print(‘text’, [x, y]) +**例程** +```python +lcd.print('this is a print text function', 80, 80) +``` +**在(x,y)处开始打印文本(字符串)text。** + +| 参数 | 描述 | +| --- | --- | +| text | 要打印的内容 | + + +* * * + +### lcd.clear([color]) + +**例程** +```python +lcd.clear() +``` + +**清屏(即以当前的背景颜色填充整个屏幕)。** + + +* * * + +### Usage + +```python +from machine import SPI, Pin +from display import LCD + +spi = SPI(1, baudrate=32000000, mosi=Pin(23), miso=Pin(19), sck=Pin(18)) + +lcd = LCD(spi = spi) #lcd init +lcd.fillScreen(lcd.BLACK) #set the default background color + +lcd.drawLine(0, 0, lcd.WHITE) +lcd.drawTriangle(22, 22, 69, 98, 51, 22, lcd.RED) +lcd.fillTriangle(122, 122, 169, 198, 151, 182, lcd.RED) +lcd.drawCircle(180, 180, 10, lcd.BLUE) +lcd.fillcircle(100, 100, 10, lcd.BLUE) +lcd.drawRect(180, 12, 122, 10, lcd.BLUE) +lcd.fillRect(180, 30, 122, 10, lcd.BLUE) +lcd.drawRoundRect(180, 50, 122, 10, 4, lcd.BLUE) +lcd.fillRoundRect(180, 70, 122, 10, 4, lcd.BLUE) +lcd.print('this is a print text function', 80, 80) +```