From d8dc2eef7a2e6280d9b9669a0f2d39cdef95ebf7 Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Fri, 21 Sep 2018 15:42:28 +0200 Subject: [PATCH] if max_feedrate_silent and max_acceleration_units_per_sq_second_silent were never stored to eeprom, use default values; eeprom_version changed back to V2 --- Firmware/ConfigurationStore.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Firmware/ConfigurationStore.cpp b/Firmware/ConfigurationStore.cpp index e0f887fe..546c774a 100644 --- a/Firmware/ConfigurationStore.cpp +++ b/Firmware/ConfigurationStore.cpp @@ -62,7 +62,7 @@ void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size, char* name) // wrong data being written to the variables. // ALSO: always make sure the variables in the Store and retrieve sections are in the same order. -#define EEPROM_VERSION "V3" +#define EEPROM_VERSION "V2" #ifdef EEPROM_SETTINGS void Config_StoreSettings(uint16_t offset) @@ -323,11 +323,19 @@ bool Config_RetrieveSettings(uint16_t offset) #endif #endif - calculate_extruder_multipliers(); - + calculate_extruder_multipliers(); + int max_feedrate_silent_address = i; EEPROM_READ_VAR(i,max_feedrate_silent); EEPROM_READ_VAR(i,max_acceleration_units_per_sq_second_silent); + //if max_feedrate_silent and max_acceleration_units_per_sq_second_silent were never stored to eeprom, use default values: + float tmp_feedrate[]=DEFAULT_MAX_FEEDRATE_SILENT; + unsigned long tmp_acceleration[]=DEFAULT_MAX_ACCELERATION_SILENT; + for (uint8_t axis = X_AXIS; axis <= E_AXIS; axis++) { + if (eeprom_read_dword((uint32_t*)(max_feedrate_silent_address + axis * 4)) == 0xffffffff) max_feedrate_silent[axis] = tmp_feedrate[axis]; + if (max_acceleration_units_per_sq_second_silent[axis] == 0xffffffff) max_acceleration_units_per_sq_second_silent[axis] = tmp_acceleration[axis]; + } + #ifdef TMC2130 for (uint8_t j = X_AXIS; j <= Y_AXIS; j++) {