0
0
Fork 0
mirror of https://github.com/MarlinFirmware/Marlin.git synced 2025-02-20 16:14:06 +00:00

Rebuild SD file sort array on Stop SD Print (#9975)

Thanks Chuck Hellebuyck.
This commit is contained in:
Scott Lahteine 2018-03-07 01:42:30 -06:00 committed by GitHub
parent 1ed1882766
commit 1f77930e01
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 29 additions and 9 deletions

View file

@ -290,18 +290,25 @@ void CardReader::openAndPrintFile(const char *name) {
void CardReader::startFileprint() { void CardReader::startFileprint() {
if (cardOK) { if (cardOK) {
sdprinting = true; sdprinting = true;
#if ENABLED(SDCARD_SORT_ALPHA) #if SD_RESORT
flush_presort(); flush_presort();
#endif #endif
} }
} }
void CardReader::stopSDPrint() { void CardReader::stopSDPrint(
#if SD_RESORT
const bool re_sort/*=false*/
#endif
) {
#if ENABLED(ADVANCED_PAUSE_FEATURE) #if ENABLED(ADVANCED_PAUSE_FEATURE)
did_pause_print = 0; did_pause_print = 0;
#endif #endif
sdprinting = false; sdprinting = false;
if (isFileOpen()) file.close(); if (isFileOpen()) file.close();
#if SD_RESORT
if (re_sort) presort();
#endif
} }
void CardReader::openLogFile(char* name) { void CardReader::openLogFile(char* name) {
@ -664,14 +671,14 @@ int8_t CardReader::updir() {
*/ */
void CardReader::presort() { void CardReader::presort() {
// Throw away old sort index
flush_presort();
// Sorting may be turned off // Sorting may be turned off
#if ENABLED(SDSORT_GCODE) #if ENABLED(SDSORT_GCODE)
if (!sort_alpha) return; if (!sort_alpha) return;
#endif #endif
// Throw away old sort index
flush_presort();
// If there are files, sort up to the limit // If there are files, sort up to the limit
uint16_t fileCnt = getnrfilenames(); uint16_t fileCnt = getnrfilenames();
if (fileCnt > 0) { if (fileCnt > 0) {
@ -904,7 +911,6 @@ void CardReader::printingHasFinished() {
#if ENABLED(SDCARD_SORT_ALPHA) #if ENABLED(SDCARD_SORT_ALPHA)
presort(); presort();
#endif #endif
#if ENABLED(SD_REPRINT_LAST_SELECTED_FILE) #if ENABLED(SD_REPRINT_LAST_SELECTED_FILE)
lcd_reselect_last_file(); lcd_reselect_last_file();
#endif #endif

View file

@ -27,6 +27,8 @@
#if ENABLED(SDSUPPORT) #if ENABLED(SDSUPPORT)
#define SD_RESORT ENABLED(SDCARD_SORT_ALPHA) && ENABLED(SDSORT_DYNAMIC_RAM)
#define MAX_DIR_DEPTH 10 // Maximum folder depth #define MAX_DIR_DEPTH 10 // Maximum folder depth
#include "SdFile.h" #include "SdFile.h"
@ -52,7 +54,11 @@ public:
void release(); void release();
void openAndPrintFile(const char *name); void openAndPrintFile(const char *name);
void startFileprint(); void startFileprint();
void stopSDPrint(); void stopSDPrint(
#if SD_RESORT
const bool re_sort=false
#endif
);
void getStatus(); void getStatus();
void printingHasFinished(); void printingHasFinished();

View file

@ -225,7 +225,11 @@ void process_lcd_p_command(const char* command) {
case 'X': case 'X':
// cancel print // cancel print
write_to_lcd_P(PSTR("{SYS:CANCELING}")); write_to_lcd_P(PSTR("{SYS:CANCELING}"));
card.stopSDPrint(); card.stopSDPrint(
#if SD_RESORT
true
#endif
);
clear_command_queue(); clear_command_queue();
quickstop_stepper(); quickstop_stepper();
print_job_timer.stop(); print_job_timer.stop();

View file

@ -845,7 +845,11 @@ void kill_screen(const char* lcd_msg) {
} }
void lcd_sdcard_stop() { void lcd_sdcard_stop() {
card.stopSDPrint(); card.stopSDPrint(
#if SD_RESORT
true
#endif
);
clear_command_queue(); clear_command_queue();
quickstop_stepper(); quickstop_stepper();
print_job_timer.stop(); print_job_timer.stop();