From 0a727d857364f5bd177bf401d9c1d8c995df4340 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gu=C3=B0ni=20M=C3=A1r=20Gilbert?= Date: Sat, 24 Feb 2024 15:01:13 +0000 Subject: [PATCH] optimisation: initialise axis_ustep_resolution in EEPROM When the cs variable is loaded into RAM, cs.axis_ustep_resolution will always have some value and none of the 0xff values. Change in memory: Flash: -40 bytes SRAM: 0 bytes --- Firmware/ConfigurationStore.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Firmware/ConfigurationStore.cpp b/Firmware/ConfigurationStore.cpp index aaa2089b2..5f656f2a8 100644 --- a/Firmware/ConfigurationStore.cpp +++ b/Firmware/ConfigurationStore.cpp @@ -214,6 +214,10 @@ bool Config_RetrieveSettings() eeprom_init_default_block(&EEPROM_M500_base->max_feedrate_silent, sizeof(EEPROM_M500_base->max_feedrate_silent), default_conf.max_feedrate_silent); eeprom_init_default_block(&EEPROM_M500_base->max_acceleration_mm_per_s2_silent, sizeof(EEPROM_M500_base->max_acceleration_mm_per_s2_silent), default_conf.max_acceleration_mm_per_s2_silent); +#ifdef TMC2130 + eeprom_init_default_block(&EEPROM_M500_base->axis_ustep_resolution, sizeof(EEPROM_M500_base->axis_ustep_resolution), default_conf.axis_ustep_resolution); +#endif // TMC2130 + // load the CS to RAM eeprom_read_block(reinterpret_cast(&cs), reinterpret_cast(EEPROM_M500_base), sizeof(cs)); calculate_extruder_multipliers(); @@ -230,11 +234,6 @@ bool Config_RetrieveSettings() if (cs.max_acceleration_mm_per_s2_silent[j] > SILENT_MAX_ACCEL_XY) cs.max_acceleration_mm_per_s2_silent[j] = SILENT_MAX_ACCEL_XY; } - - if(cs.axis_ustep_resolution[X_AXIS] == 0xff){ cs.axis_ustep_resolution[X_AXIS] = TMC2130_USTEPS_XY; } - if(cs.axis_ustep_resolution[Y_AXIS] == 0xff){ cs.axis_ustep_resolution[Y_AXIS] = TMC2130_USTEPS_XY; } - if(cs.axis_ustep_resolution[Z_AXIS] == 0xff){ cs.axis_ustep_resolution[Z_AXIS] = TMC2130_USTEPS_Z; } - if(cs.axis_ustep_resolution[E_AXIS] == 0xff){ cs.axis_ustep_resolution[E_AXIS] = TMC2130_USTEPS_E; } tmc2130_set_res(X_AXIS, cs.axis_ustep_resolution[X_AXIS]); tmc2130_set_res(Y_AXIS, cs.axis_ustep_resolution[Y_AXIS]);