|
@@ -266,10 +266,10 @@ void CardReader::release() {
|
266
|
266
|
}
|
267
|
267
|
|
268
|
268
|
void CardReader::openAndPrintFile(const char *name) {
|
269
|
|
- char cmd[4 + (FILENAME_LENGTH + 1) * MAX_DIR_DEPTH + 2]; // Room for "M23 ", names with slashes, a null, and one extra
|
|
269
|
+ char cmd[4 + strlen(name) + 1]; // Room for "M23 ", filename, and null
|
270
|
270
|
sprintf_P(cmd, PSTR("M23 %s"), name);
|
271
|
271
|
for (char *c = &cmd[4]; *c; c++) *c = tolower(*c);
|
272
|
|
- enqueue_and_echo_command_now(cmd);
|
|
272
|
+ enqueue_and_echo_command(cmd);
|
273
|
273
|
enqueue_and_echo_commands_P(PSTR("M24"));
|
274
|
274
|
}
|
275
|
275
|
|
|
@@ -300,10 +300,10 @@ void CardReader::getAbsFilename(char *t) {
|
300
|
300
|
t[0] = 0;
|
301
|
301
|
}
|
302
|
302
|
|
303
|
|
-void CardReader::openFile(char* name, bool read, bool replace_current/*=true*/) {
|
|
303
|
+void CardReader::openFile(char* name, bool read, bool push_current/*=false*/) {
|
304
|
304
|
if (!cardOK) return;
|
305
|
305
|
if (file.isOpen()) { //replacing current file by new file, or subfile call
|
306
|
|
- if (!replace_current) {
|
|
306
|
+ if (push_current) {
|
307
|
307
|
if (file_subcall_ctr > SD_PROCEDURE_DEPTH - 1) {
|
308
|
308
|
SERIAL_ERROR_START;
|
309
|
309
|
SERIAL_ERRORPGM("trying to call sub-gcode files with too many levels. MAX level is:");
|
|
@@ -318,20 +318,20 @@ void CardReader::openFile(char* name, bool read, bool replace_current/*=true*/)
|
318
|
318
|
SERIAL_ECHOPGM("\" parent:\"");
|
319
|
319
|
|
320
|
320
|
//store current filename and position
|
321
|
|
- getAbsFilename(filenames[file_subcall_ctr]);
|
|
321
|
+ getAbsFilename(proc_filenames[file_subcall_ctr]);
|
322
|
322
|
|
323
|
|
- SERIAL_ECHO(filenames[file_subcall_ctr]);
|
|
323
|
+ SERIAL_ECHO(proc_filenames[file_subcall_ctr]);
|
324
|
324
|
SERIAL_ECHOPGM("\" pos");
|
325
|
325
|
SERIAL_ECHOLN(sdpos);
|
326
|
326
|
filespos[file_subcall_ctr] = sdpos;
|
327
|
327
|
file_subcall_ctr++;
|
328
|
|
- }
|
329
|
|
- else {
|
330
|
|
- SERIAL_ECHO_START;
|
331
|
|
- SERIAL_ECHOPGM("Now doing file: ");
|
332
|
|
- SERIAL_ECHOLN(name);
|
333
|
|
- }
|
334
|
|
- file.close();
|
|
328
|
+ }
|
|
329
|
+ else {
|
|
330
|
+ SERIAL_ECHO_START;
|
|
331
|
+ SERIAL_ECHOPGM("Now doing file: ");
|
|
332
|
+ SERIAL_ECHOLN(name);
|
|
333
|
+ }
|
|
334
|
+ file.close();
|
335
|
335
|
}
|
336
|
336
|
else { //opening fresh file
|
337
|
337
|
file_subcall_ctr = 0; //resetting procedure depth in case user cancels print while in procedure
|
|
@@ -584,22 +584,15 @@ void CardReader::chdir(const char * relpath) {
|
584
|
584
|
SERIAL_ECHOLN(relpath);
|
585
|
585
|
}
|
586
|
586
|
else {
|
587
|
|
- if (workDirDepth < MAX_DIR_DEPTH) {
|
588
|
|
- ++workDirDepth;
|
589
|
|
- for (int d = workDirDepth; d--;) workDirParents[d + 1] = workDirParents[d];
|
590
|
|
- workDirParents[0] = *parent;
|
591
|
|
- }
|
|
587
|
+ if (workDirDepth < MAX_DIR_DEPTH)
|
|
588
|
+ workDirParents[workDirDepth++] = *parent;
|
592
|
589
|
workDir = newfile;
|
593
|
590
|
}
|
594
|
591
|
}
|
595
|
592
|
|
596
|
593
|
void CardReader::updir() {
|
597
|
|
- if (workDirDepth > 0) {
|
598
|
|
- --workDirDepth;
|
599
|
|
- workDir = workDirParents[0];
|
600
|
|
- for (uint16_t d = 0; d < workDirDepth; d++)
|
601
|
|
- workDirParents[d] = workDirParents[d+1];
|
602
|
|
- }
|
|
594
|
+ if (workDirDepth > 0)
|
|
595
|
+ workDir = workDirParents[--workDirDepth];
|
603
|
596
|
}
|
604
|
597
|
|
605
|
598
|
void CardReader::printingHasFinished() {
|
|
@@ -607,17 +600,15 @@ void CardReader::printingHasFinished() {
|
607
|
600
|
if (file_subcall_ctr > 0) { // Heading up to a parent file that called current as a procedure.
|
608
|
601
|
file.close();
|
609
|
602
|
file_subcall_ctr--;
|
610
|
|
- openFile(filenames[file_subcall_ctr], true, true);
|
|
603
|
+ openFile(proc_filenames[file_subcall_ctr], true, true);
|
611
|
604
|
setIndex(filespos[file_subcall_ctr]);
|
612
|
605
|
startFileprint();
|
613
|
606
|
}
|
614
|
607
|
else {
|
615
|
608
|
file.close();
|
616
|
609
|
sdprinting = false;
|
617
|
|
- if (SD_FINISHED_STEPPERRELEASE) {
|
618
|
|
- //finishAndDisableSteppers();
|
|
610
|
+ if (SD_FINISHED_STEPPERRELEASE)
|
619
|
611
|
enqueue_and_echo_commands_P(PSTR(SD_FINISHED_RELEASECOMMAND));
|
620
|
|
- }
|
621
|
612
|
autotempShutdown();
|
622
|
613
|
}
|
623
|
614
|
}
|