40
40
* M920: Set Homing Current for one or more axes
41
41
*
42
42
* 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)
52
52
*
53
53
* I<index> - For multi-stepper axes, the zero-based index of the stepper to modify in each axis.
54
54
* If omitted all steppers of each axis will be set to the given axis current.
55
55
*/
56
56
void GcodeSuite::M920 () {
57
57
bool report = true ;
58
- const uint8_t index = parser.byteval (I_PARAM);
58
+ const int8_t index = parser.intval (I_PARAM, - 1 );
59
59
LOOP_NUM_AXES (i) if (parser.seen (AXIS_CHAR (i))) {
60
60
const int16_t value = parser.value_int ();
61
61
report = false ;
62
62
switch (i) {
63
63
#if X_HAS_HOME_CURRENT
64
64
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);
67
67
break ;
68
68
#endif
69
69
#if Y_HAS_HOME_CURRENT
70
70
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);
73
73
break ;
74
74
#endif
75
75
#if Z_HAS_HOME_CURRENT
76
76
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);
81
81
break ;
82
82
#endif
83
83
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*/) {
97
97
98
98
report_heading (forReplay, F (STR_HOMING_CURRENT));
99
99
100
- auto say_M920 = [](const bool forReplay, int16_t index=-1 ) {
100
+ auto say_M920 = [](const bool forReplay, int8_t index=-1 ) {
101
101
report_echo_start (forReplay);
102
102
SERIAL_ECHOPGM (" M920" );
103
103
if (index >= 0 ) SERIAL_ECHOPGM (" " I_PARAM_STR, index);
@@ -113,6 +113,7 @@ void GcodeSuite::M920_report(const bool forReplay/*=true*/) {
113
113
TERN_ (Y_SENSORLESS, SERIAL_ECHOPGM_P (SP_Y_STR, homing_current_mA.Y ));
114
114
TERN_ (Z_SENSORLESS, SERIAL_ECHOPGM_P (SP_Z_STR, homing_current_mA.Z ));
115
115
#if X2_SENSORLESS || Y2_SENSORLESS || Z2_SENSORLESS || Z3_SENSORLESS || Z4_SENSORLESS
116
+ SERIAL_EOL ();
116
117
say_M920 (forReplay);
117
118
#endif
118
119
TERN_ (I_SENSORLESS, SERIAL_ECHOPGM_P (SP_I_STR, homing_current_mA.I ));
0 commit comments