|
|
@ -123,7 +123,7 @@ CardReader::CardReader() { |
|
|
|
//sort_reverse = false;
|
|
|
|
#endif |
|
|
|
#endif |
|
|
|
flag.sdprinting = flag.detected = flag.saving = flag.logging = false; |
|
|
|
flag.sdprinting = flag.mounted = flag.saving = flag.logging = false; |
|
|
|
filesize = sdpos = 0; |
|
|
|
file_subcall_ctr = 0; |
|
|
|
|
|
|
@ -329,8 +329,8 @@ void CardReader::printFilename() { |
|
|
|
SERIAL_EOL(); |
|
|
|
} |
|
|
|
|
|
|
|
void CardReader::initsd() { |
|
|
|
flag.detected = false; |
|
|
|
void CardReader::mount() { |
|
|
|
flag.mounted = false; |
|
|
|
if (root.isOpen()) root.close(); |
|
|
|
|
|
|
|
#ifndef SPI_SPEED |
|
|
@ -350,7 +350,7 @@ void CardReader::initsd() { |
|
|
|
else if (!root.openRoot(&volume)) |
|
|
|
SERIAL_ERROR_MSG(MSG_SD_OPENROOT_FAIL); |
|
|
|
else { |
|
|
|
flag.detected = true; |
|
|
|
flag.mounted = true; |
|
|
|
SERIAL_ECHO_MSG(MSG_SD_CARD_OK); |
|
|
|
#if ENABLED(EEPROM_SETTINGS) && NONE(FLASH_EEPROM_EMULATION, SPI_EEPROM, I2C_EEPROM) |
|
|
|
settings.first_load(); |
|
|
@ -363,7 +363,7 @@ void CardReader::initsd() { |
|
|
|
|
|
|
|
void CardReader::release() { |
|
|
|
stopSDPrint(); |
|
|
|
flag.detected = false; |
|
|
|
flag.mounted = false; |
|
|
|
} |
|
|
|
|
|
|
|
void CardReader::openAndPrintFile(const char *name) { |
|
|
@ -375,7 +375,7 @@ void CardReader::openAndPrintFile(const char *name) { |
|
|
|
} |
|
|
|
|
|
|
|
void CardReader::startFileprint() { |
|
|
|
if (isDetected()) { |
|
|
|
if (isMounted()) { |
|
|
|
flag.sdprinting = true; |
|
|
|
#if SD_RESORT |
|
|
|
flush_presort(); |
|
|
@ -425,7 +425,7 @@ void CardReader::getAbsFilename(char *t) { |
|
|
|
|
|
|
|
void CardReader::openFile(char * const path, const bool read, const bool subcall/*=false*/) { |
|
|
|
|
|
|
|
if (!isDetected()) return; |
|
|
|
if (!isMounted()) return; |
|
|
|
|
|
|
|
uint8_t doing = 0; |
|
|
|
if (isFileOpen()) { // Replacing current file or doing a subroutine
|
|
|
@ -499,7 +499,7 @@ void CardReader::openFile(char * const path, const bool read, const bool subcall |
|
|
|
} |
|
|
|
|
|
|
|
void CardReader::removeFile(const char * const name) { |
|
|
|
if (!isDetected()) return; |
|
|
|
if (!isMounted()) return; |
|
|
|
|
|
|
|
//stopSDPrint();
|
|
|
|
|
|
|
@ -558,12 +558,12 @@ void CardReader::checkautostart() { |
|
|
|
|
|
|
|
if (autostart_index < 0 || flag.sdprinting) return; |
|
|
|
|
|
|
|
if (!isDetected()) initsd(); |
|
|
|
if (!isMounted()) mount(); |
|
|
|
#if ENABLED(EEPROM_SETTINGS) && NONE(FLASH_EEPROM_EMULATION, SPI_EEPROM, I2C_EEPROM) |
|
|
|
else settings.first_load(); |
|
|
|
#endif |
|
|
|
|
|
|
|
if (isDetected() |
|
|
|
if (isMounted() |
|
|
|
#if ENABLED(POWER_LOSS_RECOVERY) |
|
|
|
&& !recovery.valid() // Don't run auto#.g when a resume file exists
|
|
|
|
#endif |
|
|
@ -1049,7 +1049,7 @@ void CardReader::printingHasFinished() { |
|
|
|
} |
|
|
|
|
|
|
|
void CardReader::openJobRecoveryFile(const bool read) { |
|
|
|
if (!isDetected()) return; |
|
|
|
if (!isMounted()) return; |
|
|
|
if (recovery.file.isOpen()) return; |
|
|
|
if (!recovery.file.open(&root, recovery.filename, read ? O_READ : O_CREAT | O_WRITE | O_TRUNC | O_SYNC)) |
|
|
|
SERIAL_ECHOLNPAIR(MSG_SD_OPEN_FILE_FAIL, recovery.filename, "."); |
|
|
|