From 9769d799df76c1df0cfbeb78c9da02219f8a689c Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 13 Apr 2018 21:59:09 -0500 Subject: [PATCH] clear_block_buffer, kill_current_block in quick_stop --- Marlin/planner.cpp | 6 +++--- Marlin/planner.h | 4 +++- Marlin/stepper.cpp | 5 +++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Marlin/planner.cpp b/Marlin/planner.cpp index 0ed70c3e8..eb09dd6ff 100644 --- a/Marlin/planner.cpp +++ b/Marlin/planner.cpp @@ -85,8 +85,8 @@ Planner planner; * A ring buffer of moves described in steps */ block_t Planner::block_buffer[BLOCK_BUFFER_SIZE]; -volatile uint8_t Planner::block_buffer_head = 0, // Index of the next block to be pushed - Planner::block_buffer_tail = 0; +volatile uint8_t Planner::block_buffer_head, // Index of the next block to be pushed + Planner::block_buffer_tail; float Planner::max_feedrate_mm_s[XYZE_N], // Max speeds in mm per second Planner::axis_steps_per_mm[XYZE_N], @@ -192,7 +192,6 @@ float Planner::previous_speed[NUM_AXIS], Planner::Planner() { init(); } void Planner::init() { - block_buffer_head = block_buffer_tail = 0; ZERO(position); #if HAS_POSITION_FLOAT ZERO(position_float); @@ -202,6 +201,7 @@ void Planner::init() { #if ABL_PLANAR bed_level_matrix.set_to_identity(); #endif + clear_block_buffer(); } #define MINIMAL_STEP_RATE 120 diff --git a/Marlin/planner.h b/Marlin/planner.h index adebbb0f3..61af55fc8 100644 --- a/Marlin/planner.h +++ b/Marlin/planner.h @@ -296,6 +296,8 @@ class Planner { */ FORCE_INLINE static uint8_t movesplanned() { return BLOCK_MOD(block_buffer_head - block_buffer_tail + BLOCK_BUFFER_SIZE); } + FORCE_INLINE static void clear_block_buffer() { block_buffer_head = block_buffer_tail = 0; } + FORCE_INLINE static bool is_full() { return block_buffer_tail == next_block_index(block_buffer_head); } // Update multipliers based on new diameter measurements @@ -581,7 +583,7 @@ class Planner { return bbru; } - static void clear_block_buffer_runtime(){ + static void clear_block_buffer_runtime() { CRITICAL_SECTION_START block_buffer_runtime_us = 0; CRITICAL_SECTION_END diff --git a/Marlin/stepper.cpp b/Marlin/stepper.cpp index baba2d731..809cc54a9 100644 --- a/Marlin/stepper.cpp +++ b/Marlin/stepper.cpp @@ -1210,10 +1210,11 @@ void Stepper::finish_and_disable() { } void Stepper::quick_stop() { - cleaning_buffer_counter = 5000; DISABLE_STEPPER_DRIVER_INTERRUPT(); - while (planner.has_blocks_queued()) planner.discard_current_block(); + kill_current_block(); current_block = NULL; + cleaning_buffer_counter = 5000; + planner.clear_block_buffer(); ENABLE_STEPPER_DRIVER_INTERRUPT(); #if ENABLED(ULTRA_LCD) planner.clear_block_buffer_runtime();