Skip to content

Commit 462a4da

Browse files
committed
Merge branch 'master' of github.com:m5stack/M5Stack
2 parents d7529e7 + b5a9dbe commit 462a4da

File tree

9 files changed

+235
-178
lines changed

9 files changed

+235
-178
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,9 @@ examples/Advanced/Proof
5050
docs/datesheet
5151

5252
.vscode/*
53+
54+
examples/.DS_Store
55+
.DS_Store
56+
examples/Basics/.DS_Store
57+
.development
58+
examples/Touch/.DS_Store

examples/Basics/Button/Button.ino

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,45 @@
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:Button example
8-
* date:2021/7/15
9+
* describe:Button example. 按键示例
10+
* date:2021/7/21
911
*******************************************************************************
1012
*/
1113
#include <M5Stack.h>
12-
// After M5Core is started or reset
13-
// the program in the setUp () function will be run, and this part will only be run once.
14+
/* After M5Core is started or reset
15+
the program in the setUp () function will be run, and this part will only be run once.
16+
在 M5Core 启动或者复位后,即会开始执行setup()函数中的程序,该部分只会执行一次。 */
1417
void setup() {
15-
M5.begin(); //Init M5Core
16-
M5.Power.begin();//Init Power module
17-
18-
M5.Lcd.setTextColor(YELLOW); // Set the font color to yellow
19-
M5.Lcd.setTextSize(2); // Set the font size
20-
M5.Lcd.setCursor(65, 10); //Move the cursor position to (x, y)
21-
M5.Lcd.println("Button example"); //The screen prints the formatted string and wraps the line
18+
M5.begin(); //Init M5Core. 初始化 M5Core
19+
M5.Power.begin(); //Init Power module. 初始化电源模块
20+
M5.Lcd.setTextColor(YELLOW); //Set the font color to yellow. 设置字体颜色为黄色
21+
M5.Lcd.setTextSize(2); //Set the font size. 设置字体大小为2
22+
M5.Lcd.setCursor(65, 10); //Move the cursor position to (x, y). 移动光标位置到 (x, y)处
23+
M5.Lcd.println("Button example"); //The screen prints the formatted string and wraps the line. 输出格式化字符串并换行
2224
M5.Lcd.setCursor(3, 35);
2325
M5.Lcd.println("Press button B for 700ms");
2426
M5.Lcd.println("to clear screen.");
2527
M5.Lcd.setTextColor(RED);
2628
}
2729

28-
//After the program in setup() runs, it runs the program in loop()
29-
//The loop() function is an infinite loop in which the program runs repeatedly
30+
/* After the program in setup() runs, it runs the program in loop()
31+
The loop() function is an infinite loop in which the program runs repeatedly
32+
在setup()函数中的程序执行完后,会接着执行loop()函数中的程序
33+
loop()函数是一个死循环,其中的程序会不断的重复运行 */
3034
void loop() {
31-
M5.update(); //Read the press state of the key
32-
//Returns 1 if key A is released or pressed longer than the specified time
35+
M5.update(); //Read the press state of the key. 读取按键 A, B, C 的状态
3336
if (M5.BtnA.wasReleased() || M5.BtnA.pressedFor(1000, 200)) {
3437
M5.Lcd.print('A');
3538
} else if (M5.BtnB.wasReleased() || M5.BtnB.pressedFor(1000, 200)) {
3639
M5.Lcd.print('B');
3740
} else if (M5.BtnC.wasReleased() || M5.BtnC.pressedFor(1000, 200)) {
3841
M5.Lcd.print('C');
3942
} else if (M5.BtnB.wasReleasefor(700)) {
40-
M5.Lcd.clear(WHITE); // Clear the screen and set white to the background color
43+
M5.Lcd.clear(WHITE); // Clear the screen and set white to the background color. 清空屏幕并将白色设置为底色
4144
M5.Lcd.setCursor(0, 0);
4245
}
4346
}

examples/Basics/Display/Display.ino

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,24 @@
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()函数中的程序,该部分只会执行一次。 */
1518
void 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()函数是一个死循环,其中的程序会不断的重复运行 */
5256
void 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
}
Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,33 @@
11
/*
22
*******************************************************************************
3-
*Copyright (c) 2021 by M5Stack
3+
* 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
*
79
* describe:Hello World
810
* date:2021/7/15
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()函数中的程序,该部分只会执行一次。 */
1518
void setup(){
16-
M5.begin(); //Init M5Core
17-
M5.Power.begin(); /*Power chip connected to gpio21, gpio22, I2C device
19+
M5.begin(); //Init M5Core. 初始化 M5Core
20+
M5.Power.begin(); //Init Power module. 初始化电源模块
21+
/* Power chip connected to gpio21, gpio22, I2C device
1822
Set battery charging voltage and current
19-
If used battery, please call this function in your project*/
20-
21-
M5.Lcd.print("Hello World"); // Print text on the screen (string)
23+
If used battery, please call this function in your project */
24+
M5.Lcd.print("Hello World"); // Print text on the screen (string) 在屏幕上打印文本(字符串)
2225
}
2326

