Merge pull request #215 from PavelSindler/sorting

Sorting files improvements
This commit is contained in:
PavelSindler 2017-10-03 23:30:53 +02:00 committed by GitHub
commit 7306e08471
12 changed files with 227 additions and 125 deletions

View File

@ -5,7 +5,7 @@
#include "Configuration_prusa.h"
// Firmware version
#define FW_version "3.0.12-8"
#define FW_version "3.0.12-9"
#define FW_PRUSA3D_MAGIC "PRUSA3DFW"
#define FW_PRUSA3D_MAGIC_LEN 10

View File

@ -261,13 +261,15 @@
#define SD_SORT_ALPHA 1
#define SD_SORT_NONE 2
#define SDSORT_LIMIT 20 // Maximum number of sorted items (10-256).
#define SDSORT_LIMIT 100 // Maximum number of sorted items (10-256).
#define FOLDER_SORTING -1 // -1=above 0=none 1=below
#define SDSORT_GCODE false // Allow turning sorting on/off with LCD and M34 g-code.
#define SDSORT_USES_RAM true // Pre-allocate a static array for faster pre-sorting.
#define SDSORT_USES_STACK true // Prefer the stack for pre-sorting to give back some SRAM. (Negated by next 2 options.)
#define SDSORT_USES_RAM false // Pre-allocate a static array for faster pre-sorting.
#define SDSORT_USES_STACK false // Prefer the stack for pre-sorting to give back some SRAM. (Negated by next 2 options.)
#define SDSORT_CACHE_NAMES false // Keep sorted items in RAM longer for speedy performance. Most expensive option.
#define SDSORT_DYNAMIC_RAM false // Use dynamic allocation (within SD menus). Least expensive option. Set SDSORT_LIMIT before use!
// #define SDSORT_QUICKSORT
#endif
#if defined(SDCARD_SORT_ALPHA)

View File

