diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index d06d42392..738b7988c 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -8210,8 +8210,8 @@ Sigma_Exit: break; /*! - ### M916 - Set TMC2130 Stallguard sensitivity threshold M916: Set TMC2130 Stallguard sensitivity threshold - Not active in default, only if `TMC2130_SERVICE_CODES_M910_M918` is defined in source code. + ### M916 - Set TMC2130 Stallguard sensitivity threshold M916: Set TMC2130 Stallguard sensitivity threshold + Not active in default, only if `TMC2130_SERVICE_CODES_M910_M918` is defined in source code. #### Usage M916 [ X | Y | Z | E ] @@ -8222,20 +8222,20 @@ Sigma_Exit: - `Z` - Z stepper driver stallguard sensitivity threshold value - `E` - Extruder stepper driver stallguard sensitivity threshold value */ - case 916: + case 916: { - if (code_seen('X')) tmc2130_sg_thr[X_AXIS] = code_value(); - if (code_seen('Y')) tmc2130_sg_thr[Y_AXIS] = code_value(); - if (code_seen('Z')) tmc2130_sg_thr[Z_AXIS] = code_value(); - if (code_seen('E')) tmc2130_sg_thr[E_AXIS] = code_value(); - for (uint8_t a = X_AXIS; a <= E_AXIS; a++) - printf_P(_N("tmc2130_sg_thr[%c]=%d\n"), "XYZE"[a], tmc2130_sg_thr[a]); + for (uint8_t axis = 0; axis < NUM_AXIS; axis++) { + if (code_seen(axis_codes[axis])) { + tmc2130_sg_thr[axis] = code_value_uint8(); + } + printf_P(_N("tmc2130_sg_thr[%c]=%d\n"), "XYZE"[axis], tmc2130_sg_thr[axis]); + } } break; /*! - ### M917 - Set TMC2130 PWM amplitude offset (pwm_ampl) M917: Set TMC2130 PWM amplitude offset (pwm_ampl) - Not active in default, only if `TMC2130_SERVICE_CODES_M910_M918` is defined in source code. + ### M917 - Set TMC2130 PWM amplitude offset (pwm_ampl) M917: Set TMC2130 PWM amplitude offset (pwm_ampl) + Not active in default, only if `TMC2130_SERVICE_CODES_M910_M918` is defined in source code. #### Usage M917 [ X | Y | Z | E ] @@ -8246,18 +8246,19 @@ Sigma_Exit: - `Z` - Z stepper driver PWM amplitude offset value - `E` - Extruder stepper driver PWM amplitude offset value */ - case 917: + case 917: { - if (code_seen('X')) tmc2130_set_pwm_ampl(0, code_value()); - if (code_seen('Y')) tmc2130_set_pwm_ampl(1, code_value()); - if (code_seen('Z')) tmc2130_set_pwm_ampl(2, code_value()); - if (code_seen('E')) tmc2130_set_pwm_ampl(3, code_value()); + for (uint8_t axis = 0; axis < NUM_AXIS; axis++) { + if (code_seen(axis_codes[axis])) { + tmc2130_set_pwm_ampl(axis, code_value_uint8()); + } + } } break; /*! - ### M918 - Set TMC2130 PWM amplitude gradient (pwm_grad) M918: Set TMC2130 PWM amplitude gradient (pwm_grad) - Not active in default, only if `TMC2130_SERVICE_CODES_M910_M918` is defined in source code. + ### M918 - Set TMC2130 PWM amplitude gradient (pwm_grad) M918: Set TMC2130 PWM amplitude gradient (pwm_grad) + Not active in default, only if `TMC2130_SERVICE_CODES_M910_M918` is defined in source code. #### Usage M918 [ X | Y | Z | E ] @@ -8268,12 +8269,13 @@ Sigma_Exit: - `Z` - Z stepper driver PWM amplitude gradient value - `E` - Extruder stepper driver PWM amplitude gradient value */ - case 918: + case 918: { - if (code_seen('X')) tmc2130_set_pwm_grad(0, code_value()); - if (code_seen('Y')) tmc2130_set_pwm_grad(1, code_value()); - if (code_seen('Z')) tmc2130_set_pwm_grad(2, code_value()); - if (code_seen('E')) tmc2130_set_pwm_grad(3, code_value()); + for (uint8_t axis = 0; axis < NUM_AXIS; axis++) { + if (code_seen(axis_codes[axis])) { + tmc2130_set_pwm_grad(axis, code_value_uint8()); + } + } } break;