|
@@ -203,6 +203,7 @@ void CardReader::startFileprint()
|
203
|
203
|
if(cardOK)
|
204
|
204
|
{
|
205
|
205
|
sdprinting = true;
|
|
206
|
+ flush_presort();
|
206
|
207
|
}
|
207
|
208
|
}
|
208
|
209
|
|
|
@@ -555,6 +556,7 @@ void CardReader::getfilename(const uint16_t nr)
|
555
|
556
|
{
|
556
|
557
|
#if defined(SDCARD_SORT_ALPHA) && SORT_USES_RAM && SORT_USES_MORE_RAM
|
557
|
558
|
if (nr < sort_count) {
|
|
559
|
+ strcpy(filename, sortshort[nr]);
|
558
|
560
|
strcpy(longFilename, sortnames[nr]);
|
559
|
561
|
filenameIsDir = isDir[nr];
|
560
|
562
|
return;
|
|
@@ -648,6 +650,7 @@ void CardReader::presort()
|
648
|
650
|
|
649
|
651
|
#if SORT_USES_RAM
|
650
|
652
|
#if SORT_USES_MORE_RAM
|
|
653
|
+ sortshort = (char**)calloc(fileCnt, sizeof(char*));
|
651
|
654
|
sortnames = (char**)calloc(fileCnt, sizeof(char*));
|
652
|
655
|
#else
|
653
|
656
|
char *sortnames[fileCnt];
|
|
@@ -664,7 +667,6 @@ void CardReader::presort()
|
664
|
667
|
#endif
|
665
|
668
|
#endif
|
666
|
669
|
|
667
|
|
- sort_count = fileCnt;
|
668
|
670
|
sort_order = new uint8_t[fileCnt];
|
669
|
671
|
|
670
|
672
|
if (fileCnt > 1) {
|
|
@@ -675,6 +677,9 @@ void CardReader::presort()
|
675
|
677
|
#if SORT_USES_RAM
|
676
|
678
|
getfilename(i);
|
677
|
679
|
sortnames[i] = strdup(longFilename[0] ? longFilename : filename);
|
|
680
|
+ #if SORT_USES_MORE_RAM
|
|
681
|
+ sortshort[i] = strdup(filename);
|
|
682
|
+ #endif
|
678
|
683
|
// char out[30];
|
679
|
684
|
// sprintf_P(out, PSTR("---- %i %s %s"), i, filenameIsDir ? "D" : " ", sortnames[i]);
|
680
|
685
|
// SERIAL_ECHOLN(out);
|
|
@@ -729,20 +734,27 @@ void CardReader::presort()
|
729
|
734
|
sort_order[0] = 0;
|
730
|
735
|
#if SORT_USES_RAM && SORT_USES_MORE_RAM
|
731
|
736
|
sortnames = (char**)malloc(sizeof(char*));
|
|
737
|
+ sortshort = (char**)malloc(sizeof(char*));
|
732
|
738
|
isDir = (uint8_t*)malloc(sizeof(uint8_t));
|
733
|
739
|
getfilename(0);
|
734
|
740
|
sortnames[0] = strdup(longFilename[0] ? longFilename : filename);
|
|
741
|
+ sortshort[0] = strdup(filename);
|
735
|
742
|
isDir[0] = filenameIsDir;
|
736
|
743
|
#endif
|
737
|
744
|
}
|
738
|
745
|
|
|
746
|
+ sort_count = fileCnt;
|
739
|
747
|
}
|
740
|
748
|
}
|
741
|
749
|
|
742
|
750
|
void CardReader::flush_presort() {
|
743
|
751
|
if (sort_count > 0) {
|
744
|
752
|
#if SORT_USES_RAM && SORT_USES_MORE_RAM
|
745
|
|
- for (uint8_t i=0; i<sort_count; ++i) free(sortnames[i]);
|
|
753
|
+ for (uint8_t i=0; i<sort_count; ++i) {
|
|
754
|
+ free(sortshort[i]);
|
|
755
|
+ free(sortnames[i]);
|
|
756
|
+ }
|
|
757
|
+ free(sortshort);
|
746
|
758
|
free(sortnames);
|
747
|
759
|
#endif
|
748
|
760
|
delete sort_order;
|
|
@@ -774,6 +786,9 @@ void CardReader::printingHasFinished()
|
774
|
786
|
enquecommand_P(PSTR(SD_FINISHED_RELEASECOMMAND));
|
775
|
787
|
}
|
776
|
788
|
autotempShutdown();
|
|
789
|
+ #ifdef SDCARD_SORT_ALPHA
|
|
790
|
+ presort();
|
|
791
|
+ #endif
|
777
|
792
|
}
|
778
|
793
|
}
|
779
|
794
|
#endif //SDSUPPORT
|