From b3a682d3303005a963cd88c7ff1e81f86a3cb20f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0ni=20M=C3=A1r=20Gilbert?= Date: Sun, 1 Sep 2024 22:14:25 +0000 Subject: [PATCH] Always re-init the TMC drivers after leaving linearity correction menu Change in memory: Flash: -22 bytes SRAM: 0 bytes --- Firmware/ultralcd.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 1cac649676..2d8ee2214c 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -4495,20 +4495,17 @@ static void lcd_settings_menu() #ifdef TMC2130 static void lcd_settings_linearity_correction_menu_save() { - bool changed = false; for (uint8_t axis = 0; axis < NUM_AXIS; axis++) { - // Constrain the value - if (tmc2130_wave_fac[axis] < TMC2130_WAVE_FAC1000_MIN) tmc2130_wave_fac[axis] = 0; - // Has the value changed? - changed |= (eeprom_read_byte((uint8_t*)EEPROM_TMC2130_WAVE_X_FAC - axis) != tmc2130_wave_fac[axis]); + if (tmc2130_wave_fac[axis] < TMC2130_WAVE_FAC1000_MIN) { + tmc2130_wave_fac[axis] = 0; + } - // If the value is changed, then write to EEPROM eeprom_update_byte_notify((uint8_t*)EEPROM_TMC2130_WAVE_X_FAC - axis, tmc2130_wave_fac[axis]); } - // If any of the values changed, then re-init the TMC2130 driver - if (changed) tmc2130_init(TMCInitParams(false, FarmOrUserECool())); + // Re-init the TMC2130 driver to apply changes, if any + tmc2130_init(TMCInitParams(false, FarmOrUserECool())); } #endif //TMC2130