From 071873b38ab15b599084830f4e4d9da63c6ac233 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Wed, 6 Dec 2017 17:48:16 +0100 Subject: [PATCH] init; last merged file: Marlin_main.cpp --- Firmware/Configuration.h | 1 + Firmware/Configuration_adv.h | 46 ++++++++++++++++++++++++++++++++++++ Firmware/Marlin.h | 1 + Firmware/Marlin_main.cpp | 5 ++++ 4 files changed, 53 insertions(+) diff --git a/Firmware/Configuration.h b/Firmware/Configuration.h index 557a5fa4..c1379c0c 100644 --- a/Firmware/Configuration.h +++ b/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 diff --git a/Firmware/Configuration_adv.h b/Firmware/Configuration_adv.h index e365d79d..e399867c 100644 --- a/Firmware/Configuration_adv.h +++ b/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 diff --git a/Firmware/Marlin.h b/Firmware/Marlin.h index 74455a38..51ce9dbc 100644 --- a/Firmware/Marlin.h +++ b/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]; diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 99328679..e2bcbbb8 100644 --- a/Firmware/Marlin_main.cpp +++ b/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();