From 390f1f7c69f6bcb41b7e179dcdd45187da3bfec3 Mon Sep 17 00:00:00 2001 From: Jason Smith Date: Fri, 5 Apr 2024 17:27:30 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Don't=20apply=20settings=20durin?= =?UTF-8?q?g=20validation=20(#26935)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Check the `validating` variable before applying settings for several features. This specifically avoids settings corruption for BACKLASH_PREVENTION, which has side-effects when first applied using incorrect values. --- Marlin/src/module/settings.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 48800138621f..17b8ae4d72fa 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -1940,7 +1940,7 @@ void MarlinSettings::postprocess() { _FIELD_TEST(runout_sensor_enabled); EEPROM_READ(runout_sensor_enabled); #if HAS_FILAMENT_SENSOR - runout.enabled = runout_sensor_enabled < 0 ? FIL_RUNOUT_ENABLED_DEFAULT : runout_sensor_enabled; + if (!validating) runout.enabled = runout_sensor_enabled < 0 ? FIL_RUNOUT_ENABLED_DEFAULT : runout_sensor_enabled; #endif TERN_(HAS_FILAMENT_SENSOR, if (runout.enabled) runout.reset()); @@ -2121,7 +2121,7 @@ void MarlinSettings::postprocess() { #if ENABLED(PTC_HOTEND) EEPROM_READ(ptc.z_offsets_hotend); #endif - ptc.reset_index(); + if (!validating) ptc.reset_index(); #else // No placeholder data for this feature #endif @@ -2681,11 +2681,13 @@ void MarlinSettings::postprocess() { EEPROM_READ(backlash_smoothing_mm); #if ENABLED(BACKLASH_GCODE) + if (!validating) { LOOP_NUM_AXES(axis) backlash.set_distance_mm((AxisEnum)axis, backlash_distance_mm[axis]); backlash.set_correction_uint8(backlash_correction); #ifdef BACKLASH_SMOOTHING_MM backlash.set_smoothing_mm(backlash_smoothing_mm); #endif + } #endif } #endif // NUM_AXES @@ -2787,7 +2789,7 @@ void MarlinSettings::postprocess() { uint8_t ui_language; EEPROM_READ(ui_language); if (ui_language >= NUM_LANGUAGES) ui_language = 0; - ui.set_language(ui_language); + if (!validating) ui.set_language(ui_language); } #endif @@ -2813,8 +2815,10 @@ void MarlinSettings::postprocess() { { float _data[2]; EEPROM_READ(_data); - stepper.set_shaping_frequency(X_AXIS, _data[0]); - stepper.set_shaping_damping_ratio(X_AXIS, _data[1]); + if (!validating) { + stepper.set_shaping_frequency(X_AXIS, _data[0]); + stepper.set_shaping_damping_ratio(X_AXIS, _data[1]); + } } #endif @@ -2822,8 +2826,10 @@ void MarlinSettings::postprocess() { { float _data[2]; EEPROM_READ(_data); - stepper.set_shaping_frequency(Y_AXIS, _data[0]); - stepper.set_shaping_damping_ratio(Y_AXIS, _data[1]); + if (!validating) { + stepper.set_shaping_frequency(Y_AXIS, _data[0]); + stepper.set_shaping_damping_ratio(Y_AXIS, _data[1]); + } } #endif