Browse Source

Merge pull request #296 from PavelSindler/MK3_for_merging

Save filename to eeprom first, then check if file is complete
PavelSindler 7 years ago
parent
commit
8a950d5972
2 changed files with 14 additions and 16 deletions
  1. 1 1
      Firmware/Configuration.h
  2. 13 15
      Firmware/ultralcd.cpp

+ 1 - 1
Firmware/Configuration.h

@@ -9,7 +9,7 @@
 
 // Firmware version
 #define FW_version "3.1.1-RC1"
-#define FW_build   125
+#define FW_build   126
 //#define FW_build   --BUILD-NUMBER--
 #define FW_version_build FW_version " b" STR(FW_build)
 

+ 13 - 15
Firmware/ultralcd.cpp

@@ -6188,27 +6188,25 @@ static void menu_action_sdfile(const char* filename, char* longFilename)
   sprintf_P(cmd, PSTR("M23 %s"), filename);
   for (c = &cmd[4]; *c; c++)
     *c = tolower(*c);
+
+  for (int i = 0; i < 8; i++) {
+	  eeprom_write_byte((uint8_t*)EEPROM_FILENAME + i, filename[i]);
+  }
+
+  uint8_t depth = (uint8_t)card.getWorkDirDepth();
+  eeprom_write_byte((uint8_t*)EEPROM_DIR_DEPTH, depth);
+
+  for (uint8_t i = 0; i < depth; i++) {
+	  for (int j = 0; j < 8; j++) {
+		  eeprom_write_byte((uint8_t*)EEPROM_DIRS + j + 8 * i, dir_names[i][j]);
+	  }
+  }
   
   if (!check_file(filename)) {
 	  result = lcd_show_fullscreen_message_yes_no_and_wait_P(MSG_FILE_INCOMPLETE, false, false);
 	  lcd_update_enable(true);
   }
   if (result) {
-
-	  for (int i = 0; i < 8; i++) {
-		  eeprom_write_byte((uint8_t*)EEPROM_FILENAME + i, filename[i]);
-	  }
-
-	  uint8_t depth = (uint8_t)card.getWorkDirDepth();
-
-	  for (uint8_t i = 0; i < depth; i++) {
-		  for (int j = 0; j < 8; j++) {
-			  eeprom_write_byte((uint8_t*)EEPROM_DIRS + j + 8 * i, dir_names[i][j]);
-		  }
-
-	  }
-	  eeprom_write_byte((uint8_t*)EEPROM_DIR_DEPTH, depth);
-
 	  enquecommand(cmd);
 	  enquecommand_P(PSTR("M24"));
   }