erase eeprom section which belongs to M500 gcode in case that version was changed and default settings are used

This commit is contained in:
PavelSindler 2018-02-05 16:49:06 +01:00
parent 8375e2cee3
commit 3bd892135a
6 changed files with 21 additions and 9 deletions

View File

@ -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

View File

@ -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);

View File

@ -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);
}

View File

@ -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

View File

@ -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]"

View File

@ -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]"