|
|
@ -32,12 +32,9 @@
|
|
|
|
#if ENABLED(SDSUPPORT)
|
|
|
|
#if ENABLED(SDSUPPORT)
|
|
|
|
|
|
|
|
|
|
|
|
CardReader::CardReader() {
|
|
|
|
CardReader::CardReader() {
|
|
|
|
|
|
|
|
sdprinting = cardOK = saving = logging = false;
|
|
|
|
filesize = 0;
|
|
|
|
filesize = 0;
|
|
|
|
sdpos = 0;
|
|
|
|
sdpos = 0;
|
|
|
|
sdprinting = false;
|
|
|
|
|
|
|
|
cardOK = false;
|
|
|
|
|
|
|
|
saving = false;
|
|
|
|
|
|
|
|
logging = false;
|
|
|
|
|
|
|
|
workDirDepth = 0;
|
|
|
|
workDirDepth = 0;
|
|
|
|
file_subcall_ctr = 0;
|
|
|
|
file_subcall_ctr = 0;
|
|
|
|
memset(workDirParents, 0, sizeof(workDirParents));
|
|
|
|
memset(workDirParents, 0, sizeof(workDirParents));
|
|
|
@ -276,19 +273,12 @@ void CardReader::openAndPrintFile(const char *name) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CardReader::startFileprint() {
|
|
|
|
void CardReader::startFileprint() {
|
|
|
|
if (cardOK)
|
|
|
|
if (cardOK) sdprinting = true;
|
|
|
|
sdprinting = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CardReader::pauseSDPrint() {
|
|
|
|
|
|
|
|
if (sdprinting) sdprinting = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CardReader::stopSDPrint() {
|
|
|
|
void CardReader::stopSDPrint() {
|
|
|
|
if (sdprinting) {
|
|
|
|
sdprinting = false;
|
|
|
|
sdprinting = false;
|
|
|
|
if (isFileOpen()) file.close();
|
|
|
|
file.close();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CardReader::openLogFile(char* name) {
|
|
|
|
void CardReader::openLogFile(char* name) {
|
|
|
@ -310,8 +300,11 @@ void CardReader::getAbsFilename(char *t) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CardReader::openFile(char* name, bool read, bool push_current/*=false*/) {
|
|
|
|
void CardReader::openFile(char* name, bool read, bool push_current/*=false*/) {
|
|
|
|
|
|
|
|
|
|
|
|
if (!cardOK) return;
|
|
|
|
if (!cardOK) return;
|
|
|
|
if (file.isOpen()) { //replacing current file by new file, or subfile call
|
|
|
|
|
|
|
|
|
|
|
|
uint8_t doing = 0;
|
|
|
|
|
|
|
|
if (isFileOpen()) { //replacing current file by new file, or subfile call
|
|
|
|
if (push_current) {
|
|
|
|
if (push_current) {
|
|
|
|
if (file_subcall_ctr > SD_PROCEDURE_DEPTH - 1) {
|
|
|
|
if (file_subcall_ctr > SD_PROCEDURE_DEPTH - 1) {
|
|
|
|
SERIAL_ERROR_START;
|
|
|
|
SERIAL_ERROR_START;
|
|
|
@ -321,40 +314,39 @@ void CardReader::openFile(char* name, bool read, bool push_current/*=false*/) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SERIAL_ECHO_START;
|
|
|
|
// Store current filename and position
|
|
|
|
SERIAL_ECHOPGM("SUBROUTINE CALL target:\"");
|
|
|
|
|
|
|
|
SERIAL_ECHO(name);
|
|
|
|
|
|
|
|
SERIAL_ECHOPGM("\" parent:\"");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//store current filename and position
|
|
|
|
|
|
|
|
getAbsFilename(proc_filenames[file_subcall_ctr]);
|
|
|
|
getAbsFilename(proc_filenames[file_subcall_ctr]);
|
|
|
|
|
|
|
|
|
|
|
|
SERIAL_ECHO(proc_filenames[file_subcall_ctr]);
|
|
|
|
SERIAL_ECHO_START;
|
|
|
|
SERIAL_ECHOPGM("\" pos");
|
|
|
|
SERIAL_ECHOPAIR("SUBROUTINE CALL target:\"", name);
|
|
|
|
SERIAL_ECHOLN(sdpos);
|
|
|
|
SERIAL_ECHOPAIR("\" parent:\"", proc_filenames[file_subcall_ctr]);
|
|
|
|
|
|
|
|
SERIAL_ECHOLNPAIR("\" pos", sdpos);
|
|
|
|
filespos[file_subcall_ctr] = sdpos;
|
|
|
|
filespos[file_subcall_ctr] = sdpos;
|
|
|
|
file_subcall_ctr++;
|
|
|
|
file_subcall_ctr++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
SERIAL_ECHO_START;
|
|
|
|
doing = 1;
|
|
|
|
SERIAL_ECHOPGM("Now doing file: ");
|
|
|
|
|
|
|
|
SERIAL_ECHOLN(name);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
file.close();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else { //opening fresh file
|
|
|
|
else { // Opening fresh file
|
|
|
|
file_subcall_ctr = 0; //resetting procedure depth in case user cancels print while in procedure
|
|
|
|
doing = 2;
|
|
|
|
|
|
|
|
file_subcall_ctr = 0; // Reset procedure depth in case user cancels print while in procedure
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (doing) {
|
|
|
|
SERIAL_ECHO_START;
|
|
|
|
SERIAL_ECHO_START;
|
|
|
|
SERIAL_ECHOPGM("Now fresh file: ");
|
|
|
|
SERIAL_ECHOPGM("Now ");
|
|
|
|
SERIAL_ECHOLN(name);
|
|
|
|
SERIAL_ECHO(doing == 1 ? "doing" : "fresh");
|
|
|
|
|
|
|
|
SERIAL_ECHOLNPAIR(" file: ", name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
sdprinting = false;
|
|
|
|
|
|
|
|
|
|
|
|
stopSDPrint();
|
|
|
|
|
|
|
|
|
|
|
|
SdFile myDir;
|
|
|
|
SdFile myDir;
|
|
|
|
curDir = &root;
|
|
|
|
curDir = &root;
|
|
|
|
char *fname = name;
|
|
|
|
char *fname = name;
|
|
|
|
|
|
|
|
|
|
|
|
char *dirname_start, *dirname_end;
|
|
|
|
char *dirname_start, *dirname_end;
|
|
|
|
|
|
|
|
|
|
|
|
if (name[0] == '/') {
|
|
|
|
if (name[0] == '/') {
|
|
|
|
dirname_start = &name[1];
|
|
|
|
dirname_start = &name[1];
|
|
|
|
while (dirname_start != NULL) {
|
|
|
|
while (dirname_start != NULL) {
|
|
|
@ -425,8 +417,7 @@ void CardReader::openFile(char* name, bool read, bool push_current/*=false*/) {
|
|
|
|
void CardReader::removeFile(char* name) {
|
|
|
|
void CardReader::removeFile(char* name) {
|
|
|
|
if (!cardOK) return;
|
|
|
|
if (!cardOK) return;
|
|
|
|
|
|
|
|
|
|
|
|
file.close();
|
|
|
|
stopSDPrint();
|
|
|
|
sdprinting = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SdFile myDir;
|
|
|
|
SdFile myDir;
|
|
|
|
curDir = &root;
|
|
|
|
curDir = &root;
|
|
|
|