Browse Source

init; last merged file: Marlin_main.cpp

PavelSindler 6 years ago
parent
commit
071873b38a
4 changed files with 53 additions and 0 deletions
  1. 1 0
      Firmware/Configuration.h
  2. 46 0
      Firmware/Configuration_adv.h
  3. 1 0
      Firmware/Marlin.h
  4. 5 0
      Firmware/Marlin_main.cpp

+ 1 - 0
Firmware/Configuration.h

@@ -81,6 +81,7 @@
 #define EEPROM_POWER_COUNT       (EEPROM_UVLO_MESH_BED_LEVELING-17)
 #define EEPROM_DIR_DEPTH        (EEPROM_POWER_COUNT-1)
 #define EEPROM_DIRS  (EEPROM_DIR_DEPTH-80) //8 chars for each dir name, max 10 levels
+#define EEPROM_SD_SORT (EEPROM_CALIBRATION_STATUS_PINDA - 1) //0 -time, 1-alpha, 2-none
 
 //TMC2130 configuration
 #define EEPROM_TMC_AXIS_SIZE  //axis configuration block size

+ 46 - 0
Firmware/Configuration_adv.h

@@ -224,6 +224,52 @@
 // using:
 //#define MENU_ADDAUTOSTART
 
+/**
+* Sort SD file listings in alphabetical order.
+*
+* With this option enabled, items on SD cards will be sorted
+* by name for easier navigation.
+*
+* By default...
+*
+*  - Use the slowest -but safest- method for sorting.
+*  - Folders are sorted to the top.
+*  - The sort key is statically allocated.
+*  - No added G-code (M34) support.
+*  - 40 item sorting limit. (Items after the first 40 are unsorted.)
+*
+* SD sorting uses static allocation (as set by SDSORT_LIMIT), allowing the
+* compiler to calculate the worst-case usage and throw an error if the SRAM
+* limit is exceeded.
+*
+*  - SDSORT_USES_RAM provides faster sorting via a static directory buffer.
+*  - SDSORT_USES_STACK does the same, but uses a local stack-based buffer.
+*  - SDSORT_CACHE_NAMES will retain the sorted file listing in RAM. (Expensive!)
+*  - SDSORT_DYNAMIC_RAM only uses RAM when the SD menu is visible. (Use with caution!)
+*/
+	#define SDCARD_SORT_ALPHA //Alphabetical sorting of SD files menu
+	
+	// SD Card Sorting options
+	// 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.
+	  #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_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!
+	#endif
+	
+	#if defined(SDCARD_SORT_ALPHA)
+	  #define HAS_FOLDER_SORTING(FOLDER_SORTING || SDSORT_GCODE)
+	#endif
+
 // Show a progress bar on the LCD when printing from SD?
 //#define LCD_PROGRESS_BAR
 

+ 1 - 0
Firmware/Marlin.h

@@ -349,6 +349,7 @@ extern bool mesh_bed_leveling_flag;
 extern bool mesh_bed_run_from_menu;
 
 extern float distance_from_min[2];
+extern bool sortAlpha;
 
 extern char dir_names[3][9];
 

+ 5 - 0
Firmware/Marlin_main.cpp

@@ -322,6 +322,8 @@ int fan_speed[2];
 
 char dir_names[3][9];
 
+bool sortAlpha = false;
+
 bool volumetric_enabled = false;
 float filament_size[EXTRUDERS] = { DEFAULT_NOMINAL_FILAMENT_DIA
   #if EXTRUDERS > 1
@@ -1096,6 +1098,9 @@ void setup()
 	if (eeprom_read_byte((uint8_t*)EEPROM_UVLO) == 255) {
 		eeprom_write_byte((uint8_t*)EEPROM_UVLO, 0);
 	}
+	if (eeprom_read_byte((uint8_t*)EEPROM_SD_SORT) == 255) {
+		eeprom_write_byte((uint8_t*)EEPROM_SD_SORT, 0);
+	}
 
 	check_babystep(); //checking if Z babystep is in allowed range
 	setup_uvlo_interrupt();