24-
//After the program in setup() runs, it runs the program in loop()
25-
//The loop() function is an infinite loop in which the program runs repeatedly
27+
/* After the program in setup() runs, it runs the program in loop()
28+
The loop() function is an infinite loop in which the program runs repeatedly
29+
在setup()函数中的程序执行完后,会接着执行loop()函数中的程序
30+
loop()函数是一个死循环,其中的程序会不断的重复运行 */
2631
void loop() {
2732

2833
}

examples/Basics/IMU/IMU.ino

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,19 @@
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:MPU6886 example
8-
* date:2021/7/15
9+
* describe:MPU6886 example. 惯性传感器
10+
* date:2021/7/21
911
*******************************************************************************
1012
*/
1113
#define M5STACK_MPU6886
1214
#include <M5Stack.h>
1315

1416
float accX = 0.0F; // Define variables for storing inertial sensor data
15-
float accY = 0.0F;
17+
float accY = 0.0F; //定义存储惯性传感器相关数据的相关变量
1618
float accZ = 0.0F;
1719

1820
float gyroX = 0.0F;
@@ -25,49 +27,59 @@ float yaw = 0.0F;
2527

2628
float temp = 0.0F;
2729

28-
// After M5Core is started or reset
29-
// the program in the setUp () function will be run, and this part will only be run once.
30+
/* After M5Core is started or reset
31+
the program in the setUp () function will be run, and this part will only be run once.
32+
在 M5Core 启动或者复位后,即会开始执行setup()函数中的程序,该部分只会执行一次。 */
3033
void setup(){
31-
M5.begin(); //Init M5Core
32-
M5.Power.begin(); //Init Power module
33-
34-
M5.IMU.Init(); //Init IMU sensor
34+
M5.begin(); //Init M5Core. 初始化 M5Core
35+
M5.Power.begin(); //Init Power module. 初始化电源
3536

36-
M5.Lcd.fillScreen(BLACK); // Set the screen background color to black
37-
M5.Lcd.setTextColor(GREEN , BLACK); // Sets the foreground color and background color of the displayed text
38-
M5.Lcd.setTextSize(2); // Set the font size
37+
M5.IMU.Init(); //Init IMU sensor. 初始化惯性传感器
38+
39+
M5.Lcd.fillScreen(BLACK); //Set the screen background color to black. 设置屏幕背景色为黑色
40+
M5.Lcd.setTextColor(GREEN , BLACK); //Sets the foreground color and background color of the displayed text. 设置显示文本的前景颜色和背景颜色
41+
M5.Lcd.setTextSize(2); //Set the font size. 设置字体大小
3942
}
4043

