Discard all CONTINUED blocks on interrupted move

This commit is contained in:
Scott Lahteine 2017-12-07 22:38:40 -06:00
parent 8be7a0b131
commit 75eb93140f
3 changed files with 34 additions and 14 deletions

View file

@ -427,16 +427,19 @@ void Stepper::isr() {
// When cleaning, discard the current block and run fast
//
if (cleaning_buffer_counter) {
current_block = NULL;
planner.discard_current_block();
if (cleaning_buffer_counter < 0)
++cleaning_buffer_counter; // Count up for endstop hit
if (cleaning_buffer_counter < 0) { // Count up for endstop hit
if (current_block) planner.discard_current_block(); // Discard the active block that led to the trigger
if (!planner.discard_continued_block()) // Discard next CONTINUED block
cleaning_buffer_counter = 0; // Keep discarding until non-CONTINUED
}
else {
--cleaning_buffer_counter; // Count down for abort print
planner.discard_current_block();
--cleaning_buffer_counter; // Count down for abort print
#ifdef SD_FINISHED_RELEASECOMMAND
if (!cleaning_buffer_counter && (SD_FINISHED_STEPPERRELEASE)) enqueue_and_echo_commands_P(PSTR(SD_FINISHED_RELEASECOMMAND));
#endif
}
current_block = NULL; // Prep to get a new block after cleaning
_NEXT_ISR(200); // Run at max speed - 10 KHz
_ENABLE_ISRs();
return;
@ -1124,9 +1127,9 @@ void Stepper::init() {
/**
* Block until all buffered steps are executed
* Block until all buffered steps are executed / cleaned
*/
void Stepper::synchronize() { while (planner.blocks_queued()) idle(); }
void Stepper::synchronize() { while (planner.blocks_queued() || cleaning_buffer_counter) idle(); }
/**
* Set the stepper positions directly in steps
@ -1250,7 +1253,7 @@ void Stepper::endstop_triggered(AxisEnum axis) {
#endif // !COREXY && !COREXZ && !COREYZ
kill_current_block();
cleaning_buffer_counter = -(BLOCK_BUFFER_SIZE - 1); // Ignore remaining blocks
cleaning_buffer_counter = -1; // Discard the rest of the move
}
void Stepper::report_positions() {