From 82c99625facf9711dc974759f3ed31320abd90d2 Mon Sep 17 00:00:00 2001
From: Bernhard <bkubicek@x201.(none)>
Date: Sun, 11 Dec 2011 22:10:06 +0100
Subject: [PATCH] instant stop of sd prints from the panel.

---
 Marlin/cardreader.pde | 1 +
 Marlin/stepper.cpp    | 9 +++++++++
 Marlin/stepper.h      | 2 +-
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/Marlin/cardreader.pde b/Marlin/cardreader.pde
index 6ad04068e..735a1cdcd 100644
--- a/Marlin/cardreader.pde
+++ b/Marlin/cardreader.pde
@@ -432,6 +432,7 @@ void CardReader::updir()
 
 void CardReader::printingHasFinished()
 {
+ quickStop();
  sdprinting = false;
  if(SD_FINISHED_STEPPERRELEASE)
  {
diff --git a/Marlin/stepper.cpp b/Marlin/stepper.cpp
index 33c7e154c..51a9fe071 100644
--- a/Marlin/stepper.cpp
+++ b/Marlin/stepper.cpp
@@ -752,3 +752,12 @@ void finishAndDisableSteppers()
   disable_z(); 
   disable_e(); 
 }
+
+void quickStop()
+{
+  DISABLE_STEPPER_DRIVER_INTERRUPT();
+  while(blocks_queued())
+    plan_discard_current_block();
+  ENABLE_STEPPER_DRIVER_INTERRUPT();
+}
+
diff --git a/Marlin/stepper.h b/Marlin/stepper.h
index fd388ca68..37ce3b546 100644
--- a/Marlin/stepper.h
+++ b/Marlin/stepper.h
@@ -52,5 +52,5 @@ void finishAndDisableSteppers();
 
 extern block_t *current_block;  // A pointer to the block currently being traced
 
-
+void quickStop();
 #endif