Skip to content

Commit c7fc6ee

Browse files
committed
🚸 Match M920 indexing to M919
1 parent 72c0437 commit c7fc6ee

File tree

1 file changed

+20
-19
lines changed
  • Marlin/src/gcode/feature/trinamic

1 file changed

+20
-19
lines changed

Marlin/src/gcode/feature/trinamic/M920.cpp

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -40,44 +40,44 @@
4040
* M920: Set Homing Current for one or more axes
4141
*
4242
* Parameters:
43-
* X[current] - Homing Current to use for X axis stepper(s)
44-
* Y[current] - Homing Current to use for Y axis stepper(s)
45-
* Z[current] - Homing Current to use for Z axis stepper(s)
46-
* A[current] - Homing Current to use for A axis stepper(s)
47-
* B[current] - Homing Current to use for B axis stepper(s)
48-
* C[current] - Homing Current to use for C axis stepper(s)
49-
* U[current] - Homing Current to use for U axis stepper(s)
50-
* V[current] - Homing Current to use for V axis stepper(s)
51-
* W[current] - Homing Current to use for W axis stepper(s)
43+
* X<current> - Homing Current to use for X axis stepper(s)
44+
* Y<current> - Homing Current to use for Y axis stepper(s)
45+
* Z<current> - Homing Current to use for Z axis stepper(s)
46+
* A<current> - Homing Current to use for A axis stepper(s)
47+
* B<current> - Homing Current to use for B axis stepper(s)
48+
* C<current> - Homing Current to use for C axis stepper(s)
49+
* U<current> - Homing Current to use for U axis stepper(s)
50+
* V<current> - Homing Current to use for V axis stepper(s)
51+
* W<current> - Homing Current to use for W axis stepper(s)
5252
*
5353
* I<index> - For multi-stepper axes, the zero-based index of the stepper to modify in each axis.
5454
* If omitted all steppers of each axis will be set to the given axis current.
5555
*/
5656
void GcodeSuite::M920() {
5757
bool report = true;
58-
const uint8_t index = parser.byteval(I_PARAM);
58+
const int8_t index = parser.intval(I_PARAM, -1);
5959
LOOP_NUM_AXES(i) if (parser.seen(AXIS_CHAR(i))) {
6060
const int16_t value = parser.value_int();
6161
report = false;
6262
switch (i) {
6363
#if X_HAS_HOME_CURRENT
6464
case X_AXIS:
65-
if (index < 1) homing_current_mA.X = value;
66-
TERN_(X2_HAS_HOME_CURRENT, if (!index || index == 1) homing_current_mA.X2 = value);
65+
if (index <= 0) homing_current_mA.X = value;
66+
TERN_(X2_HAS_HOME_CURRENT, if (index < 0 || index == 1) homing_current_mA.X2 = value);
6767
break;
6868
#endif
6969
#if Y_HAS_HOME_CURRENT
7070
case Y_AXIS:
71-
if (index < 1) homing_current_mA.Y = value;
72-
TERN_(Y2_HAS_HOME_CURRENT, if (!index || index == 1) homing_current_mA.Y2 = value);
71+
if (index <= 0) homing_current_mA.Y = value;
72+
TERN_(Y2_HAS_HOME_CURRENT, if (index < 0 || index == 1) homing_current_mA.Y2 = value);
7373
break;
7474
#endif
7575
#if Z_HAS_HOME_CURRENT
7676
case Z_AXIS:
77-
if (index < 1) homing_current_mA.Z = value;
78-
TERN_(Z2_HAS_HOME_CURRENT, if (!index || index == 1) homing_current_mA.Z2 = value);
79-
TERN_(Z3_HAS_HOME_CURRENT, if (!index || index == 2) homing_current_mA.Z3 = value);
80-
TERN_(Z4_HAS_HOME_CURRENT, if (!index || index == 3) homing_current_mA.Z4 = value);
77+
if (index <= 0) homing_current_mA.Z = value;
78+
TERN_(Z2_HAS_HOME_CURRENT, if (index < 0 || index == 1) homing_current_mA.Z2 = value);
79+
TERN_(Z3_HAS_HOME_CURRENT, if (index < 0 || index == 2) homing_current_mA.Z3 = value);
80+
TERN_(Z4_HAS_HOME_CURRENT, if (index < 0 || index == 3) homing_current_mA.Z4 = value);
8181
break;
8282
#endif
8383
OPTCODE(I_HAS_HOME_CURRENT, case I_AXIS: homing_current_mA.I = value; break)
@@ -97,7 +97,7 @@ void GcodeSuite::M920_report(const bool forReplay/*=true*/) {
9797

9898
report_heading(forReplay, F(STR_HOMING_CURRENT));
9999

100-
auto say_M920 = [](const bool forReplay, int16_t index=-1) {
100+
auto say_M920 = [](const bool forReplay, int8_t index=-1) {
101101
report_echo_start(forReplay);
102102
SERIAL_ECHOPGM(" M920");
103103
if (index >= 0) SERIAL_ECHOPGM(" " I_PARAM_STR, index);
@@ -113,6 +113,7 @@ void GcodeSuite::M920_report(const bool forReplay/*=true*/) {
113113
TERN_(Y_SENSORLESS, SERIAL_ECHOPGM_P(SP_Y_STR, homing_current_mA.Y));
114114
TERN_(Z_SENSORLESS, SERIAL_ECHOPGM_P(SP_Z_STR, homing_current_mA.Z));
115115
#if X2_SENSORLESS || Y2_SENSORLESS || Z2_SENSORLESS || Z3_SENSORLESS || Z4_SENSORLESS
116+
SERIAL_EOL();
116117
say_M920(forReplay);
117118
#endif
118119
TERN_(I_SENSORLESS, SERIAL_ECHOPGM_P(SP_I_STR, homing_current_mA.I));

0 commit comments

Comments
 (0)