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
4 changed files with 29 additions and 9 deletions

View File

@@ -290,18 +290,25 @@ void CardReader::openAndPrintFile(const char *name) {
void CardReader::startFileprint() {
if (cardOK) {
sdprinting = true;
#if ENABLED(SDCARD_SORT_ALPHA)
#if SD_RESORT
flush_presort();
#endif
}
}
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) {
@@ -664,14 +671,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) {
@@ -904,7 +911,6 @@ void CardReader::printingHasFinished() {
#if ENABLED(SDCARD_SORT_ALPHA)
presort();
#endif
#if ENABLED(SD_REPRINT_LAST_SELECTED_FILE)
lcd_reselect_last_file();
#endif