Browse Source

Reset LA state more carefully during stop conditions

Yuri D'Elia 5 years ago
parent
commit
cda9ed4a1d
1 changed files with 12 additions and 0 deletions
  1. 12 0
      Firmware/stepper.cpp

+ 12 - 0
Firmware/stepper.cpp

@@ -426,6 +426,13 @@ FORCE_INLINE void stepper_next_block()
   }
   else {
       _NEXT_ISR(2000); // 1kHz.
+
+#ifdef LIN_ADVANCE
+      // reset LA state and pressure when there's no block
+      nextAdvanceISR = ADV_NEVER;
+      e_steps = 0;
+      current_adv_steps = 0;
+#endif
   }
   //WRITE_NC(LOGIC_ANALYZER_CH2, false);
 }
@@ -982,6 +989,8 @@ FORCE_INLINE void advance_isr_scheduler() {
 }
 
 void clear_current_adv_vars() {
+    nextAdvanceISR = ADV_NEVER;
+    e_steps = 0;
     current_adv_steps = 0;
 }
 
@@ -1336,6 +1345,9 @@ void quickStop()
   DISABLE_STEPPER_DRIVER_INTERRUPT();
   while (blocks_queued()) plan_discard_current_block(); 
   current_block = NULL;
+#ifdef LIN_ADVANCE
+  clear_current_adv_vars();
+#endif
   st_reset_timer();
   ENABLE_STEPPER_DRIVER_INTERRUPT();
 }