Skip to content

Commit 3dd0200

Browse files
authored
Merge pull request #258 from Tinyu-Zhao/master
Add some annotation
2 parents 352b2aa + 2f85a39 commit 3dd0200

53 files changed

Lines changed: 12114 additions & 6341 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

examples/Advanced/Storage/EEPROM/EEPROM.ino

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,25 @@ int addr = 0; //EEPROM Start number of an ADDRESS. EEPROM地址起始编号
2424
void setup() {
2525
M5.begin(); //Init M5Core. 初始化 M5Core
2626
M5.Power.begin(); //Init power 初始化电源模块
27+
M5.lcd.setTextSize(2); //Set the text size to 2. 设置文字大小为2
2728
if (!EEPROM.begin(SIZE)){ //Request storage of SIZE size(success return 1). 申请SIZE大小的存储(成功返回1)
2829
M5.Lcd.println("\nFailed to initialise EEPROM!"); //串口输出格式化字符串. Serial output format string
2930
delay(1000000);
3031
}
31-
M5.Lcd.println("\nRead data from Flash. Values are:");
32+
M5.Lcd.println("\nRead data from EEPROM. Values are:");
3233
for (int i = 0; i < SIZE; i++){
3334
M5.Lcd.printf("%d ",EEPROM.read(i)); //Reads data from 0 to SIZE in EEPROM. 读取EEPROM中从0到SIZE中的数据
3435
}
36+
M5.Lcd.println("\n\nPress BtnA to Write EEPROM");
3537
}
3638