41-
//After the program in setup() runs, it runs the program in loop()
42-
//The loop() function is an infinite loop in which the program runs repeatedly
44+
/* After the program in setup() runs, it runs the program in loop()
45+
The loop() function is an infinite loop in which the program runs repeatedly
46+
在setup()函数中的程序执行完后,会接着执行loop()函数中的程序
47+
loop()函数是一个死循环,其中的程序会不断的重复运行 */
4348
void loop() {
44-
M5.IMU.getGyroData(&gyroX,&gyroY,&gyroZ); // Stores the triaxial gyroscope data of the inertial sensor to the relevant variable
45-
M5.IMU.getAccelData(&accX,&accY,&accZ); // Stores the triaxial accelerometer data of the inertial sensor to the relevant variable
46-
M5.IMU.getAhrsData(&pitch,&roll,&yaw); // Stores the inertial sensor attitude to the relevant variable
47-
M5.IMU.getTempData(&temp); // Stores the inertial sensor temperature to temp
49+
//Stores the triaxial gyroscope data of the inertial sensor to the relevant variable
50+
//将惯性传感器的三轴陀螺仪数据存储至相关变量
51+
M5.IMU.getGyroData(&gyroX,&gyroY,&gyroZ);
52+
M5.IMU.getAccelData(&accX,&accY,&accZ); //Stores the triaxial accelerometer. 存储三轴加速度计数据
53+
M5.IMU.getAhrsData(&pitch,&roll,&yaw); //Stores the inertial sensor attitude. 存储惯性传感器的姿态
54+
M5.IMU.getTempData(&temp); //Stores the inertial sensor temperature to temp. 存储惯性传感器的温度
4855

49-
// The M5Core screen is 320x240 pixels, starting at the top left corner of the screen (0,0).
50-
// gyroscope output related
51-
M5.Lcd.setCursor(0, 20); // Move the cursor position to (x,y)
52-
M5.Lcd.printf("gyroX, gyroY, gyroZ"); // Screen printingformatted string
56+
/* The M5Core screen is 320x240 pixels, starting at the top left corner of the screen (0,0).
57+
gyroscope output related
58+
M5Stack屏幕像素为 320x240,以屏幕左上角为原点 (0,0)*/
59+
//gyroscope output related. 陀螺仪输出相关
60+
M5.Lcd.setCursor(0, 20); //Move the cursor position to (x,y). 移动光标位置到(x,y)处
61+
M5.Lcd.printf("gyroX, gyroY, gyroZ"); //Screen printingformatted string. 输出格式化字符串
5362
M5.Lcd.setCursor(0, 42);
5463
M5.Lcd.printf("%6.2f %6.2f%6.2f o/s", gyroX, gyroY, gyroZ);
5564

5665
// Accelerometer output is related
66+
//加速度计输出相关
5767
M5.Lcd.setCursor(0, 70);
5868
M5.Lcd.printf("accX, accY, accZ");
5969
M5.Lcd.setCursor(0, 92);
6070
M5.Lcd.printf("%5.2f %5.2f %5.2f G", accX, accY, accZ);
6171

6272
// Pose output is related
73+
//姿态输出相关
6374
M5.Lcd.setCursor(0, 120);
6475
M5.Lcd.printf("pitch, roll, yaw");
6576
M5.Lcd.setCursor(0, 142);
6677
M5.Lcd.printf("%5.2f %5.2f %5.2f deg", pitch, roll, yaw);
6778

6879
// Inertial sensor temperature output related
80+
//惯性传感器温度输出相关
6981
M5.Lcd.setCursor(0, 175);
7082
M5.Lcd.printf("Temperature : %.2f C", temp);
7183

72-
delay(1000); // Delay 1000ms (1 sec)
84+
delay(1000); // Delay 1000ms (1 sec) //延迟1000ms(1秒)
7385
}
Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,35 @@
11
/*
22
*******************************************************************************
3-
* Copyright (c) 2021 by M5Stack
3+
*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:Power Management Example
8-
* date:2021/7/15
9+
* describe:Power Management 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()函数中的程序,该部分只会执行一次。 */
1518
void setup(){
16-
M5.begin(); //Init M5Core
17-
M5.Power.begin(); //Init Power module
18-
M5.Power.lightSleep(SLEEP_SEC(5));
19-
M5.Lcd.setTextSize(2); // Set the font size
20-
M5.Lcd.print("press ButtonA: shutdown, use power button to turn back on");// Screen printing the formatted string
21-
}
19+
M5.begin(); //Init M5Core. 初始化 M5Core
20+
M5.Power.begin(); //Init Power module. 初始化电源
21+
M5.Power.lightSleep(SLEEP_SEC(5));
22+
M5.Lcd.setTextSize(2); //Set the font size. 设置字体大小
23+
M5.Lcd.print("press ButtonA: shutdown, use power button to turn back on"); //Screen printingformatted string. 输出格式化字符串
24+
}
2225

23-
//After the program in setup() runs, it runs the program in loop()
24-
//The loop() function is an infinite loop in which the program runs repeatedly
26+
/* After the program in setup() runs, it runs the program in loop()
27+
The loop() function is an infinite loop in which the program runs repeatedly
28+
在setup()函数中的程序执行完后,会接着执行loop()函数中的程序
29+
loop()函数是一个死循环,其中的程序会不断的重复运行 */
2530
void loop() {
26-
M5.update(); //Read the press state of the key
27-
if(M5.BtnA.wasPressed()) { // Check if the key is pressed
28-
M5.Power.powerOFF(); //Turn off power
31+
M5.update(); //Read the press state of the key. 读取按键 A, B, C 的状态
32+
if(M5.BtnA.wasPressed()) { //Check if the key is pressed. 如果按键A被按下
33+
M5.Power.powerOFF(); //Turn off power. 关闭电源
2934
}
3035
}

0 commit comments

Comments
 (0)