@ -1099,8 +1099,6 @@ void setup()
tp_init(); // Initialize temperature loop
plan_init(); // Initialize planner;
watchdog_init();
lcd_print_at_PGM(0, 1, PSTR(" Original Prusa ")); // we need to do this again for some reason, no time to research
lcd_print_at_PGM(0, 2, PSTR(" 3D Printers "));
st_init(); // Initialize stepper, this enables interrupts!
setup_photpin();
servo_init();
@ -1197,6 +1195,8 @@ void setup()
card.ToshibaFlashAir_enable(eeprom_read_byte((unsigned char*)EEPROM_TOSHIBA_FLASH_AIR_COMPATIBLITY) == 1);
// Force SD card update. Otherwise the SD card update is done from loop() on card.checkautostart(false),
// but this times out if a blocking dialog is shown in setup().
lcd_print_at_PGM(0, 1, PSTR(" Original Prusa ")); // we need to do this again for some reason, no time to research
lcd_print_at_PGM(0, 2, PSTR(" 3D Printers "));
card.initsd();
if (eeprom_read_dword((uint32_t*)(EEPROM_TOP - 4)) == 0x0ffffffff &&

View File

@ -1113,21 +1113,28 @@ int16_t SdBaseFile::read(void* buf, uint16_t nbyte) {
int8_t SdBaseFile::readDir(dir_t* dir, char* longFilename) {
int16_t n;
// if not a directory file or miss-positioned return an error
if (!isDir() || (0X1F & curPosition_)) return -1;
if (!isDir() || (0X1F & curPosition_)) {
return -1;
}
//If we have a longFilename buffer, mark it as invalid. If we find a long filename it will be filled automaticly.
if (longFilename != NULL)
{
longFilename[0] = '\0';
}
while (1) {
n = read(dir, sizeof(dir_t));
if (n != sizeof(dir_t)) return n == 0 ? 0 : -1;
// last entry if DIR_NAME_FREE
if (dir->name[0] == DIR_NAME_FREE) return 0;
if (dir->name[0] == DIR_NAME_FREE) {
return 0;
SERIAL_ECHOLNPGM("DIR_NAME_FREE");
}
// skip empty entries and entry for . and ..
if (dir->name[0] == DIR_NAME_DELETED || dir->name[0] == '.') continue;
if (dir->name[0] == DIR_NAME_DELETED || dir->name[0] == '.') {
continue;
}
//Fill the long filename if we have a long filename entry,
// long filename entries are stored before the actual filename.
if (DIR_IS_LONG_NAME(dir) && longFilename != NULL)
@ -1152,8 +1159,9 @@ int8_t SdBaseFile::readDir(dir_t* dir, char* longFilename) {
longFilename[n+11] = VFAT->name3[0];
longFilename[n+12] = VFAT->name3[1];
//If this VFAT entry is the last one, add a NUL terminator at the end of the string
if (VFAT->sequenceNumber & 0x40)
longFilename[n+13] = '\0';
if (VFAT->sequenceNumber & 0x40) {
longFilename[n + 13] = '\0';
}
}
}
// return if normal file or subdirectory

View File

@ -306,6 +306,7 @@ class SdBaseFile {
*/
bool seekEnd(int32_t offset = 0) {return seekSet(fileSize_ + offset);}
bool seekSet(uint32_t pos);
//bool setCluster(uint32_t clust);
bool sync();
bool timestamp(SdBaseFile* file);
bool timestamp(uint8_t flag, uint16_t year, uint8_t month, uint8_t day,

View File

@ -59,6 +59,33 @@ char *createFilename(char *buffer,const dir_t &p) //buffer>12characters
}
void CardReader::lsDive_pointer(const char *prepend, SdFile parent, const char * const match) {
dir_t p;
uint8_t cnt = 0;
//parent.seekSet =
// Read the next entry from a directory
//SERIAL_ECHOPGM("Cur pos before.: ");
//uint32_t pom = parent.curPosition();
//MYSERIAL.println(pom, 10);
parent.readDir(p, longFilename);
//SERIAL_ECHOPGM("Cur pos.: ");
//pom = parent.curPosition();
//MYSERIAL.println(pom, 10);
uint8_t pn0 = p.name[0];
filenameIsDir = DIR_IS_SUBDIR(&p);
createFilename(filename, p);
creationDate = p.creationDate;
creationTime = p.creationTime;
}
/**
* Dive into a folder and recurse depth-first to perform a pre-set operation lsAction:
* LS_Count - Add +1 to nrFiles for every file within the parent
@ -72,7 +99,7 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m
// Read the next entry from a directory
while (parent.readDir(p, longFilename) > 0) {
// If the entry is a directory and the action is LS_SerialPrint
if (DIR_IS_SUBDIR(&p) && lsAction != LS_Count && lsAction != LS_GetFilename) {
@ -133,27 +160,18 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m
break;
case LS_GetFilename:
//SERIAL_ECHOPGM("File: ");
createFilename(filename, p);
/*MYSERIAL.println(filename);
SERIAL_ECHOPGM("Write date: ");
writeDate = p.lastWriteDate;
MYSERIAL.println(writeDate);
writeTime = p.lastWriteTime;
SERIAL_ECHOPGM("Creation date: ");
MYSERIAL.println(p.creationDate);
SERIAL_ECHOPGM("Access date: ");
MYSERIAL.println(p.lastAccessDate);
SERIAL_ECHOLNPGM("");*/
cluster = parent.curCluster();
position = parent.curPosition();
creationDate = p.creationDate;
creationTime = p.creationTime;
//writeDate = p.lastAccessDate;
if (match != NULL) {
if (strcasecmp(match, filename) == 0) return;
}
else if (cnt == nrFiles) return;
else if (cnt == nrFiles) {
return;
}
cnt++;
break;
}
@ -640,6 +658,16 @@ void CardReader::getfilename(uint16_t nr, const char * const match/*=NULL*/)
}
void CardReader::getfilename_simple(uint32_t position, const char * const match/*=NULL*/)
{
curDir = &workDir;
lsAction = LS_GetFilename;
nrFiles = 0;
curDir->seekSet(position);
lsDive("", *curDir, match);
}
uint16_t CardReader::getnrfilenames()
{
curDir=&workDir;
@ -702,6 +730,45 @@ void CardReader::getfilename_sorted(const uint16_t nr) {
);
}
#ifdef SDSORT_QUICKSORT
void CardReader::swap(uint8_t left, uint8_t right) {
uint8_t tmp = sort_order[right];
sort_order[right] = sort_order[left];
sort_order[left] = tmp;
}
void CardReader::quicksort(uint8_t left, uint8_t right) {
if (left < right) {
char name_left[LONG_FILENAME_LENGTH + 1];
char name_i[LONG_FILENAME_LENGTH + 1];
uint16_t creation_time_left;
uint16_t creation_date_left;
uint8_t boundary = left;
for (uint8_t i = left+1; i < right; i++) {
uint8_t o_left = sort_order[left];
uint8_t o_i = sort_order[i];
getfilename_simple(positions[o_left]);
strcpy(name_left, LONGEST_FILENAME); // save (or getfilename below will trounce it)
creation_date_left = creationDate;
creation_time_left = creationTime;
getfilename_simple(positions[o_i]);
strcpy(name_i, LONGEST_FILENAME);
if (strcasecmp(name_left, name_i) > 0) {
swap(i, ++boundary);
}
}
swap(left, boundary);
quicksort(left, boundary);
quicksort(boundary + 1, right);
}
}
#endif //SDSORT_QUICKSORT
/**
* Read all the files and produce a sort key
*
@ -711,21 +778,15 @@ void CardReader::getfilename_sorted(const uint16_t nr) {
* - Most RAM: Buffer the directory and return filenames from RAM
*/
void CardReader::presort() {
if (farm_mode) return; //sorting is not used in farm mode
if (farm_mode || IS_SD_INSERTED == false) return; //sorting is not used in farm mode
uint8_t sdSort = eeprom_read_byte((uint8_t*)EEPROM_SD_SORT);
if (sdSort == SD_SORT_NONE) return; //sd sort is turned off
#if !SDSORT_USES_RAM
lcd_set_progress();
#endif
lcd_implementation_clear();
lcd_print_at_PGM(0, 1, MSG_SORTING);
#if SDSORT_GCODE
if (!sort_alpha) return;
#endif
KEEPALIVE_STATE(IN_HANDLER);
// Throw away old sort index
flush_presort();
@ -735,7 +796,15 @@ void CardReader::presort() {
// Never sort more than the max allowed
// If you use folders to organize, 20 may be enough
if (fileCnt > SDSORT_LIMIT) fileCnt = SDSORT_LIMIT;
if (fileCnt > SDSORT_LIMIT) {
lcd_show_fullscreen_message_and_wait_P(MSG_FILE_CNT);
fileCnt = SDSORT_LIMIT;
}
lcd_implementation_clear();
#if !SDSORT_USES_RAM
lcd_set_progress();
#endif
lcd_print_at_PGM(0, 1, MSG_SORTING);
// Sort order is always needed. May be static or dynamic.
#if SDSORT_DYNAMIC_RAM
@ -754,8 +823,9 @@ void CardReader::presort() {
#endif
#elif SDSORT_USES_STACK
char sortnames[fileCnt][LONG_FILENAME_LENGTH];
uint16_t creation_time[SDSORT_LIMIT];
uint16_t creation_date[SDSORT_LIMIT];
uint16_t creation_time[fileCnt];
uint16_t creation_date[fileCnt];
#endif
// Folder sorting needs 1 bit per entry for flags.
@ -769,6 +839,8 @@ void CardReader::presort() {
#else // !SDSORT_USES_RAM
uint32_t positions[fileCnt];
// By default re-read the names from SD for every compare
// retaining only two filenames at a time. This is very
// slow but is safest and uses minimal RAM.
@ -777,11 +849,16 @@ void CardReader::presort() {
uint16_t creation_date_bckp;
#endif
position = 0;
if (fileCnt > 1) {
// Init sort order.
for (uint16_t i = 0; i < fileCnt; i++) {
manage_heater();
sort_order[i] = i;
positions[i] = position;
getfilename(i);
// If using RAM then read all filenames now.
#if SDSORT_USES_RAM
getfilename(i);
@ -812,66 +889,74 @@ void CardReader::presort() {
#endif
#endif
}
// Bubble Sort
uint16_t counter = 0;
#ifdef QUICKSORT
quicksort(0, fileCnt - 1);
#else //Qicksort not defined, use Bubble Sort
uint32_t counter = 0;
uint16_t total = 0.5*(fileCnt-1)*(fileCnt);
// Compare names from the array or just the two buffered names
#if SDSORT_USES_RAM
#define _SORT_CMP_NODIR() (strcasecmp(sortnames[o1], sortnames[o2]) > 0)
#define _SORT_CMP_TIME_NODIR() (((creation_date[o1] == creation_date[o2]) && (creation_time[o1] < creation_time[o2])) || \
(creation_date[o1] < creation_date [o2]))
#else
#define _SORT_CMP_NODIR() (strcasecmp(name1, name2) > 0) //true if lowercase(name1) > lowercase(name2)
#define _SORT_CMP_TIME_NODIR() (((creation_date_bckp == creationDate) && (creation_time_bckp > creationTime)) || \
(creation_date_bckp > creationDate))
#endif
#if HAS_FOLDER_SORTING
#if SDSORT_USES_RAM
// Folder sorting needs an index and bit to test for folder-ness.
const uint8_t ind1 = o1 >> 3, bit1 = o1 & 0x07,
ind2 = o2 >> 3, bit2 = o2 & 0x07;
#define _SORT_CMP_DIR(fs) \
(((isDir[ind1] & _BV(bit1)) != 0) == ((isDir[ind2] & _BV(bit2)) != 0) \
? _SORT_CMP_NODIR() \
: (isDir[fs > 0 ? ind1 : ind2] & (fs > 0 ? _BV(bit1) : _BV(bit2))) != 0)
#define _SORT_CMP_TIME_DIR(fs) \
(((isDir[ind1] & _BV(bit1)) != 0) == ((isDir[ind2] & _BV(bit2)) != 0) \
? _SORT_CMP_TIME_NODIR() \
: (isDir[fs > 0 ? ind1 : ind2] & (fs > 0 ? _BV(bit1) : _BV(bit2))) != 0)
#else
#define _SORT_CMP_DIR(fs) ((dir1 == filenameIsDir) ? _SORT_CMP_NODIR() : (fs > 0 ? dir1 : !dir1))
#define _SORT_CMP_TIME_DIR(fs) ((dir1 == filenameIsDir) ? _SORT_CMP_TIME_NODIR() : (fs < 0 ? dir1 : !dir1))
#endif
#endif
for (uint16_t i = fileCnt; --i;) {
bool didSwap = false;
#if !SDSORT_USES_RAM //show progresss bar only if slow sorting method is used
int8_t percent = ((counter * 100) / (fileCnt-1));
int8_t percent = (counter * 100) / total;//((counter * 100) / pow((fileCnt-1),2));
for (int column = 0; column < 20; column++) {
if (column < (percent/5)) lcd_implementation_print_at(column, 2, "\x01"); //simple progress bar
}
counter++;
#endif
//MYSERIAL.println(int(i));
for (uint16_t j = 0; j < i; ++j) {
manage_heater();
const uint16_t o1 = sort_order[j], o2 = sort_order[j + 1];
// Compare names from the array or just the two buffered names
#if SDSORT_USES_RAM
#define _SORT_CMP_NODIR() (strcasecmp(sortnames[o1], sortnames[o2]) > 0)
#define _SORT_CMP_TIME_NODIR() (((creation_date[o1] == creation_date[o2]) && (creation_time[o1] < creation_time[o2])) || \
(creation_date[o1] < creation_date [o2]))
#else
#define _SORT_CMP_NODIR() (strcasecmp(name1, name2) > 0) //true if lowercase(name1) > lowercase(name2)
#define _SORT_CMP_TIME_NODIR() (((creation_date_bckp == creationDate) && (creation_time_bckp < creationTime)) || \
(creation_date_bckp < creationDate))
#endif
#if HAS_FOLDER_SORTING
#if SDSORT_USES_RAM
// Folder sorting needs an index and bit to test for folder-ness.
const uint8_t ind1 = o1 >> 3, bit1 = o1 & 0x07,
ind2 = o2 >> 3, bit2 = o2 & 0x07;
#define _SORT_CMP_DIR(fs) \
(((isDir[ind1] & _BV(bit1)) != 0) == ((isDir[ind2] & _BV(bit2)) != 0) \
? _SORT_CMP_NODIR() \
: (isDir[fs > 0 ? ind1 : ind2] & (fs > 0 ? _BV(bit1) : _BV(bit2))) != 0)
#define _SORT_CMP_TIME_DIR(fs) \
(((isDir[ind1] & _BV(bit1)) != 0) == ((isDir[ind2] & _BV(bit2)) != 0) \
? _SORT_CMP_TIME_NODIR() \
: (isDir[fs > 0 ? ind1 : ind2] & (fs > 0 ? _BV(bit1) : _BV(bit2))) != 0)
#else
#define _SORT_CMP_DIR(fs) ((dir1 == filenameIsDir) ? _SORT_CMP_NODIR() : (fs > 0 ? dir1 : !dir1))
#define _SORT_CMP_TIME_DIR(fs) ((dir1 == filenameIsDir) ? _SORT_CMP_TIME_NODIR() : (fs > 0 ? dir1 : !dir1))
#endif
#endif
// The most economical method reads names as-needed
// throughout the loop. Slow if there are many.
#if !SDSORT_USES_RAM
getfilename(o1);
counter++;
getfilename_simple(positions[o1]);
strcpy(name1, LONGEST_FILENAME); // save (or getfilename below will trounce it)
creation_date_bckp = creationDate;
creation_time_bckp = creationTime;
#if HAS_FOLDER_SORTING
bool dir1 = filenameIsDir;
#endif
getfilename(o2);
getfilename_simple(positions[o2]);
char *name2 = LONGEST_FILENAME; // use the string in-place
#endif // !SDSORT_USES_RAM
// Sort the current pair according to settings.
@ -885,13 +970,12 @@ void CardReader::presort() {
{
sort_order[j] = o2;
sort_order[j + 1] = o1;
didSwap = true;
//SERIAL_ECHOLNPGM("did swap");
didSwap = true;
}
}
if (!didSwap) break;
} //end of bubble sort loop
#endif
// Using RAM but not keeping names around
#if (SDSORT_USES_RAM && !SDSORT_CACHE_NAMES)
#if SDSORT_DYNAMIC_RAM
@ -922,12 +1006,15 @@ void CardReader::presort() {
sort_count = fileCnt;
}
#if !SDSORT_USES_RAM //show progresss bar only if slow sorting method is used
for(int column = 0; column <=19; column++ ) lcd_implementation_print_at(column, 2, "\x01"); //simple progress bar
delay(500);
lcd_set_arrows();
#if !SDSORT_USES_RAM //show progress bar only if slow sorting method is used
for (int column = 0; column <= 19; column++) lcd_implementation_print_at(column, 2, "\x01"); //simple progress bar
delay(300);
lcd_set_degree();
lcd_implementation_clear();
lcd_update(2);
#endif
KEEPALIVE_STATE(NOT_BUSY);
lcd_timeoutToStatus = millis() + LCD_TIMEOUT_TO_STATUS;
}
void CardReader::flush_presort() {

View File

@ -32,6 +32,7 @@ public:
void printingHasFinished();
void getfilename(uint16_t nr, const char* const match=NULL);
void getfilename_simple(uint32_t position, const char * const match=NULL);
uint16_t getnrfilenames();
void getAbsFilename(char *t);
@ -44,6 +45,10 @@ public:
#ifdef SDCARD_SORT_ALPHA
void presort();
#ifdef SDSORT_QUICKSORT
void swap(uint8_t left, uint8_t right);
void quicksort(uint8_t left, uint8_t right);
#endif //SDSORT_QUICKSORT
void getfilename_sorted(const uint16_t nr);
#if SDSORT_GCODE
FORCE_INLINE void setSortOn(bool b) { sort_alpha = b; presort(); }
@ -70,6 +75,7 @@ public:
bool cardOK ;
char filename[13];
uint16_t creationTime, creationDate;
uint32_t cluster, position;
char longFilename[LONG_FILENAME_LENGTH];
bool filenameIsDir;
int lastnr; //last number of the autostart;
@ -142,7 +148,7 @@ private:
int16_t nrFiles; //counter for the files in the current directory and recycled as position counter for getting the nrFiles'th name in the directory.
char* diveDirName;
void lsDive(const char *prepend, SdFile parent, const char * const match=NULL);
void lsDive_pointer(const char *prepend, SdFile parent, const char * const match = NULL);
#ifdef SDCARD_SORT_ALPHA
void flush_presort();
#endif

View File

@ -1097,6 +1097,11 @@ const char * const MSG_FILAMENT_LOADING_T3_LANG_TABLE[LANG_NUM] PROGMEM = {
MSG_FILAMENT_LOADING_T3_DE
};
const char MSG_FILE_CNT_EN[] PROGMEM = "Some files will not be sorted. Max. No. of files in 1 folder for sorting is 100.";
const char * const MSG_FILE_CNT_LANG_TABLE[1] PROGMEM = {
MSG_FILE_CNT_EN
};
const char MSG_FILE_INCOMPLETE_EN[] PROGMEM = "File incomplete. Continue anyway?";
const char * const MSG_FILE_INCOMPLETE_LANG_TABLE[1] PROGMEM = {
MSG_FILE_INCOMPLETE_EN

View File

@ -220,6 +220,8 @@ extern const char* const MSG_FILAMENT_LOADING_T2_LANG_TABLE[LANG_NUM];
#define MSG_FILAMENT_LOADING_T2 LANG_TABLE_SELECT(MSG_FILAMENT_LOADING_T2_LANG_TABLE)
extern const char* const MSG_FILAMENT_LOADING_T3_LANG_TABLE[LANG_NUM];
#define MSG_FILAMENT_LOADING_T3 LANG_TABLE_SELECT(MSG_FILAMENT_LOADING_T3_LANG_TABLE)
extern const char* const MSG_FILE_CNT_LANG_TABLE[1];
#define MSG_FILE_CNT LANG_TABLE_SELECT_EXPLICIT(MSG_FILE_CNT_LANG_TABLE, 0)
extern const char* const MSG_FILE_INCOMPLETE_LANG_TABLE[1];
#define MSG_FILE_INCOMPLETE LANG_TABLE_SELECT_EXPLICIT(MSG_FILE_INCOMPLETE_LANG_TABLE, 0)
extern const char* const MSG_FILE_PRINTED_LANG_TABLE[1];

View File

@ -341,3 +341,4 @@
#define MSG_WIZARD_INSERT_CORRECT_FILAMENT "Please load PLA filament and then resume Wizard by rebooting the printer."
#define MSG_PLA_FILAMENT_LOADED "Is PLA filament loaded?"
#define MSG_PLEASE_LOAD_PLA "Please load PLA filament first."
#define(length=20, lines=4) MSG_FILE_CNT "Some files will not be sorted. Max. No. of files in 1 folder for sorting is 100."

View File

@ -100,6 +100,10 @@ int8_t SilentModeMenu = 0;
uint8_t snmm_extruder = 0;
#endif
#ifdef SDCARD_SORT_ALPHA
bool presort_flag = false;
#endif
int lcd_commands_type=LCD_COMMAND_IDLE;
int lcd_commands_step=0;
bool isPrintPaused = false;
@ -2743,7 +2747,6 @@ void EEPROM_read(int pos, uint8_t* value, uint8_t size)
#ifdef SDCARD_SORT_ALPHA
static void lcd_sort_type_set() {
uint8_t sdSort;
EEPROM_read(EEPROM_SD_SORT, (uint8_t*)&sdSort, sizeof(sdSort));
switch (sdSort) {
case SD_SORT_TIME: sdSort = SD_SORT_ALPHA; break;
@ -2751,11 +2754,8 @@ static void lcd_sort_type_set() {
default: sdSort = SD_SORT_TIME;
}
eeprom_update_byte((unsigned char *)EEPROM_SD_SORT, sdSort);
lcd_goto_menu(lcd_sdcard_menu, 1);
//lcd_update(2);
//delay(1000);
card.presort();
presort_flag = true;
lcd_goto_menu(lcd_settings_menu, 8);
}
#endif //SDCARD_SORT_ALPHA
@ -2781,8 +2781,8 @@ static void lcd_set_lang(unsigned char lang) {
}
#if !SDSORT_USES_RAM
void lcd_set_arrows() {
void lcd_set_custom_characters_arrows();
void lcd_set_degree() {
lcd_set_custom_characters_degree();
}
void lcd_set_progress() {
@ -3189,6 +3189,17 @@ static void lcd_settings_menu()
} else {
MENU_ITEM(function, MSG_TOSHIBA_FLASH_AIR_COMPATIBILITY_OFF, lcd_toshiba_flash_air_compatibility_toggle);
}
#ifdef SDCARD_SORT_ALPHA
if (!farm_mode) {
uint8_t sdSort;
EEPROM_read(EEPROM_SD_SORT, (uint8_t*)&sdSort, sizeof(sdSort));
switch (sdSort) {
case SD_SORT_TIME: MENU_ITEM(function, MSG_SORT_TIME, lcd_sort_type_set); break;
case SD_SORT_ALPHA: MENU_ITEM(function, MSG_SORT_ALPHA, lcd_sort_type_set); break;
default: MENU_ITEM(function, MSG_SORT_NONE, lcd_sort_type_set);
}
}
#endif // SDCARD_SORT_ALPHA
if (farm_mode)
{
@ -4711,8 +4722,13 @@ void getFileDescription(char *name, char *description) {
void lcd_sdcard_menu()
{
uint8_t sdSort;
uint8_t sdSort = eeprom_read_byte((uint8_t*)EEPROM_SD_SORT);
int tempScrool = 0;
if (presort_flag == true) {
presort_flag = false;
card.presort();
}
if (lcdDrawUpdate == 0 && LCD_CLICKED == 0)
//delay(100);
return; // nothing to do (so don't thrash the SD card)
@ -4720,16 +4736,6 @@ void lcd_sdcard_menu()
START_MENU();
MENU_ITEM(back, MSG_MAIN, lcd_main_menu);
if (!farm_mode) {
#ifdef SDCARD_SORT_ALPHA
EEPROM_read(EEPROM_SD_SORT, (uint8_t*)&sdSort, sizeof(sdSort));
switch (sdSort) {
case SD_SORT_TIME: MENU_ITEM(function, MSG_SORT_TIME, lcd_sort_type_set); break;
case SD_SORT_ALPHA: MENU_ITEM(function, MSG_SORT_ALPHA, lcd_sort_type_set); break;
default: MENU_ITEM(function, MSG_SORT_NONE, lcd_sort_type_set);
}
#endif // SDCARD_SORT_ALPHA
}
card.getWorkDirName();
if (card.filename[0] == '/')
{
@ -4744,14 +4750,8 @@ void lcd_sdcard_menu()
{
if (_menuItemNr == _lineNr)
{
const uint16_t nr = ((sdSort == SD_SORT_NONE) || farm_mode) ? (fileCnt - 1 - i) : i;
uint16_t nr = ((sdSort == SD_SORT_NONE) || farm_mode || (sdSort == SD_SORT_TIME)) ? (fileCnt - 1 - i) : i;
/* #ifdef SDCARD_RATHERRECENTFIRST
#ifndef SDCARD_SORT_ALPHA
fileCnt - 1 -
#endif
#endif
i;*/
#ifdef SDCARD_SORT_ALPHA
if (sdSort == SD_SORT_NONE) card.getfilename(nr);
else card.getfilename_sorted(nr);
@ -4770,17 +4770,6 @@ void lcd_sdcard_menu()
END_MENU();
}
//char description [10] [31];
/*void get_description() {
uint16_t fileCnt = card.getnrfilenames();
for (uint16_t i = 0; i < fileCnt; i++)
{
card.getfilename(fileCnt - 1 - i);
getFileDescription(card.filename, description[i]);
}
}*/
/*void lcd_farm_sdcard_menu()
{
static int i = 0;
@ -5787,6 +5776,7 @@ void lcd_update(uint8_t lcdDrawUpdateOverride)
(*currentMenu)();
menuExiting = false;
}
lcd_implementation_clear();
lcd_return_to_status();
lcdDrawUpdate = 2;
}

View File

@ -75,7 +75,7 @@ void lcd_mylang();
#define LCD_ALERTMESSAGERPGM(x) lcd_setalertstatuspgm((x))
#define LCD_UPDATE_INTERVAL 100
#define LCD_TIMEOUT_TO_STATUS 15000
#define LCD_TIMEOUT_TO_STATUS 30000
#ifdef ULTIPANEL
void lcd_buttons_update();
@ -266,7 +266,7 @@ void display_loading();
void lcd_service_mode_show_result();
#if !SDSORT_USES_RAM
void lcd_set_arrows();
void lcd_set_degree();
void lcd_set_progress();
#endif