|
@ -62,15 +62,13 @@ CardReader::CardReader() { |
|
|
workDirDepth = 0; |
|
|
workDirDepth = 0; |
|
|
ZERO(workDirParents); |
|
|
ZERO(workDirParents); |
|
|
|
|
|
|
|
|
autostart_stilltocheck = true; //the SD start is delayed, because otherwise the serial cannot answer fast enough to make contact with the host software.
|
|
|
// Disable autostart until card is initialized
|
|
|
autostart_index = 0; |
|
|
autostart_index = -1; |
|
|
|
|
|
|
|
|
//power to SD reader
|
|
|
//power to SD reader
|
|
|
#if SDPOWER > -1 |
|
|
#if SDPOWER > -1 |
|
|
OUT_WRITE(SDPOWER, HIGH); |
|
|
OUT_WRITE(SDPOWER, HIGH); |
|
|
#endif // SDPOWER
|
|
|
#endif |
|
|
|
|
|
|
|
|
next_autostart_ms = millis() + 5000; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
char *createFilename(char *buffer, const dir_t &p) { //buffer > 12characters
|
|
|
char *createFilename(char *buffer, const dir_t &p) { //buffer > 12characters
|
|
@ -607,40 +605,42 @@ void CardReader::write_command(char *buf) { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void CardReader::checkautostart(bool force) { |
|
|
//
|
|
|
if (!force && (!autostart_stilltocheck || PENDING(millis(), next_autostart_ms))) |
|
|
// Run the next autostart file. Called:
|
|
|
return; |
|
|
// - On boot after successful card init
|
|
|
|
|
|
// - After finishing the previous autostart file
|
|
|
|
|
|
// - From the LCD command to run the autostart file
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
autostart_stilltocheck = false; |
|
|
void CardReader::checkautostart() { |
|
|
|
|
|
|
|
|
if (!cardOK) { |
|
|
if (autostart_index < 0 || sdprinting) return; |
|
|
initsd(); |
|
|
|
|
|
if (!cardOK) return; // fail
|
|
|
if (!cardOK) initsd(); |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (cardOK) { |
|
|
char autoname[10]; |
|
|
char autoname[10]; |
|
|
sprintf_P(autoname, PSTR("auto%i.g"), autostart_index); |
|
|
sprintf_P(autoname, PSTR("auto%i.g"), autostart_index); |
|
|
for (int8_t i = 0; i < (int8_t)strlen(autoname); i++) autoname[i] = tolower(autoname[i]); |
|
|
|
|
|
|
|
|
|
|
|
dir_t p; |
|
|
dir_t p; |
|
|
|
|
|
|
|
|
root.rewind(); |
|
|
root.rewind(); |
|
|
|
|
|
|
|
|
bool found = false; |
|
|
|
|
|
while (root.readDir(p, NULL) > 0) { |
|
|
while (root.readDir(p, NULL) > 0) { |
|
|
for (int8_t i = (int8_t)strlen((char*)p.name); i--;) p.name[i] = tolower(p.name[i]); |
|
|
for (int8_t i = (int8_t)strlen((char*)p.name); i--;) p.name[i] = tolower(p.name[i]); |
|
|
if (p.name[9] != '~' && strncmp((char*)p.name, autoname, 5) == 0) { |
|
|
if (p.name[9] != '~' && strncmp((char*)p.name, autoname, 5) == 0) { |
|
|
openAndPrintFile(autoname); |
|
|
openAndPrintFile(autoname); |
|
|
found = true; |
|
|
autostart_index++; |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
if (!found) |
|
|
|
|
|
autostart_index = -1; |
|
|
autostart_index = -1; |
|
|
else |
|
|
|
|
|
autostart_index++; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void CardReader::closefile(bool store_location) { |
|
|
void CardReader::beginautostart() { |
|
|
|
|
|
autostart_index = 0; |
|
|
|
|
|
setroot(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void CardReader::closefile(const bool store_location) { |
|
|
file.sync(); |
|
|
file.sync(); |
|
|
file.close(); |
|
|
file.close(); |
|
|
saving = logging = false; |
|
|
saving = logging = false; |
|
|