diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index 654db63f05..7a657efae8 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -534,3 +534,16 @@ #define IS_CARTESIAN !IS_KINEMATIC #define HAS_ACTION_COMMANDS (defined(ACTION_ON_KILL) || defined(ACTION_ON_PAUSE) || defined(ACTION_ON_PAUSED) || defined(ACTION_ON_RESUME) || defined(ACTION_ON_RESUMED) || defined(ACTION_ON_CANCEL) || defined(G29_ACTION_ON_RECOVER) || defined(G29_ACTION_ON_FAILURE) || defined(ACTION_ON_FILAMENT_RUNOUT)) + +#ifndef INVERT_X_DIR + #define INVERT_X_DIR false +#endif +#ifndef INVERT_Y_DIR + #define INVERT_Y_DIR false +#endif +#ifndef INVERT_Z_DIR + #define INVERT_Z_DIR false +#endif +#ifndef INVERT_E_DIR + #define INVERT_E_DIR false +#endif diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index 10c524bdc8..72032dcb60 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -129,10 +129,10 @@ Stepper stepper; // Singleton // private: -block_t* Stepper::current_block = NULL; // A pointer to the block currently being traced +block_t* Stepper::current_block; // (= NULL) A pointer to the block currently being traced -uint8_t Stepper::last_direction_bits = 0, - Stepper::axis_did_move; +uint8_t Stepper::last_direction_bits, // = 0 + Stepper::axis_did_move; // = 0 bool Stepper::abort_current_block; @@ -2143,14 +2143,20 @@ void Stepper::init() { E_AXIS_INIT(5); #endif - set_directions(); - // Init Stepper ISR to 122 Hz for quick starting HAL_timer_start(STEP_TIMER_NUM, 122); ENABLE_STEPPER_DRIVER_INTERRUPT(); sei(); + + // Init direction bits for first moves + last_direction_bits = 0 + | (INVERT_X_DIR ? _BV(X_AXIS) : 0) + | (INVERT_Y_DIR ? _BV(Y_AXIS) : 0) + | (INVERT_Z_DIR ? _BV(Z_AXIS) : 0); + + set_directions(); } /**