Skip to content

Commit e0ae072

Browse files
committed
🔧 Overridable Stepper EN init
1 parent 4099763 commit e0ae072

File tree

1 file changed

+52
-16
lines changed

1 file changed

+52
-16
lines changed

Marlin/src/module/stepper.cpp

+52-16
Original file line numberDiff line numberDiff line change
@@ -2776,35 +2776,44 @@ void Stepper::init() {
27762776

27772777
// Init Enable Pins - steppers default to disabled.
27782778
#if HAS_X_ENABLE
2779+
#ifndef X_ENABLE_INIT_STATE
2780+
#define X_ENABLE_INIT_STATE !X_ENABLE_ON
2781+
#endif
27792782
X_ENABLE_INIT();
2780-
if (!X_ENABLE_ON) X_ENABLE_WRITE(HIGH);
2783+
if (X_ENABLE_INIT_STATE) X_ENABLE_WRITE(X_ENABLE_INIT_STATE);
27812784
#if BOTH(HAS_X2_STEPPER, HAS_X2_ENABLE)
27822785
X2_ENABLE_INIT();
2783-
if (!X_ENABLE_ON) X2_ENABLE_WRITE(HIGH);
2786+
if (X_ENABLE_INIT_STATE) X2_ENABLE_WRITE(X_ENABLE_INIT_STATE);
27842787
#endif
27852788
#endif
27862789
#if HAS_Y_ENABLE
2790+
#ifndef Y_ENABLE_INIT_STATE
2791+
#define Y_ENABLE_INIT_STATE !Y_ENABLE_ON
2792+
#endif
27872793
Y_ENABLE_INIT();
2788-
if (!Y_ENABLE_ON) Y_ENABLE_WRITE(HIGH);
2794+
if (Y_ENABLE_INIT_STATE) Y_ENABLE_WRITE(Y_ENABLE_INIT_STATE);
27892795
#if BOTH(HAS_DUAL_Y_STEPPERS, HAS_Y2_ENABLE)
27902796
Y2_ENABLE_INIT();
2791-
if (!Y_ENABLE_ON) Y2_ENABLE_WRITE(HIGH);
2797+
if (Y_ENABLE_INIT_STATE) Y2_ENABLE_WRITE(Y_ENABLE_INIT_STATE);
27922798
#endif
27932799
#endif
27942800
#if HAS_Z_ENABLE
2801+
#ifndef Z_ENABLE_INIT_STATE
2802+
#define Z_ENABLE_INIT_STATE !Z_ENABLE_ON
2803+
#endif
27952804
Z_ENABLE_INIT();
2796-
if (!Z_ENABLE_ON) Z_ENABLE_WRITE(HIGH);
2805+
if (Z_ENABLE_INIT_STATE) Z_ENABLE_WRITE(Z_ENABLE_INIT_STATE);
27972806
#if NUM_Z_STEPPERS >= 2 && HAS_Z2_ENABLE
27982807
Z2_ENABLE_INIT();
2799-
if (!Z_ENABLE_ON) Z2_ENABLE_WRITE(HIGH);
2808+
if (Z_ENABLE_INIT_STATE) Z2_ENABLE_WRITE(Z_ENABLE_INIT_STATE);
28002809
#endif
28012810
#if NUM_Z_STEPPERS >= 3 && HAS_Z3_ENABLE
28022811
Z3_ENABLE_INIT();
2803-
if (!Z_ENABLE_ON) Z3_ENABLE_WRITE(HIGH);
2812+
if (Z_ENABLE_INIT_STATE) Z3_ENABLE_WRITE(Z_ENABLE_INIT_STATE);
28042813
#endif
28052814
#if NUM_Z_STEPPERS >= 4 && HAS_Z4_ENABLE
28062815
Z4_ENABLE_INIT();
2807-
if (!Z_ENABLE_ON) Z4_ENABLE_WRITE(HIGH);
2816+
if (Z_ENABLE_INIT_STATE) Z4_ENABLE_WRITE(Z_ENABLE_INIT_STATE);
28082817
#endif
28092818
#endif
28102819
#if HAS_I_ENABLE
@@ -2832,36 +2841,63 @@ void Stepper::init() {
28322841
if (!W_ENABLE_ON) W_ENABLE_WRITE(HIGH);
28332842
#endif
28342843
#if HAS_E0_ENABLE
2844+
#ifndef E_ENABLE_INIT_STATE
2845+
#define E_ENABLE_INIT_STATE !E_ENABLE_ON
2846+
#endif
2847+
#ifndef E0_ENABLE_INIT_STATE
2848+
#define E0_ENABLE_INIT_STATE E_ENABLE_INIT_STATE
2849+
#endif
28352850
E0_ENABLE_INIT();
2836-
if (!E_ENABLE_ON) E0_ENABLE_WRITE(HIGH);
2851+
if (E0_ENABLE_INIT_STATE) E0_ENABLE_WRITE(E0_ENABLE_INIT_STATE);
28372852
#endif
28382853
#if HAS_E1_ENABLE
2854+
#ifndef E1_ENABLE_INIT_STATE
2855+
#define E1_ENABLE_INIT_STATE E_ENABLE_INIT_STATE
2856+
#endif
28392857
E1_ENABLE_INIT();
2840-
if (!E_ENABLE_ON) E1_ENABLE_WRITE(HIGH);
2858+
if (E1_ENABLE_INIT_STATE) E1_ENABLE_WRITE(E1_ENABLE_INIT_STATE);
28412859
#endif
28422860
#if HAS_E2_ENABLE
2861+
#ifndef E2_ENABLE_INIT_STATE
2862+
#define E2_ENABLE_INIT_STATE E_ENABLE_INIT_STATE
2863+
#endif
28432864
E2_ENABLE_INIT();
2844-
if (!E_ENABLE_ON) E2_ENABLE_WRITE(HIGH);
2865+
if (E2_ENABLE_INIT_STATE) E2_ENABLE_WRITE(E2_ENABLE_INIT_STATE);
28452866
#endif
28462867
#if HAS_E3_ENABLE
2868+
#ifndef E3_ENABLE_INIT_STATE
2869+
#define E3_ENABLE_INIT_STATE E_ENABLE_INIT_STATE
2870+
#endif
28472871
E3_ENABLE_INIT();
2848-
if (!E_ENABLE_ON) E3_ENABLE_WRITE(HIGH);
2872+
if (E3_ENABLE_INIT_STATE) E3_ENABLE_WRITE(E3_ENABLE_INIT_STATE);
28492873
#endif
28502874
#if HAS_E4_ENABLE
2875+
#ifndef E4_ENABLE_INIT_STATE
2876+
#define E4_ENABLE_INIT_STATE E_ENABLE_INIT_STATE
2877+
#endif
28512878
E4_ENABLE_INIT();
2852-
if (!E_ENABLE_ON) E4_ENABLE_WRITE(HIGH);
2879+
if (E4_ENABLE_INIT_STATE) E4_ENABLE_WRITE(E4_ENABLE_INIT_STATE);
28532880
#endif
28542881
#if HAS_E5_ENABLE
2882+
#ifndef E5_ENABLE_INIT_STATE
2883+
#define E5_ENABLE_INIT_STATE E_ENABLE_INIT_STATE
2884+
#endif
28552885
E5_ENABLE_INIT();
2856-
if (!E_ENABLE_ON) E5_ENABLE_WRITE(HIGH);
2886+
if (E5_ENABLE_INIT_STATE) E5_ENABLE_WRITE(E5_ENABLE_INIT_STATE);
28572887
#endif
28582888
#if HAS_E6_ENABLE
2889+
#ifndef E6_ENABLE_INIT_STATE
2890+
#define E6_ENABLE_INIT_STATE E_ENABLE_INIT_STATE
2891+
#endif
28592892
E6_ENABLE_INIT();
2860-
if (!E_ENABLE_ON) E6_ENABLE_WRITE(HIGH);
2893+
if (E6_ENABLE_INIT_STATE) E6_ENABLE_WRITE(E6_ENABLE_INIT_STATE);
28612894
#endif
28622895
#if HAS_E7_ENABLE
2896+
#ifndef E7_ENABLE_INIT_STATE
2897+
#define E7_ENABLE_INIT_STATE E_ENABLE_INIT_STATE
2898+
#endif
28632899
E7_ENABLE_INIT();
2864-
if (!E_ENABLE_ON) E7_ENABLE_WRITE(HIGH);
2900+
if (E7_ENABLE_INIT_STATE) E7_ENABLE_WRITE(E7_ENABLE_INIT_STATE);
28652901
#endif
28662902

28672903
#define _STEP_INIT(AXIS) AXIS ##_STEP_INIT()

0 commit comments

Comments
 (0)