Browse Source
Rebuild SD file sort array on Stop SD Print (#9976)
Thanks Chuck Hellebuyck.
pull/1/head
Scott Lahteine
7 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with
38 additions and
14 deletions
-
Marlin/src/lcd/malyanlcd.cpp
-
Marlin/src/lcd/ultralcd.cpp
-
Marlin/src/sd/cardreader.cpp
-
Marlin/src/sd/cardreader.h
|
|
@ -228,7 +228,11 @@ void process_lcd_p_command(const char* command) { |
|
|
|
case 'X': |
|
|
|
// cancel print
|
|
|
|
write_to_lcd_P(PSTR("{SYS:CANCELING}")); |
|
|
|
card.stopSDPrint(); |
|
|
|
card.stopSDPrint( |
|
|
|
#if SD_RESORT |
|
|
|
true |
|
|
|
#endif |
|
|
|
); |
|
|
|
clear_command_queue(); |
|
|
|
quickstop_stepper(); |
|
|
|
print_job_timer.stop(); |
|
|
@ -448,4 +452,4 @@ void lcd_setalertstatusPGM(const char* message) { |
|
|
|
write_to_lcd(message_buffer); |
|
|
|
} |
|
|
|
|
|
|
|
#endif // Malyan LCD
|
|
|
|
#endif // MALYAN_LCD
|
|
|
|
|
|
@ -856,7 +856,11 @@ void kill_screen(const char* lcd_msg) { |
|
|
|
} |
|
|
|
|
|
|
|
void lcd_sdcard_stop() { |
|
|
|
card.stopSDPrint(); |
|
|
|
card.stopSDPrint( |
|
|
|
#if SD_RESORT |
|
|
|
true |
|
|
|
#endif |
|
|
|
); |
|
|
|
clear_command_queue(); |
|
|
|
quickstop_stepper(); |
|
|
|
print_job_timer.stop(); |
|
|
|
|
|
@ -328,12 +328,19 @@ void CardReader::startFileprint() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void CardReader::stopSDPrint() { |
|
|
|
void CardReader::stopSDPrint( |
|
|
|
#if SD_RESORT |
|
|
|
const bool re_sort/*=false*/ |
|
|
|
#endif |
|
|
|
) { |
|
|
|
#if ENABLED(ADVANCED_PAUSE_FEATURE) |
|
|
|
did_pause_print = 0; |
|
|
|
#endif |
|
|
|
sdprinting = false; |
|
|
|
if (isFileOpen()) file.close(); |
|
|
|
#if SD_RESORT |
|
|
|
if (re_sort) presort(); |
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
|
void CardReader::openLogFile(char* name) { |
|
|
@ -700,14 +707,14 @@ int8_t CardReader::updir() { |
|
|
|
*/ |
|
|
|
void CardReader::presort() { |
|
|
|
|
|
|
|
// Throw away old sort index
|
|
|
|
flush_presort(); |
|
|
|
|
|
|
|
// Sorting may be turned off
|
|
|
|
#if ENABLED(SDSORT_GCODE) |
|
|
|
if (!sort_alpha) return; |
|
|
|
#endif |
|
|
|
|
|
|
|
// Throw away old sort index
|
|
|
|
flush_presort(); |
|
|
|
|
|
|
|
// If there are files, sort up to the limit
|
|
|
|
uint16_t fileCnt = getnrfilenames(); |
|
|
|
if (fileCnt > 0) { |
|
|
@ -940,7 +947,6 @@ void CardReader::printingHasFinished() { |
|
|
|
#if ENABLED(SDCARD_SORT_ALPHA) |
|
|
|
presort(); |
|
|
|
#endif |
|
|
|
|
|
|
|
#if ENABLED(SD_REPRINT_LAST_SELECTED_FILE) |
|
|
|
lcd_reselect_last_file(); |
|
|
|
#endif |
|
|
|
|
|
@ -23,12 +23,16 @@ |
|
|
|
#ifndef _CARDREADER_H_ |
|
|
|
#define _CARDREADER_H_ |
|
|
|
|
|
|
|
#include "../inc/MarlinConfig.h" |
|
|
|
|
|
|
|
#if ENABLED(SDSUPPORT) |
|
|
|
|
|
|
|
#define SD_RESORT ENABLED(SDCARD_SORT_ALPHA) && ENABLED(SDSORT_DYNAMIC_RAM) |
|
|
|
|
|
|
|
#define MAX_DIR_DEPTH 10 // Maximum folder depth
|
|
|
|
|
|
|
|
#include "SdFile.h" |
|
|
|
|
|
|
|
#include "../inc/MarlinConfig.h" |
|
|
|
|
|
|
|
class CardReader { |
|
|
|
public: |
|
|
|
CardReader(); |
|
|
@ -48,7 +52,11 @@ public: |
|
|
|
void release(); |
|
|
|
void openAndPrintFile(const char *name); |
|
|
|
void startFileprint(); |
|
|
|
void stopSDPrint(); |
|
|
|
void stopSDPrint( |
|
|
|
#if SD_RESORT |
|
|
|
const bool re_sort=false |
|
|
|
#endif |
|
|
|
); |
|
|
|
void getStatus( |
|
|
|
#if NUM_SERIAL > 1 |
|
|
|
const int8_t port = -1 |
|
|
@ -217,10 +225,14 @@ private: |
|
|
|
#define IS_SD_INSERTED (READ(SD_DETECT_PIN) == LOW) |
|
|
|
#endif |
|
|
|
#else |
|
|
|
//No card detect line? Assume the card is inserted.
|
|
|
|
// No card detect line? Assume the card is inserted.
|
|
|
|
#define IS_SD_INSERTED true |
|
|
|
#endif |
|
|
|
|
|
|
|
extern CardReader card; |
|
|
|
|
|
|
|
#endif // SDSUPPORT
|
|
|
|
|
|
|
|
#if ENABLED(SDSUPPORT) |
|
|
|
#define IS_SD_PRINTING (card.sdprinting) |
|
|
|
#define IS_SD_FILE_OPEN (card.isFileOpen()) |
|
|
@ -229,6 +241,4 @@ private: |
|
|
|
#define IS_SD_FILE_OPEN (false) |
|
|
|
#endif |
|
|
|
|
|
|
|
extern CardReader card; |
|
|
|
|
|
|
|
#endif // _CARDREADER_H_
|
|
|
|