From 3662f60f8fb63538885d410602e61d1eb12ce18a Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Mon, 24 Sep 2018 17:57:35 +0200 Subject: [PATCH] if max_feedrate_silent and max_acceleration_units_per_sq_second_silent were never stored to eeprom, use default values; --- Firmware/ConfigurationStore.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/Firmware/ConfigurationStore.cpp b/Firmware/ConfigurationStore.cpp index 3295f1b4..bd3656d8 100644 --- a/Firmware/ConfigurationStore.cpp +++ b/Firmware/ConfigurationStore.cpp @@ -245,6 +245,23 @@ bool Config_RetrieveSettings(uint16_t offset) calculate_extruder_multipliers(); + //if max_feedrate_silent and max_acceleration_units_per_sq_second_silent were never stored to eeprom, use default values: + { + const uint32_t erased = 0xffffffff; + bool initialized = false; + for (uint8_t i = 0; i < (sizeof(cs.max_feedrate_silent)/sizeof(cs.max_feedrate_silent[0])); ++i) + { + if(erased != reinterpret_cast(cs.max_feedrate_silent[i])) initialized = true; + if(erased != reinterpret_cast(cs.max_acceleration_units_per_sq_second_silent[i])) initialized = true; + } + if (!initialized) + { + memcpy_P(&cs.max_feedrate_silent,&default_conf.max_feedrate_silent, sizeof(cs.max_feedrate_silent)); + memcpy_P(&cs.max_acceleration_units_per_sq_second_silent,&default_conf.max_acceleration_units_per_sq_second_silent, + sizeof(cs.max_acceleration_units_per_sq_second_silent)); + } + } + #ifdef TMC2130 for (uint8_t j = X_AXIS; j <= Y_AXIS; j++) {