Selaa lähdekoodia

Move routine of direction signal of ADVANCE and LIN_ADVANCE from Stepper::isr() to Stepper::advance_isr()

esenapaj 8 vuotta sitten
vanhempi
commit
f8df88f271
1 muutettua tiedostoa jossa 26 lisäystä ja 10 poistoa
  1. 26
    10
      Marlin/stepper.cpp

+ 26
- 10
Marlin/stepper.cpp Näytä tiedosto

91
 
91
 
92
 #if ENABLED(ADVANCE) || ENABLED(LIN_ADVANCE)
92
 #if ENABLED(ADVANCE) || ENABLED(LIN_ADVANCE)
93
 
93
 
94
-  unsigned char Stepper::old_OCR0A;
94
+  unsigned char Stepper::old_OCR0A = 0;
95
   volatile unsigned char Stepper::eISR_Rate = 200; // Keep the ISR at a low rate until needed
95
   volatile unsigned char Stepper::eISR_Rate = 200; // Keep the ISR at a low rate until needed
96
 
96
 
97
   #if ENABLED(LIN_ADVANCE)
97
   #if ENABLED(LIN_ADVANCE)
299
     SET_STEP_DIR(Z); // C
299
     SET_STEP_DIR(Z); // C
300
   #endif
300
   #endif
301
 
301
 
302
-  if (motor_direction(E_AXIS)) {
303
-    REV_E_DIR();
304
-    count_direction[E_AXIS] = -1;
305
-  }
306
-  else {
307
-    NORM_E_DIR();
308
-    count_direction[E_AXIS] = 1;
309
-  }
302
+  #if DISABLED(ADVANCE) && DISABLED(LIN_ADVANCE)
303
+    if (motor_direction(E_AXIS)) {
304
+      REV_E_DIR();
305
+      count_direction[E_AXIS] = -1;
306
+    }
307
+    else {
308
+      NORM_E_DIR();
309
+      count_direction[E_AXIS] = 1;
310
+    }
311
+  #endif // !ADVANCE && !LIN_ADVANCE
310
 }
312
 }
311
 
313
 
312
 // "The Stepper Driver Interrupt" - This timer interrupt is the workhorse.
314
 // "The Stepper Driver Interrupt" - This timer interrupt is the workhorse.
680
     old_OCR0A += eISR_Rate;
682
     old_OCR0A += eISR_Rate;
681
     OCR0A = old_OCR0A;
683
     OCR0A = old_OCR0A;
682
 
684
 
685
+    #define SET_E_STEP_DIR(INDEX) \
686
+      if (e_steps[INDEX]) E## INDEX ##_DIR_WRITE(e_steps[INDEX] < 0 ? INVERT_E## INDEX ##_DIR : !INVERT_E## INDEX ##_DIR)
687
+
683
     #define START_E_PULSE(INDEX) \
688
     #define START_E_PULSE(INDEX) \
684
       if (e_steps[INDEX]) E## INDEX ##_STEP_WRITE(!INVERT_E_STEP_PIN)
689
       if (e_steps[INDEX]) E## INDEX ##_STEP_WRITE(!INVERT_E_STEP_PIN)
685
 
690
 
686
     #define STOP_E_PULSE(INDEX) \
691
     #define STOP_E_PULSE(INDEX) \
687
       if (e_steps[INDEX]) { \
692
       if (e_steps[INDEX]) { \
688
-        e_steps[INDEX] <= 0 ? ++e_steps[INDEX] : --e_steps[INDEX]; \
693
+        e_steps[INDEX] < 0 ? ++e_steps[INDEX] : --e_steps[INDEX]; \
689
         E## INDEX ##_STEP_WRITE(INVERT_E_STEP_PIN); \
694
         E## INDEX ##_STEP_WRITE(INVERT_E_STEP_PIN); \
690
       }
695
       }
691
 
696
 
697
+    SET_E_STEP_DIR(0);
698
+    #if E_STEPPERS > 1
699
+      SET_E_STEP_DIR(1);
700
+      #if E_STEPPERS > 2
701
+        SET_E_STEP_DIR(2);
702
+        #if E_STEPPERS > 3
703
+          SET_E_STEP_DIR(3);
704
+        #endif
705
+      #endif
706
+    #endif
707
+
692
     #define CYCLES_EATEN_BY_E 60
708
     #define CYCLES_EATEN_BY_E 60
693
 
709
 
694
     // Step all E steppers that have steps
710
     // Step all E steppers that have steps

Loading…
Peruuta
Tallenna