Skip to content

Commit 6606d63

Browse files
committed
♻️ Stepper options refactor (MarlinFirmware#25422)
1 parent fc099a2 commit 6606d63

15 files changed

+264
-264
lines changed

Marlin/Configuration.h

+9-9
Original file line numberDiff line numberDiff line change
@@ -1673,15 +1673,15 @@
16731673

16741674
// Disable axis steppers immediately when they're not being stepped.
16751675
// WARNING: When motors turn off there is a chance of losing position accuracy!
1676-
#define DISABLE_X false
1677-
#define DISABLE_Y false
1678-
#define DISABLE_Z false
1679-
//#define DISABLE_I false
1680-
//#define DISABLE_J false
1681-
//#define DISABLE_K false
1682-
//#define DISABLE_U false
1683-
//#define DISABLE_V false
1684-
//#define DISABLE_W false
1676+
//#define DISABLE_X
1677+
//#define DISABLE_Y
1678+
//#define DISABLE_Z
1679+
//#define DISABLE_I
1680+
//#define DISABLE_J
1681+
//#define DISABLE_K
1682+
//#define DISABLE_U
1683+
//#define DISABLE_V
1684+
//#define DISABLE_W
16851685

16861686
// Turn off the display blinking that warns about possible accuracy reduction
16871687
//#define DISABLE_REDUCED_ACCURACY_WARNING

Marlin/Configuration_adv.h

+20-21
Original file line numberDiff line numberDiff line change
@@ -1104,34 +1104,33 @@
11041104
// Add a Duplicate option for well-separated conjoined nozzles
11051105
//#define MULTI_NOZZLE_DUPLICATION
11061106

1107-
// By default pololu step drivers require an active high signal. However, some high power drivers require an active low signal as step.
1108-
#define INVERT_X_STEP_PIN false
1109-
#define INVERT_Y_STEP_PIN false
1110-
#define INVERT_Z_STEP_PIN false
1111-
#define INVERT_I_STEP_PIN false
1112-
#define INVERT_J_STEP_PIN false
1113-
#define INVERT_K_STEP_PIN false
1114-
#define INVERT_U_STEP_PIN false
1115-
#define INVERT_V_STEP_PIN false
1116-
#define INVERT_W_STEP_PIN false
1117-
#define INVERT_E_STEP_PIN false
1107+
// By default stepper drivers require an active-HIGH signal but some high-power drivers require an active-LOW signal to step.
1108+
#define STEP_STATE_X HIGH
1109+
#define STEP_STATE_Y HIGH
1110+
#define STEP_STATE_Z HIGH
1111+
#define STEP_STATE_I HIGH
1112+
#define STEP_STATE_J HIGH
1113+
#define STEP_STATE_K HIGH
1114+
#define STEP_STATE_U HIGH
1115+
#define STEP_STATE_V HIGH
1116+
#define STEP_STATE_W HIGH
1117+
#define STEP_STATE_E HIGH
11181118

11191119
/**
11201120
* Idle Stepper Shutdown
11211121
* Set DISABLE_INACTIVE_? 'true' to shut down axis steppers after an idle period.
11221122
* The Deactive Time can be overridden with M18 and M84. Set to 0 for No Timeout.
11231123
*/
11241124
#define DEFAULT_STEPPER_DEACTIVE_TIME 120
1125-
#define DISABLE_INACTIVE_X true
1126-
#define DISABLE_INACTIVE_Y true
1127-
#define DISABLE_INACTIVE_Z true // Set 'false' if the nozzle could fall onto your printed part!
1128-
#define DISABLE_INACTIVE_I true
1129-
#define DISABLE_INACTIVE_J true
1130-
#define DISABLE_INACTIVE_K true
1131-
#define DISABLE_INACTIVE_U true
1132-
#define DISABLE_INACTIVE_V true
1133-
#define DISABLE_INACTIVE_W true
1134-
#define DISABLE_INACTIVE_E true
1125+
#define DISABLE_INACTIVE_X
1126+
#define DISABLE_INACTIVE_Y
1127+
#define DISABLE_INACTIVE_Z // Disable if the nozzle could fall onto your printed part!
1128+
//#define DISABLE_INACTIVE_I
1129+
//#define DISABLE_INACTIVE_J
1130+
//#define DISABLE_INACTIVE_K
1131+
//#define DISABLE_INACTIVE_U
1132+
//#define DISABLE_INACTIVE_V
1133+
//#define DISABLE_INACTIVE_W
11351134

11361135
// Default Minimum Feedrates for printing and travel moves
11371136
#define DEFAULT_MINIMUMFEEDRATE 0.0 // (mm/s. °/s for rotational-only moves) Minimum feedrate. Set with M205 S.

Marlin/src/MarlinCore.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) {
448448
TERN_(DISABLE_INACTIVE_U, stepper.disable_axis(U_AXIS));
449449
TERN_(DISABLE_INACTIVE_V, stepper.disable_axis(V_AXIS));
450450
TERN_(DISABLE_INACTIVE_W, stepper.disable_axis(W_AXIS));
451-
TERN_(DISABLE_INACTIVE_E, stepper.disable_e_steppers());
451+
TERN_(DISABLE_INACTIVE_EXTRUDER, stepper.disable_e_steppers());
452452

453453
TERN_(AUTO_BED_LEVELING_UBL, bedlevel.steppers_were_disabled());
454454
}

