M500 EEPROM version changed; if EEPROM_M500_SIZE is not updated, data are not stored

This commit is contained in:
PavelSindler 2018-09-19 14:36:26 +02:00
parent 0d4f4fe933
commit 752aec37fb
2 changed files with 15 additions and 9 deletions

View file

@ -57,13 +57,14 @@ void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size, char* name)
//====================================================================================== //======================================================================================
#define EEPROM_OFFSET 20 #define EEPROM_OFFSET 20
#define EEPROM_M500_SIZE 188 //bytes
// IMPORTANT: Whenever there are changes made to the variables stored in EEPROM // IMPORTANT: Whenever there are changes made to the variables stored in EEPROM
// in the functions below, also increment the version number. This makes sure that // in the functions below, also increment the version number and update EEPROM_M500_SIZE. This makes sure that
// the default values are used whenever there is a change to the data, to prevent // the default values are used whenever there is a change to the data, to prevent
// wrong data being written to the variables. // wrong data being written to the variables.
// ALSO: always make sure the variables in the Store and retrieve sections are in the same order. // ALSO: always make sure the variables in the Store and retrieve sections are in the same order.
#define EEPROM_VERSION "V2" #define EEPROM_VERSION "V3"
#ifdef EEPROM_SETTINGS #ifdef EEPROM_SETTINGS
void Config_StoreSettings(uint16_t offset) void Config_StoreSettings(uint16_t offset)
@ -142,12 +143,17 @@ void Config_StoreSettings(uint16_t offset)
EEPROM_WRITE_VAR(i,max_feedrate_silent); EEPROM_WRITE_VAR(i,max_feedrate_silent);
EEPROM_WRITE_VAR(i,max_acceleration_units_per_sq_second_silent); EEPROM_WRITE_VAR(i,max_acceleration_units_per_sq_second_silent);
if (EEPROM_M500_SIZE + EEPROM_OFFSET == i) {
char ver2[4]=EEPROM_VERSION; char ver2[4] = EEPROM_VERSION;
i=offset; i = offset;
EEPROM_WRITE_VAR(i,ver2); // validate data EEPROM_WRITE_VAR(i, ver2); // validate data
SERIAL_ECHO_START; SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Settings Stored"); SERIAL_ECHOLNPGM("Settings Stored");
}
else { //size of eeprom M500 section probably changed by mistake and data are not valid; do not validate data by storing eeprom version
//M500 EEPROM section will be erased on next printer reboot and default vaules will be used
puts_P(PSTR("Data stored to EEPROM not valid."));
}
} }
#endif //EEPROM_SETTINGS #endif //EEPROM_SETTINGS

View file

@ -1642,7 +1642,7 @@ void setup()
if (!previous_settings_retrieved) { if (!previous_settings_retrieved) {
lcd_show_fullscreen_message_and_wait_P(_i("Old settings found. Default PID, Esteps etc. will be set.")); //if EEPROM version or printer type was changed, inform user that default setting were loaded////MSG_DEFAULT_SETTINGS_LOADED c=20 r=4 lcd_show_fullscreen_message_and_wait_P(_i("Old settings found. Default PID, Esteps etc. will be set.")); //if EEPROM version or printer type was changed, inform user that default setting were loaded////MSG_DEFAULT_SETTINGS_LOADED c=20 r=4
erase_eeprom_section(EEPROM_OFFSET, 156); //erase M500 part of eeprom erase_eeprom_section(EEPROM_OFFSET, EEPROM_M500_SIZE); //erase M500 part of eeprom
} }
if (eeprom_read_byte((uint8_t*)EEPROM_WIZARD_ACTIVE) == 1) { if (eeprom_read_byte((uint8_t*)EEPROM_WIZARD_ACTIVE) == 1) {
lcd_wizard(0); lcd_wizard(0);