|
| 1 | +# LCD |
| 2 | + |
| 3 | +<!-- 中文 | [English](/en/api_reference/micropython/api_lcd) | [日本語](/ja/api_reference/micropython/api_lcd) --> |
| 4 | + |
| 5 | +*屏幕像素为320x240,以屏幕左上角为原点(0,0)* |
| 6 | + |
| 7 | +### <mark>M5.lcd.setBrightness(uint8_t brightness);</mark> |
| 8 | + |
| 9 | +**例程** |
| 10 | +```c++ |
| 11 | +M5.lcd.setBrightness(200); |
| 12 | +``` |
| 13 | + |
| 14 | +**设置整个屏幕显示的亮度。** |
| 15 | + |
| 16 | +| 参数 | 描述 | |
| 17 | +| --- | --- | |
| 18 | +| brightness | 屏幕的亮度(0-254) | |
| 19 | + |
| 20 | +* * * |
| 21 | + |
| 22 | +### <mark>M5.Lcd.setCursor(uint16_t x0, uint16_t y0);</mark> |
| 23 | + |
| 24 | +**例程** |
| 25 | +```c++ |
| 26 | +M5.lcd.setCursor(20, 40); |
| 27 | +``` |
| 28 | + |
| 29 | +**设置下一次要显示的起始位置(x0, y0)** |
| 30 | + |
| 31 | +* * * |
| 32 | + |
| 33 | +### <mark>M5.Lcd.fillScreen(uint16_t color);</mark> |
| 34 | +**例程** |
| 35 | +```c++ |
| 36 | +M5.Lcd.fillScreen(BLUE) |
| 37 | +``` |
| 38 | +**以指定的颜色填充整个屏幕。** |
| 39 | + |
| 40 | +| 参数 | 描述 | |
| 41 | +| --- | --- | |
| 42 | +| color | 颜色值 | |
| 43 | + |
| 44 | + |
| 45 | + |
| 46 | +* * * |
| 47 | + |
| 48 | +<!-- |
| 49 | +### <mark>lcd.drawPixel(x, y [,color])</mark> |
| 50 | +**例程** |
| 51 | +```python |
| 52 | +lcd.drawPixel(22,22,lcd.RED) |
| 53 | +``` |
| 54 | +**在位置(x,y)处画点。** |
| 55 | +
|
| 56 | +*如果函数的color值没给出,则使用当前的背景颜色。* |
| 57 | +
|
| 58 | +| 参数 | 描述 | |
| 59 | +| --- | --- | |
| 60 | +| color | 颜色值 | |
| 61 | +
|
| 62 | +
|
| 63 | +
|
| 64 | +* * * |
| 65 | +
|
| 66 | +### <mark>lcd.drawLine(x, y, x1, y1 [,color])</mark> |
| 67 | +**例程** |
| 68 | +```python |
| 69 | +lcd.drawLine(0,0,12,12,lcd.WHITE) |
| 70 | +``` |
| 71 | +**以指定的颜色从点(x,y)到点(x1,y1)画直线。** |
| 72 | +
|
| 73 | +*如果函数的color值没给出,则使用当前的背景颜色。* |
| 74 | +
|
| 75 | +| 参数 | 描述 | |
| 76 | +| --- | --- | |
| 77 | +| color | 颜色值 | |
| 78 | +
|
| 79 | +
|
| 80 | +* * * |
| 81 | +
|
| 82 | +### <mark>lcd.drawTriangle(x, y, x1, y1, x2, y2 [,color])</mark> |
| 83 | +
|
| 84 | +**例程** |
| 85 | +```python |
| 86 | +lcd.drawTriangle(22,22,69,98,51,22,lcd.RED) |
| 87 | +``` |
| 88 | +
|
| 89 | +**以指定颜色画三角形,顶点分别为(x,y),(x1,y1)和(x2,y2)。** |
| 90 | +
|
| 91 | +*如果函数的color值没给出,则使用当前的背景颜色。* |
| 92 | +
|
| 93 | +| 参数 | 描述 | |
| 94 | +| --- | --- | |
| 95 | +| color | 颜色值 | |
| 96 | +
|
| 97 | +* * * |
| 98 | +
|
| 99 | +### <mark>lcd.fillTriangle(x, y, x1, y1, x2, y2 [,color])</mark> |
| 100 | +
|
| 101 | +**例程** |
| 102 | +```python |
| 103 | +lcd.fillTriangle(122, 122, 169, 198, 151, 182, lcd.RED) |
| 104 | +``` |
| 105 | +**以指定颜色画<mark>填充形式</mark>的三角形,顶点分别为(x,y),(x1,y1)和(x2,y2)。** |
| 106 | +
|
| 107 | +*如果函数的color值没给出,则使用当前的背景颜色。* |
| 108 | +
|
| 109 | +| 参数 | 描述 | |
| 110 | +| --- | --- | |
| 111 | +| color | 颜色值 | |
| 112 | +
|
| 113 | +
|
| 114 | +* * * |
| 115 | +### <mark>lcd.drawRect(x, y, w, h, [,color])</mark> |
| 116 | +**例程** |
| 117 | +```python |
| 118 | +lcd.drawRect(180, 12, 122, 10, lcd.BLUE) |
| 119 | +``` |
| 120 | +**以指定颜色画矩形,其中矩形左上角坐标为(x,y),宽高分别为width和height。** |
| 121 | +
|
| 122 | +*如果函数的color值没给出,则使用当前的背景颜色。* |
| 123 | +
|
| 124 | +| 参数 | 描述 | |
| 125 | +| --- | --- | |
| 126 | +| w | 图形宽(单位: 像素) | |
| 127 | +| h | 图形高(单位: 像素) | |
| 128 | +| color | 颜色值 | |
| 129 | +
|
| 130 | +
|
| 131 | +
|
| 132 | +
|
| 133 | +* * * |
| 134 | +
|
| 135 | +### <mark>lcd.drawRoundRect(x, y, w, h, r [,color])</mark> |
| 136 | +**例程** |
| 137 | +```python |
| 138 | +lcd.fillRoundRect(180,70,122,10,4,lcd.BLUE) |
| 139 | +``` |
| 140 | +**以指定颜色画<mark>圆角</mark>矩形,其中矩形左上角坐标为(x,y),宽高分别为width和height,圆角半径为r。** |
| 141 | +
|
| 142 | +*如果函数的color值没给出,则使用当前的背景颜色。* |
| 143 | +
|
| 144 | +| 参数 | 描述 | |
| 145 | +| --- | --- | |
| 146 | +| w | 图形宽(单位: 像素) | |
| 147 | +| h | 图形高(单位: 像素) | |
| 148 | +| r | 圆角半径 | |
| 149 | +| color | 颜色值 | |
| 150 | +
|
| 151 | +
|
| 152 | +
|
| 153 | +
|
| 154 | +* * * |
| 155 | +### <mark>lcd.print(‘text’, [x, y])</mark> |
| 156 | +**例程** |
| 157 | +```python |
| 158 | +lcd.print('this is a print text function', 80, 80) |
| 159 | +``` |
| 160 | +**在(x,y)处开始打印文本(字符串)text。** |
| 161 | +
|
| 162 | +| 参数 | 描述 | |
| 163 | +| --- | --- | |
| 164 | +| text | 要打印的内容 | |
| 165 | +
|
| 166 | +
|
| 167 | +* * * |
| 168 | +
|
| 169 | +### <mark>lcd.clear([color])</mark> |
| 170 | +
|
| 171 | +**例程** |
| 172 | +```python |
| 173 | +lcd.clear() |
| 174 | +``` |
| 175 | +
|
| 176 | +**清屏(即以当前的背景颜色填充整个屏幕)。** |
| 177 | +
|
| 178 | +
|
| 179 | +* * * |
| 180 | +
|
| 181 | +### Usage |
| 182 | +
|
| 183 | +```python |
| 184 | +from machine import SPI, Pin |
| 185 | +from display import LCD |
| 186 | +
|
| 187 | +spi = SPI(1, baudrate=32000000, mosi=Pin(23), miso=Pin(19), sck=Pin(18)) |
| 188 | +
|
| 189 | +lcd = LCD(spi = spi) #lcd init |
| 190 | +lcd.fillScreen(lcd.BLACK) #set the default background color |
| 191 | +
|
| 192 | +lcd.drawLine(0, 0, lcd.WHITE) |
| 193 | +lcd.drawTriangle(22, 22, 69, 98, 51, 22, lcd.RED) |
| 194 | +lcd.fillTriangle(122, 122, 169, 198, 151, 182, lcd.RED) |
| 195 | +lcd.drawCircle(180, 180, 10, lcd.BLUE) |
| 196 | +lcd.fillcircle(100, 100, 10, lcd.BLUE) |
| 197 | +lcd.drawRect(180, 12, 122, 10, lcd.BLUE) |
| 198 | +lcd.fillRect(180, 30, 122, 10, lcd.BLUE) |
| 199 | +lcd.drawRoundRect(180, 50, 122, 10, 4, lcd.BLUE) |
| 200 | +lcd.fillRoundRect(180, 70, 122, 10, 4, lcd.BLUE) |
| 201 | +lcd.print('this is a print text function', 80, 80) |
| 202 | +``` --> |
0 commit comments