From 561c409d5974c2b691c0967efa738e8278f16ae3 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 15 Dec 2025 00:50:36 -0600 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20Adjust=20Ca?= =?UTF-8?q?rdReader=20conditions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/sd/cardreader.cpp | 22 ++++++++++++---------- Marlin/src/sd/cardreader.h | 8 ++++---- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/Marlin/src/sd/cardreader.cpp b/Marlin/src/sd/cardreader.cpp index a284af2c18..426437d9d1 100644 --- a/Marlin/src/sd/cardreader.cpp +++ b/Marlin/src/sd/cardreader.cpp @@ -95,13 +95,13 @@ int16_t CardReader::nrItems = -1; #if ENABLED(SDCARD_SORT_ALPHA) - int16_t CardReader::sort_count; #if ENABLED(SDSORT_GCODE) SortFlag CardReader::sort_alpha; int8_t CardReader::sort_folders; //bool CardReader::sort_reverse; #endif + int16_t CardReader::sort_count; uint8_t *CardReader::sort_order; #if ENABLED(SDSORT_USES_RAM) @@ -159,13 +159,15 @@ CardReader::CardReader() { static uint8_t sort_order_static[SDSORT_LIMIT]; sort_order = sort_order_static; #endif - #if ENABLED(SDSORT_CACHE_NAMES) && DISABLED(SDSORT_DYNAMIC_RAM) - static char sortshort_static[SDSORT_LIMIT][FILENAME_LENGTH]; - sortshort = sortshort_static; - #endif - #if ENABLED(SDSORT_CACHE_NAMES) && !ALL(SDSORT_DYNAMIC_RAM, SDSORT_USES_STACK) - static char sortnames_static[SDSORT_LIMIT][SORTED_LONGNAME_STORAGE]; - sortnames = sortnames_static; + #if ENABLED(SDSORT_CACHE_NAMES) + #if DISABLED(SDSORT_DYNAMIC_RAM) + static char sortshort_static[SDSORT_LIMIT][FILENAME_LENGTH]; + sortshort = sortshort_static; + #endif + #if !ALL(SDSORT_DYNAMIC_RAM, SDSORT_USES_STACK) + static char sortnames_static[SDSORT_LIMIT][SORTED_LONGNAME_STORAGE]; + sortnames = sortnames_static; + #endif #endif sort_count = 0; @@ -1344,7 +1346,7 @@ void CardReader::cdroot() { #define SET_SORTSHORT(I) NOOP #endif #endif - #endif + #endif // SDSORT_USES_RAM /** * Read all the files and produce a sort key @@ -1600,7 +1602,7 @@ void CardReader::cdroot() { } else { sort_order[0] = uint8_t(0); - #if ALL(SDSORT_USES_RAM, SDSORT_CACHE_NAMES) + #if ENABLED(SDSORT_CACHE_NAMES) #if ENABLED(SDSORT_DYNAMIC_RAM) sortnames = new char[1][SORTED_LONGNAME_STORAGE]; sortshort = new char[1][SORTED_SHORTNAME_STORAGE]; diff --git a/Marlin/src/sd/cardreader.h b/Marlin/src/sd/cardreader.h index 5956ffd091..fd514a5340 100644 --- a/Marlin/src/sd/cardreader.h +++ b/Marlin/src/sd/cardreader.h @@ -353,17 +353,17 @@ private: // Alphabetical file and folder sorting // #if ENABLED(SDCARD_SORT_ALPHA) - static int16_t sort_count; // Count of sorted items in the current directory + #if ENABLED(SDSORT_GCODE) static SortFlag sort_alpha; // Sorting: REV, OFF, FWD static int8_t sort_folders; // Folder sorting before/none/after //static bool sort_reverse; // Flag to enable / disable reverse sorting #endif - // Pointer to the static or dynamic sort index - static uint8_t *sort_order; + static int16_t sort_count; // Count of sorted items in the current directory + static uint8_t *sort_order; // Pointer to the static or dynamic sort index - #if ALL(SDSORT_USES_RAM, SDSORT_CACHE_NAMES) && DISABLED(SDSORT_DYNAMIC_RAM) + #if ENABLED(SDSORT_CACHE_NAMES) && DISABLED(SDSORT_DYNAMIC_RAM) #define SORTED_LONGNAME_MAXLEN (SDSORT_CACHE_VFATS) * (FILENAME_LENGTH) #define SORTED_LONGNAME_STORAGE (SORTED_LONGNAME_MAXLEN + 1) #else