Merge pull request #4226 from thinkyhead/rc_emergency_command_parser

MarlinSerial emergency-command parser (with M108)
This commit is contained in:
Scott Lahteine
2016-07-07 16:53:55 -07:00
committed by GitHub
29 changed files with 294 additions and 56 deletions

View File

@@ -160,7 +160,7 @@
* M105 - Read current temp
* M106 - Fan on
* M107 - Fan off
* M108 - Cancel heatup and wait for the hotend and bed, this G-code is asynchronously handled in the get_serial_commands() parser
* M108 - Stop the waiting for heaters in M109, M190, M303. Does not affect the target temperature.
* M109 - Sxxx Wait for extruder current temp to reach target temp. Waits only when heating
* Rxxx Wait for extruder current temp to reach target temp. Waits when heating and cooling
* IF AUTOTEMP is enabled, S<mintemp> B<maxtemp> F<factor>. Exit autotemp by any M109 without F
@@ -332,7 +332,7 @@ uint8_t active_extruder = 0;
// Relative Mode. Enable with G91, disable with G90.
static bool relative_mode = false;
bool wait_for_heatup = true;
volatile bool wait_for_heatup = true;
const char errormagic[] PROGMEM = "Error:";
const char echomagic[] PROGMEM = "echo:";
@@ -1105,9 +1105,12 @@ inline void get_serial_commands() {
}
}
// If command was e-stop process now
if (strcmp(command, "M112") == 0) kill(PSTR(MSG_KILLED));
if (strcmp(command, "M108") == 0) wait_for_heatup = false;
#if DISABLED(EMERGENCY_PARSER)
// If command was e-stop process now
if (strcmp(command, "M108") == 0) wait_for_heatup = false;
if (strcmp(command, "M112") == 0) kill(PSTR(MSG_KILLED));
if (strcmp(command, "M410") == 0) { quickstop_stepper(); }
#endif
#if defined(NO_TIMEOUTS) && NO_TIMEOUTS > 0
last_command_time = ms;
@@ -4535,10 +4538,29 @@ inline void gcode_M105() {
#endif // FAN_COUNT > 0
/**
* M108: Cancel heatup and wait for the hotend and bed, this G-code is asynchronously handled in the get_serial_commands() parser
*/
inline void gcode_M108() { wait_for_heatup = false; }
#if DISABLED(EMERGENCY_PARSER)
/**
* M108: Stop the waiting for heaters in M109, M190, M303. Does not affect the target temperature.
*/
inline void gcode_M108() { wait_for_heatup = false; }
/**
* M112: Emergency Stop
*/
inline void gcode_M112() { kill(PSTR(MSG_KILLED)); }
/**
* M410: Quickstop - Abort all planned moves
*
* This will stop the carriages mid-move, so most likely they
* will be out of sync with the stepper position after this.
*/
inline void gcode_M410() { quickstop_stepper(); }
#endif
/**
* M109: Sxxx Wait for extruder(s) to reach temperature. Waits only when heating.
@@ -4810,11 +4832,6 @@ inline void gcode_M111() {
SERIAL_EOL;
}
/**
* M112: Emergency Stop
*/
inline void gcode_M112() { kill(PSTR(MSG_KILLED)); }
#if ENABLED(HOST_KEEPALIVE_FEATURE)
/**
@@ -5970,8 +5987,9 @@ inline void gcode_M400() { stepper.synchronize(); }
#endif // FILAMENT_WIDTH_SENSOR
#if DISABLED(DELTA) && DISABLED(SCARA)
void set_current_position_from_planner() {
void quickstop_stepper() {
stepper.quick_stop();
#if DISABLED(DELTA) && DISABLED(SCARA)
stepper.synchronize();
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
vector_3 pos = planner.adjusted_position(); // values directly from steppers...
@@ -5984,23 +6002,9 @@ inline void gcode_M400() { stepper.synchronize(); }
current_position[Z_AXIS] = stepper.get_axis_position_mm(Z_AXIS);
#endif
sync_plan_position(); // ...re-apply to planner position
}
#endif
/**
* M410: Quickstop - Abort all planned moves
*
* This will stop the carriages mid-move, so most likely they
* will be out of sync with the stepper position after this.
*/
inline void gcode_M410() {
stepper.quick_stop();
#if DISABLED(DELTA) && DISABLED(SCARA)
set_current_position_from_planner();
#endif
}
#if ENABLED(MESH_BED_LEVELING)
/**
@@ -6955,9 +6959,21 @@ void process_next_command() {
gcode_M111();
break;
case 112: // M112: Emergency Stop
gcode_M112();
break;
#if DISABLED(EMERGENCY_PARSER)
case 108: // M108: Cancel Waiting
gcode_M108();
break;
case 112: // M112: Emergency Stop
gcode_M112();
break;
case 410: // M410 quickstop - Abort all the planned moves.
gcode_M410();
break;
#endif
#if ENABLED(HOST_KEEPALIVE_FEATURE)
@@ -6976,10 +6992,6 @@ void process_next_command() {
KEEPALIVE_STATE(NOT_BUSY);
return; // "ok" already printed
case 108:
gcode_M108();
break;
case 109: // M109: Wait for temperature
gcode_M109();
break;
@@ -7263,10 +7275,6 @@ void process_next_command() {
break;
#endif // ENABLED(FILAMENT_WIDTH_SENSOR)
case 410: // M410 quickstop - Abort all the planned moves.
gcode_M410();
break;
#if ENABLED(MESH_BED_LEVELING)
case 420: // M420 Enable/Disable Mesh Bed Leveling
gcode_M420();