clear_block_buffer, kill_current_block in quick_stop

This commit is contained in:
Scott Lahteine 2018-04-13 21:59:09 -05:00
parent a783caabac
commit 9769d799df
3 changed files with 9 additions and 6 deletions

View File

@ -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

View File

@ -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

View File

@ -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();