Browse Source

clear_block_buffer, kill_current_block in quick_stop

Scott Lahteine 6 years ago
parent
commit
36b97bde9f
3 changed files with 9 additions and 6 deletions
  1. 3
    3
      Marlin/src/module/planner.cpp
  2. 3
    1
      Marlin/src/module/planner.h
  3. 3
    2
      Marlin/src/module/stepper.cpp

+ 3
- 3
Marlin/src/module/planner.cpp View File

@@ -100,8 +100,8 @@ Planner planner;
100 100
  * A ring buffer of moves described in steps
101 101
  */
102 102
 block_t Planner::block_buffer[BLOCK_BUFFER_SIZE];
103
-volatile uint8_t Planner::block_buffer_head = 0,           // Index of the next block to be pushed
104
-                 Planner::block_buffer_tail = 0;
103
+volatile uint8_t Planner::block_buffer_head, // Index of the next block to be pushed
104
+                 Planner::block_buffer_tail;
105 105
 
106 106
 float Planner::max_feedrate_mm_s[XYZE_N], // Max speeds in mm per second
107 107
       Planner::axis_steps_per_mm[XYZE_N],
@@ -207,7 +207,6 @@ float Planner::previous_speed[NUM_AXIS],
207 207
 Planner::Planner() { init(); }
208 208
 
209 209
 void Planner::init() {
210
-  block_buffer_head = block_buffer_tail = 0;
211 210
   ZERO(position);
212 211
   #if HAS_POSITION_FLOAT
213 212
     ZERO(position_float);
@@ -217,6 +216,7 @@ void Planner::init() {
217 216
   #if ABL_PLANAR
218 217
     bed_level_matrix.set_to_identity();
219 218
   #endif
219
+  clear_block_buffer();
220 220
 }
221 221
 
222 222
 #if ENABLED(BEZIER_JERK_CONTROL)

+ 3
- 1
Marlin/src/module/planner.h View File

@@ -309,6 +309,8 @@ class Planner {
309 309
      */
310 310
     FORCE_INLINE static uint8_t movesplanned() { return BLOCK_MOD(block_buffer_head - block_buffer_tail + BLOCK_BUFFER_SIZE); }
311 311
 
312
+    FORCE_INLINE static void clear_block_buffer() { block_buffer_head = block_buffer_tail = 0; }
313
+
312 314
     FORCE_INLINE static bool is_full() { return block_buffer_tail == next_block_index(block_buffer_head); }
313 315
 
314 316
     // Update multipliers based on new diameter measurements
@@ -594,7 +596,7 @@ class Planner {
594 596
         return bbru;
595 597
       }
596 598
 
597
-      static void clear_block_buffer_runtime(){
599
+      static void clear_block_buffer_runtime() {
598 600
         CRITICAL_SECTION_START
599 601
           block_buffer_runtime_us = 0;
600 602
         CRITICAL_SECTION_END

+ 3
- 2
Marlin/src/module/stepper.cpp View File

@@ -2083,10 +2083,11 @@ void Stepper::finish_and_disable() {
2083 2083
 }
2084 2084
 
2085 2085
 void Stepper::quick_stop() {
2086
-  cleaning_buffer_counter = 5000;
2087 2086
   DISABLE_STEPPER_DRIVER_INTERRUPT();
2088
-  while (planner.has_blocks_queued()) planner.discard_current_block();
2087
+  kill_current_block();
2089 2088
   current_block = NULL;
2089
+  cleaning_buffer_counter = 5000;
2090
+  planner.clear_block_buffer();
2090 2091
   ENABLE_STEPPER_DRIVER_INTERRUPT();
2091 2092
   #if ENABLED(ULTRA_LCD)
2092 2093
     planner.clear_block_buffer_runtime();

Loading…
Cancel
Save