Browse Source

Merge pull request #462 from PavelSindler/eeprom_version_change_fix

erase eeprom section which belongs to M500 gcode in case that version…
PavelSindler 6 years ago
parent
commit
a58767271b

+ 1 - 1
Firmware/Configuration.h

@@ -8,7 +8,7 @@
 
 // Firmware version
 #define FW_VERSION "3.1.1"
-#define FW_COMMIT_NR   197
+#define FW_COMMIT_NR   201
 // FW_VERSION_UNKNOWN means this is an unofficial build.
 // The firmware should only be checked into github with this symbol.
 #define FW_DEV_VERSION FW_VERSION_UNKNOWN

+ 5 - 3
Firmware/ConfigurationStore.cpp

@@ -136,10 +136,12 @@ void Config_StoreSettings(uint16_t offset, uint8_t level)
   }
 #endif //LIN_ADVANCE
 
-  /*MYSERIAL.print("Top address used:\n");
+/*  MYSERIAL.print("Top address used:\n");
   MYSERIAL.print(i); 
-  MYSERIAL.print("\n");
-  */
+  MYSERIAL.print("; (0x");
+  MYSERIAL.print(i, HEX);
+  MYSERIAL.println(")");
+*/ 
   char ver2[4]=EEPROM_VERSION;
   i=offset;
   EEPROM_WRITE_VAR(i,ver2); // validate data

+ 1 - 0
Firmware/Marlin.h

@@ -379,6 +379,7 @@ float temp_comp_interpolation(float temperature);
 void temp_compensation_apply();
 void temp_compensation_start();
 void show_fw_version_warnings();
+void erase_eeprom_section(uint16_t offset, uint16_t bytes);
 
 #ifdef PINDA_THERMISTOR
 float temp_compensation_pinda_thermistor_offset(float temperature_pinda);

+ 11 - 2
Firmware/Marlin_main.cpp

@@ -930,6 +930,13 @@ void show_fw_version_warnings() {
 	lcd_update_enable(true);
 }
 
+
+
+void erase_eeprom_section(uint16_t offset, uint16_t bytes)
+{
+	for (int i = offset; i < (offset+bytes); i++) eeprom_write_byte((uint8_t*)i, 0xFF);
+}
+
 // "Setup" function is called by the Arduino framework on startup.
 // Before startup, the Timers-functions (PWM)/Analog RW and HardwareSerial provided by the Arduino-code 
 // are initialized by the main() routine provided by the Arduino framework.
@@ -1172,8 +1179,10 @@ void setup()
 
   show_fw_version_warnings();
 
-  if (!previous_settings_retrieved) lcd_show_fullscreen_message_and_wait_P(MSG_DEFAULT_SETTINGS_LOADED); //if EEPROM version was changed, inform user that default setting were loaded
-
+  if (!previous_settings_retrieved) {
+	  lcd_show_fullscreen_message_and_wait_P(MSG_DEFAULT_SETTINGS_LOADED); //if EEPROM version was changed, inform user that default setting were loaded
+	  erase_eeprom_section(EEPROM_OFFSET, 156); 							   //erase M500 part of eeprom
+  }
   if (eeprom_read_byte((uint8_t*)EEPROM_WIZARD_ACTIVE) == 1) {
 	  lcd_wizard(0);
   }

+ 2 - 2
Firmware/language_all.cpp

@@ -478,8 +478,8 @@ const char * const MSG_DATE_LANG_TABLE[LANG_NUM] PROGMEM = {
 	MSG_DATE_CZ
 };
 
-const char MSG_DEFAULT_SETTINGS_LOADED_EN[] PROGMEM = "Default settings loaded";
-const char MSG_DEFAULT_SETTINGS_LOADED_CZ[] PROGMEM = "Nahrano vychozi nastaveni";
+const char MSG_DEFAULT_SETTINGS_LOADED_EN[] PROGMEM = "Old settings found. Default PID, Esteps etc. will be set.";
+const char MSG_DEFAULT_SETTINGS_LOADED_CZ[] PROGMEM = "Neplatne hodnoty nastaveni. Bude pouzito vychozi PID, Esteps atd.";
 const char * const MSG_DEFAULT_SETTINGS_LOADED_LANG_TABLE[LANG_NUM] PROGMEM = {
 	MSG_DEFAULT_SETTINGS_LOADED_EN,
 	MSG_DEFAULT_SETTINGS_LOADED_CZ

+ 1 - 1
Firmware/language_cz.h

@@ -375,7 +375,7 @@
 #define MSG_CHECK_IDLER						"Prosim otevrete idler a manualne odstrante filament."
 #define MSG_FILE_INCOMPLETE					"Soubor nekompletni. Pokracovat?"
 #define MSG_FILE_CNT						"Nektere soubory nebudou setrideny. Maximalni pocet souboru pro setrideni je 100."
-#define MSG_DEFAULT_SETTINGS_LOADED			"Nahrano vychozi nastaveni"
+#define MSG_DEFAULT_SETTINGS_LOADED			"Neplatne hodnoty nastaveni. Bude pouzito vychozi PID, Esteps atd."
 #define MSG_SORT_TIME						"Trideni     [Cas]"
 #define MSG_SORT_ALPHA						"Trideni [Abeceda]"
 #define MSG_SORT_NONE						"Trideni   [Zadne]"

+ 1 - 1
Firmware/language_en.h

@@ -392,7 +392,7 @@
 #define(length=20, lines=4) MSG_PULL_OUT_FILAMENT				"Please pull out filament immediately"
 #define(length=20, lines=2) MSG_FILE_INCOMPLETE					"File incomplete. Continue anyway?"
 
-#define(length=20, lines=4) MSG_DEFAULT_SETTINGS_LOADED			"Default settings loaded"
+#define(length=20, lines=4) MSG_DEFAULT_SETTINGS_LOADED			"Old settings found. Default PID, Esteps etc. will be set."
 #define(length=17, lines=1) MSG_SORT_TIME						"Sort:      [Time]"
 #define(length=17, lines=1) MSG_SORT_ALPHA						"Sort:  [Alphabet]"
 #define(length=17, lines=1) MSG_SORT_NONE						"Sort:      [None]"