From 131d7390c00e9fda19be754eebbf6d95ed2df4c4 Mon Sep 17 00:00:00 2001 From: Michael Moon Date: Wed, 22 Jun 2011 11:17:48 +1000 Subject: [PATCH] fix move to zero in next move after homing command, add M84 disable motors --- gcode_process.c | 47 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 14 deletions(-) diff --git a/gcode_process.c b/gcode_process.c index de6710c..9329b62 100644 --- a/gcode_process.c +++ b/gcode_process.c @@ -5,6 +5,7 @@ */ #include +#include #include "gcode_parse.h" @@ -137,6 +138,16 @@ void process_gcode_command() { next_tool = next_target.T; } + // if we didn't see an axis word, set it to startpoint. this fixes incorrect moves after homing + if (next_target.seen_X == 0) + next_target.target.X = startpoint.X; + if (next_target.seen_Y == 0) + next_target.target.Y = startpoint.Y; + if (next_target.seen_Z == 0) + next_target.target.Z = startpoint.Z; + if (next_target.seen_E == 0) + next_target.target.E = startpoint.E; + if (next_target.seen_G) { uint8_t axisSelected = 0; switch (next_target.G) { @@ -357,11 +368,24 @@ void process_gcode_command() { } else if (next_target.seen_M) { switch (next_target.M) { + // M0- machine stop + case 0: // M2- program end case 2: //? ==== M2: program end ==== //? //? Undocumented. + queue_wait(); + // no break- we fall through to M112 below + // M112- immediate stop + case 112: + //? ==== M112: Emergency Stop ==== + //? + //? Example: M112 + //? + //? Any moves in progress are immediately terminated, then RepRap shuts down. All motors and heaters are turned off. + //? It can be started again by pressing the reset button on the master microcontroller. See also M0. + timer_stop(); queue_flush(); x_disable(); @@ -369,6 +393,7 @@ void process_gcode_command() { z_disable(); e_disable(); power_off(); + cli(); for (;;) wd_reset(); break; @@ -380,6 +405,13 @@ void process_gcode_command() { //? Undocumented. tool = next_tool; break; + // M84- stop idle hold + case 84: + x_disable(); + y_disable(); + z_disable(); + e_disable(); + break; // M3/M101- extruder on case 3: case 101: @@ -539,20 +571,7 @@ void process_gcode_command() { debug_flags = next_target.S; break; #endif - // M112- immediate stop - case 112: - //? ==== M112: Emergency Stop ==== - //? - //? Example: M112 - //? - //? Any moves in progress are immediately terminated, then RepRap shuts down. All motors and heaters are turned off. - //? It can be started again by pressing the reset button on the master microcontroller. See also M0. - - timer_stop(); - queue_flush(); - power_off(); - break; - // M113- extruder PWM + // M113- extruder PWM // M114- report XYZEF to host case 114: //? ==== M114: Get Current Position ====