modified api_lcd.md

This commit is contained in:
LiHuashen
2018-12-03 00:21:57 +08:00
parent 8074a86810
commit b53d3c1516
5 changed files with 368 additions and 100 deletions
+2 -2
View File
@@ -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)
<!-- ## [Peripherals](en/api_reference/peripherals/api_gpio)
### 1. [GPIO](en/api_reference/peripherals/api_gpio)
## [Speaker](en/api_reference/api_speaker)
## [Speaker](en/api_reference/api_speaker) -->
+181 -47
View File
@@ -1,73 +1,207 @@
# LCD
### <mark>setbrightness</mark>
> 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 | <code>uint8_t</code> | brightness(0-254) |
### <mark>lcd.setRotation(degree)</mark>
**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 |
* * *
### <mark>fillScreen</mark>
> M5.Lcd.fillScreen(uint16_t color);
Set the color to display of the whole LCD.
| Param | Type | Description |
| --- | --- | --- |
| color | <code>uint16_t</code> | color value |
### <mark>lcd.setColor(color [, background_color])</mark>
**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 |
* * *
### <mark>fillRect</mark>
> 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 | <code>int16_t</code> | offset of x, y direction |
| w, h | <code>int16_t</code> | width and height of graphics |
| color | <code>uint16_t</code> | color to fill |
### <mark>lcd.fillScreen(color)</mark>
**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 |
* * *
### <mark>fillRoundRect</mark>
> M5.Lcd.fillRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color);
### <mark>lcd.drawPixel(x, y [,color])</mark>
**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 | <code>int16_t</code> | offset of x, y direction |
| w, h | <code>int16_t</code> | width and height of graphics |
| radius | <code>int16_t</code> | fillet radius |
| color | <code>uint16_t</code> | color to fill |
| Param | Description |
| --- | --- |
| color | color value |
* * *
### <mark>lcd.drawLine(x, y, x1, y1 [,color])</mark>
**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 |
* * *
### <mark>lcd.drawTriangle(x, y, x1, y1, x2, y2 [,color])</mark>
**Example**
```c++
M5.Lcd.fillRoundRect(50,50,60,150,4,WHITE);
```python
lcd.drawTriangle(22,22,69,98,51,22,lcd.RED)
```
* * *
**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 |
* * *
### <mark>lcd.fillTriangle(x, y, x1, y1, x2, y2 [,color])</mark>
**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 |
* * *
### <mark>lcd.drawRect(x, y, w, h, [,color])</mark>
**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 (displays smaller dimension) |
| h | display phisical height in pixels (displays larger dimension) |
| color | color value |
* * *
### <mark>lcd.drawRoundRect(x, y, w, h, r [,color])</mark>
**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 (displays smaller dimension) |
| h | display phisical height in pixels (displays larger dimension) |
| r | the radius of circle |
| color | color value |
* * *
### <mark>lcd.print(text, [x, y])</mark>
**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 |
* * *
### <mark>lcd.clear([color])</mark>
**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)
```
+2 -2
View File
@@ -2,7 +2,7 @@
[中文](/zh_CN/api_reference) | [English](/en/api_reference) | 日本語
## [LCD](ja/api_reference/api_lcd)
<!-- ## [LCD](ja/api_reference/api_lcd)
## [Peripherals](ja/api_reference/peripherals/api_gpio)
### 1. [GPIO](ja/api_reference/peripherals/api_gpio)
## [Speaker](ja/api_reference/api_speaker)
## [Speaker](ja/api_reference/api_speaker) -->
+2 -2
View File
@@ -5,6 +5,6 @@
*这是MicroPython的编程API*
## [LCD](zh_CN/api_reference/api_lcd)
## [Peripherals](zh_CN/api_reference/peripherals/api_gpio)
<!-- ## [Peripherals](zh_CN/api_reference/peripherals/api_gpio)
### 1. [GPIO](zh_CN/api_reference/peripherals/api_gpio)
## [Speaker](zh_CN/api_reference/api_speaker)
## [Speaker](zh_CN/api_reference/api_speaker) -->
+181 -47
View File
@@ -1,73 +1,207 @@
# LCD
### <mark>setbrightness</mark>
> M5.Lcd.setbrightness(uint8_t brightness);
中文 | [English](https://m5stack.github.io/m5-docs/#/en/api_reference/api_lcd)
设置LCD屏幕的亮度
| Param | Type | Description |
| --- | --- | --- |
| brightness | <code>uint8_t</code> | 亮度值(0-254) |
### <mark>lcd.setRotation(degree)</mark>
**例程**
```c++
M5.Lcd.setbrightness(100);
```python
lcd.setRotation(90)
```
**设置整个屏幕显示的旋转角度。**
| 参数 | 描述 |
| --- | --- |
| degree | 旋转的角度 |
* * *
### <mark>fillScreen</mark>
> M5.Lcd.fillScreen(uint16_t color);
设置全屏颜色
| Param | Type | Description |
| --- | --- | --- |
| color | <code>uint16_t</code> | 颜色值 |
### <mark>lcd.setColor(color [, background_color])</mark>
**例程**
```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| 文本的背景颜色 |
* * *
### <mark>fillRect</mark>
> M5.Lcd.fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color);
画填充形式的矩形图形
| Param | Type | Description |
| --- | --- | --- |
| x, y | <code>int16_t</code> | x和y方向的偏移量 |
| w, h | <code>int16_t</code> | 图形宽和高 |
| color | <code>uint16_t</code> | 填充的颜色 |
### <mark>lcd.fillScreen(color)</mark>
**例程**
```c++
M5.Lcd.fillRect(50,50,60,150,WHITE);
```python
lcd.fillScreen(lcd.RED)
```
**以指定的颜色填充整个屏幕。**
| 参数 | 描述 |
| --- | --- |
| color | 颜色值 |
* * *
### <mark>fillRoundRect</mark>
> M5.Lcd.fillRoundRect(int16_t x0, int16_t y0, int16_t w, int16_t h, int16_t radius, uint16_t color);
### <mark>lcd.drawPixel(x, y [,color])</mark>
**例程**
```python
lcd.drawPixel(22,22,lcd.RED)
```
**在位置(x,y)处画点。**
画填充形式的圆角矩形图形
*如果函数的color值没给出,则使用当前的背景颜色。*
| Param | Type | Description |
| --- | --- | --- |
| x, y | <code>int16_t</code> | x和y方向的偏移量 |
| w, h | <code>int16_t</code> | 图形宽和高 |
| radius | <code>int16_t</code> | 圆角半径 |
| color | <code>uint16_t</code> | 填充的颜色 |
| 参数 | 描述 |
| --- | --- |
| color | 颜色值 |
* * *
### <mark>lcd.drawLine(x, y, x1, y1 [,color])</mark>
**例程**
```python
lcd.drawLine(0,0,12,12,lcd.WHITE)
```
**以指定的颜色从点(x,y)到点(x1,y1)画直线。**
*如果函数的color值没给出,则使用当前的背景颜色。*
| 参数 | 描述 |
| --- | --- |
| color | 颜色值 |
* * *
### <mark>lcd.drawTriangle(x, y, x1, y1, x2, y2 [,color])</mark>
**例程**
```c++
M5.Lcd.fillRoundRect(50,50,60,150,4,WHITE);
```python
lcd.drawTriangle(22,22,69,98,51,22,lcd.RED)
```
* * *
**以指定颜色画三角形,顶点分别为(x,y)(x1,y1)和(x2,y2)。**
*如果函数的color值没给出,则使用当前的背景颜色。*
| 参数 | 描述 |
| --- | --- |
| color | 颜色值 |
* * *
### <mark>lcd.fillTriangle(x, y, x1, y1, x2, y2 [,color])</mark>
**例程**
```python
lcd.fillTriangle(122, 122, 169, 198, 151, 182, lcd.RED)
```
**以指定颜色画<mark>填充形式</mark>的三角形,顶点分别为(x,y)(x1,y1)和(x2,y2)。**
*如果函数的color值没给出,则使用当前的背景颜色。*
| 参数 | 描述 |
| --- | --- |
| color | 颜色值 |
* * *
### <mark>lcd.drawRect(x, y, w, h, [,color])</mark>
**例程**
```python
lcd.drawRect(180, 12, 122, 10, lcd.BLUE)
```
**以指定颜色画矩形,其中矩形左上角坐标为(x,y),宽高分别为width和height。**
*如果函数的color值没给出,则使用当前的背景颜色。*
| 参数 | 描述 |
| --- | --- |
| w | 图形宽(单位: 像素) |
| h | 图形高(单位: 像素) |
| color | 颜色值 |
* * *
### <mark>lcd.drawRoundRect(x, y, w, h, r [,color])</mark>
**例程**
```python
lcd.fillRoundRect(180,70,122,10,4,lcd.BLUE)
```
**以指定颜色画<mark>圆角</mark>矩形,其中矩形左上角坐标为(x,y),宽高分别为width和height,圆角半径为r。**
*如果函数的color值没给出,则使用当前的背景颜色。*
| 参数 | 描述 |
| --- | --- |
| w | 图形宽(单位: 像素) |
| h | 图形高(单位: 像素) |
| r | 圆角半径 |
| color | 颜色值 |
* * *
### <mark>lcd.print(text, [x, y])</mark>
**例程**
```python
lcd.print('this is a print text function', 80, 80)
```
**在(x,y)处开始打印文本(字符串)text。**
| 参数 | 描述 |
| --- | --- |
| text | 要打印的内容 |
* * *
### <mark>lcd.clear([color])</mark>
**例程**
```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)
```