소스 검색

Merge pull request #8707 from thinkyhead/bf1_splits_are_expendable

[1.1.x] Discard "continued" blocks on interrupted move
Scott Lahteine 6 년 전
부모
커밋
ab5133514c
No account linked to committer's email address
3개의 변경된 파일34개의 추가작업 그리고 14개의 파일을 삭제
  1. 4
    1
      Marlin/planner.cpp
  2. 19
    5
      Marlin/planner.h
  3. 11
    8
      Marlin/stepper.cpp

+ 4
- 1
Marlin/planner.cpp 파일 보기

@@ -778,7 +778,7 @@ void Planner::_buffer_steps(const int32_t (&target)[XYZE], float fr_mm_s, const
778 778
   block_t* block = &block_buffer[block_buffer_head];
779 779
 
780 780
   // Clear all flags, including the "busy" bit
781
-  block->flag = 0;
781
+  block->flag = 0x00;
782 782
 
783 783
   // Set direction bits
784 784
   block->direction_bits = dm;
@@ -1139,6 +1139,7 @@ void Planner::_buffer_steps(const int32_t (&target)[XYZE], float fr_mm_s, const
1139 1139
 
1140 1140
   float safe_speed = block->nominal_speed * min_axis_accel_ratio;
1141 1141
   static float previous_safe_speed;
1142
+
1142 1143
   // Compute and limit the acceleration rate for the trapezoid generator.
1143 1144
   const float steps_per_mm = block->step_event_count * inverse_millimeters;
1144 1145
   uint32_t accel;
@@ -1423,7 +1424,9 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
1423 1424
     const int32_t between[XYZE] = { _BETWEEN(X), _BETWEEN(Y), _BETWEEN(Z), _BETWEEN(E) };
1424 1425
     DISABLE_STEPPER_DRIVER_INTERRUPT();
1425 1426
     _buffer_steps(between, fr_mm_s, extruder);
1427
+    const uint8_t next = block_buffer_head;
1426 1428
     _buffer_steps(target, fr_mm_s, extruder);
1429
+    SBI(block_buffer[next].flag, BLOCK_BIT_CONTINUED);
1427 1430
     ENABLE_STEPPER_DRIVER_INTERRUPT();
1428 1431
   }
1429 1432
   else

+ 19
- 5
Marlin/planner.h 파일 보기

@@ -53,14 +53,18 @@ enum BlockFlagBit {
53 53
   BLOCK_BIT_START_FROM_FULL_HALT,
54 54
 
55 55
   // The block is busy
56
-  BLOCK_BIT_BUSY
56
+  BLOCK_BIT_BUSY,
57
+
58
+  // The block is segment 2+ of a longer move
59
+  BLOCK_BIT_CONTINUED
57 60
 };
58 61
 
59 62
 enum BlockFlag {
60 63
   BLOCK_FLAG_RECALCULATE          = _BV(BLOCK_BIT_RECALCULATE),
61 64
   BLOCK_FLAG_NOMINAL_LENGTH       = _BV(BLOCK_BIT_NOMINAL_LENGTH),
62 65
   BLOCK_FLAG_START_FROM_FULL_HALT = _BV(BLOCK_BIT_START_FROM_FULL_HALT),
63
-  BLOCK_FLAG_BUSY                 = _BV(BLOCK_BIT_BUSY)
66
+  BLOCK_FLAG_BUSY                 = _BV(BLOCK_BIT_BUSY),
67
+  BLOCK_FLAG_CONTINUED            = _BV(BLOCK_BIT_CONTINUED)
64 68
 };
65 69
 
66 70
 /**
@@ -450,22 +454,32 @@ class Planner {
450 454
     static bool blocks_queued() { return (block_buffer_head != block_buffer_tail); }
451 455
 
452 456
     /**
453
-     * "Discards" the block and "releases" the memory.
457
+     * "Discard" the block and "release" the memory.
454 458
      * Called when the current block is no longer needed.
455 459
      */
456
-    static void discard_current_block() {
460
+    FORCE_INLINE static void discard_current_block() {
457 461
       if (blocks_queued())
458 462
         block_buffer_tail = BLOCK_MOD(block_buffer_tail + 1);
459 463
     }
460 464
 
461 465
     /**
466
+     * "Discard" the next block if it's continued.
467
+     * Called after an interrupted move to throw away the rest of the move.
468
+     */
469
+    FORCE_INLINE static bool discard_continued_block() {
470
+      const bool discard = blocks_queued() && TEST(block_buffer[block_buffer_tail].flag, BLOCK_BIT_CONTINUED);
471
+      if (discard) discard_current_block();
472
+      return discard;
473
+    }
474
+
475
+    /**
462 476
      * The current block. NULL if the buffer is empty.
463 477
      * This also marks the block as busy.
464 478
      * WARNING: Called from Stepper ISR context!
465 479
      */
466 480
     static block_t* get_current_block() {
467 481
       if (blocks_queued()) {
468
-        block_t* block = &block_buffer[block_buffer_tail];
482
+        block_t * const block = &block_buffer[block_buffer_tail];
469 483
         #if ENABLED(ULTRA_LCD)
470 484
           block_buffer_runtime_us -= block->segment_time_us; // We can't be sure how long an active block will take, so don't count it.
471 485
         #endif

+ 11
- 8
Marlin/stepper.cpp 파일 보기

@@ -427,16 +427,19 @@ void Stepper::isr() {
427 427
   // When cleaning, discard the current block and run fast
428 428
   //
429 429
   if (cleaning_buffer_counter) {
430
-    current_block = NULL;
431
-    planner.discard_current_block();
432
-    if (cleaning_buffer_counter < 0)
433
-      ++cleaning_buffer_counter;            // Count up for endstop hit
430
+    if (cleaning_buffer_counter < 0) {          // Count up for endstop hit
431
+      if (current_block) planner.discard_current_block(); // Discard the active block that led to the trigger
432
+      if (!planner.discard_continued_block())   // Discard next CONTINUED block
433
+        cleaning_buffer_counter = 0;            // Keep discarding until non-CONTINUED
434
+    }
434 435
     else {
435
-      --cleaning_buffer_counter;            // Count down for abort print
436
+      planner.discard_current_block();
437
+      --cleaning_buffer_counter;                // Count down for abort print
436 438
       #ifdef SD_FINISHED_RELEASECOMMAND
437 439
         if (!cleaning_buffer_counter && (SD_FINISHED_STEPPERRELEASE)) enqueue_and_echo_commands_P(PSTR(SD_FINISHED_RELEASECOMMAND));
438 440
       #endif
439 441
     }
442
+    current_block = NULL;                       // Prep to get a new block after cleaning
440 443
     _NEXT_ISR(200);                             // Run at max speed - 10 KHz
441 444
     _ENABLE_ISRs();
442 445
     return;
@@ -1124,9 +1127,9 @@ void Stepper::init() {
1124 1127
 
1125 1128
 
1126 1129
 /**
1127
- * Block until all buffered steps are executed
1130
+ * Block until all buffered steps are executed / cleaned
1128 1131
  */
1129
-void Stepper::synchronize() { while (planner.blocks_queued()) idle(); }
1132
+void Stepper::synchronize() { while (planner.blocks_queued() || cleaning_buffer_counter) idle(); }
1130 1133
 
1131 1134
 /**
1132 1135
  * Set the stepper positions directly in steps
@@ -1250,7 +1253,7 @@ void Stepper::endstop_triggered(AxisEnum axis) {
1250 1253
   #endif // !COREXY && !COREXZ && !COREYZ
1251 1254
 
1252 1255
   kill_current_block();
1253
-  cleaning_buffer_counter = -(BLOCK_BUFFER_SIZE - 1); // Ignore remaining blocks
1256
+  cleaning_buffer_counter = -1; // Discard the rest of the move
1254 1257
 }
1255 1258
 
1256 1259
 void Stepper::report_positions() {

Loading…
취소
저장