Marlin/src/core/types.h

+21-21
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ struct IF<true, L, R> { typedef L type; };
4444
#define NUM_AXIS_LIST_1(V) LIST_N_1(NUM_AXES, V)
4545
#define NUM_AXIS_ARRAY(V...) { NUM_AXIS_LIST(V) }
4646
#define NUM_AXIS_ARRAY_1(V) { NUM_AXIS_LIST_1(V) }
47-
#define NUM_AXIS_ARGS(T...) NUM_AXIS_LIST(T x, T y, T z, T i, T j, T k, T u, T v, T w)
47+
#define NUM_AXIS_ARGS(T) NUM_AXIS_LIST(T x, T y, T z, T i, T j, T k, T u, T v, T w)
4848
#define NUM_AXIS_ELEM(O) NUM_AXIS_LIST(O.x, O.y, O.z, O.i, O.j, O.k, O.u, O.v, O.w)
4949
#define NUM_AXIS_DEFS(T,V) NUM_AXIS_LIST(T x=V, T y=V, T z=V, T i=V, T j=V, T k=V, T u=V, T v=V, T w=V)
5050
#define MAIN_AXIS_NAMES NUM_AXIS_LIST(X, Y, Z, I, J, K, U, V, W)
@@ -57,7 +57,7 @@ struct IF<true, L, R> { typedef L type; };
5757
#define LOGICAL_AXIS_LIST_1(V) NUM_AXIS_LIST_1(V) LIST_ITEM_E(V)
5858
#define LOGICAL_AXIS_ARRAY(E,V...) { LOGICAL_AXIS_LIST(E,V) }
5959
#define LOGICAL_AXIS_ARRAY_1(V) { LOGICAL_AXIS_LIST_1(V) }
60-
#define LOGICAL_AXIS_ARGS(T...) LOGICAL_AXIS_LIST(T e, T x, T y, T z, T i, T j, T k, T u, T v, T w)
60+
#define LOGICAL_AXIS_ARGS(T) LOGICAL_AXIS_LIST(T e, T x, T y, T z, T i, T j, T k, T u, T v, T w)
6161
#define LOGICAL_AXIS_ELEM(O) LOGICAL_AXIS_LIST(O.e, O.x, O.y, O.z, O.i, O.j, O.k, O.u, O.v, O.w)
6262
#define LOGICAL_AXIS_DECL(T,V) LOGICAL_AXIS_LIST(T e=V, T x=V, T y=V, T z=V, T i=V, T j=V, T k=V, T u=V, T v=V, T w=V)
6363
#define LOGICAL_AXIS_NAMES LOGICAL_AXIS_LIST(E, X, Y, Z, I, J, K, U, V, W)
@@ -96,14 +96,14 @@ struct Flags {
9696
bits_t b;
9797
typename IF<(N>8), N16, N8>::type flag;
9898
};
99-
void reset() { b = 0; }
100-
void set(const int n, const bool onoff) { onoff ? set(n) : clear(n); }
101-
void set(const int n) { b |= (bits_t)_BV(n); }
102-
void clear(const int n) { b &= ~(bits_t)_BV(n); }
103-
bool test(const int n) const { return TEST(b, n); }
104-
bool operator[](const int n) { return test(n); }
105-
bool operator[](const int n) const { return test(n); }
106-
int size() const { return sizeof(b); }
99+
void reset() { b = 0; }
100+
void set(const int n, const bool onoff) { onoff ? set(n) : clear(n); }
101+
void set(const int n) { b |= (bits_t)_BV(n); }
102+
void clear(const int n) { b &= ~(bits_t)_BV(n); }
103+
bool test(const int n) const { return TEST(b, n); }
104+
bool operator[](const int n) { return test(n); }
105+
bool operator[](const int n) const { return test(n); }
106+
int size() const { return sizeof(b); }
107107
};
108108

