You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: examples/Advanced/Storage/EEPROM/EEPROM.ino
+7-4Lines changed: 7 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -23,22 +23,25 @@ int addr = 0; //EEPROM Start number of an ADDRESS. EEPROM地址起始编号
23
23
24
24
voidsetup() {
25
25
M5.begin(); //Init M5Core2. 初始化 M5Core2
26
+
M5.lcd.setTextSize(2); //Set the text size to 2. 设置文字大小为2
26
27
if (!EEPROM.begin(SIZE)){ //Request storage of SIZE size(success return 1). 申请SIZE大小的存储(成功返回1)
27
28
M5.Lcd.println("\nFailed to initialise EEPROM!"); //串口输出格式化字符串. Serial output format string
28
29
delay(1000000);
29
30
}
30
-
M5.Lcd.println("\nRead data from Flash. Values are:");
31
+
M5.Lcd.println("\nRead data from EEPROM. Values are:");
31
32
for (int i = 0; i < SIZE; i++){
32
33
M5.Lcd.printf("%d ",EEPROM.read(i)); //Reads data from 0 to SIZE in EEPROM. 读取EEPROM中从0到SIZE中的数据
33
34
}
35
+
M5.Lcd.println("\n\nPress BtnA to Write EEPROM");
34
36
}
35
37
36
38
voidloop() {
37
39
M5.update(); //Check button down state. 检测按键按下状态
40
+
M5.lcd.setTextSize(1); //Set the text size to 1. 设置文字大小为1
38
41
if(M5.BtnA.isPressed()){ //if the button.A is Pressed. 如果按键A按下
39
42
M5.lcd.clear();
40
-
M5.lcd.setCursor(0,20);
41
-
M5.Lcd.printf("\n%d Bytes datas written on Flash.\nValues are:\n",SIZE);
43
+
M5.lcd.setCursor(0,0);
44
+
M5.Lcd.printf("\n%d Bytes datas written on EEPROM.\nValues are:\n",SIZE);
42
45
for(int i=0;i<SIZE;i++){
43
46
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.
Copy file name to clipboardExpand all lines: examples/Advanced/Storage/SPIFFS/SPIFFS/SPIFFS.ino
+6-6Lines changed: 6 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -29,14 +29,14 @@ void setup() {
29
29
30
30
if(SPIFFS.begin()){ // Start SPIFFS, return 1 on success. 启动闪存文件系统,若成功返回1
31
31
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");
32
37
} else {
33
-
M5.Lcd.println("SPIFFS Failed to Begin.");
38
+
M5.Lcd.println("SPIFFS Failed to Begin.\nYou need to Run SPIFFS_Add.ino first");
34
39
}
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");
0 commit comments