From 3bd892135a3e127d649bb605c402defaf1df1948 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Mon, 5 Feb 2018 16:49:06 +0100 Subject: [PATCH] erase eeprom section which belongs to M500 gcode in case that version was changed and default settings are used --- Firmware/ConfigurationStore.cpp | 8 +++++--- Firmware/Marlin.h | 1 + Firmware/Marlin_main.cpp | 13 +++++++++++-- Firmware/language_all.cpp | 4 ++-- Firmware/language_cz.h | 2 +- Firmware/language_en.h | 2 +- 6 files changed, 21 insertions(+), 9 deletions(-) diff --git a/Firmware/ConfigurationStore.cpp b/Firmware/ConfigurationStore.cpp index 23e886a9..9b0d0e87 100644 --- a/Firmware/ConfigurationStore.cpp +++ b/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 diff --git a/Firmware/Marlin.h b/Firmware/Marlin.h index e200029a..68ad18f6 100644 --- a/Firmware/Marlin.h +++ b/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); diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 00534a21..67d2e915 100644 --- a/Firmware/Marlin_main.cpp +++ b/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); } diff --git a/Firmware/language_all.cpp b/Firmware/language_all.cpp index 19d5bf1c..ac9b84a5 100644 --- a/Firmware/language_all.cpp +++ b/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 diff --git a/Firmware/language_cz.h b/Firmware/language_cz.h index 362a29b5..a570b34e 100644 --- a/Firmware/language_cz.h +++ b/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]" diff --git a/Firmware/language_en.h b/Firmware/language_en.h index d21f1ed3..fd8c9310 100644 --- a/Firmware/language_en.h +++ b/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]"