clear_block_buffer, kill_current_block in quick_stop

This commit is contained in:
Scott Lahteine 2018-04-13 22:04:53 -05:00
parent 99282a46e9
commit 36b97bde9f
3 changed files with 9 additions and 6 deletions

View file

@ -100,8 +100,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],
@ -207,7 +207,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);
@ -217,6 +216,7 @@ void Planner::init() {
#if ABL_PLANAR
bed_level_matrix.set_to_identity();
#endif
clear_block_buffer();
}
#if ENABLED(BEZIER_JERK_CONTROL)

View file

@ -309,6 +309,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
@ -594,7 +596,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

View file

@ -2083,10 +2083,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();