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] 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)
+```