added defines for sorting types, removed unused variables

This commit is contained in:
PavelSindler 2017-08-15 13:09:50 +02:00
parent 59efb311c8
commit 6b2470fa4b
5 changed files with 15 additions and 18 deletions

View File

@ -253,6 +253,10 @@
// In current firmware Prusa Firmware version,
// SDSORT_CACHE_NAMES and SDSORT_DYNAMIC_RAM is not supported and must be set to false.
#ifdef SDCARD_SORT_ALPHA
#define SD_SORT_TIME 0
#define SD_SORT_ALPHA 1
#define SD_SORT_NONE 2
#define SDSORT_LIMIT 40 // 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.

View File

@ -92,12 +92,6 @@ extern const char echomagic[] PROGMEM;
#define SERIAL_ECHOPAIR(name,value) (serial_echopair_P(PSTR(name),(value)))
typedef enum {
SDSORT_TIME,
SDSORT_ALPHA,
SDSORT_NONE
} sdsort;
void serial_echopair_P(const char *s_P, float v);
void serial_echopair_P(const char *s_P, double v);
void serial_echopair_P(const char *s_P, unsigned long v);

View File

@ -708,7 +708,7 @@ void CardReader::presort() {
uint8_t sdSort = eeprom_read_byte((uint8_t*)EEPROM_SD_SORT);
if (sdSort == 2) return; //sd sort is turned off
if (sdSort == SD_SORT_NONE) return; //sd sort is turned off
#if !SDSORT_USES_RAM
lcd_set_progress();
#endif
@ -870,9 +870,9 @@ void CardReader::presort() {
// Sort the current pair according to settings.
if(
#if HAS_FOLDER_SORTING
(sdSort == 0 && _SORT_CMP_TIME_DIR(FOLDER_SORTING)) || (sdSort == 1 && _SORT_CMP_DIR(FOLDER_SORTING))
(sdSort == SD_SORT_TIME && _SORT_CMP_TIME_DIR(FOLDER_SORTING)) || (sdSort == SD_SORT_ALPHA && _SORT_CMP_DIR(FOLDER_SORTING))
#else
(sdSort == 0 && _SORT_CMP_TIME_NODIR()) || (sdSort == 1 && _SORT_CMP_NODIR())
(sdSort == SD_SORT_TIME && _SORT_CMP_TIME_NODIR()) || (sdSort == SD_SORT_ALPHA && _SORT_CMP_NODIR())
#endif
)
{

View File

@ -7,7 +7,6 @@
#include "SdFile.h"
enum LsAction {LS_SerialPrint,LS_Count,LS_GetFilename};
enum SdSort {sdSortTime, sdSortAlpha, sdSortNone};
class CardReader
{
@ -139,7 +138,6 @@ private:
bool autostart_stilltocheck; //the sd start is delayed, because otherwise the serial cannot answer fast enought to make contact with the hostsoftware.
LsAction lsAction; //stored for recursion.
uint8_t sdSort;
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);

View File

@ -2397,15 +2397,16 @@ void EEPROM_read(int pos, uint8_t* value, uint8_t size)
value++;
} while (--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 0: sdSort = 1; break;
case 1: sdSort = 2; break;
default: sdSort = 0;
case SD_SORT_TIME: sdSort = SD_SORT_ALPHA; break;
case SD_SORT_ALPHA: sdSort = SD_SORT_NONE; break;
default: sdSort = SD_SORT_TIME;
}
eeprom_update_byte((unsigned char *)EEPROM_SD_SORT, sdSort);
lcd_goto_menu(lcd_sdcard_menu, 1);
@ -4160,8 +4161,8 @@ void lcd_sdcard_menu()
#ifdef SDCARD_SORT_ALPHA
EEPROM_read(EEPROM_SD_SORT, (uint8_t*)&sdSort, sizeof(sdSort));
switch(sdSort){
case 0: MENU_ITEM(function, MSG_SORT_TIME, lcd_sort_type_set); break;
case 1: MENU_ITEM(function, MSG_SORT_ALPHA, lcd_sort_type_set); break;
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
@ -4179,7 +4180,7 @@ void lcd_sdcard_menu()
{
if (_menuItemNr == _lineNr)
{
const uint16_t nr = (sdSort == 2) ? (fileCnt - 1 - i) : i;
const uint16_t nr = (sdSort == SD_SORT_NONE) ? (fileCnt - 1 - i) : i;
/* #ifdef SDCARD_RATHERRECENTFIRST
#ifndef SDCARD_SORT_ALPHA
fileCnt - 1 -
@ -4187,7 +4188,7 @@ void lcd_sdcard_menu()
#endif
i;*/
#ifdef SDCARD_SORT_ALPHA
if (sdSort == 2) card.getfilename(nr);
if (sdSort == SD_SORT_NONE) card.getfilename(nr);
else card.getfilename_sorted(nr);
#else
card.getfilename(nr);