|
@@ -118,9 +118,11 @@ Sd2Card CardReader::sd2card;
|
118
|
118
|
SdVolume CardReader::volume;
|
119
|
119
|
SdFile CardReader::file;
|
120
|
120
|
|
121
|
|
-uint8_t CardReader::file_subcall_ctr;
|
122
|
|
-uint32_t CardReader::filespos[SD_PROCEDURE_DEPTH];
|
123
|
|
-char CardReader::proc_filenames[SD_PROCEDURE_DEPTH][MAXPATHNAMELENGTH];
|
|
121
|
+#if HAS_MEDIA_SUBCALLS
|
|
122
|
+ uint8_t CardReader::file_subcall_ctr;
|
|
123
|
+ uint32_t CardReader::filespos[SD_PROCEDURE_DEPTH];
|
|
124
|
+ char CardReader::proc_filenames[SD_PROCEDURE_DEPTH][MAXPATHNAMELENGTH];
|
|
125
|
+#endif
|
124
|
126
|
|
125
|
127
|
uint32_t CardReader::filesize, CardReader::sdpos;
|
126
|
128
|
|
|
@@ -135,7 +137,8 @@ CardReader::CardReader() {
|
135
|
137
|
#endif
|
136
|
138
|
flag.sdprinting = flag.mounted = flag.saving = flag.logging = false;
|
137
|
139
|
filesize = sdpos = 0;
|
138
|
|
- file_subcall_ctr = 0;
|
|
140
|
+
|
|
141
|
+ TERN_(HAS_MEDIA_SUBCALLS, file_subcall_ctr = 0);
|
139
|
142
|
|
140
|
143
|
workDirDepth = 0;
|
141
|
144
|
ZERO(workDirParents);
|
|
@@ -540,34 +543,39 @@ void CardReader::openFileRead(char * const path, const uint8_t subcall_type/*=0*
|
540
|
543
|
switch (subcall_type) {
|
541
|
544
|
case 0: // Starting a new print. "Now fresh file: ..."
|
542
|
545
|
announceOpen(2, path);
|
543
|
|
- file_subcall_ctr = 0;
|
|
546
|
+ TERN_(HAS_MEDIA_SUBCALLS, file_subcall_ctr = 0);
|
544
|
547
|
break;
|
545
|
548
|
|
546
|
|
- case 1: // Starting a sub-procedure
|
|
549
|
+ #if HAS_MEDIA_SUBCALLS
|
547
|
550
|
|
548
|
|
- // With no file is open it's a simple macro. "Now doing file: ..."
|
549
|
|
- if (!isFileOpen()) { announceOpen(1, path); break; }
|
|
551
|
+ case 1: // Starting a sub-procedure
|
550
|
552
|
|
551
|
|
- // Too deep? The firmware has to bail.
|
552
|
|
- if (file_subcall_ctr > SD_PROCEDURE_DEPTH - 1) {
|
553
|
|
- SERIAL_ERROR_MSG("Exceeded max SUBROUTINE depth:" STRINGIFY(SD_PROCEDURE_DEPTH));
|
554
|
|
- kill(GET_TEXT(MSG_KILL_SUBCALL_OVERFLOW));
|
555
|
|
- return;
|
556
|
|
- }
|
|
553
|
+ // With no file is open it's a simple macro. "Now doing file: ..."
|
|
554
|
+ if (!isFileOpen()) { announceOpen(1, path); break; }
|
557
|
555
|
|
558
|
|
- // Store current filename (based on workDirParents) and position
|
559
|
|
- getAbsFilename(proc_filenames[file_subcall_ctr]);
|
560
|
|
- filespos[file_subcall_ctr] = sdpos;
|
|
556
|
+ // Too deep? The firmware has to bail.
|
|
557
|
+ if (file_subcall_ctr > SD_PROCEDURE_DEPTH - 1) {
|
|
558
|
+ SERIAL_ERROR_MSG("Exceeded max SUBROUTINE depth:", int(SD_PROCEDURE_DEPTH));
|
|
559
|
+ kill(GET_TEXT(MSG_KILL_SUBCALL_OVERFLOW));
|
|
560
|
+ return;
|
|
561
|
+ }
|
561
|
562
|
|
562
|
|
- // For sub-procedures say 'SUBROUTINE CALL target: "..." parent: "..." pos12345'
|
563
|
|
- SERIAL_ECHO_START();
|
564
|
|
- SERIAL_ECHOLNPAIR("SUBROUTINE CALL target:\"", path, "\" parent:\"", proc_filenames[file_subcall_ctr], "\" pos", sdpos);
|
565
|
|
- file_subcall_ctr++;
|
566
|
|
- break;
|
|
563
|
+ // Store current filename (based on workDirParents) and position
|
|
564
|
+ getAbsFilename(proc_filenames[file_subcall_ctr]);
|
567
|
565
|
|
568
|
|
- case 2: // Resuming previous file after sub-procedure
|
569
|
|
- SERIAL_ECHO_MSG("END SUBROUTINE");
|
570
|
|
- break;
|
|
566
|
+ TERN_(HAS_MEDIA_SUBCALLS, filespos[file_subcall_ctr] = sdpos);
|
|
567
|
+
|
|
568
|
+ // For sub-procedures say 'SUBROUTINE CALL target: "..." parent: "..." pos12345'
|
|
569
|
+ SERIAL_ECHO_START();
|
|
570
|
+ SERIAL_ECHOLNPAIR("SUBROUTINE CALL target:\"", path, "\" parent:\"", proc_filenames[file_subcall_ctr], "\" pos", sdpos);
|
|
571
|
+ file_subcall_ctr++;
|
|
572
|
+ break;
|
|
573
|
+
|
|
574
|
+ case 2: // Resuming previous file after sub-procedure
|
|
575
|
+ SERIAL_ECHO_MSG("END SUBROUTINE");
|
|
576
|
+ break;
|
|
577
|
+
|
|
578
|
+ #endif
|
571
|
579
|
}
|
572
|
580
|
|
573
|
581
|
endFilePrint();
|
|
@@ -603,7 +611,7 @@ void CardReader::openFileWrite(char * const path) {
|
603
|
611
|
if (!isMounted()) return;
|
604
|
612
|
|
605
|
613
|
announceOpen(2, path);
|
606
|
|
- file_subcall_ctr = 0;
|
|
614
|
+ TERN_(HAS_MEDIA_SUBCALLS, file_subcall_ctr = 0);
|
607
|
615
|
|
608
|
616
|
endFilePrint();
|
609
|
617
|
|
|
@@ -1158,17 +1166,19 @@ uint16_t CardReader::get_num_Files() {
|
1158
|
1166
|
void CardReader::fileHasFinished() {
|
1159
|
1167
|
planner.synchronize();
|
1160
|
1168
|
file.close();
|
1161
|
|
- if (file_subcall_ctr > 0) { // Resume calling file after closing procedure
|
1162
|
|
- file_subcall_ctr--;
|
1163
|
|
- openFileRead(proc_filenames[file_subcall_ctr], 2); // 2 = Returning from sub-procedure
|
1164
|
|
- setIndex(filespos[file_subcall_ctr]);
|
1165
|
|
- startFileprint();
|
1166
|
|
- }
|
1167
|
|
- else {
|
1168
|
|
- endFilePrint(TERN_(SD_RESORT, true));
|
1169
|
1169
|
|
1170
|
|
- marlin_state = MF_SD_COMPLETE;
|
1171
|
|
- }
|
|
1170
|
+ #if HAS_MEDIA_SUBCALLS
|
|
1171
|
+ if (file_subcall_ctr > 0) { // Resume calling file after closing procedure
|
|
1172
|
+ file_subcall_ctr--;
|
|
1173
|
+ openFileRead(proc_filenames[file_subcall_ctr], 2); // 2 = Returning from sub-procedure
|
|
1174
|
+ setIndex(filespos[file_subcall_ctr]);
|
|
1175
|
+ startFileprint();
|
|
1176
|
+ return;
|
|
1177
|
+ }
|
|
1178
|
+ #endif
|
|
1179
|
+
|
|
1180
|
+ endFilePrint(TERN_(SD_RESORT, true));
|
|
1181
|
+ marlin_state = MF_SD_COMPLETE;
|
1172
|
1182
|
}
|
1173
|
1183
|
|
1174
|
1184
|
#if ENABLED(AUTO_REPORT_SD_STATUS)
|