2017-09-06 13:28:31 +02:00
|
|
|
/**
|
|
|
|
* Marlin 3D Printer Firmware
|
|
|
|
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
|
|
|
*
|
|
|
|
* Based on Sprinter and grbl.
|
|
|
|
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2017-09-08 05:33:16 +02:00
|
|
|
/**
|
|
|
|
* gcode.cpp - Temporary container for all gcode handlers
|
|
|
|
* Most will migrate to classes, by feature.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "gcode.h"
|
|
|
|
GcodeSuite gcode;
|
|
|
|
|
|
|
|
#include "parser.h"
|
|
|
|
#include "queue.h"
|
|
|
|
#include "../module/motion.h"
|
|
|
|
|
|
|
|
#if ENABLED(PRINTCOUNTER)
|
|
|
|
#include "../module/printcounter.h"
|
|
|
|
#endif
|
|
|
|
|
2017-09-30 23:06:43 +02:00
|
|
|
#if ENABLED(DIRECT_MIXING_IN_G1)
|
|
|
|
#include "../feature/mixing.h"
|
|
|
|
#endif
|
|
|
|
|
2018-03-21 06:29:09 +01:00
|
|
|
#include "../Marlin.h" // for idle() and suspend_auto_report
|
2017-09-16 03:44:40 +02:00
|
|
|
|
2017-09-08 05:33:16 +02:00
|
|
|
uint8_t GcodeSuite::target_extruder;
|
2018-03-22 01:30:06 +01:00
|
|
|
millis_t GcodeSuite::previous_move_ms;
|
2017-09-08 05:33:16 +02:00
|
|
|
|
|
|
|
bool GcodeSuite::axis_relative_modes[] = AXIS_RELATIVE_MODES;
|
|
|
|
|
2017-09-09 06:49:49 +02:00
|
|
|
#if ENABLED(HOST_KEEPALIVE_FEATURE)
|
|
|
|
GcodeSuite::MarlinBusyState GcodeSuite::busy_state = NOT_BUSY;
|
|
|
|
uint8_t GcodeSuite::host_keepalive_interval = DEFAULT_KEEPALIVE_INTERVAL;
|
|
|
|
#endif
|
|
|
|
|
2017-09-16 06:08:48 +02:00
|
|
|
#if ENABLED(CNC_WORKSPACE_PLANES)
|
|
|
|
GcodeSuite::WorkspacePlane GcodeSuite::workspace_plane = PLANE_XY;
|
|
|
|
#endif
|
|
|
|
|
2017-11-04 22:36:41 +01:00
|
|
|
#if ENABLED(CNC_COORDINATE_SYSTEMS)
|
|
|
|
int8_t GcodeSuite::active_coordinate_system = -1; // machine space
|
|
|
|
float GcodeSuite::coordinate_system[MAX_COORDINATE_SYSTEMS][XYZ];
|
|
|
|
#endif
|
|
|
|
|
2017-09-08 05:33:16 +02:00
|
|
|
/**
|
|
|
|
* Set target_extruder from the T parameter or the active_extruder
|
|
|
|
*
|
|
|
|
* Returns TRUE if the target is invalid
|
|
|
|
*/
|
|
|
|
bool GcodeSuite::get_target_extruder_from_command() {
|
|
|
|
if (parser.seenval('T')) {
|
|
|
|
const int8_t e = parser.value_byte();
|
|
|
|
if (e >= EXTRUDERS) {
|
|
|
|
SERIAL_ECHO_START();
|
|
|
|
SERIAL_CHAR('M');
|
|
|
|
SERIAL_ECHO(parser.codenum);
|
|
|
|
SERIAL_ECHOLNPAIR(" " MSG_INVALID_EXTRUDER " ", e);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
target_extruder = e;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
target_extruder = active_extruder;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set XYZE destination and feedrate from the current GCode command
|
|
|
|
*
|
|
|
|
* - Set destination from included axis codes
|
|
|
|
* - Set to current for missing axis codes
|
|
|
|
* - Set the feedrate, if included
|
|
|
|
*/
|
|
|
|
void GcodeSuite::get_destination_from_command() {
|
|
|
|
LOOP_XYZE(i) {
|
2017-11-08 19:54:00 +01:00
|
|
|
if (parser.seen(axis_codes[i])) {
|
2018-01-20 22:22:03 +01:00
|
|
|
const float v = parser.value_axis_units((AxisEnum)i);
|
|
|
|
destination[i] = (axis_relative_modes[i] || relative_mode)
|
|
|
|
? current_position[i] + v
|
|
|
|
: (i == E_AXIS) ? v : LOGICAL_TO_NATIVE(v, i);
|
2017-11-08 19:54:00 +01:00
|
|
|
}
|
2017-09-08 05:33:16 +02:00
|
|
|
else
|
|
|
|
destination[i] = current_position[i];
|
|
|
|
}
|
|
|
|
|
2018-07-01 22:20:28 +02:00
|
|
|
if (parser.linearval('F') > 0)
|
2017-09-08 05:33:16 +02:00
|
|
|
feedrate_mm_s = MMM_TO_MMS(parser.value_feedrate());
|
|
|
|
|
|
|
|
#if ENABLED(PRINTCOUNTER)
|
|
|
|
if (!DEBUGGING(DRYRUN))
|
|
|
|
print_job_timer.incFilamentUsed(destination[E_AXIS] - current_position[E_AXIS]);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Get ABCDHI mixing factors
|
|
|
|
#if ENABLED(MIXING_EXTRUDER) && ENABLED(DIRECT_MIXING_IN_G1)
|
|
|
|
gcode_get_mix();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2017-09-16 03:44:40 +02:00
|
|
|
/**
|
|
|
|
* Dwell waits immediately. It does not synchronize. Use M400 instead of G4
|
|
|
|
*/
|
|
|
|
void GcodeSuite::dwell(millis_t time) {
|
2018-03-22 01:30:06 +01:00
|
|
|
time += millis();
|
2017-09-16 03:44:40 +02:00
|
|
|
while (PENDING(millis(), time)) idle();
|
|
|
|
}
|
|
|
|
|
2018-04-18 23:56:10 +02:00
|
|
|
/**
|
|
|
|
* When G29_RETRY_AND_RECOVER is enabled, call G29() in
|
|
|
|
* a loop with recovery and retry handling.
|
|
|
|
*/
|
|
|
|
#if HAS_LEVELING && ENABLED(G29_RETRY_AND_RECOVER)
|
|
|
|
|
2018-06-30 03:48:11 +02:00
|
|
|
#ifndef G29_MAX_RETRIES
|
|
|
|
#define G29_MAX_RETRIES 0
|
|
|
|
#endif
|
2018-07-26 01:49:32 +02:00
|
|
|
|
2018-04-18 23:56:10 +02:00
|
|
|
void GcodeSuite::G29_with_retry() {
|
2018-06-30 03:48:11 +02:00
|
|
|
uint8_t retries = G29_MAX_RETRIES;
|
|
|
|
while (G29()) { // G29 should return true for failed probes ONLY
|
|
|
|
if (retries--) {
|
|
|
|
#ifdef G29_ACTION_ON_RECOVER
|
|
|
|
SERIAL_ECHOLNPGM("//action:" G29_ACTION_ON_RECOVER);
|
|
|
|
#endif
|
|
|
|
#ifdef G29_RECOVER_COMMANDS
|
|
|
|
process_subcommands_now_P(PSTR(G29_RECOVER_COMMANDS));
|
2018-07-26 01:49:32 +02:00
|
|
|
#endif
|
2018-06-30 03:48:11 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
#ifdef G29_FAILURE_COMMANDS
|
|
|
|
process_subcommands_now_P(PSTR(G29_FAILURE_COMMANDS));
|
|
|
|
#endif
|
|
|
|
#ifdef G29_ACTION_ON_FAILURE
|
|
|
|
SERIAL_ECHOLNPGM("//action:" G29_ACTION_ON_FAILURE);
|
|
|
|
#endif
|
|
|
|
#if ENABLED(G29_HALT_ON_FAILURE)
|
|
|
|
kill(PSTR(MSG_ERR_PROBING_FAILED));
|
|
|
|
#endif
|
|
|
|
return;
|
|
|
|
}
|
2018-04-18 23:56:10 +02:00
|
|
|
}
|
2018-06-30 03:48:11 +02:00
|
|
|
#ifdef G29_SUCCESS_COMMANDS
|
|
|
|
process_subcommands_now_P(PSTR(G29_SUCCESS_COMMANDS));
|
|
|
|
#endif
|
2018-04-18 23:56:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif // HAS_LEVELING && G29_RETRY_AND_RECOVER
|
|
|
|
|
2017-09-08 05:33:16 +02:00
|
|
|
//
|
|
|
|
// Placeholders for non-migrated codes
|
|
|
|
//
|
|
|
|
#if ENABLED(M100_FREE_MEMORY_WATCHER)
|
|
|
|
extern void M100_dump_routine(const char * const title, const char *start, const char *end);
|
|
|
|
#endif
|
|
|
|
|
2017-09-06 13:28:31 +02:00
|
|
|
/**
|
2017-11-04 22:36:41 +01:00
|
|
|
* Process the parsed command and dispatch it to its handler
|
2017-09-06 13:28:31 +02:00
|
|
|
*/
|
2018-04-18 23:56:10 +02:00
|
|
|
void GcodeSuite::process_parsed_command(
|
|
|
|
#if ENABLED(USE_EXECUTE_COMMANDS_IMMEDIATE)
|
|
|
|
const bool no_ok
|
|
|
|
#endif
|
|
|
|
) {
|
2017-09-06 13:28:31 +02:00
|
|
|
KEEPALIVE_STATE(IN_HANDLER);
|
|
|
|
|
|
|
|
// Handle a known G, M, or T
|
|
|
|
switch (parser.command_letter) {
|
|
|
|
case 'G': switch (parser.codenum) {
|
|
|
|
|
2018-04-13 07:08:28 +02:00
|
|
|
case 0: case 1: G0_G1( // G0: Fast Move, G1: Linear Move
|
|
|
|
#if IS_SCARA
|
|
|
|
parser.codenum == 0
|
|
|
|
#endif
|
|
|
|
);
|
|
|
|
break;
|
2017-09-06 13:28:31 +02:00
|
|
|
|
|
|
|
#if ENABLED(ARC_SUPPORT) && DISABLED(SCARA)
|
2018-04-13 07:08:28 +02:00
|
|
|
case 2: case 3: G2_G3(parser.codenum == 2); break; // G2: CW ARC, G3: CCW ARC
|
2017-09-06 13:28:31 +02:00
|
|
|
#endif
|
|
|
|
|
2018-04-13 07:08:28 +02:00
|
|
|
case 4: G4(); break; // G4: Dwell
|
2017-09-06 13:28:31 +02:00
|
|
|
|
|
|
|
#if ENABLED(BEZIER_CURVE_SUPPORT)
|
2018-04-13 07:08:28 +02:00
|
|
|
case 5: G5(); break; // G5: Cubic B_spline
|
|
|
|
#endif
|
2017-09-06 13:28:31 +02:00
|
|
|
|
|
|
|
#if ENABLED(FWRETRACT)
|
2018-04-13 07:08:28 +02:00
|
|
|
case 10: G10(); break; // G10: Retract / Swap Retract
|
|
|
|
case 11: G11(); break; // G11: Recover / Swap Recover
|
|
|
|
#endif
|
2017-09-06 13:28:31 +02:00
|
|
|
|
|
|
|
#if ENABLED(NOZZLE_CLEAN_FEATURE)
|
2018-04-13 07:08:28 +02:00
|
|
|
case 12: G12(); break; // G12: Nozzle Clean
|
|
|
|
#endif
|
2017-09-06 13:28:31 +02:00
|
|
|
|
|
|
|
#if ENABLED(CNC_WORKSPACE_PLANES)
|
2018-04-13 07:08:28 +02:00
|
|
|
case 17: G17(); break; // G17: Select Plane XY
|
|
|
|
case 18: G18(); break; // G18: Select Plane ZX
|
|
|
|
case 19: G19(); break; // G19: Select Plane YZ
|
|
|
|
#endif
|
2017-09-06 13:28:31 +02:00
|
|
|
|
|
|
|
#if ENABLED(INCH_MODE_SUPPORT)
|
2018-04-13 07:08:28 +02:00
|
|
|
case 20: G20(); break; // G20: Inch Mode
|
|
|
|
case 21: G21(); break; // G21: MM Mode
|
|
|
|
#endif
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2017-11-24 00:59:43 +01:00
|
|
|
#if ENABLED(G26_MESH_VALIDATION)
|
2018-04-13 07:08:28 +02:00
|
|
|
case 26: G26(); break; // G26: Mesh Validation Pattern generation
|
|
|
|
#endif
|
2017-09-06 13:28:31 +02:00
|
|
|
|
|
|
|
#if ENABLED(NOZZLE_PARK_FEATURE)
|
2018-04-13 07:08:28 +02:00
|
|
|
case 27: G27(); break; // G27: Nozzle Park
|
|
|
|
#endif
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2018-04-13 07:08:28 +02:00
|
|
|
case 28: G28(false); break; // G28: Home all axes, one at a time
|
2017-09-06 13:28:31 +02:00
|
|
|
|
|
|
|
#if HAS_LEVELING
|
2018-04-18 23:56:10 +02:00
|
|
|
case 29: // G29: Bed leveling calibration
|
|
|
|
#if ENABLED(G29_RETRY_AND_RECOVER)
|
|
|
|
G29_with_retry();
|
|
|
|
#else
|
|
|
|
G29();
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
#endif // HAS_LEVELING
|
2017-09-06 13:28:31 +02:00
|
|
|
|
|
|
|
#if HAS_BED_PROBE
|
2018-04-13 07:08:28 +02:00
|
|
|
case 30: G30(); break; // G30: Single Z probe
|
2017-09-06 13:28:31 +02:00
|
|
|
#if ENABLED(Z_PROBE_SLED)
|
2018-04-13 07:08:28 +02:00
|
|
|
case 31: G31(); break; // G31: dock the sled
|
|
|
|
case 32: G32(); break; // G32: undock the sled
|
|
|
|
#endif
|
|
|
|
#endif
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2017-09-08 22:35:25 +02:00
|
|
|
#if ENABLED(DELTA_AUTO_CALIBRATION)
|
2018-04-13 07:08:28 +02:00
|
|
|
case 33: G33(); break; // G33: Delta Auto-Calibration
|
|
|
|
#endif
|
2017-09-06 13:28:31 +02:00
|
|
|
|
|
|
|
#if ENABLED(G38_PROBE_TARGET)
|
2018-04-13 07:08:28 +02:00
|
|
|
case 38: // G38.2 & G38.3
|
2017-09-06 13:28:31 +02:00
|
|
|
if (parser.subcode == 2 || parser.subcode == 3)
|
2017-09-16 06:44:29 +02:00
|
|
|
G38(parser.subcode == 2);
|
2017-09-06 13:28:31 +02:00
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
|
2018-04-13 07:08:28 +02:00
|
|
|
case 90: relative_mode = false; break; // G90: Relative Mode
|
|
|
|
case 91: relative_mode = true; break; // G91: Absolute Mode
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2018-04-13 07:08:28 +02:00
|
|
|
case 92: G92(); break; // G92: Set current axis position(s)
|
2017-09-06 13:28:31 +02:00
|
|
|
|
|
|
|
#if HAS_MESH
|
2018-04-13 07:08:28 +02:00
|
|
|
case 42: G42(); break; // G42: Coordinated move to a mesh point
|
2017-09-06 13:28:31 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if ENABLED(DEBUG_GCODE_PARSER)
|
2018-04-13 07:08:28 +02:00
|
|
|
case 800: parser.debug(); break; // G800: GCode Parser Test for G
|
2017-09-06 13:28:31 +02:00
|
|
|
#endif
|
2018-04-28 00:40:27 +02:00
|
|
|
|
|
|
|
default: parser.unknown_command_error(); break;
|
2017-09-06 13:28:31 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'M': switch (parser.codenum) {
|
|
|
|
#if HAS_RESUME_CONTINUE
|
2018-04-13 07:08:28 +02:00
|
|
|
case 0: // M0: Unconditional stop - Wait for user button press on LCD
|
|
|
|
case 1: M0_M1(); break; // M1: Conditional stop - Wait for user button press on LCD
|
|
|
|
#endif
|
2017-09-06 13:28:31 +02:00
|
|
|
|
|
|
|
#if ENABLED(SPINDLE_LASER_ENABLE)
|
2018-04-13 07:08:28 +02:00
|
|
|
case 3: M3_M4(true ); break; // M3: turn spindle/laser on, set laser/spindle power/speed, set rotation direction CW
|
|
|
|
case 4: M3_M4(false); break; // M4: turn spindle/laser on, set laser/spindle power/speed, set rotation direction CCW
|
|
|
|
case 5: M5(); break; // M5 - turn spindle/laser off
|
2017-09-06 13:28:31 +02:00
|
|
|
#endif
|
2017-09-16 08:07:00 +02:00
|
|
|
|
2018-09-08 19:08:31 +02:00
|
|
|
#if ENABLED(EXTERNAL_CLOSED_LOOP_CONTROLLER)
|
|
|
|
case 12: M12(); break; // M12: Synchronize and optionally force a CLC set
|
|
|
|
#endif
|
|
|
|
|
2018-04-13 07:08:28 +02:00
|
|
|
case 17: M17(); break; // M17: Enable all stepper motors
|
2017-09-06 13:28:31 +02:00
|
|
|
|
|
|
|
#if ENABLED(SDSUPPORT)
|
2018-04-13 07:08:28 +02:00
|
|
|
case 20: M20(); break; // M20: list SD card
|
|
|
|
case 21: M21(); break; // M21: init SD card
|
|
|
|
case 22: M22(); break; // M22: release SD card
|
|
|
|
case 23: M23(); break; // M23: Select file
|
|
|
|
case 24: M24(); break; // M24: Start SD print
|
|
|
|
case 25: M25(); break; // M25: Pause SD print
|
|
|
|
case 26: M26(); break; // M26: Set SD index
|
|
|
|
case 27: M27(); break; // M27: Get SD status
|
|
|
|
case 28: M28(); break; // M28: Start SD write
|
|
|
|
case 29: M29(); break; // M29: Stop SD write
|
|
|
|
case 30: M30(); break; // M30 <filename> Delete File
|
|
|
|
case 32: M32(); break; // M32: Select file and start SD print
|
2017-09-06 13:28:31 +02:00
|
|
|
|
|
|
|
#if ENABLED(LONG_FILENAME_HOST_SUPPORT)
|
2018-04-13 07:08:28 +02:00
|
|
|
case 33: M33(); break; // M33: Get the long full path to a file or folder
|
2017-09-06 13:28:31 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if ENABLED(SDCARD_SORT_ALPHA) && ENABLED(SDSORT_GCODE)
|
2018-04-13 07:08:28 +02:00
|
|
|
case 34: M34(); break; // M34: Set SD card sorting options
|
2017-09-16 10:24:47 +02:00
|
|
|
#endif
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2018-04-13 07:08:28 +02:00
|
|
|
case 928: M928(); break; // M928: Start SD write
|
2017-09-06 13:28:31 +02:00
|
|
|
#endif // SDSUPPORT
|
|
|
|
|
2018-04-13 07:08:28 +02:00
|
|
|
case 31: M31(); break; // M31: Report time since the start of SD print or last M109
|
|
|
|
case 42: M42(); break; // M42: Change pin state
|
2017-09-06 13:28:31 +02:00
|
|
|
|
|
|
|
#if ENABLED(PINS_DEBUGGING)
|
2018-04-13 07:08:28 +02:00
|
|
|
case 43: M43(); break; // M43: Read pin state
|
2017-09-06 13:28:31 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if ENABLED(Z_MIN_PROBE_REPEATABILITY_TEST)
|
2018-04-13 07:08:28 +02:00
|
|
|
case 48: M48(); break; // M48: Z probe repeatability test
|
2017-09-16 11:13:55 +02:00
|
|
|
#endif
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2017-11-24 00:59:43 +01:00
|
|
|
#if ENABLED(G26_MESH_VALIDATION)
|
2018-04-13 07:08:28 +02:00
|
|
|
case 49: M49(); break; // M49: Turn on or off G26 debug flag for verbose output
|
2017-09-08 22:35:25 +02:00
|
|
|
#endif
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2017-10-15 09:15:19 +02:00
|
|
|
#if ENABLED(ULTRA_LCD) && ENABLED(LCD_SET_PROGRESS_MANUALLY)
|
2018-04-13 07:08:28 +02:00
|
|
|
case 73: M73(); break; // M73: Set progress percentage (for display on LCD)
|
2017-10-15 09:15:19 +02:00
|
|
|
#endif
|
|
|
|
|
2018-04-13 07:08:28 +02:00
|
|
|
case 75: M75(); break; // M75: Start print timer
|
|
|
|
case 76: M76(); break; // M76: Pause print timer
|
|
|
|
case 77: M77(); break; // M77: Stop print timer
|
2017-09-06 13:28:31 +02:00
|
|
|
|
|
|
|
#if ENABLED(PRINTCOUNTER)
|
2018-04-13 07:08:28 +02:00
|
|
|
case 78: M78(); break; // M78: Show print statistics
|
2017-09-06 13:28:31 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if ENABLED(M100_FREE_MEMORY_WATCHER)
|
2018-04-13 07:08:28 +02:00
|
|
|
case 100: M100(); break; // M100: Free Memory Report
|
2017-09-06 13:28:31 +02:00
|
|
|
#endif
|
|
|
|
|
2018-04-13 07:08:28 +02:00
|
|
|
case 104: M104(); break; // M104: Set hot end temperature
|
|
|
|
case 109: M109(); break; // M109: Wait for hotend temperature to reach target
|
|
|
|
case 110: M110(); break; // M110: Set Current Line Number
|
|
|
|
case 111: M111(); break; // M111: Set debug level
|
2017-09-06 13:28:31 +02:00
|
|
|
|
|
|
|
#if DISABLED(EMERGENCY_PARSER)
|
2018-04-13 07:08:28 +02:00
|
|
|
case 108: M108(); break; // M108: Cancel Waiting
|
|
|
|
case 112: M112(); break; // M112: Emergency Stop
|
|
|
|
case 410: M410(); break; // M410: Quickstop - Abort all the planned moves.
|
2018-08-29 07:58:32 +02:00
|
|
|
#else
|
|
|
|
case 108: case 112: case 410: break;
|
2017-09-06 13:28:31 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if ENABLED(HOST_KEEPALIVE_FEATURE)
|
2018-04-13 07:08:28 +02:00
|
|
|
case 113: M113(); break; // M113: Set Host Keepalive interval
|
2017-09-06 13:28:31 +02:00
|
|
|
#endif
|
|
|
|
|
2018-04-24 00:13:01 +02:00
|
|
|
#if HAS_HEATED_BED
|
2018-04-13 07:08:28 +02:00
|
|
|
case 140: M140(); break; // M140: Set bed temperature
|
|
|
|
case 190: M190(); break; // M190: Wait for bed temperature to reach target
|
2017-09-17 05:13:32 +02:00
|
|
|
#endif
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2018-04-13 07:08:28 +02:00
|
|
|
case 105: M105(); KEEPALIVE_STATE(NOT_BUSY); return; // M105: Report Temperatures (and say "ok")
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2018-03-07 08:53:50 +01:00
|
|
|
#if ENABLED(AUTO_REPORT_TEMPERATURES) && HAS_TEMP_SENSOR
|
2018-04-13 07:08:28 +02:00
|
|
|
case 155: M155(); break; // M155: Set temperature auto-report interval
|
2017-09-06 13:28:31 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if FAN_COUNT > 0
|
2018-04-13 07:08:28 +02:00
|
|
|
case 106: M106(); break; // M106: Fan On
|
|
|
|
case 107: M107(); break; // M107: Fan Off
|
2017-09-16 20:14:44 +02:00
|
|
|
#endif
|
2017-09-06 13:28:31 +02:00
|
|
|
|
|
|
|
#if ENABLED(PARK_HEAD_ON_PAUSE)
|
2018-04-13 07:08:28 +02:00
|
|
|
case 125: M125(); break; // M125: Store current position and move to filament change position
|
2017-09-06 13:28:31 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if ENABLED(BARICUDA)
|
|
|
|
// PWM for HEATER_1_PIN
|
|
|
|
#if HAS_HEATER_1
|
2018-04-13 07:08:28 +02:00
|
|
|
case 126: M126(); break; // M126: valve open
|
|
|
|
case 127: M127(); break; // M127: valve closed
|
2017-09-17 05:58:13 +02:00
|
|
|
#endif
|
2017-09-06 13:28:31 +02:00
|
|
|
|
|
|
|
// PWM for HEATER_2_PIN
|
|
|
|
#if HAS_HEATER_2
|
2018-04-13 07:08:28 +02:00
|
|
|
case 128: M128(); break; // M128: valve open
|
|
|
|
case 129: M129(); break; // M129: valve closed
|
2017-09-17 05:58:13 +02:00
|
|
|
#endif
|
2017-09-06 13:28:31 +02:00
|
|
|
#endif // BARICUDA
|
|
|
|
|
|
|
|
#if HAS_POWER_SWITCH
|
2018-04-13 07:08:28 +02:00
|
|
|
case 80: M80(); break; // M80: Turn on Power Supply
|
|
|
|
#endif
|
|
|
|
case 81: M81(); break; // M81: Turn off Power, including Power Supply, if possible
|
|
|
|
|
|
|
|
case 82: M82(); break; // M82: Set E axis normal mode (same as other axes)
|
|
|
|
case 83: M83(); break; // M83: Set E axis relative mode
|
|
|
|
case 18: case 84: M18_M84(); break; // M18/M84: Disable Steppers / Set Timeout
|
|
|
|
case 85: M85(); break; // M85: Set inactivity stepper shutdown timeout
|
|
|
|
case 92: M92(); break; // M92: Set the steps-per-unit for one or more axes
|
|
|
|
case 114: M114(); break; // M114: Report current position
|
|
|
|
case 115: M115(); break; // M115: Report capabilities
|
|
|
|
case 117: M117(); break; // M117: Set LCD message text, if possible
|
|
|
|
case 118: M118(); break; // M118: Display a message in the host console
|
|
|
|
case 119: M119(); break; // M119: Report endstop states
|
|
|
|
case 120: M120(); break; // M120: Enable endstops
|
|
|
|
case 121: M121(); break; // M121: Disable endstops
|
2017-09-06 13:28:31 +02:00
|
|
|
|
|
|
|
#if ENABLED(ULTIPANEL)
|
2018-04-13 07:08:28 +02:00
|
|
|
case 145: M145(); break; // M145: Set material heatup parameters
|
2017-09-06 13:28:31 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if ENABLED(TEMPERATURE_UNITS_SUPPORT)
|
2018-04-13 07:08:28 +02:00
|
|
|
case 149: M149(); break; // M149: Set temperature units
|
2017-09-06 13:28:31 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if HAS_COLOR_LEDS
|
2018-04-13 07:08:28 +02:00
|
|
|
case 150: M150(); break; // M150: Set Status LED Color
|
2017-09-17 07:50:24 +02:00
|
|
|
#endif
|
2017-09-06 13:28:31 +02:00
|
|
|
|
|
|
|
#if ENABLED(MIXING_EXTRUDER)
|
2018-04-13 07:08:28 +02:00
|
|
|
case 163: M163(); break; // M163: Set a component weight for mixing extruder
|
2017-09-06 13:28:31 +02:00
|
|
|
#if MIXING_VIRTUAL_TOOLS > 1
|
2018-04-13 07:08:28 +02:00
|
|
|
case 164: M164(); break; // M164: Save current mix as a virtual extruder
|
2017-09-06 13:28:31 +02:00
|
|
|
#endif
|
|
|
|
#if ENABLED(DIRECT_MIXING_IN_G1)
|
2018-04-13 07:08:28 +02:00
|
|
|
case 165: M165(); break; // M165: Set multiple mix weights
|
2017-09-06 13:28:31 +02:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2017-12-20 02:44:11 +01:00
|
|
|
#if DISABLED(NO_VOLUMETRICS)
|
2018-04-13 07:08:28 +02:00
|
|
|
case 200: M200(); break; // M200: Set filament diameter, E to cubic units
|
2017-12-20 02:44:11 +01:00
|
|
|
#endif
|
2017-09-17 08:33:25 +02:00
|
|
|
|
2018-04-13 07:08:28 +02:00
|
|
|
case 201: M201(); break; // M201: Set max acceleration for print moves (units/s^2)
|
2017-09-17 08:33:25 +02:00
|
|
|
|
2017-09-17 08:34:59 +02:00
|
|
|
#if 0
|
2018-04-13 07:08:28 +02:00
|
|
|
case 202: M202(); break; // M202: Not used for Sprinter/grbl gen6
|
2017-09-06 13:28:31 +02:00
|
|
|
#endif
|
2017-09-17 08:34:59 +02:00
|
|
|
|
2018-04-13 07:08:28 +02:00
|
|
|
case 203: M203(); break; // M203: Set max feedrate (units/sec)
|
|
|
|
case 204: M204(); break; // M204: Set acceleration
|
|
|
|
case 205: M205(); break; // M205: Set advanced settings
|
2017-09-06 13:28:31 +02:00
|
|
|
|
|
|
|
#if HAS_M206_COMMAND
|
2018-04-13 07:08:28 +02:00
|
|
|
case 206: M206(); break; // M206: Set home offsets
|
2017-09-06 13:28:31 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if ENABLED(DELTA)
|
2018-04-13 07:08:28 +02:00
|
|
|
case 665: M665(); break; // M665: Set delta configurations
|
2017-09-06 13:28:31 +02:00
|
|
|
#endif
|
|
|
|
|
2018-03-11 02:52:30 +01:00
|
|
|
#if ENABLED(DELTA) || ENABLED(X_DUAL_ENDSTOPS) || ENABLED(Y_DUAL_ENDSTOPS) || ENABLED(Z_DUAL_ENDSTOPS)
|
2018-04-13 07:08:28 +02:00
|
|
|
case 666: M666(); break; // M666: Set delta or dual endstop adjustment
|
2017-09-06 13:28:31 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if ENABLED(FWRETRACT)
|
2018-04-13 07:08:28 +02:00
|
|
|
case 207: M207(); break; // M207: Set Retract Length, Feedrate, and Z lift
|
|
|
|
case 208: M208(); break; // M208: Set Recover (unretract) Additional Length and Feedrate
|
2018-09-28 23:52:56 +02:00
|
|
|
#if ENABLED(FWRETRACT_AUTORETRACT)
|
|
|
|
case 209:
|
|
|
|
if (MIN_AUTORETRACT <= MAX_AUTORETRACT) M209(); // M209: Turn Automatic Retract Detection on/off
|
|
|
|
break;
|
|
|
|
#endif
|
2017-09-08 05:40:32 +02:00
|
|
|
#endif
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2018-04-13 07:08:28 +02:00
|
|
|
case 211: M211(); break; // M211: Enable, Disable, and/or Report software endstops
|
2017-09-06 13:28:31 +02:00
|
|
|
|
|
|
|
#if HOTENDS > 1
|
2018-04-13 07:08:28 +02:00
|
|
|
case 218: M218(); break; // M218: Set a tool offset
|
2017-09-06 13:28:31 +02:00
|
|
|
#endif
|
|
|
|
|
2018-04-13 07:08:28 +02:00
|
|
|
case 220: M220(); break; // M220: Set Feedrate Percentage: S<percent> ("FR" on your LCD)
|
|
|
|
case 221: M221(); break; // M221: Set Flow Percentage
|
|
|
|
case 226: M226(); break; // M226: Wait until a pin reaches a state
|
2017-09-06 13:28:31 +02:00
|
|
|
|
|
|
|
#if HAS_SERVOS
|
2018-04-13 07:08:28 +02:00
|
|
|
case 280: M280(); break; // M280: Set servo position absolute
|
2018-08-25 04:53:42 +02:00
|
|
|
#if ENABLED(EDITABLE_SERVO_ANGLES)
|
|
|
|
case 281: M281(); break; // M281: Set servo angles
|
|
|
|
#endif
|
2017-09-17 09:58:39 +02:00
|
|
|
#endif
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2017-10-25 22:49:34 +02:00
|
|
|
#if ENABLED(BABYSTEPPING)
|
2018-04-13 07:08:28 +02:00
|
|
|
case 290: M290(); break; // M290: Babystepping
|
2017-10-25 22:49:34 +02:00
|
|
|
#endif
|
|
|
|
|
2017-09-06 13:28:31 +02:00
|
|
|
#if HAS_BUZZER
|
2018-04-13 07:08:28 +02:00
|
|
|
case 300: M300(); break; // M300: Play beep tone
|
2017-09-17 10:04:52 +02:00
|
|
|
#endif
|
2017-09-06 13:28:31 +02:00
|
|
|
|
|
|
|
#if ENABLED(PIDTEMP)
|
2018-04-13 07:08:28 +02:00
|
|
|
case 301: M301(); break; // M301: Set hotend PID parameters
|
2017-09-17 10:07:35 +02:00
|
|
|
#endif
|
2017-09-06 13:28:31 +02:00
|
|
|
|
|
|
|
#if ENABLED(PIDTEMPBED)
|
2018-04-13 07:08:28 +02:00
|
|
|
case 304: M304(); break; // M304: Set bed PID parameters
|
2017-09-17 10:09:48 +02:00
|
|
|
#endif
|
2017-09-06 13:28:31 +02:00
|
|
|
|
|
|
|
#if defined(CHDK) || HAS_PHOTOGRAPH
|
2018-04-13 07:08:28 +02:00
|
|
|
case 240: M240(); break; // M240: Trigger a camera by emulating a Canon RC-1 : http://www.doc-diy.net/photo/rc-1_hacked/
|
2017-09-17 10:20:32 +02:00
|
|
|
#endif
|
2017-09-06 13:28:31 +02:00
|
|
|
|
|
|
|
#if HAS_LCD_CONTRAST
|
2018-04-13 07:08:28 +02:00
|
|
|
case 250: M250(); break; // M250: Set LCD contrast
|
2017-09-17 10:23:20 +02:00
|
|
|
#endif
|
2017-09-06 13:28:31 +02:00
|
|
|
|
|
|
|
#if ENABLED(EXPERIMENTAL_I2CBUS)
|
2018-04-13 07:08:28 +02:00
|
|
|
case 260: M260(); break; // M260: Send data to an i2c slave
|
|
|
|
case 261: M261(); break; // M261: Request data from an i2c slave
|
2017-09-17 09:49:13 +02:00
|
|
|
#endif
|
2017-09-06 13:28:31 +02:00
|
|
|
|
|
|
|
#if ENABLED(PREVENT_COLD_EXTRUSION)
|
2018-04-13 07:08:28 +02:00
|
|
|
case 302: M302(); break; // M302: Allow cold extrudes (set the minimum extrude temperature)
|
2017-09-17 10:29:29 +02:00
|
|
|
#endif
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2018-04-13 07:08:28 +02:00
|
|
|
case 303: M303(); break; // M303: PID autotune
|
2017-09-06 13:28:31 +02:00
|
|
|
|
|
|
|
#if ENABLED(MORGAN_SCARA)
|
2018-04-13 07:08:28 +02:00
|
|
|
case 360: if (M360()) return; break; // M360: SCARA Theta pos1
|
|
|
|
case 361: if (M361()) return; break; // M361: SCARA Theta pos2
|
|
|
|
case 362: if (M362()) return; break; // M362: SCARA Psi pos1
|
|
|
|
case 363: if (M363()) return; break; // M363: SCARA Psi pos2
|
|
|
|
case 364: if (M364()) return; break; // M364: SCARA Psi pos3 (90 deg to Theta)
|
2017-09-17 10:34:20 +02:00
|
|
|
#endif
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2017-09-08 05:33:16 +02:00
|
|
|
#if ENABLED(EXT_SOLENOID)
|
2018-04-13 07:08:28 +02:00
|
|
|
case 380: M380(); break; // M380: Activate solenoid on active extruder
|
|
|
|
case 381: M381(); break; // M381: Disable all solenoids
|
2017-09-08 05:33:16 +02:00
|
|
|
#endif
|
|
|
|
|
2018-04-13 07:08:28 +02:00
|
|
|
case 400: M400(); break; // M400: Finish all moves
|
2017-09-06 13:28:31 +02:00
|
|
|
|
|
|
|
#if HAS_BED_PROBE
|
2018-04-13 07:08:28 +02:00
|
|
|
case 401: M401(); break; // M401: Deploy probe
|
|
|
|
case 402: M402(); break; // M402: Stow probe
|
2017-09-17 11:16:28 +02:00
|
|
|
#endif
|
2017-09-06 13:28:31 +02:00
|
|
|
|
|
|
|
#if ENABLED(FILAMENT_WIDTH_SENSOR)
|
2018-04-13 07:08:28 +02:00
|
|
|
case 404: M404(); break; // M404: Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or display nominal filament width
|
|
|
|
case 405: M405(); break; // M405: Turn on filament sensor for control
|
|
|
|
case 406: M406(); break; // M406: Turn off filament sensor for control
|
|
|
|
case 407: M407(); break; // M407: Display measured filament diameter
|
|
|
|
#endif
|
2017-09-06 13:28:31 +02:00
|
|
|
|
|
|
|
#if HAS_LEVELING
|
2018-04-13 07:08:28 +02:00
|
|
|
case 420: M420(); break; // M420: Enable/Disable Bed Leveling
|
2017-09-06 13:28:31 +02:00
|
|
|
#endif
|
|
|
|
|
2017-09-08 22:35:25 +02:00
|
|
|
#if HAS_MESH
|
2018-04-13 07:08:28 +02:00
|
|
|
case 421: M421(); break; // M421: Set a Mesh Bed Leveling Z coordinate
|
2017-09-06 13:28:31 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if HAS_M206_COMMAND
|
2018-04-13 07:08:28 +02:00
|
|
|
case 428: M428(); break; // M428: Apply current_position to home_offset
|
2017-09-06 13:28:31 +02:00
|
|
|
#endif
|
|
|
|
|
2018-04-13 07:08:28 +02:00
|
|
|
case 500: M500(); break; // M500: Store settings in EEPROM
|
|
|
|
case 501: M501(); break; // M501: Read settings from EEPROM
|
|
|
|
case 502: M502(); break; // M502: Revert to default settings
|
2017-09-06 13:28:31 +02:00
|
|
|
#if DISABLED(DISABLE_M503)
|
2018-04-13 07:08:28 +02:00
|
|
|
case 503: M503(); break; // M503: print settings currently in memory
|
2017-09-06 13:28:31 +02:00
|
|
|
#endif
|
2018-01-05 02:51:18 +01:00
|
|
|
#if ENABLED(EEPROM_SETTINGS)
|
2018-04-13 07:08:28 +02:00
|
|
|
case 504: M504(); break; // M504: Validate EEPROM contents
|
2018-01-05 02:51:18 +01:00
|
|
|
#endif
|
2017-09-06 13:28:31 +02:00
|
|
|
|
|
|
|
#if ENABLED(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED)
|
2018-04-13 07:08:28 +02:00
|
|
|
case 540: M540(); break; // M540: Set abort on endstop hit for SD printing
|
2017-09-06 13:28:31 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if HAS_BED_PROBE
|
2018-04-13 07:08:28 +02:00
|
|
|
case 851: M851(); break; // M851: Set Z Probe Z Offset
|
|
|
|
#endif
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2017-12-01 23:42:23 +01:00
|
|
|
#if ENABLED(SKEW_CORRECTION_GCODE)
|
2018-04-13 07:08:28 +02:00
|
|
|
case 852: M852(); break; // M852: Set Skew factors
|
2017-12-01 23:42:23 +01:00
|
|
|
#endif
|
|
|
|
|
2017-09-06 13:28:31 +02:00
|
|
|
#if ENABLED(ADVANCED_PAUSE_FEATURE)
|
2018-04-13 07:08:28 +02:00
|
|
|
case 600: M600(); break; // M600: Pause for Filament Change
|
|
|
|
case 603: M603(); break; // M603: Configure Filament Change
|
|
|
|
#endif
|
2017-09-06 13:28:31 +02:00
|
|
|
|
|
|
|
#if ENABLED(DUAL_X_CARRIAGE) || ENABLED(DUAL_NOZZLE_DUPLICATION_MODE)
|
2018-04-13 07:08:28 +02:00
|
|
|
case 605: M605(); break; // M605: Set Dual X Carriage movement mode
|
2017-09-18 00:24:56 +02:00
|
|
|
#endif
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2018-01-22 17:21:42 +01:00
|
|
|
#if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES)
|
2018-04-13 07:08:28 +02:00
|
|
|
case 701: M701(); break; // M701: Load Filament
|
|
|
|
case 702: M702(); break; // M702: Unload Filament
|
2017-09-06 13:28:31 +02:00
|
|
|
#endif
|
|
|
|
|
2018-06-19 05:04:03 +02:00
|
|
|
#if ENABLED(MAX7219_GCODE)
|
|
|
|
case 7219: M7219(); break; // M7219: Set LEDs, columns, and rows
|
|
|
|
#endif
|
|
|
|
|
2017-09-06 13:28:31 +02:00
|
|
|
#if ENABLED(LIN_ADVANCE)
|
2018-04-13 07:08:28 +02:00
|
|
|
case 900: M900(); break; // M900: Set advance K factor.
|
2017-09-06 13:28:31 +02:00
|
|
|
#endif
|
|
|
|
|
2017-09-24 01:09:14 +02:00
|
|
|
#if HAS_DIGIPOTSS || HAS_MOTOR_CURRENT_PWM || ENABLED(DIGIPOT_I2C) || ENABLED(DAC_STEPPER_CURRENT)
|
2018-04-13 07:08:28 +02:00
|
|
|
case 907: M907(); break; // M907: Set digital trimpot motor current using axis codes.
|
2017-09-24 01:09:14 +02:00
|
|
|
#if HAS_DIGIPOTSS || ENABLED(DAC_STEPPER_CURRENT)
|
2018-04-13 07:08:28 +02:00
|
|
|
case 908: M908(); break; // M908: Control digital trimpot directly.
|
|
|
|
#if ENABLED(DAC_STEPPER_CURRENT)
|
|
|
|
case 909: M909(); break; // M909: Print digipot/DAC current value
|
|
|
|
case 910: M910(); break; // M910: Commit digipot/DAC value to external EEPROM
|
2017-09-24 01:09:14 +02:00
|
|
|
#endif
|
2017-09-06 13:28:31 +02:00
|
|
|
#endif
|
2017-09-18 01:45:21 +02:00
|
|
|
#endif
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2017-12-29 20:38:08 +01:00
|
|
|
#if HAS_TRINAMIC
|
|
|
|
#if ENABLED(TMC_DEBUG)
|
|
|
|
case 122: M122(); break;
|
|
|
|
#endif
|
2018-04-13 07:08:28 +02:00
|
|
|
case 906: M906(); break; // M906: Set motor current in milliamps using axis codes X, Y, Z, E
|
|
|
|
case 911: M911(); break; // M911: Report TMC2130 prewarn triggered flags
|
|
|
|
case 912: M912(); break; // M912: Clear TMC2130 prewarn triggered flags
|
2017-09-06 13:28:31 +02:00
|
|
|
#if ENABLED(HYBRID_THRESHOLD)
|
2018-04-13 07:08:28 +02:00
|
|
|
case 913: M913(); break; // M913: Set HYBRID_THRESHOLD speed.
|
2017-09-06 13:28:31 +02:00
|
|
|
#endif
|
2018-09-09 21:59:12 +02:00
|
|
|
#if USE_SENSORLESS
|
|
|
|
case 914: M914(); break; // M914: Set StallGuard sensitivity.
|
2017-09-06 13:28:31 +02:00
|
|
|
#endif
|
2017-12-29 20:38:08 +01:00
|
|
|
#if ENABLED(TMC_Z_CALIBRATION)
|
2018-04-13 07:08:28 +02:00
|
|
|
case 915: M915(); break; // M915: TMC Z axis calibration.
|
2017-12-29 20:38:08 +01:00
|
|
|
#endif
|
2017-09-06 13:28:31 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if HAS_MICROSTEPS
|
2018-04-13 07:08:28 +02:00
|
|
|
case 350: M350(); break; // M350: Set microstepping mode. Warning: Steps per unit remains unchanged. S code sets stepping mode for all drivers.
|
|
|
|
case 351: M351(); break; // M351: Toggle MS1 MS2 pins directly, S# determines MS1 or MS2, X# sets the pin high/low.
|
2017-09-18 01:48:55 +02:00
|
|
|
#endif
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2018-04-13 07:08:28 +02:00
|
|
|
case 355: M355(); break; // M355: Set case light brightness
|
2017-09-06 13:28:31 +02:00
|
|
|
|
|
|
|
#if ENABLED(DEBUG_GCODE_PARSER)
|
2018-04-13 07:08:28 +02:00
|
|
|
case 800: parser.debug(); break; // M800: GCode Parser Test for M
|
2017-09-06 13:28:31 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if ENABLED(I2C_POSITION_ENCODERS)
|
2018-04-13 07:08:28 +02:00
|
|
|
case 860: M860(); break; // M860: Report encoder module position
|
|
|
|
case 861: M861(); break; // M861: Report encoder module status
|
|
|
|
case 862: M862(); break; // M862: Perform axis test
|
|
|
|
case 863: M863(); break; // M863: Calibrate steps/mm
|
|
|
|
case 864: M864(); break; // M864: Change module address
|
|
|
|
case 865: M865(); break; // M865: Check module firmware version
|
|
|
|
case 866: M866(); break; // M866: Report axis error count
|
|
|
|
case 867: M867(); break; // M867: Toggle error correction
|
|
|
|
case 868: M868(); break; // M868: Set error correction threshold
|
|
|
|
case 869: M869(); break; // M869: Report axis error
|
|
|
|
#endif
|
|
|
|
|
|
|
|
case 999: M999(); break; // M999: Restart after being Stopped
|
2018-04-28 00:40:27 +02:00
|
|
|
|
|
|
|
default: parser.unknown_command_error(); break;
|
2017-09-06 13:28:31 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2018-04-13 07:08:28 +02:00
|
|
|
case 'T': T(parser.codenum); break; // Tn: Tool Change
|
2017-09-06 13:28:31 +02:00
|
|
|
|
|
|
|
default: parser.unknown_command_error();
|
|
|
|
}
|
|
|
|
|
|
|
|
KEEPALIVE_STATE(NOT_BUSY);
|
|
|
|
|
2018-04-18 23:56:10 +02:00
|
|
|
#if ENABLED(USE_EXECUTE_COMMANDS_IMMEDIATE)
|
|
|
|
if (!no_ok)
|
|
|
|
#endif
|
|
|
|
ok_to_send();
|
2017-09-08 05:33:16 +02:00
|
|
|
}
|
2017-09-09 06:49:49 +02:00
|
|
|
|
2017-11-04 22:36:41 +01:00
|
|
|
/**
|
|
|
|
* Process a single command and dispatch it to its handler
|
|
|
|
* This is called from the main loop()
|
|
|
|
*/
|
|
|
|
void GcodeSuite::process_next_command() {
|
|
|
|
char * const current_command = command_queue[cmd_queue_index_r];
|
|
|
|
|
|
|
|
if (DEBUGGING(ECHO)) {
|
|
|
|
SERIAL_ECHO_START();
|
|
|
|
SERIAL_ECHOLN(current_command);
|
|
|
|
#if ENABLED(M100_FREE_MEMORY_WATCHER)
|
|
|
|
SERIAL_ECHOPAIR("slot:", cmd_queue_index_r);
|
|
|
|
M100_dump_routine(" Command Queue:", (const char*)command_queue, (const char*)(command_queue + sizeof(command_queue)));
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
// Parse the next command in the queue
|
|
|
|
parser.parse(current_command);
|
|
|
|
process_parsed_command();
|
|
|
|
}
|
|
|
|
|
2018-04-18 23:56:10 +02:00
|
|
|
#if ENABLED(USE_EXECUTE_COMMANDS_IMMEDIATE)
|
|
|
|
/**
|
|
|
|
* Run a series of commands, bypassing the command queue to allow
|
|
|
|
* G-code "macros" to be called from within other G-code handlers.
|
|
|
|
*/
|
|
|
|
void GcodeSuite::process_subcommands_now_P(const char *pgcode) {
|
|
|
|
// Save the parser state
|
2018-04-28 00:48:52 +02:00
|
|
|
char * const saved_cmd = parser.command_ptr;
|
2018-04-18 23:56:10 +02:00
|
|
|
|
|
|
|
// Process individual commands in string
|
|
|
|
while (pgm_read_byte_near(pgcode)) {
|
|
|
|
// Break up string at '\n' delimiters
|
|
|
|
const char *delim = strchr_P(pgcode, '\n');
|
|
|
|
size_t len = delim ? delim - pgcode : strlen_P(pgcode);
|
|
|
|
char cmd[len + 1];
|
|
|
|
strncpy_P(cmd, pgcode, len);
|
|
|
|
cmd[len] = '\0';
|
|
|
|
pgcode += len;
|
|
|
|
if (delim) pgcode++;
|
|
|
|
|
|
|
|
// Parse the next command in the string
|
|
|
|
parser.parse(cmd);
|
|
|
|
process_parsed_command(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Restore the parser state
|
|
|
|
parser.parse(saved_cmd);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-09-09 06:49:49 +02:00
|
|
|
#if ENABLED(HOST_KEEPALIVE_FEATURE)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Output a "busy" message at regular intervals
|
|
|
|
* while the machine is not accepting commands.
|
|
|
|
*/
|
|
|
|
void GcodeSuite::host_keepalive() {
|
|
|
|
const millis_t ms = millis();
|
|
|
|
static millis_t next_busy_signal_ms = 0;
|
2018-03-21 06:29:09 +01:00
|
|
|
if (!suspend_auto_report && host_keepalive_interval && busy_state != NOT_BUSY) {
|
2017-09-09 06:49:49 +02:00
|
|
|
if (PENDING(ms, next_busy_signal_ms)) return;
|
|
|
|
switch (busy_state) {
|
|
|
|
case IN_HANDLER:
|
|
|
|
case IN_PROCESS:
|
|
|
|
SERIAL_ECHO_START();
|
|
|
|
SERIAL_ECHOLNPGM(MSG_BUSY_PROCESSING);
|
|
|
|
break;
|
|
|
|
case PAUSED_FOR_USER:
|
|
|
|
SERIAL_ECHO_START();
|
|
|
|
SERIAL_ECHOLNPGM(MSG_BUSY_PAUSED_FOR_USER);
|
|
|
|
break;
|
|
|
|
case PAUSED_FOR_INPUT:
|
|
|
|
SERIAL_ECHO_START();
|
|
|
|
SERIAL_ECHOLNPGM(MSG_BUSY_PAUSED_FOR_INPUT);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
next_busy_signal_ms = ms + host_keepalive_interval * 1000UL;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // HOST_KEEPALIVE_FEATURE
|