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