109109
// Specialization for a single bool flag
@@ -129,14 +129,14 @@ typedef struct AxisFlags {
129129
struct Flags<LOGICAL_AXES> flags;
130130
struct { bool LOGICAL_AXIS_LIST(e:1, x:1, y:1, z:1, i:1, j:1, k:1, u:1, v:1, w:1); };
131131
};
132-
void reset() { flags.reset(); }
133-
void set(const int n) { flags.set(n); }
134-
void set(const int n, const bool onoff) { flags.set(n, onoff); }
135-
void clear(const int n) { flags.clear(n); }
136-
bool test(const int n) const { return flags.test(n); }
137-
bool operator[](const int n) { return flags[n]; }
138-
bool operator[](const int n) const { return flags[n]; }
139-
int size() const { return sizeof(flags); }
132+
void reset() { flags.reset(); }
133+
void set(const int n) { flags.set(n); }
134+
void set(const int n, const bool onoff) { flags.set(n, onoff); }
135+
void clear(const int n) { flags.clear(n); }
136+
bool test(const int n) const { return flags.test(n); }
137+
bool operator[](const int n) { return flags[n]; }
138+
bool operator[](const int n) const { return flags[n]; }
139+
int size() const { return sizeof(flags); }
140140
} axis_flags_t;
141141

142142
//
@@ -188,9 +188,9 @@ typedef IF<(NUM_AXIS_ENUMS > 8), uint16_t, uint8_t>::type axis_bits_t;
188188
// Loop over axes
189189
//
190190
#define LOOP_ABC(VAR) LOOP_S_LE_N(VAR, A_AXIS, C_AXIS)
191-
#define LOOP_NUM_AXES(VAR) LOOP_S_L_N(VAR, X_AXIS, NUM_AXES)
192-
#define LOOP_LOGICAL_AXES(VAR) LOOP_S_L_N(VAR, X_AXIS, LOGICAL_AXES)
193-
#define LOOP_DISTINCT_AXES(VAR) LOOP_S_L_N(VAR, X_AXIS, DISTINCT_AXES)
191+
#define LOOP_NUM_AXES(VAR) LOOP_S_L_N(VAR, 0, NUM_AXES)
192+
#define LOOP_LOGICAL_AXES(VAR) LOOP_S_L_N(VAR, 0, LOGICAL_AXES)
193+
#define LOOP_DISTINCT_AXES(VAR) LOOP_S_L_N(VAR, 0, DISTINCT_AXES)
194194
#define LOOP_DISTINCT_E(VAR) LOOP_L_N(VAR, DISTINCT_E)
195195

196196
//

Marlin/src/gcode/calibrate/G28.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
NUM_AXIS_LIST(
8787
TERN0(X_SENSORLESS, tmc_enable_stallguard(stepperX)),
8888
TERN0(Y_SENSORLESS, tmc_enable_stallguard(stepperY)),
89-
false, false, false, false
89+
false, false, false, false, false, false, false
9090
)
9191
, TERN0(X2_SENSORLESS, tmc_enable_stallguard(stepperX2))
9292
, TERN0(Y2_SENSORLESS, tmc_enable_stallguard(stepperY2))

