Skip to content

Commit

Permalink
Always re-init the TMC drivers after leaving linearity correction menu
Browse files Browse the repository at this point in the history
Change in memory:
Flash: -22 bytes
SRAM: 0 bytes
  • Loading branch information
gudnimg committed Sep 1, 2024
1 parent 312f79c commit b3a682d
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions Firmware/ultralcd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit b3a682d

Please sign in to comment.