diff --git a/Firmware/Configuration.h b/Firmware/Configuration.h index 130b5875..1722d65f 100644 --- a/Firmware/Configuration.h +++ b/Firmware/Configuration.h @@ -77,10 +77,8 @@ #define EEPROM_FERROR_COUNT (EEPROM_UVLO_MESH_BED_LEVELING-16) // Power loss errors #define EEPROM_POWER_COUNT (EEPROM_UVLO_MESH_BED_LEVELING-17) -#define UVLO_DIR_LEVEL (EEPROM_POWER_COUNT-1) -#define UVLO_FIRST_LEVEL_FOLDER (EEPROM_FOLDER_LEVEL-8) -#define UVLO_SECOND_LEVEL_FOLDER (EEPROM_FIRST_LEVEL-8) -#define UVLO_THIRD_LEVEL_FOLDER (EEPROM_SECOND_LEVEL-8) +#define EEPROM_DIR_DEPTH (EEPROM_POWER_COUNT-1) +#define EEPROM_DIRS (EEPROM_DIR_DEPTH-80) //8 chars for each dir name, max 10 levels //TMC2130 configuration #define EEPROM_TMC_AXIS_SIZE //axis configuration block size diff --git a/Firmware/Marlin.h b/Firmware/Marlin.h index 93cab1e6..c23a3156 100644 --- a/Firmware/Marlin.h +++ b/Firmware/Marlin.h @@ -350,6 +350,8 @@ extern bool mesh_bed_run_from_menu; extern float distance_from_min[2]; +extern char dir_names[3][9]; + extern void calculate_volumetric_multipliers(); // Similar to the default Arduino delay function, diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 74fb22e1..9e8014d9 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -320,6 +320,7 @@ bool fan_state[2]; int fan_edge_counter[2]; int fan_speed[2]; +char dir_names[3][9]; bool volumetric_enabled = false; float filament_size[EXTRUDERS] = { DEFAULT_NOMINAL_FILAMENT_DIA @@ -7272,11 +7273,27 @@ void restore_print_from_eeprom() { char cmd[30]; char* c; char filename[13]; + uint8_t depth = 0; + char dir_name[9]; fan_speed_rec = eeprom_read_byte((uint8_t*)EEPROM_UVLO_FAN_SPEED); EEPROM_read_B(EEPROM_UVLO_FEEDRATE, &feedrate_rec); SERIAL_ECHOPGM("Feedrate:"); MYSERIAL.println(feedrate_rec); + + depth = eeprom_read_byte((uint8_t*)EEPROM_DIR_DEPTH); + + MYSERIAL.println(int(depth)); + for (int i = 0; i < depth; i++) { + for (int j = 0; j < 8; j++) { + dir_name[j] = eeprom_read_byte((uint8_t*)EEPROM_DIRS + j + 8 * i); + + } + dir_name[8] = '\0'; + MYSERIAL.println(dir_name); + card.chdir(dir_name); + } + for (int i = 0; i < 8; i++) { filename[i] = eeprom_read_byte((uint8_t*)EEPROM_FILENAME + i); diff --git a/Firmware/SdBaseFile.cpp b/Firmware/SdBaseFile.cpp index e29b216f..be04ab1a 100644 --- a/Firmware/SdBaseFile.cpp +++ b/Firmware/SdBaseFile.cpp @@ -284,7 +284,6 @@ bool SdBaseFile::getFilename(char* name) { name[0] = '/'; name[1] = '\0'; return true; - dir_level = 0; } // cache entry dir_t* p = cacheDirEntry(SdVolume::CACHE_FOR_READ); diff --git a/Firmware/cardreader.cpp b/Firmware/cardreader.cpp index 28102aa1..5426eb0f 100644 --- a/Firmware/cardreader.cpp +++ b/Firmware/cardreader.cpp @@ -233,6 +233,15 @@ void CardReader::openLogFile(char* name) openFile(name, false); } +void CardReader::getDirName(char* name, uint8_t level) +{ + workDirParents[level].getFilename(name); +} + +uint16_t CardReader::getWorkDirDepth() { + return workDirDepth; +} + void CardReader::getAbsFilename(char *t) { uint8_t cnt=0; @@ -635,7 +644,7 @@ void CardReader::updir() { --workDirDepth; workDir = workDirParents[0]; - int d; + int d; for (int d = 0; d < workDirDepth; d++) workDirParents[d] = workDirParents[d+1]; } diff --git a/Firmware/cardreader.h b/Firmware/cardreader.h index ec7f3e7c..11768621 100644 --- a/Firmware/cardreader.h +++ b/Firmware/cardreader.h @@ -33,6 +33,8 @@ public: uint16_t getnrfilenames(); void getAbsFilename(char *t); + void getDirName(char* name, uint8_t level); + uint16_t getWorkDirDepth(); void ls(); diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 69b5f3dc..a23f95e4 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -6131,12 +6131,33 @@ static void menu_action_sdfile(const char* filename, char* longFilename) for (int i = 0; i < 8; i++) { eeprom_write_byte((uint8_t*)EEPROM_FILENAME + i, filename[i]); } + + uint8_t depth = (uint8_t)card.getWorkDirDepth(); + + char dir_name[9]; + + for (uint8_t i = 0; i < depth; i++) { +// card.getDirName(dir_name, i + 1); + MYSERIAL.println(dir_name); + for (int j = 0; j < 8; j++) { + eeprom_write_byte((uint8_t*)EEPROM_DIRS + j + 8*i, dir_names[i][j]); + } + + } + //MYSERIAL.println(int(depth)); + eeprom_write_byte((uint8_t*)EEPROM_DIR_DEPTH, depth); + enquecommand_P(PSTR("M24")); lcd_return_to_status(); } static void menu_action_sddirectory(const char* filename, char* longFilename) { MYSERIAL.println(filename); + + uint8_t depth = (uint8_t)card.getWorkDirDepth(); + + strcpy(dir_names[depth], filename); + MYSERIAL.println(dir_names[depth]); card.chdir(filename); encoderPosition = 0; }