22*******************************************************************************
33* Copyright (c) 2021 by M5Stack
44* Equipped with M5Core sample source code
5- * Visit the website for more information:https://docs.m5stack.com/en/products
5+ * 配套 M5Core 示例源代码
6+ * Visit the website for more information:https://docs.m5stack.com/en/core/gray
7+ * 获取更多资料请访问:https://docs.m5stack.com/zh_CN/core/gray
68*
7- * describe:Display Example
8- * date:2021/7/15
9+ * describe:Display Example. 显示屏示例
10+ * date:2021/7/21
911*******************************************************************************
1012*/
1113#include < M5Stack.h>
1214
13- // After M5Core is started or reset
14- // the program in the setUp () function will be run, and this part will only be run once.
15+ /* After M5Core is started or reset
16+ the program in the setUp () function will be run, and this part will only be run once.
17+ 在 M5Core 启动或者复位后,即会开始执行setup()函数中的程序,该部分只会执行一次。 */
1518void setup () {
16- M5.begin (); // Init M5Core
17- M5.Power .begin (); // Init Power module
18-
19- M5.Lcd .fillScreen (WHITE); // Set the screen background color to white
20- delay (500 ); // Delay 500ms
19+ M5.begin (); // Init M5Core. 初始化 M5Core
20+ M5.Power .begin (); // Init Power module. 初始化电源模块
21+ M5.Lcd .fillScreen (WHITE); // Set the screen background. 设置屏幕底色为白色
22+ delay (500 ); // Delay 500ms. 延迟500ms
2123 M5.Lcd .fillScreen (RED);
2224 delay (500 );
2325 M5.Lcd .fillScreen (GREEN);
@@ -27,31 +29,33 @@ void setup() {
2729 M5.Lcd .fillScreen (BLACK);
2830 delay (500 );
2931
30- M5.Lcd .setCursor (10 , 10 ); // Move the cursor position to (x,y)
31- M5.Lcd .setTextColor (WHITE); // Set the font color to white,
32- M5.Lcd .setTextSize (1 ); // Set the font size
33- M5.Lcd .printf (" Display Test!" ); // Serial output format string
32+ M5.Lcd .setCursor (10 , 10 ); // Move the cursor position to (x,y). 移动光标位置到 (x,y)处
33+ M5.Lcd .setTextColor (WHITE); // Set the font color to white. 设置字体颜色为白色
34+ M5.Lcd .setTextSize (1 ); // Set the font size. 设置字体大小
35+ M5.Lcd .printf (" Display Test!" ); // Serial output format string. 输出格式化字符串
3436
3537 // draw graphic
3638 delay (1000 );
37- M5.Lcd .drawRect (100 , 100 , 50 , 50 , BLUE); // Draw a 50x50 blue rectangle wireframe at (x,y)
38- delay (1000 );
39- M5.Lcd .fillRect (100 , 100 , 50 , 50 , BLUE); // Draw a blue rectangle 50x50 at (x,y)
40- delay (1000 );
41- M5.Lcd .drawCircle (100 , 100 , 50 , RED); // Draw a red circle of radius 50 at (x,y)
42- delay (1000 );
39+ M5.Lcd .drawRect (100 , 100 , 50 , 50 , BLUE); // Draw a 50x50 blue rectangle wireframe at (x,y).
40+ delay (1000 ); // 在(x,y)处画 长宽为50x50的蓝色矩形线框
41+ M5.Lcd .fillRect (100 , 100 , 50 , 50 , BLUE);// Draw a blue rectangle 50x50 at (x,y)
42+ delay (1000 ); // 在(x,y)处画 长宽为50x50的蓝色矩形
43+ M5.Lcd .drawCircle (100 , 100 , 50 , RED); // Draw a red circle of radius 50 at (x,y)
44+ delay (1000 ); // 在(x,y)处画 半径为50的红色圆线圈
4345 M5.Lcd .fillCircle (100 , 100 , 50 , RED); // Draw a red circle of radius 50 at (x,y)
44- delay (1000 );
45- M5.Lcd .drawTriangle (30 , 30 , 180 , 100 , 80 , 150 , YELLOW); // Make a triangle wireframe with (x1,y1) (x2,y2) (x3,y3) as the vertices
46- delay (1000 );
47- M5.Lcd .fillTriangle (30 , 30 , 180 , 100 , 80 , 150 , YELLOW); // Construct a triangle with (x1,y1) (x2,y2) (x3,y3) as its vertices
48- }
46+ delay (1000 ); // 在(x,y)处画 半径为50的红色圆
47+ M5.Lcd .drawTriangle (30 , 30 , 180 , 100 , 80 , 150 , YELLOW); // Make a triangle wireframe with (x1,y1) (x2,y2) (x3,y3) as the vertices
48+ delay (1000 ); // 以 (x1,y1) (x2,y2) (x3,y3)为顶点作三角形线框
49+ M5.Lcd .fillTriangle (30 , 30 , 180 , 100 , 80 , 150 , YELLOW); // 以 (x1,y1) (x2,y2) (x3,y3)为顶点作三角形
50+ } // Construct a triangle with (x1,y1) (x2,y2) (x3,y3) as its vertices
4951
50- // After the program in setup() runs, it runs the program in loop()
51- // The loop() function is an infinite loop in which the program runs repeatedly
52+ /* After the program in setup() runs, it runs the program in loop()
53+ The loop() function is an infinite loop in which the program runs repeatedly
54+ 在setup()函数中的程序执行完后,会接着执行loop()函数中的程序
55+ loop()函数是一个死循环,其中的程序会不断的重复运行 */
5256void loop (){
5357
5458 M5.Lcd .fillTriangle (random (M5.Lcd .width ()-1 ), random (M5.Lcd .height ()-1 ), random (M5.Lcd .width ()-1 ), random (M5.Lcd .height ()-1 ), random (M5.Lcd .width ()-1 ), random (M5.Lcd .height ()-1 ), random (0xfffe ));
5559
56- M5.update (); // Read the press state of the key
60+ M5.update (); // Read the press state of the key. 读取按键 A, B, C 的状态
5761}
0 commit comments