Do SD sort order in CardReader
This commit is contained in:
parent
fc98383659
commit
967c1d8534
4 changed files with 5 additions and 16 deletions
|
@ -1039,13 +1039,7 @@ namespace ExtUI {
|
||||||
bool FileList::seek(const uint16_t pos, const bool skip_range_check) {
|
bool FileList::seek(const uint16_t pos, const bool skip_range_check) {
|
||||||
#if ENABLED(SDSUPPORT)
|
#if ENABLED(SDSUPPORT)
|
||||||
if (!skip_range_check && (pos + 1) > count()) return false;
|
if (!skip_range_check && (pos + 1) > count()) return false;
|
||||||
const uint16_t nr =
|
card.getfilename_sorted(SD_ORDER(pos, count()));
|
||||||
#if ENABLED(SDCARD_RATHERRECENTFIRST) && DISABLED(SDCARD_SORT_ALPHA)
|
|
||||||
count() - 1 -
|
|
||||||
#endif
|
|
||||||
pos;
|
|
||||||
|
|
||||||
card.getfilename_sorted(nr);
|
|
||||||
return card.filename[0] != '\0';
|
return card.filename[0] != '\0';
|
||||||
#else
|
#else
|
||||||
UNUSED(pos);
|
UNUSED(pos);
|
||||||
|
|
|
@ -140,14 +140,7 @@ void menu_media() {
|
||||||
|
|
||||||
if (ui.should_draw()) for (uint16_t i = 0; i < fileCnt; i++) {
|
if (ui.should_draw()) for (uint16_t i = 0; i < fileCnt; i++) {
|
||||||
if (_menuLineNr == _thisItemNr) {
|
if (_menuLineNr == _thisItemNr) {
|
||||||
const uint16_t nr =
|
card.getfilename_sorted(SD_ORDER(i, fileCnt));
|
||||||
#if ENABLED(SDCARD_RATHERRECENTFIRST) && DISABLED(SDCARD_SORT_ALPHA)
|
|
||||||
fileCnt - 1 -
|
|
||||||
#endif
|
|
||||||
i;
|
|
||||||
|
|
||||||
card.getfilename_sorted(nr);
|
|
||||||
|
|
||||||
if (card.flag.filenameIsDir)
|
if (card.flag.filenameIsDir)
|
||||||
MENU_ITEM(sdfolder, MSG_MEDIA_MENU, card);
|
MENU_ITEM(sdfolder, MSG_MEDIA_MENU, card);
|
||||||
else
|
else
|
||||||
|
|
|
@ -924,7 +924,7 @@ void CardReader::cdroot() {
|
||||||
|
|
||||||
// Init sort order.
|
// Init sort order.
|
||||||
for (uint16_t i = 0; i < fileCnt; i++) {
|
for (uint16_t i = 0; i < fileCnt; i++) {
|
||||||
sort_order[i] = TERN(SDCARD_RATHERRECENTFIRST, fileCnt - 1 - i, i);
|
sort_order[i] = SD_ORDER(i, fileCnt);
|
||||||
// If using RAM then read all filenames now.
|
// If using RAM then read all filenames now.
|
||||||
#if ENABLED(SDSORT_USES_RAM)
|
#if ENABLED(SDSORT_USES_RAM)
|
||||||
selectFileByIndex(i);
|
selectFileByIndex(i);
|
||||||
|
|
|
@ -29,6 +29,8 @@
|
||||||
#define SD_RESORT 1
|
#define SD_RESORT 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define SD_ORDER(N,C) (TERN(SDCARD_RATHERRECENTFIRST, C - 1 - (N), N))
|
||||||
|
|
||||||
#define MAX_DIR_DEPTH 10 // Maximum folder depth
|
#define MAX_DIR_DEPTH 10 // Maximum folder depth
|
||||||
#define MAXDIRNAMELENGTH 8 // DOS folder name size
|
#define MAXDIRNAMELENGTH 8 // DOS folder name size
|
||||||
#define MAXPATHNAMELENGTH (1 + (MAXDIRNAMELENGTH + 1) * (MAX_DIR_DEPTH) + 1 + FILENAME_LENGTH) // "/" + N * ("ADIRNAME/") + "filename.ext"
|
#define MAXPATHNAMELENGTH (1 + (MAXDIRNAMELENGTH + 1) * (MAX_DIR_DEPTH) + 1 + FILENAME_LENGTH) // "/" + N * ("ADIRNAME/") + "filename.ext"
|
||||||
|
|
Reference in a new issue