Marlin/src/gcode/geometry/M206_M428.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@
3333
/**
3434
* M206: Set Additional Homing Offset (X Y Z). SCARA aliases T=X, P=Y
3535
*
36-
* *** @thinkyhead: I recommend deprecating M206 for SCARA in favor of M665.
37-
* *** M206 for SCARA will remain enabled in 1.1.x for compatibility.
38-
* *** In the 2.0 release, it will simply be disabled by default.
36+
* *** TODO: Deprecate M206 for SCARA in favor of M665.
3937
*/
4038
void GcodeSuite::M206() {
4139
if (!parser.seen_any()) return M206_report();

Marlin/src/inc/Conditionals_LCD.h

+34-31
Original file line numberDiff line numberDiff line change
@@ -758,39 +758,31 @@
758758
#define HAS_X_AXIS 1
759759
#if NUM_AXES >= XY
760760
#define HAS_Y_AXIS 1
761-
#if NUM_AXES >= XYZ
762-
#define HAS_Z_AXIS 1
763-
#ifdef Z4_DRIVER_TYPE
764-
#define NUM_Z_STEPPERS 4
765-
#elif defined(Z3_DRIVER_TYPE)
766-
#define NUM_Z_STEPPERS 3
767-
#elif defined(Z2_DRIVER_TYPE)
768-
#define NUM_Z_STEPPERS 2
769-
#else
770-
#define NUM_Z_STEPPERS 1
771-
#endif
772-
#if NUM_AXES >= 4
773-
#define HAS_I_AXIS 1
774-
#if NUM_AXES >= 5
775-
#define HAS_J_AXIS 1
776-
#if NUM_AXES >= 6
777-
#define HAS_K_AXIS 1
778-
#if NUM_AXES >= 7
779-
#define HAS_U_AXIS 1
780-
#if NUM_AXES >= 8
781-
#define HAS_V_AXIS 1
782-
#if NUM_AXES >= 9
783-
#define HAS_W_AXIS 1
784-
#endif
785-
#endif
786-
#endif
787-
#endif
788-
#endif
789-
#endif
790-
#endif
761+
#endif
762+
#if NUM_AXES >= XYZ
763+
#define HAS_Z_AXIS 1
764+
#endif
765+
#if NUM_AXES >= 4
766+
#define HAS_I_AXIS 1
767+
#endif
768+
#if NUM_AXES >= 5
769+
#define HAS_J_AXIS 1
770+
#endif
771+
#if NUM_AXES >= 6
772+
#define HAS_K_AXIS 1
773+
#endif
774+
#if NUM_AXES >= 7
775+
#define HAS_U_AXIS 1
776+
#endif
777+
#if NUM_AXES >= 8
778+
#define HAS_V_AXIS 1
779+
#endif
780+
#if NUM_AXES >= 9
781+
#define HAS_W_AXIS 1
791782
#endif
792783

793784
#if !HAS_Y_AXIS
785+
#undef AVOID_OBSTACLES
794786
#undef ENDSTOPPULLUP_YMIN
795787
#undef ENDSTOPPULLUP_YMAX
796788
#undef Y_MIN_ENDSTOP_INVERTING
@@ -807,7 +799,17 @@
807799
#undef MAX_SOFTWARE_ENDSTOP_Y
808800
#endif
809801

810-
#if !HAS_Z_AXIS
802+
#if HAS_Z_AXIS
803+
#ifdef Z4_DRIVER_TYPE
804+
#define NUM_Z_STEPPERS 4
805+
#elif defined(Z3_DRIVER_TYPE)
806+
#define NUM_Z_STEPPERS 3
807+
#elif defined(Z2_DRIVER_TYPE)
808+
#define NUM_Z_STEPPERS 2
809+
#else
810+
#define NUM_Z_STEPPERS 1
811+
#endif
812+
#else
811813
#undef ENDSTOPPULLUP_ZMIN
812814
#undef ENDSTOPPULLUP_ZMAX
813815
#undef Z_MIN_ENDSTOP_INVERTING
@@ -822,6 +824,7 @@
822824
#undef Z_MIN_POS
823825
#undef Z_MAX_POS
824826
#undef MANUAL_Z_HOME_POS
827+
#undef Z_SAFE_HOMING
825828
#undef MIN_SOFTWARE_ENDSTOP_Z
826829
#undef MAX_SOFTWARE_ENDSTOP_Z
827830
#endif

0 commit comments

Comments
 (0)