Browse Source

Fix init of last_direction_bits (#13067)

Mark Zachmann 6 years ago
parent
commit
4d1093b386
2 changed files with 24 additions and 5 deletions
  1. 13
    0
      Marlin/src/inc/Conditionals_LCD.h
  2. 11
    5
      Marlin/src/module/stepper.cpp

+ 13
- 0
Marlin/src/inc/Conditionals_LCD.h View File

534
 #define IS_CARTESIAN !IS_KINEMATIC
534
 #define IS_CARTESIAN !IS_KINEMATIC
535
 
535
 
536
 #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))
536
 #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))
537
+
538
+#ifndef INVERT_X_DIR
539
+  #define INVERT_X_DIR false
540
+#endif
541
+#ifndef INVERT_Y_DIR
542
+  #define INVERT_Y_DIR false
543
+#endif
544
+#ifndef INVERT_Z_DIR
545
+  #define INVERT_Z_DIR false
546
+#endif
547
+#ifndef INVERT_E_DIR
548
+  #define INVERT_E_DIR false
549
+#endif

+ 11
- 5
Marlin/src/module/stepper.cpp View File

129
 
129
 
130
 // private:
130
 // private:
131
 
131
 
132
-block_t* Stepper::current_block = NULL; // A pointer to the block currently being traced
132
+block_t* Stepper::current_block; // (= NULL) A pointer to the block currently being traced
133
 
133
 
134
-uint8_t Stepper::last_direction_bits = 0,
135
-        Stepper::axis_did_move;
134
+uint8_t Stepper::last_direction_bits, // = 0
135
+        Stepper::axis_did_move; // = 0
136
 
136
 
137
 bool Stepper::abort_current_block;
137
 bool Stepper::abort_current_block;
138
 
138
 
2143
     E_AXIS_INIT(5);
2143
     E_AXIS_INIT(5);
2144
   #endif
2144
   #endif
2145
 
2145
 
2146
-  set_directions();
2147
-
2148
   // Init Stepper ISR to 122 Hz for quick starting
2146
   // Init Stepper ISR to 122 Hz for quick starting
2149
   HAL_timer_start(STEP_TIMER_NUM, 122);
2147
   HAL_timer_start(STEP_TIMER_NUM, 122);
2150
 
2148
 
2151
   ENABLE_STEPPER_DRIVER_INTERRUPT();
2149
   ENABLE_STEPPER_DRIVER_INTERRUPT();
2152
 
2150
 
2153
   sei();
2151
   sei();
2152
+
2153
+  // Init direction bits for first moves
2154
+  last_direction_bits = 0
2155
+    | (INVERT_X_DIR ? _BV(X_AXIS) : 0)
2156
+    | (INVERT_Y_DIR ? _BV(Y_AXIS) : 0)
2157
+    | (INVERT_Z_DIR ? _BV(Z_AXIS) : 0);
2158
+
2159
+  set_directions();
2154
 }
2160
 }
2155
 
2161
 
2156
 /**
2162
 /**

Loading…
Cancel
Save