From 4d6a5c29df87270b13c6ec7b5adb58c1aa29e3a8 Mon Sep 17 00:00:00 2001
From: Bernhard <bkubicek@x201.(none)>
Date: Sat, 26 Nov 2011 11:50:23 +0100
Subject: [PATCH] disable steppers as routine in stepper.cpp

---
 Marlin/Marlin.pde  |  8 ++------
 Marlin/stepper.cpp | 10 ++++++++++
 Marlin/stepper.h   |  2 ++
 3 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/Marlin/Marlin.pde b/Marlin/Marlin.pde
index 60ec2b22e5..d94f810c1d 100644
--- a/Marlin/Marlin.pde
+++ b/Marlin/Marlin.pde
@@ -641,6 +641,7 @@ inline void process_commands()
       //processed in write to file routine above
       //card,saving = false;
       break;
+      
     #endif //SDSUPPORT
 
     case 30: //M30 take time since the start of the SD print or an M109 command
@@ -832,12 +833,7 @@ inline void process_commands()
       }
       else
       { 
-        st_synchronize(); 
-        LCD_MESSAGEPGM("Free move.");
-        disable_x(); 
-        disable_y(); 
-        disable_z(); 
-        disable_e(); 
+        finishAndDisableSteppers();
       }
       break;
     case 85: // M85
diff --git a/Marlin/stepper.cpp b/Marlin/stepper.cpp
index 0c3f0ee1bd..491b6e7f2b 100644
--- a/Marlin/stepper.cpp
+++ b/Marlin/stepper.cpp
@@ -702,3 +702,13 @@ long st_get_position(char axis)
   CRITICAL_SECTION_END;
   return count_pos;
 }
+
+void finishAndDisableSteppers()
+{
+  st_synchronize(); 
+  LCD_MESSAGEPGM("Released.");
+  disable_x(); 
+  disable_y(); 
+  disable_z(); 
+  disable_e(); 
+}
diff --git a/Marlin/stepper.h b/Marlin/stepper.h
index 97f72bf2ed..73b7efb1cd 100644
--- a/Marlin/stepper.h
+++ b/Marlin/stepper.h
@@ -46,6 +46,8 @@ void endstops_hit_on_purpose(); //avoid creation of the message, i.e. after home
 
 void checkStepperErrors(); //Print errors detected by the stepper
 
+void finishAndDisableSteppers();
+
 extern block_t *current_block;  // A pointer to the block currently being traced
 
 
-- 
GitLab