2018-08-05 17:19:37 +08:00
LCD API
********
2018-08-05 15:28:48 +08:00
2018-08-05 17:19:37 +08:00
-----------------------------
2018-08-05 15:28:48 +08:00
2018-08-05 17:19:37 +08:00
Function
---------
2018-08-05 15:28:48 +08:00
2018-09-03 10:39:27 +08:00
lcd.setbrightness(uint8_t brightness)
2018-09-19 11:12:18 +08:00
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
2018-09-03 10:39:27 +08:00
2018-08-05 17:19:37 +08:00
lcd.setRotation(degree)
>>>>>>>>>>>>>>>>>>>>>>>
2018-08-05 15:28:48 +08:00
2018-09-19 11:12:18 +08:00
| **Description:**
2018-08-05 17:19:37 +08:00
| set the angle of rotation of the entire screen
2018-09-19 11:12:18 +08:00
| **Parament:**
2018-08-05 17:19:37 +08:00
| **degree:** the angle of rotation
| **Example:**
2018-09-19 11:12:18 +08:00
2018-08-05 15:28:48 +08:00
.. code :: python
#The M5Stack Core LCD has been initialized
2018-08-05 17:19:37 +08:00
lcd . setRotation ( 90 )
2018-08-05 15:28:48 +08:00
2018-08-05 17:19:37 +08:00
lcd.setColor(color [, background\_color])
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
2018-08-05 15:28:48 +08:00
2018-08-05 17:19:37 +08:00
| **Description:**
| Set the default foreground/background color
2018-08-05 15:28:48 +08:00
2018-08-05 17:19:37 +08:00
| **Parament:**
| **color:** the color of text
2018-09-19 11:12:18 +08:00
| **background\_color:** the fill color of text
2018-08-05 17:19:37 +08:00
| **Example:**
2018-09-19 11:12:18 +08:00
2018-08-05 15:28:48 +08:00
.. code :: python
#The M5Stack Core LCD has been initialized
2018-09-19 11:12:18 +08:00
lcd . setColor ( lcd . RED )
lcd . setColor ( lcd . ORANGE , LCD . DARKCYAN )
2018-08-05 15:28:48 +08:00
2018-08-05 17:19:37 +08:00
lcd.setTextColor(color [,background\_color])
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
2018-08-05 15:28:48 +08:00
2018-08-05 17:19:37 +08:00
| **Description:**
2018-09-19 11:12:18 +08:00
| This function is as same as *setColor(color [, background\_color])*
2018-08-05 15:28:48 +08:00
2018-08-05 17:19:37 +08:00
| **Example:**
2018-09-19 11:12:18 +08:00
2018-08-05 15:28:48 +08:00
.. code :: python
#The M5Stack Core LCD has been initialized
2018-09-19 11:12:18 +08:00
lcd . setTextColor ( lcd . PINK )
lcd . setTextColor ( lcd . ORANGE , LCD . DARKCYAN )
2018-08-05 15:28:48 +08:00
2018-08-05 17:19:37 +08:00
lcd.fillScreen(color)
>>>>>>>>>>>>>>>>>>>>>>>
2018-08-05 15:28:48 +08:00
2018-08-05 17:19:37 +08:00
| **Description:**
| Fill the entire screen with the given color
2018-08-05 15:28:48 +08:00
2018-09-19 11:12:18 +08:00
| **Parament:**
| **color:** color values
2018-08-05 17:19:37 +08:00
| **Example:**
2018-09-19 11:12:18 +08:00
2018-08-05 15:28:48 +08:00
.. code :: python
#The M5Stack Core LCD has been initialized
2018-08-05 17:19:37 +08:00
lcd . fillScreen ( lcd . RED )
2018-08-05 15:28:48 +08:00
2018-08-05 17:19:37 +08:00
lcd.drawPixel(x, y [,color])
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
2018-08-05 15:28:48 +08:00
2018-08-05 17:19:37 +08:00
| **Description:**
2018-09-19 11:12:18 +08:00
| Draw the pixel at position **(x,y)**
2018-08-05 17:19:37 +08:00
| *Note:*
| *If color is not given, current foreground color is used*
2018-08-05 15:28:48 +08:00
2018-09-19 11:12:18 +08:00
| **Parament:**
| **color: ** color values
2018-08-05 17:19:37 +08:00
| **Example:**
2018-09-19 11:12:18 +08:00
2018-08-05 15:28:48 +08:00
.. code :: python
#The M5Stack Core LCD has been initialized
lcd . drawPixel ( 22 , 22 , lcd . RED )
2018-08-05 17:19:37 +08:00
lcd.drawLine(x, y, x1, y1 [,color])
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
2018-08-05 15:28:48 +08:00
2018-08-05 17:19:37 +08:00
| **Description:**
2018-09-19 11:12:18 +08:00
| Draw the line from point **(x,y)** to point **(x1,y1)**
| *Note:*
2018-08-05 17:19:37 +08:00
| *If color is not given, current foreground color is used*
2018-08-05 15:28:48 +08:00
2018-09-19 11:12:18 +08:00
| **Parament:**
| **color: ** color values
2018-08-05 17:19:37 +08:00
| **Example:**
2018-09-19 11:12:18 +08:00
2018-08-05 15:28:48 +08:00
.. code :: python
#The M5Stack Core LCD has been initialized
2018-09-19 11:12:18 +08:00
lcd . drawLine ( 0 , 0 , 12 , 12 , lcd . WHITE )
2018-08-05 15:28:48 +08:00
2018-08-05 17:19:37 +08:00
lcd.drawTriangle(x, y, x1, y1, x2, y2 [,color])
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
2018-08-05 15:28:48 +08:00
2018-08-05 17:19:37 +08:00
| **Description:**
2018-09-19 11:12:18 +08:00
| Draw the triangel between points **(x,y)** , **(x1,y1)** and **(x2,y2)**
2018-08-05 17:19:37 +08:00
| *Note:*
2018-09-19 11:12:18 +08:00
| If color is not given, current foreground color is used
| **Parament:**
| **color:** color values
2018-08-05 15:28:48 +08:00
2018-08-05 17:19:37 +08:00
| **Example:**
2018-09-19 11:12:18 +08:00
2018-08-05 15:28:48 +08:00
.. code :: python
#The M5Stack Core LCD has been initialized
lcd . drawTriangle ( 22 , 22 , 69 , 98 , 51 , 22 , lcd . RED )
2018-08-05 17:19:37 +08:00
lcd.fillTriangle(x, y, x1, y1, x2, y2 [,color])
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
2018-08-05 15:28:48 +08:00
2018-08-05 17:19:37 +08:00
| **Description:**
2018-09-19 11:12:18 +08:00
| Fill the triangel between points **(x,y)** , **(x1,y1)** and **(x2,y2)**
2018-08-05 17:19:37 +08:00
| *Note:*
| *If color is not given, triangle will be filled in current foreground color*
| **Parament:**
| **color: ** color values
| **Example:**
2018-09-19 11:12:18 +08:00
2018-08-05 17:19:37 +08:00
.. code :: python
#The M5Stack Core LCD has been initialized
lcd . fillTriangle ( 122 , 122 , 169 , 198 , 151 , 182 , lcd . RED )
lcd.drawCircle(x, y, r [,color])
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
| **Description:** *
2018-09-19 11:12:18 +08:00
| Draw the circle with center at **(x,y)** and radius **r**
2018-08-05 17:19:37 +08:00
| *Note:*
| *If color is not given, current foreground color is used*
| **Parament:**
2018-09-19 11:12:18 +08:00
| **r:** the radius of circle
| **color:** color values
2018-08-05 17:19:37 +08:00
| **Example:**
2018-08-05 15:28:48 +08:00
.. code :: python
#The M5Stack Core LCD has been initialized
2018-08-05 17:19:37 +08:00
lcd . drawCircle ( 180 , 180 , 10 , lcd . BLUE )
2018-08-05 15:28:48 +08:00
2018-08-05 17:19:37 +08:00
lcd.fillCircle(x, y, r [,color])
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
2018-08-05 15:28:48 +08:00
2018-08-05 17:19:37 +08:00
| **Description:**
2018-09-19 11:12:18 +08:00
| Fill the circle with center at **(x,y)** and radius **r**
2018-08-05 17:19:37 +08:00
| *Note:*
| *If color is not given, current foregroundcolor will be used*
2018-08-05 15:28:48 +08:00
2018-08-05 17:19:37 +08:00
| **Parament:**
2018-09-19 11:12:18 +08:00
| **r:** the radius of circle
| **color:** color values
2018-08-05 17:19:37 +08:00
| **Example:**
2018-09-19 11:12:18 +08:00
2018-08-05 15:28:48 +08:00
.. code :: python
#The M5Stack Core LCD has been initialized
2018-09-19 11:12:18 +08:00
lcd . fillcircle ( 100 , 100 , 10 , lcd . BLUE )
2018-08-05 15:28:48 +08:00
2018-08-05 17:19:37 +08:00
lcd.drawRect(x, y, w, h, [,color])
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
2018-08-05 15:28:48 +08:00
2018-08-05 17:19:37 +08:00
| **Description:**
2018-09-19 11:12:18 +08:00
| Draw the rectangle from the upper left point at **(x,y)** and **width** and **height**
2018-08-05 17:19:37 +08:00
| *Note:*
| *If color is not given, rectangle will be drawn in current foreground color*
2018-08-05 15:28:48 +08:00
2018-08-05 17:19:37 +08:00
| **Parament:**
| **w:** display phisical width in pixels (display's smaller dimension)
| **h:** display phisical height in pixels (display's larger dimension)
2018-09-19 11:12:18 +08:00
| **color:** optional, color values
2018-08-05 15:28:48 +08:00
2018-08-05 17:19:37 +08:00
| **Example:**
2018-09-19 11:12:18 +08:00
2018-08-05 15:28:48 +08:00
.. code :: python
#The M5Stack Core LCD has been initialized
2018-08-05 17:19:37 +08:00
lcd . drawRect ( 180 , 12 , 122 , 10 , lcd . BLUE )
2018-08-05 15:28:48 +08:00
2018-08-05 17:19:37 +08:00
lcd.fillRect(x, y, w, h, [,color])
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
2018-08-05 15:28:48 +08:00
2018-08-05 17:19:37 +08:00
| **Description:**
2018-09-19 11:12:18 +08:00
| Fill the rectangle from the upper left point at **(x,y)** and **width** and **height**
2018-08-05 17:19:37 +08:00
| *Note:*
2018-09-19 11:12:18 +08:00
| *If fillcolor is not given, rectangle will be filled in current foreground color*
2018-08-05 15:28:48 +08:00
2018-08-05 17:19:37 +08:00
| **Parament:**
| **w:** display phisical width in pixels (display's smaller dimension)
2018-09-19 11:12:18 +08:00
| **h:** display phisical height in pixels (display's larger dimension)
| **color:** optional, color values
2018-08-05 15:28:48 +08:00
2018-08-05 17:19:37 +08:00
| **Example:**
2018-08-05 15:28:48 +08:00
.. code :: python
#The M5Stack Core LCD has been initialized
lcd . fillRect ( 180 , 30 , 122 , 10 , lcd . BLUE )
2018-08-05 17:19:37 +08:00
lcd.drawRoundRect(x, y, w, h, r [,color])
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
2018-08-05 15:28:48 +08:00
2018-08-05 17:19:37 +08:00
| **Description:**
2018-09-19 11:12:18 +08:00
| 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
2018-08-05 17:19:37 +08:00
| *Note:*
2018-09-19 11:12:18 +08:00
| *If * color* is not given, current foreground color will be used*
2018-08-05 17:19:37 +08:00
| **Parament:**
2018-09-19 11:12:18 +08:00
| **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:** optional, color values
2018-08-05 17:19:37 +08:00
| **Example:**
2018-08-05 15:28:48 +08:00
.. code :: python
#The M5Stack Core LCD has been initialized
lcd . drawRoundRect ( 180 , 50 , 122 , 10 , 4 , lcd . BLUE )
2018-08-05 17:19:37 +08:00
lcd.fillRoundRect(x, y, w, h, r [,color])
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
2018-08-05 15:28:48 +08:00
2018-08-05 17:19:37 +08:00
| **Description:**
2018-09-19 11:12:18 +08:00
| Fill the rectangle with rounded corners from the upper left point at **(x,y)** and **width** and **height** . Corner radius is given by **r** argument
2018-08-05 17:19:37 +08:00
| *Note:*
2018-09-19 11:12:18 +08:00
| If **color** is not given, current foreground color will be used
2018-08-05 15:28:48 +08:00
2018-08-05 17:19:37 +08:00
| **Parament:**
2018-09-19 11:12:18 +08:00
| **w:** display phisical width in pixel (display's smaller dimension)
2018-08-05 17:19:37 +08:00
| **h:** display phisical height in pixels (display's larger dimension)
2018-09-19 11:12:18 +08:00
| **r:** the radius of circle
| **color:** optional, color values
2018-08-05 17:19:37 +08:00
| **Example:**
2018-09-19 11:12:18 +08:00
2018-08-05 15:28:48 +08:00
.. code :: python
#The M5Stack Core LCD has been initialized
lcd . fillRoundRect ( 180 , 70 , 122 , 10 , 4 , lcd . BLUE )
2018-08-05 17:19:37 +08:00
lcd.print('text', [x, y])
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
2018-08-05 15:28:48 +08:00
2018-08-05 17:19:37 +08:00
| **Description:**
| Print the **text** at position **(x,y)**
2018-08-05 15:28:48 +08:00
2018-08-05 17:19:37 +08:00
| **Parament:**
| **text:** the string need to print
2018-08-05 15:28:48 +08:00
2018-08-05 17:19:37 +08:00
| **Example:**
2018-09-19 11:12:18 +08:00
2018-08-05 15:28:48 +08:00
.. code :: python
#The M5Stack Core LCD has been initialized
lcd . print ( 'this is a print text function' , 80 , 80 )
2018-08-05 17:19:37 +08:00
lcd.clear([color])
>>>>>>>>>>>>>>>>>>>>>>
2018-08-05 15:28:48 +08:00
2018-08-05 17:19:37 +08:00
| **Description:**
2018-09-19 11:12:18 +08:00
| Clear the screen with default background color orspecific color if given
2018-08-05 15:28:48 +08:00
2018-09-19 11:12:18 +08:00
| **Parament:**
2018-08-05 17:19:37 +08:00
| **color:** optional, color values
| **Example:**
2018-09-19 11:12:18 +08:00
2018-08-05 15:28:48 +08:00
.. code :: python
#The M5Stack Core LCD has been initialized
lcd . clear ()
2018-08-05 17:19:37 +08:00
---------------------
Usage
------
.. code :: 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
2018-09-19 11:12:18 +08:00
lcd . drawLine ( 0 , 0 , lcd . WHITE )
2018-08-05 17:19:37 +08:00
lcd . drawTriangle ( 22 , 22 , 69 , 98 , 51 , 22 , lcd . RED )
lcd . fillTriangle ( 122 , 122 , 169 , 198 , 151 , 182 , lcd . RED )
2018-09-19 11:12:18 +08:00
lcd . drawCircle ( 180 , 180 , 10 , lcd . BLUE )
lcd . fillcircle ( 100 , 100 , 10 , lcd . BLUE )
2018-08-05 17:19:37 +08:00
lcd . drawRect ( 180 , 12 , 122 , 10 , lcd . BLUE )
2018-09-19 11:12:18 +08:00
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 )