Browse Source

Set a bool when a stepper block is done

Scott Lahteine 8 years ago
parent
commit
d9bcc7bb45
1 changed files with 6 additions and 3 deletions
  1. 6
    3
      Marlin/stepper.cpp

+ 6
- 3
Marlin/stepper.cpp View File

@@ -372,6 +372,7 @@ void Stepper::isr() {
372 372
     ) endstops.update();
373 373
 
374 374
     // Take multiple steps per interrupt (For high speed moves)
375
+    bool all_steps_done = false;
375 376
     for (int8_t i = 0; i < step_loops; i++) {
376 377
       #ifndef USBCON
377 378
         customizedSerial.checkRx(); // Check for serial chars.
@@ -524,8 +525,10 @@ void Stepper::isr() {
524 525
         #endif
525 526
       #endif // !ADVANCE && !LIN_ADVANCE
526 527
 
527
-      step_events_completed++;
528
-      if (step_events_completed >= current_block->step_event_count) break;
528
+      if (++step_events_completed >= current_block->step_event_count) {
529
+        all_steps_done = true;
530
+        break;
531
+      }
529 532
     }
530 533
 
531 534
     #if ENABLED(ADVANCE) || ENABLED(LIN_ADVANCE)
@@ -657,7 +660,7 @@ void Stepper::isr() {
657 660
     OCR1A = (OCR1A < (TCNT1 + 16)) ? (TCNT1 + 16) : OCR1A;
658 661
 
659 662
     // If current block is finished, reset pointer
660
-    if (step_events_completed >= current_block->step_event_count) {
663
+    if (all_steps_done) {
661 664
       current_block = NULL;
662 665
       planner.discard_current_block();
663 666
     }

Loading…
Cancel
Save