1
1
#include < Arduino_UnifiedStorage.h>
2
2
3
- InternalStorage internalStorage = InternalStorage();
4
3
4
+ InternalStorage internalStorage = InternalStorage();
5
5
6
6
void setup () {
7
7
/* UNCOMMENT THIS PART IF YOU WANT TO ENABLE FORMATTING*/
8
8
9
9
10
+ #if defined(ARDUINO_PORTENTA_C33) || defined(ARDUINO_PORTENTA_H7_M7)
11
+ Serial.begin (115200 );
12
+ while (!Serial);
13
+ #elif defined(ARDUINO_OPTA)
14
+ beginRS485 (115200 );
15
+ #endif
10
16
11
- Serial.begin (9600 );
12
- delay (1000 ); // Give time to open the Serial Monitor
13
- while (!Serial);
14
17
15
18
16
19
@@ -19,36 +22,30 @@ void setup() {
19
22
20
23
21
24
Folder root = internalStorage.getRootFolder ();
22
- Serial. println (root. getPathAsString ());
25
+
23
26
24
27
// Test copyTo
25
- Serial. println (" Testing copyTo..." );
28
+ printFormatted (" Testing copyTo... \n " );
26
29
Folder sourceFolder2 = root.createSubfolder (" source_folder" );
27
- Serial. println (" Folder 1 created" );
30
+ printFormatted (" Folder 1 created \n " );
28
31
29
- Serial. println (" Trying to create a folder on top of an existing one... without overwrite" );
32
+ printFormatted (" Trying to create a folder on top of an existing one... without overwrite \n " );
30
33
Folder sourceFolder3 = root.createSubfolder (" source_folder" );
31
34
32
- Serial. println (" Trying to create a folder on top of an existing one... with overwrite" );
35
+ printFormatted (" Trying to create a folder on top of an existing one... with overwrite \n " );
33
36
Folder sourceFolder4 = root.createSubfolder (" source_folder" , true );
34
37
35
38
Folder destinationFolder2 = root.createSubfolder (" destination_folder" );
36
- Serial.println (" Folder 2 created" );
37
-
38
- Serial.println (sourceFolder2.getPathAsString ());
39
- Serial.println (destinationFolder2.getPathAsString ());
39
+ printFormatted (" Folder 2 created \n " );
40
40
41
- Serial.println ();
42
- Serial.println ();
43
41
44
42
45
43
bool copyResult = sourceFolder2.copyTo (destinationFolder2, true ); // Overwrite if exists
46
44
if (copyResult) {
47
- Serial. println (" Copy successful" );
45
+ printFormatted (" Copy successful \n " );
48
46
} else {
49
- Serial. println (" Copy failed" );
47
+ printFormatted (" Copy failed \n " );
50
48
}
51
- Serial.println ();
52
49
53
50
54
51
@@ -57,15 +54,12 @@ void setup() {
57
54
Folder sourceFolder = root.createSubfolder (" source" );
58
55
Folder destinationFolder = root.createSubfolder (" destination" );
59
56
60
-
61
- Serial.println ();
62
- Serial.println ();
63
- Serial.println (" Testing moveTo..." );
57
+ printFormatted (" Testing moveTo... \n " );
64
58
bool moveResult = sourceFolder.moveTo (destinationFolder, true ); // Overwrite if exists
65
59
if (moveResult) {
66
- Serial. println (" Move successful" );
60
+ printFormatted (" Move successful \n " );
67
61
} else {
68
- Serial. println (" Move failed" );
62
+ printFormatted (" Move failed \n " );
69
63
}
70
64
71
65
@@ -79,14 +73,10 @@ void setup() {
79
73
80
74
81
75
bool success = someFile.copyTo (someOtherFolder);
82
- Serial.println (" trying to copy file without overwrite" );
83
- Serial.println (success);
76
+ printFormatted (" trying to copy file without overwrite: %d\n " , success);
84
77
85
78
success = someFile.copyTo (someOtherFolder,true );
86
- Serial.println (" trying to copy file with overwrite" );
87
- Serial.println (success);
88
-
89
-
79
+ printFormatted (" trying to copy file with overwrite: %d \n " , success);
90
80
91
81
}
92
82
0 commit comments