3739
void loop() {
3840
M5.update(); //Check button down state. 检测按键按下状态
41+
M5.lcd.setTextSize(1); //Set the text size to 1. 设置文字大小为1
3942
if(M5.BtnA.isPressed()){ //if the button.A is Pressed. 如果按键A按下
4043
M5.lcd.clear();
41-
M5.lcd.setCursor(0,20);
42-
M5.Lcd.printf("\n%d Bytes datas written on Flash.\nValues are:\n",SIZE);
44+
M5.lcd.setCursor(0,0);
45+
M5.Lcd.printf("\n%d Bytes datas written on EEPROM.\nValues are:\n",SIZE);
4346
for(int i=0;i<SIZE;i++){
4447
int val = random(256); //Integer values to be stored in the EEPROM (EEPROM can store one byte per memory address, and can only store numbers from 0 to 255. Therefore, if you want to use EEPROM to store the numeric value read by the analog input pin, divide the numeric value by 4.
4548
//将要存储于EEPROM的整数数值(EEPROM每一个存储地址可以储存一个字节,只能存储0-255的数.故如果要使用EEPROM存储模拟输入引脚所读取到的数值需要将该数值除以4)
@@ -49,7 +52,7 @@ void loop() {
4952
}
5053
//When the storage address sequence number reaches the end of the storage space of the EEPROM, return to. 当存储地址序列号达到EEPROM的存储空间结尾,返回到EEPROM开始地址
5154
addr = 0;
52-
M5.Lcd.println("\n\nBytes written on Flash. Values are:");
55+
M5.Lcd.println("\n\nRead form EEPROM. Values are:");
5356
for(int i=0;i<SIZE;i++){
5457
M5.Lcd.printf("%d ",EEPROM.read(i));
5558
}

examples/Advanced/Storage/SPIFFS/SPIFFS/SPIFFS.ino

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,15 @@ void setup() {
2929
}
3030
if(SPIFFS.begin()){ // Start SPIFFS, return 1 on success. 启动闪存文件系统,若成功返回1
3131
M5.Lcd.println("SPIFFS Begin.");
32+
//Write operation
33+
File dataFile = SPIFFS.open(file_name, "w"); // Create a File object dafa File to write information to file_name in the SPIFFS. 建立File对象dafaFile用于向SPIFFS中的file_name写入信息
34+
dataFile.println("Hello IOT World."); // Writes string information and newlines to the dataFile. 向dataFile写入字符串信息并换行
35+
dataFile.close(); // Close the file when writing is complete. 完成写入后关闭文件
36+
M5.Lcd.println("Finished Writing data to SPIFFS");
37+
M5.Lcd.println("Press BtnA to read form SPIFFS");
3238
} else {
33-
M5.Lcd.println("SPIFFS Failed to Begin.");
39+
M5.Lcd.println("SPIFFS Failed to Begin.\nYou need to Run SPIFFS_Add.ino first");
3440
}
35-
//Write operation
36-
File dataFile = SPIFFS.open(file_name, "w"); // Create a File object dafa File to write information to file_name in the SPIFFS. 建立File对象dafaFile用于向SPIFFS中的file_name写入信息
37-
dataFile.println("Hello IOT World."); // Writes string information and newlines to the dataFile. 向dataFile写入字符串信息并换行
38-
dataFile.close(); // Close the file when writing is complete. 完成写入后关闭文件
39-
M5.Lcd.println("Finished Writing data to SPIFFS");
4041
}
4142

4243
void loop() {

examples/Basics/Button/Button.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ void setup() {
1919
M5.Power.begin(); //Init Power module. 初始化电源模块
2020
M5.Lcd.setTextColor(YELLOW); //Set the font color to yellow. 设置字体颜色为黄色
2121
M5.Lcd.setTextSize(2); //Set the font size. 设置字体大小为2
22-
M5.Lcd.setCursor(65, 10); //Move the cursor position to (x, y). 移动光标位置到 (x, y)
22+
M5.Lcd.setCursor(65, 10); //Move the cursor position to (65, 10). 移动光标位置到 (65, 10)
2323
M5.Lcd.println("Button example"); //The screen prints the formatted string and wraps the line. 输出格式化字符串并换行
2424
M5.Lcd.setCursor(3, 35);
2525
M5.Lcd.println("Press button B for 700ms");

examples/Basics/FactoryTest/bmp_map.c

Lines changed: 9603 additions & 0 deletions
Large diffs are not rendered by default.

examples/Basics/FactoryTest/startup_music.c

Lines changed: 23 additions & 0 deletions
Large diffs are not rendered by default.

examples/Basics/IMU/IMU.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,5 @@ M5Stack屏幕像素为 320x240,以屏幕左上角为原点 (0,0)*/
8181
M5.Lcd.setCursor(0, 175);
8282
M5.Lcd.printf("Temperature : %.2f C", temp);
8383

84-
delay(1000); // Delay 1000ms (1 sec) //延迟1000ms(1秒)
84+
delay(10); // Delay 10ms //延迟10ms
8585
}

examples/Basics/PowerOFF/PowerOFF.ino

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ the program in the setUp () function will be run, and this part will only be run
1818
void setup(){
1919
M5.begin(); //Init M5Core. 初始化 M5Core
2020
M5.Power.begin(); //Init Power module. 初始化电源
21-
M5.Power.lightSleep(SLEEP_SEC(5));
2221
M5.Lcd.setTextSize(2); //Set the font size. 设置字体大小
22+
M5.Lcd.print("After 5 seconds, the program entered light sleep\n\n"); //Screen printingformatted string. 输出格式化字符串
23+
delay(5000);
24+
M5.Power.lightSleep(SLEEP_SEC(5)); //Sleep for 5 seconds, then continue the program. 睡眠5秒,结束后程序继续往下进行
2325
M5.Lcd.print("press ButtonA: shutdown, use power button to turn back on"); //Screen printingformatted string. 输出格式化字符串
2426
}
2527

examples/Basics/Sleep/Sleep.ino

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ void setup() {
2020
M5.Power.begin(); //Init Power module. 初始化电源模块
2121
M5.Power.setWakeupButton(BUTTON_A_PIN); //Set the screen wake-up button to A. 将屏幕唤醒的按键设置为A
2222
M5.Lcd.setBrightness(200); //Set the screen brightness to 200 nits. 设置屏幕亮度为200尼特
23+
M5.lcd.setTextSize(2); //Set the text size to 2. 设置文字大小为2
2324
}
2425

2526
/* After the program in setup() runs, it runs the program in loop()
@@ -35,7 +36,7 @@ void loop() {
3536
M5.Lcd.printf("power-on triggered at:%s%s\n\n",(c) ? ("POWER-SW") : (""),(d) ? ("DeepSleep-end") : (""));
3637

3738
M5.Lcd.printf("Go lightSleep (5s or press buttonA wake up)\n");
38-
delay(2500); //delay 2500ms. 延迟2500ms
39+
delay(5000); //delay 5000ms. 延迟5000ms
3940
/*Restart after 10 seconds of light sleep and continue from the next line
4041
Calling this function power button will disable the power button to restore
4142
Please call M5.Power.setPowerBoostKeepOn(false)*/
@@ -44,11 +45,11 @@ void loop() {
4445
请调用M5.Power.setPowerBoostKeepOn(false)*/
4546
M5.Power.lightSleep(SLEEP_SEC(10));
4647
M5.Lcd.printf("Go lightSleep (press buttonA wake up)\n");
47-
delay(2500);
48+
delay(5000);
4849
M5.Power.lightSleep(0);
4950

5051
M5.Lcd.printf("resume.\n\nGo deepSleep (press buttonA wake up) ");
51-
delay(2500);
52+
delay(5000);
5253
/*After waking up from deep sleep for 0 seconds, the CPU will restart and
5354
the program will be executed from the beginning
5455
Calling this function will disable the power button to restore the power button

examples/Basics/Speaker/Speaker.ino

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ the program in the setUp () function will be run, and this part will only be run
4545
void setup() {
4646
M5.begin(); //Init M5Core. 初始化 M5Core
4747
M5.Power.begin(); //Init Power module. 初始化电源
48+
M5.lcd.setTextSize(2); //Set the text size to 2. 设置文字大小为2
4849
M5.Lcd.println("M5Stack Speaker test"); //Screen printingformatted string. 输出格式化字符串
4950
}
5051

0 commit comments

Comments
 (0)