Skip to content

Commit

Permalink
Merge pull request #258 from Tinyu-Zhao/master
Browse files Browse the repository at this point in the history
Add some annotation
  • Loading branch information
Tinyu-Zhao authored Aug 20, 2021
2 parents 352b2aa + 2f85a39 commit 3dd0200
Show file tree
Hide file tree
Showing 53 changed files with 12,114 additions and 6,341 deletions.
11 changes: 7 additions & 4 deletions examples/Advanced/Storage/EEPROM/EEPROM.ino
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,25 @@ int addr = 0; //EEPROM Start number of an ADDRESS. EEPROM地址起始编号
void setup() {
M5.begin(); //Init M5Core. 初始化 M5Core
M5.Power.begin(); //Init power 初始化电源模块
M5.lcd.setTextSize(2); //Set the text size to 2. 设置文字大小为2
if (!EEPROM.begin(SIZE)){ //Request storage of SIZE size(success return 1). 申请SIZE大小的存储(成功返回1)
M5.Lcd.println("\nFailed to initialise EEPROM!"); //串口输出格式化字符串. Serial output format string
delay(1000000);
}
M5.Lcd.println("\nRead data from Flash. Values are:");
M5.Lcd.println("\nRead data from EEPROM. Values are:");
for (int i = 0; i < SIZE; i++){
M5.Lcd.printf("%d ",EEPROM.read(i)); //Reads data from 0 to SIZE in EEPROM. 读取EEPROM中从0到SIZE中的数据
}
M5.Lcd.println("\n\nPress BtnA to Write EEPROM");
}

void loop() {
M5.update(); //Check button down state. 检测按键按下状态
M5.lcd.setTextSize(1); //Set the text size to 1. 设置文字大小为1
if(M5.BtnA.isPressed()){ //if the button.A is Pressed. 如果按键A按下
M5.lcd.clear();
M5.lcd.setCursor(0,20);
M5.Lcd.printf("\n%d Bytes datas written on Flash.\nValues are:\n",SIZE);
M5.lcd.setCursor(0,0);
M5.Lcd.printf("\n%d Bytes datas written on EEPROM.\nValues are:\n",SIZE);
for(int i=0;i<SIZE;i++){
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.
//将要存储于EEPROM的整数数值(EEPROM每一个存储地址可以储存一个字节,只能存储0-255的数.故如果要使用EEPROM存储模拟输入引脚所读取到的数值需要将该数值除以4)
Expand All @@ -49,7 +52,7 @@ void loop() {
}
//When the storage address sequence number reaches the end of the storage space of the EEPROM, return to. 当存储地址序列号达到EEPROM的存储空间结尾,返回到EEPROM开始地址
addr = 0;
M5.Lcd.println("\n\nBytes written on Flash. Values are:");
M5.Lcd.println("\n\nRead form EEPROM. Values are:");
for(int i=0;i<SIZE;i++){
M5.Lcd.printf("%d ",EEPROM.read(i));
}
Expand Down
13 changes: 7 additions & 6 deletions examples/Advanced/Storage/SPIFFS/SPIFFS/SPIFFS.ino
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,15 @@ void setup() {
}
if(SPIFFS.begin()){ // Start SPIFFS, return 1 on success. 启动闪存文件系统,若成功返回1
M5.Lcd.println("SPIFFS Begin.");
//Write operation
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写入信息
dataFile.println("Hello IOT World."); // Writes string information and newlines to the dataFile. 向dataFile写入字符串信息并换行
dataFile.close(); // Close the file when writing is complete. 完成写入后关闭文件
M5.Lcd.println("Finished Writing data to SPIFFS");
M5.Lcd.println("Press BtnA to read form SPIFFS");
} else {
M5.Lcd.println("SPIFFS Failed to Begin.");
M5.Lcd.println("SPIFFS Failed to Begin.\nYou need to Run SPIFFS_Add.ino first");
}
//Write operation
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写入信息
dataFile.println("Hello IOT World."); // Writes string information and newlines to the dataFile. 向dataFile写入字符串信息并换行
dataFile.close(); // Close the file when writing is complete. 完成写入后关闭文件
M5.Lcd.println("Finished Writing data to SPIFFS");
}

void loop() {
Expand Down
2 changes: 1 addition & 1 deletion examples/Basics/Button/Button.ino
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void setup() {
M5.Power.begin(); //Init Power module. 初始化电源模块
M5.Lcd.setTextColor(YELLOW); //Set the font color to yellow. 设置字体颜色为黄色
M5.Lcd.setTextSize(2); //Set the font size. 设置字体大小为2
M5.Lcd.setCursor(65, 10); //Move the cursor position to (x, y). 移动光标位置到 (x, y)
M5.Lcd.setCursor(65, 10); //Move the cursor position to (65, 10). 移动光标位置到 (65, 10)
M5.Lcd.println("Button example"); //The screen prints the formatted string and wraps the line. 输出格式化字符串并换行
M5.Lcd.setCursor(3, 35);
M5.Lcd.println("Press button B for 700ms");
Expand Down
9,603 changes: 9,603 additions & 0 deletions examples/Basics/FactoryTest/bmp_map.c

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions examples/Basics/FactoryTest/startup_music.c

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/Basics/IMU/IMU.ino
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,5 @@ M5Stack屏幕像素为 320x240,以屏幕左上角为原点 (0,0)*/
M5.Lcd.setCursor(0, 175);
M5.Lcd.printf("Temperature : %.2f C", temp);

delay(1000); // Delay 1000ms (1 sec) //延迟1000ms(1秒)
delay(10); // Delay 10ms //延迟10ms
}
4 changes: 3 additions & 1 deletion examples/Basics/PowerOFF/PowerOFF.ino
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ the program in the setUp () function will be run, and this part will only be run
void setup(){
M5.begin(); //Init M5Core. 初始化 M5Core
M5.Power.begin(); //Init Power module. 初始化电源
M5.Power.lightSleep(SLEEP_SEC(5));
M5.Lcd.setTextSize(2); //Set the font size. 设置字体大小
M5.Lcd.print("After 5 seconds, the program entered light sleep\n\n"); //Screen printingformatted string. 输出格式化字符串
delay(5000);
M5.Power.lightSleep(SLEEP_SEC(5)); //Sleep for 5 seconds, then continue the program. 睡眠5秒,结束后程序继续往下进行
M5.Lcd.print("press ButtonA: shutdown, use power button to turn back on"); //Screen printingformatted string. 输出格式化字符串
}

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

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

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

M5.Lcd.printf("resume.\n\nGo deepSleep (press buttonA wake up) ");
delay(2500);
delay(5000);
/*After waking up from deep sleep for 0 seconds, the CPU will restart and
the program will be executed from the beginning
Calling this function will disable the power button to restore the power button
Expand Down
1 change: 1 addition & 0 deletions examples/Basics/Speaker/Speaker.ino
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ the program in the setUp () function will be run, and this part will only be run
void setup() {
M5.begin(); //Init M5Core. 初始化 M5Core
M5.Power.begin(); //Init Power module. 初始化电源
M5.lcd.setTextSize(2); //Set the text size to 2. 设置文字大小为2
M5.Lcd.println("M5Stack Speaker test"); //Screen printingformatted string. 输出格式化字符串
}

Expand Down
Loading

0 comments on commit 3dd0200

Please sign in to comment.