diff --git a/Marlin/src/feature/caselight.cpp b/Marlin/src/feature/caselight.cpp
index 6d755ff9d5..22ace5871b 100644
--- a/Marlin/src/feature/caselight.cpp
+++ b/Marlin/src/feature/caselight.cpp
@@ -24,7 +24,7 @@
#if HAS_CASE_LIGHT
-int case_light_brightness = CASE_LIGHT_DEFAULT_BRIGHTNESS;
+uint8_t case_light_brightness = CASE_LIGHT_DEFAULT_BRIGHTNESS;
bool case_light_on = CASE_LIGHT_DEFAULT_ON;
#ifndef INVERT_CASE_LIGHT
@@ -33,7 +33,6 @@ bool case_light_on = CASE_LIGHT_DEFAULT_ON;
void update_case_light() {
SET_OUTPUT(CASE_LIGHT_PIN);
- uint8_t case_light_bright = (uint8_t)case_light_brightness;
if (case_light_on) {
if (USEABLE_HARDWARE_PWM(CASE_LIGHT_PIN)) {
analogWrite(CASE_LIGHT_PIN, INVERT_CASE_LIGHT ? 255 - case_light_brightness : case_light_brightness );
diff --git a/Marlin/src/feature/caselight.h b/Marlin/src/feature/caselight.h
index 98b8c7d52b..e97051d2e5 100644
--- a/Marlin/src/feature/caselight.h
+++ b/Marlin/src/feature/caselight.h
@@ -23,7 +23,7 @@
#ifndef __CASELIGHT_H__
#define __CASELIGHT_H__
-extern int case_light_brightness; // LCD routine wants INT
+extern uint8_t case_light_brightness;
extern bool case_light_on;
void update_case_light();
diff --git a/Marlin/src/gcode/config/M200-M205.cpp b/Marlin/src/gcode/config/M200-M205.cpp
new file mode 100644
index 0000000000..b7b9bf56d5
--- /dev/null
+++ b/Marlin/src/gcode/config/M200-M205.cpp
@@ -0,0 +1,129 @@
+/**
+ * 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 .
+ *
+ */
+
+#include "../gcode.h"
+#include "../../Marlin.h"
+#include "../../module/planner.h"
+
+/**
+ * M200: Set filament diameter and set E axis units to cubic units
+ *
+ * T - Optional extruder number. Current extruder if omitted.
+ * D - Diameter of the filament. Use "D0" to switch back to linear units on the E axis.
+ */
+void GcodeSuite::M200() {
+
+ if (get_target_extruder_from_command()) return;
+
+ if (parser.seen('D')) {
+ // setting any extruder filament size disables volumetric on the assumption that
+ // slicers either generate in extruder values as cubic mm or as as filament feeds
+ // for all extruders
+ if ( (parser.volumetric_enabled = (parser.value_linear_units() != 0.0)) )
+ planner.set_filament_size(target_extruder, parser.value_linear_units());
+ }
+ planner.calculate_volumetric_multipliers();
+}
+
+/**
+ * M201: Set max acceleration in units/s^2 for print moves (M201 X1000 Y1000)
+ *
+ * With multiple extruders use T to specify which one.
+ */
+void GcodeSuite::M201() {
+
+ GET_TARGET_EXTRUDER();
+
+ LOOP_XYZE(i) {
+ if (parser.seen(axis_codes[i])) {
+ const uint8_t a = i + (i == E_AXIS ? TARGET_EXTRUDER : 0);
+ planner.max_acceleration_mm_per_s2[a] = parser.value_axis_units((AxisEnum)a);
+ }
+ }
+ // steps per sq second need to be updated to agree with the units per sq second (as they are what is used in the planner)
+ planner.reset_acceleration_rates();
+}
+
+/**
+ * M203: Set maximum feedrate that your machine can sustain (M203 X200 Y200 Z300 E10000) in units/sec
+ *
+ * With multiple extruders use T to specify which one.
+ */
+void GcodeSuite::M203() {
+
+ GET_TARGET_EXTRUDER();
+
+ LOOP_XYZE(i)
+ if (parser.seen(axis_codes[i])) {
+ const uint8_t a = i + (i == E_AXIS ? TARGET_EXTRUDER : 0);
+ planner.max_feedrate_mm_s[a] = parser.value_axis_units((AxisEnum)a);
+ }
+}
+
+/**
+ * M204: Set Accelerations in units/sec^2 (M204 P1200 R3000 T3000)
+ *
+ * P = Printing moves
+ * R = Retract only (no X, Y, Z) moves
+ * T = Travel (non printing) moves
+ *
+ * Also sets minimum segment time in ms (B20000) to prevent buffer under-runs and M20 minimum feedrate
+ */
+void GcodeSuite::M204() {
+ if (parser.seen('S')) { // Kept for legacy compatibility. Should NOT BE USED for new developments.
+ planner.travel_acceleration = planner.acceleration = parser.value_linear_units();
+ SERIAL_ECHOLNPAIR("Setting Print and Travel Acceleration: ", planner.acceleration);
+ }
+ if (parser.seen('P')) {
+ planner.acceleration = parser.value_linear_units();
+ SERIAL_ECHOLNPAIR("Setting Print Acceleration: ", planner.acceleration);
+ }
+ if (parser.seen('R')) {
+ planner.retract_acceleration = parser.value_linear_units();
+ SERIAL_ECHOLNPAIR("Setting Retract Acceleration: ", planner.retract_acceleration);
+ }
+ if (parser.seen('T')) {
+ planner.travel_acceleration = parser.value_linear_units();
+ SERIAL_ECHOLNPAIR("Setting Travel Acceleration: ", planner.travel_acceleration);
+ }
+}
+
+/**
+ * M205: Set Advanced Settings
+ *
+ * S = Min Feed Rate (units/s)
+ * T = Min Travel Feed Rate (units/s)
+ * B = Min Segment Time (µs)
+ * X = Max X Jerk (units/sec^2)
+ * Y = Max Y Jerk (units/sec^2)
+ * Z = Max Z Jerk (units/sec^2)
+ * E = Max E Jerk (units/sec^2)
+ */
+void GcodeSuite::M205() {
+ if (parser.seen('S')) planner.min_feedrate_mm_s = parser.value_linear_units();
+ if (parser.seen('T')) planner.min_travel_feedrate_mm_s = parser.value_linear_units();
+ if (parser.seen('B')) planner.min_segment_time = parser.value_millis();
+ if (parser.seen('X')) planner.max_jerk[X_AXIS] = parser.value_linear_units();
+ if (parser.seen('Y')) planner.max_jerk[Y_AXIS] = parser.value_linear_units();
+ if (parser.seen('Z')) planner.max_jerk[Z_AXIS] = parser.value_linear_units();
+ if (parser.seen('E')) planner.max_jerk[E_AXIS] = parser.value_linear_units();
+}
diff --git a/Marlin/src/gcode/config/M200.cpp b/Marlin/src/gcode/config/M200.cpp
deleted file mode 100644
index 0811716384..0000000000
--- a/Marlin/src/gcode/config/M200.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * 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 .
- *
- */
-
-#include "../gcode.h"
-#include "../../Marlin.h"
-#include "../../module/planner.h"
-
-/**
- * M200: Set filament diameter and set E axis units to cubic units
- *
- * T - Optional extruder number. Current extruder if omitted.
- * D - Diameter of the filament. Use "D0" to switch back to linear units on the E axis.
- */
-void GcodeSuite::M200() {
-
- if (get_target_extruder_from_command()) return;
-
- if (parser.seen('D')) {
- // setting any extruder filament size disables volumetric on the assumption that
- // slicers either generate in extruder values as cubic mm or as as filament feeds
- // for all extruders
- if ( (parser.volumetric_enabled = (parser.value_linear_units() != 0.0)) )
- planner.set_filament_size(target_extruder, parser.value_linear_units());
- }
- planner.calculate_volumetric_multipliers();
-}
diff --git a/Marlin/src/gcode/config/M201.cpp b/Marlin/src/gcode/config/M201.cpp
deleted file mode 100644
index d6740499aa..0000000000
--- a/Marlin/src/gcode/config/M201.cpp
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * 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 .
- *
- */
-
-#include "../gcode.h"
-#include "../../module/planner.h"
-
-/**
- * M201: Set max acceleration in units/s^2 for print moves (M201 X1000 Y1000)
- *
- * With multiple extruders use T to specify which one.
- */
-void GcodeSuite::M201() {
-
- GET_TARGET_EXTRUDER();
-
- LOOP_XYZE(i) {
- if (parser.seen(axis_codes[i])) {
- const uint8_t a = i + (i == E_AXIS ? TARGET_EXTRUDER : 0);
- planner.max_acceleration_mm_per_s2[a] = parser.value_axis_units((AxisEnum)a);
- }
- }
- // steps per sq second need to be updated to agree with the units per sq second (as they are what is used in the planner)
- planner.reset_acceleration_rates();
-}
diff --git a/Marlin/src/gcode/config/M203.cpp b/Marlin/src/gcode/config/M203.cpp
deleted file mode 100644
index 60f9ce37be..0000000000
--- a/Marlin/src/gcode/config/M203.cpp
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * 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 .
- *
- */
-
-#include "../gcode.h"
-#include "../../module/planner.h"
-
-/**
- * M203: Set maximum feedrate that your machine can sustain (M203 X200 Y200 Z300 E10000) in units/sec
- *
- * With multiple extruders use T to specify which one.
- */
-void GcodeSuite::M203() {
-
- GET_TARGET_EXTRUDER();
-
- LOOP_XYZE(i)
- if (parser.seen(axis_codes[i])) {
- const uint8_t a = i + (i == E_AXIS ? TARGET_EXTRUDER : 0);
- planner.max_feedrate_mm_s[a] = parser.value_axis_units((AxisEnum)a);
- }
-}
diff --git a/Marlin/src/gcode/config/M204.cpp b/Marlin/src/gcode/config/M204.cpp
deleted file mode 100644
index c8edcbf971..0000000000
--- a/Marlin/src/gcode/config/M204.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-/**
- * 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 .
- *
- */
-
-#include "../gcode.h"
-#include "../../module/planner.h"
-
-/**
- * M204: Set Accelerations in units/sec^2 (M204 P1200 R3000 T3000)
- *
- * P = Printing moves
- * R = Retract only (no X, Y, Z) moves
- * T = Travel (non printing) moves
- *
- * Also sets minimum segment time in ms (B20000) to prevent buffer under-runs and M20 minimum feedrate
- */
-void GcodeSuite::M204() {
- if (parser.seen('S')) { // Kept for legacy compatibility. Should NOT BE USED for new developments.
- planner.travel_acceleration = planner.acceleration = parser.value_linear_units();
- SERIAL_ECHOLNPAIR("Setting Print and Travel Acceleration: ", planner.acceleration);
- }
- if (parser.seen('P')) {
- planner.acceleration = parser.value_linear_units();
- SERIAL_ECHOLNPAIR("Setting Print Acceleration: ", planner.acceleration);
- }
- if (parser.seen('R')) {
- planner.retract_acceleration = parser.value_linear_units();
- SERIAL_ECHOLNPAIR("Setting Retract Acceleration: ", planner.retract_acceleration);
- }
- if (parser.seen('T')) {
- planner.travel_acceleration = parser.value_linear_units();
- SERIAL_ECHOLNPAIR("Setting Travel Acceleration: ", planner.travel_acceleration);
- }
-}
diff --git a/Marlin/src/gcode/config/M205.cpp b/Marlin/src/gcode/config/M205.cpp
deleted file mode 100644
index e6b39150d0..0000000000
--- a/Marlin/src/gcode/config/M205.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * 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 .
- *
- */
-
-#include "../gcode.h"
-#include "../../module/planner.h"
-
-/**
- * M205: Set Advanced Settings
- *
- * S = Min Feed Rate (units/s)
- * T = Min Travel Feed Rate (units/s)
- * B = Min Segment Time (µs)
- * X = Max X Jerk (units/sec^2)
- * Y = Max Y Jerk (units/sec^2)
- * Z = Max Z Jerk (units/sec^2)
- * E = Max E Jerk (units/sec^2)
- */
-void GcodeSuite::M205() {
- if (parser.seen('S')) planner.min_feedrate_mm_s = parser.value_linear_units();
- if (parser.seen('T')) planner.min_travel_feedrate_mm_s = parser.value_linear_units();
- if (parser.seen('B')) planner.min_segment_time = parser.value_millis();
- if (parser.seen('X')) planner.max_jerk[X_AXIS] = parser.value_linear_units();
- if (parser.seen('Y')) planner.max_jerk[Y_AXIS] = parser.value_linear_units();
- if (parser.seen('Z')) planner.max_jerk[Z_AXIS] = parser.value_linear_units();
- if (parser.seen('E')) planner.max_jerk[E_AXIS] = parser.value_linear_units();
-}
diff --git a/Marlin/src/gcode/control/M108.cpp b/Marlin/src/gcode/control/M108.cpp
deleted file mode 100644
index 238025283e..0000000000
--- a/Marlin/src/gcode/control/M108.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * 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 .
- *
- */
-
-#include "../../inc/MarlinConfig.h"
-
-#if DISABLED(EMERGENCY_PARSER)
-
-#include "../gcode.h"
-#include "../../Marlin.h" // for wait_for_heatup
-
-/**
- * M108: Stop the waiting for heaters in M109, M190, M303. Does not affect the target temperature.
- */
-void GcodeSuite::M108() {
-
- wait_for_heatup = false;
-
-}
-
-#endif // !EMERGENCY_PARSER
diff --git a/Marlin/src/gcode/control/M410.cpp b/Marlin/src/gcode/control/M108_M112_M410.cpp
similarity index 79%
rename from Marlin/src/gcode/control/M410.cpp
rename to Marlin/src/gcode/control/M108_M112_M410.cpp
index f2c12e672d..7b49951266 100644
--- a/Marlin/src/gcode/control/M410.cpp
+++ b/Marlin/src/gcode/control/M108_M112_M410.cpp
@@ -25,7 +25,21 @@
#if DISABLED(EMERGENCY_PARSER)
#include "../gcode.h"
-#include "../../Marlin.h" // for quickstop_stepper
+#include "../../Marlin.h" // for wait_for_heatup, kill, quickstop_stepper
+
+/**
+ * M108: Stop the waiting for heaters in M109, M190, M303. Does not affect the target temperature.
+ */
+void GcodeSuite::M108() {
+ wait_for_heatup = false;
+}
+
+/**
+ * M112: Emergency Stop
+ */
+void GcodeSuite::M112() {
+ kill(PSTR(MSG_KILLED));
+}
/**
* M410: Quickstop - Abort all planned moves
@@ -34,9 +48,7 @@
* will be out of sync with the stepper position after this.
*/
void GcodeSuite::M410() {
-
quickstop_stepper();
-
}
#endif // !EMERGENCY_PARSER
diff --git a/Marlin/src/gcode/control/M112.cpp b/Marlin/src/gcode/control/M112.cpp
deleted file mode 100644
index 40b99ee1be..0000000000
--- a/Marlin/src/gcode/control/M112.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * 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 .
- *
- */
-
-#include "../../inc/MarlinConfig.h"
-
-#if DISABLED(EMERGENCY_PARSER)
-
-#include "../gcode.h"
-#include "../../Marlin.h" // for kill
-
-/**
- * M112: Emergency Stop
- */
-void GcodeSuite::M112() {
-
- kill(PSTR(MSG_KILLED));
-
-}
-
-#endif // !EMERGENCY_PARSER
diff --git a/Marlin/src/gcode/control/M17.cpp b/Marlin/src/gcode/control/M17.cpp
deleted file mode 100644
index 1a089794f7..0000000000
--- a/Marlin/src/gcode/control/M17.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-/**
- * 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 .
- *
- */
-
-#include "../gcode.h"
-#include "../../lcd/ultralcd.h"
-#include "../../Marlin.h"
-
-/**
- * M17: Enable power on all stepper motors
- */
-void GcodeSuite::M17() {
- LCD_MESSAGEPGM(MSG_NO_MOVE);
- enable_all_steppers();
-}
diff --git a/Marlin/src/gcode/control/M18_M84.cpp b/Marlin/src/gcode/control/M17_M18_M84.cpp
similarity index 92%
rename from Marlin/src/gcode/control/M18_M84.cpp
rename to Marlin/src/gcode/control/M17_M18_M84.cpp
index 1fc3bb0b59..8f55d8836b 100644
--- a/Marlin/src/gcode/control/M18_M84.cpp
+++ b/Marlin/src/gcode/control/M17_M18_M84.cpp
@@ -22,13 +22,21 @@
#include "../gcode.h"
#include "../../Marlin.h" // for stepper_inactive_time
+#include "../../lcd/ultralcd.h"
#include "../../module/stepper.h"
#if ENABLED(AUTO_BED_LEVELING_UBL) && ENABLED(ULTRA_LCD)
#include "../../feature/bedlevel/bedlevel.h"
- #include "../../lcd/ultralcd.h"
#endif
+/**
+ * M17: Enable power on all stepper motors
+ */
+void GcodeSuite::M17() {
+ LCD_MESSAGEPGM(MSG_NO_MOVE);
+ enable_all_steppers();
+}
+
/**
* M18, M84: Disable stepper motors
*/
diff --git a/Marlin/src/gcode/feature/digipot/M907.cpp b/Marlin/src/gcode/feature/digipot/M907-M910.cpp
similarity index 75%
rename from Marlin/src/gcode/feature/digipot/M907.cpp
rename to Marlin/src/gcode/feature/digipot/M907-M910.cpp
index 8a1062c10f..10849f2eb8 100644
--- a/Marlin/src/gcode/feature/digipot/M907.cpp
+++ b/Marlin/src/gcode/feature/digipot/M907-M910.cpp
@@ -20,6 +20,10 @@
*
*/
+#include "../../../inc/MarlinConfig.h"
+
+#if HAS_DIGIPOTSS || HAS_MOTOR_CURRENT_PWM || ENABLED(DIGIPOT_I2C) || ENABLED(DAC_STEPPER_CURRENT)
+
#include "../../gcode.h"
#if HAS_DIGIPOTSS || HAS_MOTOR_CURRENT_PWM
@@ -73,3 +77,34 @@ void GcodeSuite::M907() {
LOOP_XYZE(i) if (parser.seen(axis_codes[i])) dac_current_percent(i, parser.value_float());
#endif
}
+
+#if HAS_DIGIPOTSS || ENABLED(DAC_STEPPER_CURRENT)
+
+ /**
+ * M908: Control digital trimpot directly (M908 P S)
+ */
+ void GcodeSuite::M908() {
+ #if HAS_DIGIPOTSS
+ stepper.digitalPotWrite(
+ parser.intval('P'),
+ parser.intval('S')
+ );
+ #endif
+ #if ENABLED(DAC_STEPPER_CURRENT)
+ dac_current_raw(
+ parser.byteval('P', -1),
+ parser.ushortval('S', 0)
+ );
+ #endif
+ }
+
+#endif // HAS_DIGIPOTSS || DAC_STEPPER_CURRENT
+
+#if ENABLED(DAC_STEPPER_CURRENT)
+
+ void GcodeSuite::M909() { dac_print_values(); }
+ void GcodeSuite::M910() { dac_commit_eeprom(); }
+
+#endif // DAC_STEPPER_CURRENT
+
+#endif // HAS_DIGIPOTSS || DAC_STEPPER_CURRENT || HAS_MOTOR_CURRENT_PWM || DIGIPOT_I2C
diff --git a/Marlin/src/gcode/feature/digipot/M908.cpp b/Marlin/src/gcode/feature/digipot/M908.cpp
deleted file mode 100644
index 0422927e34..0000000000
--- a/Marlin/src/gcode/feature/digipot/M908.cpp
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- * 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 .
- *
- */
-
-#include "../../../inc/MarlinConfig.h"
-
-#if HAS_DIGIPOTSS || ENABLED(DAC_STEPPER_CURRENT)
-
-#include "../../gcode.h"
-
-#if HAS_DIGIPOTSS
- #include "../../../module/stepper.h"
-#endif
-
-#if ENABLED(DAC_STEPPER_CURRENT)
- #include "../../../feature/dac/stepper_dac.h"
-#endif
-
-/**
- * M908: Control digital trimpot directly (M908 P S)
- */
-void GcodeSuite::M908() {
- #if HAS_DIGIPOTSS
- stepper.digitalPotWrite(
- parser.intval('P'),
- parser.intval('S')
- );
- #endif
- #if ENABLED(DAC_STEPPER_CURRENT)
- dac_current_raw(
- parser.byteval('P', -1),
- parser.ushortval('S', 0)
- );
- #endif
-}
-
-#endif // HAS_DIGIPOTSS || DAC_STEPPER_CURRENT
diff --git a/Marlin/src/gcode/feature/digipot/M909.cpp b/Marlin/src/gcode/feature/digipot/M909.cpp
deleted file mode 100644
index f23b9afdc5..0000000000
--- a/Marlin/src/gcode/feature/digipot/M909.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * 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 .
- *
- */
-
-#include "../../../inc/MarlinConfig.h"
-
-#if ENABLED(DAC_STEPPER_CURRENT)
-
-#include "../../gcode.h"
-#include "../../../feature/dac/stepper_dac.h"
-
-void GcodeSuite::M909() {
-
- dac_print_values();
-
-}
-
-#endif // DAC_STEPPER_CURRENT
diff --git a/Marlin/src/gcode/feature/digipot/M910.cpp b/Marlin/src/gcode/feature/digipot/M910.cpp
deleted file mode 100644
index 1e717c6e26..0000000000
--- a/Marlin/src/gcode/feature/digipot/M910.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * 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 .
- *
- */
-
-#include "../../../inc/MarlinConfig.h"
-
-#if ENABLED(DAC_STEPPER_CURRENT)
-
-#include "../../gcode.h"
-#include "../../../feature/dac/stepper_dac.h"
-
-void GcodeSuite::M910() {
-
- dac_commit_eeprom();
-
-}
-
-#endif // DAC_STEPPER_CURRENT
diff --git a/Marlin/src/gcode/feature/fwretract/M208.cpp b/Marlin/src/gcode/feature/fwretract/M207-M209.cpp
similarity index 63%
rename from Marlin/src/gcode/feature/fwretract/M208.cpp
rename to Marlin/src/gcode/feature/fwretract/M207-M209.cpp
index 85d234f414..f319cec9c4 100644
--- a/Marlin/src/gcode/feature/fwretract/M208.cpp
+++ b/Marlin/src/gcode/feature/fwretract/M207-M209.cpp
@@ -27,6 +27,21 @@
#include "../../../feature/fwretract.h"
#include "../../gcode.h"
+/**
+ * M207: Set firmware retraction values
+ *
+ * S[+units] retract_length
+ * W[+units] swap_retract_length (multi-extruder)
+ * F[units/min] retract_feedrate_mm_s
+ * Z[units] retract_zlift
+ */
+void GcodeSuite::M207() {
+ if (parser.seen('S')) fwretract.retract_length = parser.value_axis_units(E_AXIS);
+ if (parser.seen('F')) fwretract.retract_feedrate_mm_s = MMM_TO_MMS(parser.value_axis_units(E_AXIS));
+ if (parser.seen('Z')) fwretract.retract_zlift = parser.value_linear_units();
+ if (parser.seen('W')) fwretract.swap_retract_length = parser.value_axis_units(E_AXIS);
+}
+
/**
* M208: Set firmware un-retraction values
*
@@ -42,4 +57,18 @@ void GcodeSuite::M208() {
if (parser.seen('W')) fwretract.swap_retract_recover_length = parser.value_axis_units(E_AXIS);
}
+/**
+ * M209: Enable automatic retract (M209 S1)
+ * For slicers that don't support G10/11, reversed extrude-only
+ * moves will be classified as retraction.
+ */
+void GcodeSuite::M209() {
+ if (MIN_AUTORETRACT <= MAX_AUTORETRACT) {
+ if (parser.seen('S')) {
+ fwretract.autoretract_enabled = parser.value_bool();
+ for (uint8_t i = 0; i < EXTRUDERS; i++) fwretract.retracted[i] = false;
+ }
+ }
+}
+
#endif // FWRETRACT
diff --git a/Marlin/src/gcode/feature/fwretract/M207.cpp b/Marlin/src/gcode/feature/fwretract/M207.cpp
deleted file mode 100644
index 07a043fafe..0000000000
--- a/Marlin/src/gcode/feature/fwretract/M207.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * 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 .
- *
- */
-
-#include "../../../inc/MarlinConfig.h"
-
-#if ENABLED(FWRETRACT)
-
-#include "../../../feature/fwretract.h"
-#include "../../gcode.h"
-
-/**
- * M207: Set firmware retraction values
- *
- * S[+units] retract_length
- * W[+units] swap_retract_length (multi-extruder)
- * F[units/min] retract_feedrate_mm_s
- * Z[units] retract_zlift
- */
-void GcodeSuite::M207() {
- if (parser.seen('S')) fwretract.retract_length = parser.value_axis_units(E_AXIS);
- if (parser.seen('F')) fwretract.retract_feedrate_mm_s = MMM_TO_MMS(parser.value_axis_units(E_AXIS));
- if (parser.seen('Z')) fwretract.retract_zlift = parser.value_linear_units();
- if (parser.seen('W')) fwretract.swap_retract_length = parser.value_axis_units(E_AXIS);
-}
-
-#endif // FWRETRACT
diff --git a/Marlin/src/gcode/feature/fwretract/M209.cpp b/Marlin/src/gcode/feature/fwretract/M209.cpp
deleted file mode 100644
index 7d5a334b86..0000000000
--- a/Marlin/src/gcode/feature/fwretract/M209.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-/**
- * 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 .
- *
- */
-
-#include "../../../inc/MarlinConfig.h"
-
-#if ENABLED(FWRETRACT)
-
-#include "../../../feature/fwretract.h"
-#include "../../gcode.h"
-
-/**
- * M209: Enable automatic retract (M209 S1)
- * For slicers that don't support G10/11, reversed extrude-only
- * moves will be classified as retraction.
- */
-void GcodeSuite::M209() {
- if (MIN_AUTORETRACT <= MAX_AUTORETRACT) {
- if (parser.seen('S')) {
- fwretract.autoretract_enabled = parser.value_bool();
- for (uint8_t i = 0; i < EXTRUDERS; i++) fwretract.retracted[i] = false;
- }
- }
-}
-
-#endif // FWRETRACT
diff --git a/Marlin/src/gcode/feature/mixing/M163.cpp b/Marlin/src/gcode/feature/mixing/M163-M165.cpp
similarity index 57%
rename from Marlin/src/gcode/feature/mixing/M163.cpp
rename to Marlin/src/gcode/feature/mixing/M163-M165.cpp
index 721928289e..34d84163ea 100644
--- a/Marlin/src/gcode/feature/mixing/M163.cpp
+++ b/Marlin/src/gcode/feature/mixing/M163-M165.cpp
@@ -44,4 +44,42 @@ void GcodeSuite::M163() {
}
}
+#if MIXING_VIRTUAL_TOOLS > 1
+
+ /**
+ * M164: Store the current mix factors as a virtual tool.
+ *
+ * S[index] The virtual tool to store
+ *
+ */
+ void GcodeSuite::M164() {
+ const int tool_index = parser.intval('S');
+ if (tool_index < MIXING_VIRTUAL_TOOLS) {
+ normalize_mix();
+ for (uint8_t i = 0; i < MIXING_STEPPERS; i++)
+ mixing_virtual_tool_mix[tool_index][i] = mixing_factor[i];
+ }
+ }
+
+#endif // MIXING_VIRTUAL_TOOLS > 1
+
+#if ENABLED(DIRECT_MIXING_IN_G1)
+
+ /**
+ * M165: Set multiple mix factors for a mixing extruder.
+ * Factors that are left out will be set to 0.
+ * All factors together must add up to 1.0.
+ *
+ * A[factor] Mix factor for extruder stepper 1
+ * B[factor] Mix factor for extruder stepper 2
+ * C[factor] Mix factor for extruder stepper 3
+ * D[factor] Mix factor for extruder stepper 4
+ * H[factor] Mix factor for extruder stepper 5
+ * I[factor] Mix factor for extruder stepper 6
+ *
+ */
+ void GcodeSuite::M165() { gcode_get_mix(); }
+
+#endif // DIRECT_MIXING_IN_G1
+
#endif // MIXING_EXTRUDER
diff --git a/Marlin/src/gcode/feature/mixing/M164.cpp b/Marlin/src/gcode/feature/mixing/M164.cpp
deleted file mode 100644
index 138b374fd9..0000000000
--- a/Marlin/src/gcode/feature/mixing/M164.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * 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 .
- *
- */
-
-#include "../../../inc/MarlinConfig.h"
-
-#if ENABLED(MIXING_EXTRUDER) && MIXING_VIRTUAL_TOOLS > 1
-
-#include "../../gcode.h"
-#include "../../../feature/mixing.h"
-
-/**
- * M164: Store the current mix factors as a virtual tool.
- *
- * S[index] The virtual tool to store
- *
- */
-void GcodeSuite::M164() {
- const int tool_index = parser.intval('S');
- if (tool_index < MIXING_VIRTUAL_TOOLS) {
- normalize_mix();
- for (uint8_t i = 0; i < MIXING_STEPPERS; i++)
- mixing_virtual_tool_mix[tool_index][i] = mixing_factor[i];
- }
-}
-
-#endif // MIXING_EXTRUDER && MIXING_VIRTUAL_TOOLS > 1
diff --git a/Marlin/src/gcode/feature/mixing/M165.cpp b/Marlin/src/gcode/feature/mixing/M165.cpp
deleted file mode 100644
index feaa8248ee..0000000000
--- a/Marlin/src/gcode/feature/mixing/M165.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-/**
- * 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 .
- *
- */
-
-#include "../../../inc/MarlinConfig.h"
-
-#if ENABLED(DIRECT_MIXING_IN_G1)
-
-#include "../../gcode.h"
-#include "../../../feature/mixing.h"
-
-/**
- * M165: Set multiple mix factors for a mixing extruder.
- * Factors that are left out will be set to 0.
- * All factors together must add up to 1.0.
- *
- * A[factor] Mix factor for extruder stepper 1
- * B[factor] Mix factor for extruder stepper 2
- * C[factor] Mix factor for extruder stepper 3
- * D[factor] Mix factor for extruder stepper 4
- * H[factor] Mix factor for extruder stepper 5
- * I[factor] Mix factor for extruder stepper 6
- *
- */
-void GcodeSuite::M165() { gcode_get_mix(); }
-
-#endif // DIRECT_MIXING_IN_G1
diff --git a/Marlin/src/gcode/feature/trinamic/M911-M914.cpp b/Marlin/src/gcode/feature/trinamic/M911-M914.cpp
new file mode 100644
index 0000000000..e6365c6340
--- /dev/null
+++ b/Marlin/src/gcode/feature/trinamic/M911-M914.cpp
@@ -0,0 +1,155 @@
+/**
+ * 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 .
+ *
+ */
+
+#include "../../../inc/MarlinConfig.h"
+
+#if ENABLED(HAVE_TMC2130)
+
+#include "../../gcode.h"
+#include "../../../feature/tmc2130.h"
+#include "../../../module/stepper_indirection.h"
+
+inline void tmc2130_report_otpw(TMC2130Stepper &st, const char name) {
+ SERIAL_CHAR(name);
+ SERIAL_ECHOPGM(" axis temperature prewarn triggered: ");
+ serialprintPGM(st.getOTPW() ? PSTR("true") : PSTR("false"));
+ SERIAL_EOL();
+}
+
+/**
+ * M911: Report TMC2130 stepper driver overtemperature pre-warn flag
+ * The flag is held by the library and persist until manually cleared by M912
+ */
+void GcodeSuite::M911() {
+ const bool reportX = parser.seen('X'), reportY = parser.seen('Y'), reportZ = parser.seen('Z'), reportE = parser.seen('E'),
+ reportAll = (!reportX && !reportY && !reportZ && !reportE) || (reportX && reportY && reportZ && reportE);
+ #if ENABLED(X_IS_TMC2130)
+ if (reportX || reportAll) tmc2130_report_otpw(stepperX, 'X');
+ #endif
+ #if ENABLED(Y_IS_TMC2130)
+ if (reportY || reportAll) tmc2130_report_otpw(stepperY, 'Y');
+ #endif
+ #if ENABLED(Z_IS_TMC2130)
+ if (reportZ || reportAll) tmc2130_report_otpw(stepperZ, 'Z');
+ #endif
+ #if ENABLED(E0_IS_TMC2130)
+ if (reportE || reportAll) tmc2130_report_otpw(stepperE0, 'E');
+ #endif
+}
+
+inline void tmc2130_clear_otpw(TMC2130Stepper &st, const char name) {
+ st.clear_otpw();
+ SERIAL_CHAR(name);
+ SERIAL_ECHOLNPGM(" prewarn flag cleared");
+}
+
+/**
+ * M912: Clear TMC2130 stepper driver overtemperature pre-warn flag held by the library
+ */
+void GcodeSuite::M912() {
+ const bool clearX = parser.seen('X'), clearY = parser.seen('Y'), clearZ = parser.seen('Z'), clearE = parser.seen('E'),
+ clearAll = (!clearX && !clearY && !clearZ && !clearE) || (clearX && clearY && clearZ && clearE);
+ #if ENABLED(X_IS_TMC2130)
+ if (clearX || clearAll) tmc2130_clear_otpw(stepperX, 'X');
+ #endif
+ #if ENABLED(Y_IS_TMC2130)
+ if (clearY || clearAll) tmc2130_clear_otpw(stepperY, 'Y');
+ #endif
+ #if ENABLED(Z_IS_TMC2130)
+ if (clearZ || clearAll) tmc2130_clear_otpw(stepperZ, 'Z');
+ #endif
+ #if ENABLED(E0_IS_TMC2130)
+ if (clearE || clearAll) tmc2130_clear_otpw(stepperE0, 'E');
+ #endif
+}
+
+#if ENABLED(HYBRID_THRESHOLD)
+
+ #include "../../../module/planner.h"
+
+ inline void tmc2130_get_pwmthrs(TMC2130Stepper &st, const char name, const uint16_t spmm) {
+ SERIAL_CHAR(name);
+ SERIAL_ECHOPGM(" stealthChop max speed set to ");
+ SERIAL_ECHOLN(12650000UL * st.microsteps() / (256 * st.stealth_max_speed() * spmm));
+ }
+ inline void tmc2130_set_pwmthrs(TMC2130Stepper &st, const char name, const int32_t thrs, const uint32_t spmm) {
+ st.stealth_max_speed(12650000UL * st.microsteps() / (256 * thrs * spmm));
+ tmc2130_get_pwmthrs(st, name, spmm);
+ }
+
+ /**
+ * M913: Set HYBRID_THRESHOLD speed.
+ */
+ void GcodeSuite::M913() {
+ uint16_t values[XYZE];
+ LOOP_XYZE(i)
+ values[i] = parser.intval(axis_codes[i]);
+
+ #if ENABLED(X_IS_TMC2130)
+ if (values[X_AXIS]) tmc2130_set_pwmthrs(stepperX, 'X', values[X_AXIS], planner.axis_steps_per_mm[X_AXIS]);
+ else tmc2130_get_pwmthrs(stepperX, 'X', planner.axis_steps_per_mm[X_AXIS]);
+ #endif
+ #if ENABLED(Y_IS_TMC2130)
+ if (values[Y_AXIS]) tmc2130_set_pwmthrs(stepperY, 'Y', values[Y_AXIS], planner.axis_steps_per_mm[Y_AXIS]);
+ else tmc2130_get_pwmthrs(stepperY, 'Y', planner.axis_steps_per_mm[Y_AXIS]);
+ #endif
+ #if ENABLED(Z_IS_TMC2130)
+ if (values[Z_AXIS]) tmc2130_set_pwmthrs(stepperZ, 'Z', values[Z_AXIS], planner.axis_steps_per_mm[Z_AXIS]);
+ else tmc2130_get_pwmthrs(stepperZ, 'Z', planner.axis_steps_per_mm[Z_AXIS]);
+ #endif
+ #if ENABLED(E0_IS_TMC2130)
+ if (values[E_AXIS]) tmc2130_set_pwmthrs(stepperE0, 'E', values[E_AXIS], planner.axis_steps_per_mm[E_AXIS]);
+ else tmc2130_get_pwmthrs(stepperE0, 'E', planner.axis_steps_per_mm[E_AXIS]);
+ #endif
+ }
+
+#endif // HYBRID_THRESHOLD
+
+#if ENABLED(SENSORLESS_HOMING)
+
+ inline void tmc2130_get_sgt(TMC2130Stepper &st, const char name) {
+ SERIAL_CHAR(name);
+ SERIAL_ECHOPGM(" driver homing sensitivity set to ");
+ SERIAL_ECHOLN(st.sgt());
+ }
+ inline void tmc2130_set_sgt(TMC2130Stepper &st, const char name, const int8_t sgt_val) {
+ st.sgt(sgt_val);
+ tmc2130_get_sgt(st, name);
+ }
+
+ /**
+ * M914: Set SENSORLESS_HOMING sensitivity.
+ */
+ void GcodeSuite::M914() {
+ #if ENABLED(X_IS_TMC2130)
+ if (parser.seen(axis_codes[X_AXIS])) tmc2130_set_sgt(stepperX, 'X', parser.value_int());
+ else tmc2130_get_sgt(stepperX, 'X');
+ #endif
+ #if ENABLED(Y_IS_TMC2130)
+ if (parser.seen(axis_codes[Y_AXIS])) tmc2130_set_sgt(stepperY, 'Y', parser.value_int());
+ else tmc2130_get_sgt(stepperY, 'Y');
+ #endif
+ }
+
+#endif // SENSORLESS_HOMING
+
+#endif // HAVE_TMC2130
diff --git a/Marlin/src/gcode/feature/trinamic/M911.cpp b/Marlin/src/gcode/feature/trinamic/M911.cpp
deleted file mode 100644
index 9ffbbeae91..0000000000
--- a/Marlin/src/gcode/feature/trinamic/M911.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-/**
- * 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 .
- *
- */
-
-#include "../../../inc/MarlinConfig.h"
-
-#if ENABLED(HAVE_TMC2130)
-
-#include "../../gcode.h"
-#include "../../../feature/tmc2130.h"
-#include "../../../module/stepper_indirection.h"
-
-inline void tmc2130_report_otpw(TMC2130Stepper &st, const char name) {
- SERIAL_CHAR(name);
- SERIAL_ECHOPGM(" axis temperature prewarn triggered: ");
- serialprintPGM(st.getOTPW() ? PSTR("true") : PSTR("false"));
- SERIAL_EOL();
-}
-
-/**
- * M911: Report TMC2130 stepper driver overtemperature pre-warn flag
- * The flag is held by the library and persist until manually cleared by M912
- */
-void GcodeSuite::M911() {
- const bool reportX = parser.seen('X'), reportY = parser.seen('Y'), reportZ = parser.seen('Z'), reportE = parser.seen('E'),
- reportAll = (!reportX && !reportY && !reportZ && !reportE) || (reportX && reportY && reportZ && reportE);
- #if ENABLED(X_IS_TMC2130)
- if (reportX || reportAll) tmc2130_report_otpw(stepperX, 'X');
- #endif
- #if ENABLED(Y_IS_TMC2130)
- if (reportY || reportAll) tmc2130_report_otpw(stepperY, 'Y');
- #endif
- #if ENABLED(Z_IS_TMC2130)
- if (reportZ || reportAll) tmc2130_report_otpw(stepperZ, 'Z');
- #endif
- #if ENABLED(E0_IS_TMC2130)
- if (reportE || reportAll) tmc2130_report_otpw(stepperE0, 'E');
- #endif
-}
-
-#endif // HAVE_TMC2130
diff --git a/Marlin/src/gcode/feature/trinamic/M912.cpp b/Marlin/src/gcode/feature/trinamic/M912.cpp
deleted file mode 100644
index 2931623c7a..0000000000
--- a/Marlin/src/gcode/feature/trinamic/M912.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
-/**
- * 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 .
- *
- */
-
-#include "../../../inc/MarlinConfig.h"
-
-#if ENABLED(HAVE_TMC2130)
-
-#include "../../gcode.h"
-#include "../../../feature/tmc2130.h"
-#include "../../../module/stepper_indirection.h"
-
-inline void tmc2130_clear_otpw(TMC2130Stepper &st, const char name) {
- st.clear_otpw();
- SERIAL_CHAR(name);
- SERIAL_ECHOLNPGM(" prewarn flag cleared");
-}
-
-/**
- * M912: Clear TMC2130 stepper driver overtemperature pre-warn flag held by the library
- */
-void GcodeSuite::M912() {
- const bool clearX = parser.seen('X'), clearY = parser.seen('Y'), clearZ = parser.seen('Z'), clearE = parser.seen('E'),
- clearAll = (!clearX && !clearY && !clearZ && !clearE) || (clearX && clearY && clearZ && clearE);
- #if ENABLED(X_IS_TMC2130)
- if (clearX || clearAll) tmc2130_clear_otpw(stepperX, 'X');
- #endif
- #if ENABLED(Y_IS_TMC2130)
- if (clearY || clearAll) tmc2130_clear_otpw(stepperY, 'Y');
- #endif
- #if ENABLED(Z_IS_TMC2130)
- if (clearZ || clearAll) tmc2130_clear_otpw(stepperZ, 'Z');
- #endif
- #if ENABLED(E0_IS_TMC2130)
- if (clearE || clearAll) tmc2130_clear_otpw(stepperE0, 'E');
- #endif
-}
-
-#endif // HAVE_TMC2130
diff --git a/Marlin/src/gcode/feature/trinamic/M913.cpp b/Marlin/src/gcode/feature/trinamic/M913.cpp
deleted file mode 100644
index 523f94b359..0000000000
--- a/Marlin/src/gcode/feature/trinamic/M913.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-/**
- * 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 .
- *
- */
-
-#include "../../../inc/MarlinConfig.h"
-
-#if ENABLED(HAVE_TMC2130) && ENABLED(HYBRID_THRESHOLD)
-
-#include "../../gcode.h"
-#include "../../../feature/tmc2130.h"
-#include "../../../module/planner.h"
-#include "../../../module/stepper_indirection.h"
-
-inline void tmc2130_get_pwmthrs(TMC2130Stepper &st, const char name, const uint16_t spmm) {
- SERIAL_CHAR(name);
- SERIAL_ECHOPGM(" stealthChop max speed set to ");
- SERIAL_ECHOLN(12650000UL * st.microsteps() / (256 * st.stealth_max_speed() * spmm));
-}
-inline void tmc2130_set_pwmthrs(TMC2130Stepper &st, const char name, const int32_t thrs, const uint32_t spmm) {
- st.stealth_max_speed(12650000UL * st.microsteps() / (256 * thrs * spmm));
- tmc2130_get_pwmthrs(st, name, spmm);
-}
-
-/**
- * M913: Set HYBRID_THRESHOLD speed.
- */
-void GcodeSuite::M913() {
- uint16_t values[XYZE];
- LOOP_XYZE(i)
- values[i] = parser.intval(axis_codes[i]);
-
- #if ENABLED(X_IS_TMC2130)
- if (values[X_AXIS]) tmc2130_set_pwmthrs(stepperX, 'X', values[X_AXIS], planner.axis_steps_per_mm[X_AXIS]);
- else tmc2130_get_pwmthrs(stepperX, 'X', planner.axis_steps_per_mm[X_AXIS]);
- #endif
- #if ENABLED(Y_IS_TMC2130)
- if (values[Y_AXIS]) tmc2130_set_pwmthrs(stepperY, 'Y', values[Y_AXIS], planner.axis_steps_per_mm[Y_AXIS]);
- else tmc2130_get_pwmthrs(stepperY, 'Y', planner.axis_steps_per_mm[Y_AXIS]);
- #endif
- #if ENABLED(Z_IS_TMC2130)
- if (values[Z_AXIS]) tmc2130_set_pwmthrs(stepperZ, 'Z', values[Z_AXIS], planner.axis_steps_per_mm[Z_AXIS]);
- else tmc2130_get_pwmthrs(stepperZ, 'Z', planner.axis_steps_per_mm[Z_AXIS]);
- #endif
- #if ENABLED(E0_IS_TMC2130)
- if (values[E_AXIS]) tmc2130_set_pwmthrs(stepperE0, 'E', values[E_AXIS], planner.axis_steps_per_mm[E_AXIS]);
- else tmc2130_get_pwmthrs(stepperE0, 'E', planner.axis_steps_per_mm[E_AXIS]);
- #endif
-}
-
-#endif // HAVE_TMC2130 && HYBRID_THRESHOLD
diff --git a/Marlin/src/gcode/feature/trinamic/M914.cpp b/Marlin/src/gcode/feature/trinamic/M914.cpp
deleted file mode 100644
index 25aefc1364..0000000000
--- a/Marlin/src/gcode/feature/trinamic/M914.cpp
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- * 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 .
- *
- */
-
-#include "../../../inc/MarlinConfig.h"
-
-#if ENABLED(HAVE_TMC2130) && ENABLED(SENSORLESS_HOMING)
-
-#include "../../gcode.h"
-#include "../../../feature/tmc2130.h"
-#include "../../../module/stepper_indirection.h"
-
-inline void tmc2130_get_sgt(TMC2130Stepper &st, const char name) {
- SERIAL_CHAR(name);
- SERIAL_ECHOPGM(" driver homing sensitivity set to ");
- SERIAL_ECHOLN(st.sgt());
-}
-inline void tmc2130_set_sgt(TMC2130Stepper &st, const char name, const int8_t sgt_val) {
- st.sgt(sgt_val);
- tmc2130_get_sgt(st, name);
-}
-
-/**
- * M914: Set SENSORLESS_HOMING sensitivity.
- */
-void GcodeSuite::M914() {
- #if ENABLED(X_IS_TMC2130)
- if (parser.seen(axis_codes[X_AXIS])) tmc2130_set_sgt(stepperX, 'X', parser.value_int());
- else tmc2130_get_sgt(stepperX, 'X');
- #endif
- #if ENABLED(Y_IS_TMC2130)
- if (parser.seen(axis_codes[Y_AXIS])) tmc2130_set_sgt(stepperY, 'Y', parser.value_int());
- else tmc2130_get_sgt(stepperY, 'Y');
- #endif
-}
-
-#endif // HAVE_TMC2130 && SENSORLESS_HOMING
diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp
index aa8cfd6dfc..1dccf74469 100644
--- a/Marlin/src/gcode/gcode.cpp
+++ b/Marlin/src/gcode/gcode.cpp
@@ -636,13 +636,14 @@ void GcodeSuite::process_next_command() {
case 900: M900(); break; // M900: Set advance K factor.
#endif
- case 907: M907(); break; // M907: Set digital trimpot motor current using axis codes.
-
- #if HAS_DIGIPOTSS || ENABLED(DAC_STEPPER_CURRENT)
- case 908: M908(); break; // M908: Control digital trimpot directly.
- #if ENABLED(DAC_STEPPER_CURRENT) // As with Printrbot RevF
- case 909: M909(); break; // M909: Print digipot/DAC current value
- case 910: M910(); break; // M910: Commit digipot/DAC value to external EEPROM
+ #if HAS_DIGIPOTSS || HAS_MOTOR_CURRENT_PWM || ENABLED(DIGIPOT_I2C) || ENABLED(DAC_STEPPER_CURRENT)
+ case 907: M907(); break; // M907: Set digital trimpot motor current using axis codes.
+ #if HAS_DIGIPOTSS || ENABLED(DAC_STEPPER_CURRENT)
+ case 908: M908(); break; // M908: Control digital trimpot directly.
+ #if ENABLED(DAC_STEPPER_CURRENT) // As with Printrbot RevF
+ case 909: M909(); break; // M909: Print digipot/DAC current value
+ case 910: M910(); break; // M910: Commit digipot/DAC value to external EEPROM
+ #endif
#endif
#endif
diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h
index 4bf97f79c8..48f3bff5be 100644
--- a/Marlin/src/gcode/gcode.h
+++ b/Marlin/src/gcode/gcode.h
@@ -706,13 +706,14 @@ private:
#endif
#endif
- static void M907();
-
- #if HAS_DIGIPOTSS || ENABLED(DAC_STEPPER_CURRENT)
- static void M908();
- #if ENABLED(DAC_STEPPER_CURRENT)
- static void M909();
- static void M910();
+ #if HAS_DIGIPOTSS || HAS_MOTOR_CURRENT_PWM || ENABLED(DIGIPOT_I2C) || ENABLED(DAC_STEPPER_CURRENT)
+ static void M907();
+ #if HAS_DIGIPOTSS || ENABLED(DAC_STEPPER_CURRENT)
+ static void M908();
+ #if ENABLED(DAC_STEPPER_CURRENT)
+ static void M909();
+ static void M910();
+ #endif
#endif
#endif
diff --git a/Marlin/src/gcode/geometry/M206.cpp b/Marlin/src/gcode/geometry/M206.cpp
deleted file mode 100644
index f537e884c8..0000000000
--- a/Marlin/src/gcode/geometry/M206.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * 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 .
- *
- */
-
-#include "../../inc/MarlinConfig.h"
-
-#if HAS_M206_COMMAND
-
-#include "../gcode.h"
-#include "../../module/motion.h"
-
-/**
- * M206: Set Additional Homing Offset (X Y Z). SCARA aliases T=X, P=Y
- *
- * *** @thinkyhead: I recommend deprecating M206 for SCARA in favor of M665.
- * *** M206 for SCARA will remain enabled in 1.1.x for compatibility.
- * *** In the 2.0 release, it will simply be disabled by default.
- */
-void GcodeSuite::M206() {
- LOOP_XYZ(i)
- if (parser.seen(axis_codes[i]))
- set_home_offset((AxisEnum)i, parser.value_linear_units());
-
- #if ENABLED(MORGAN_SCARA)
- if (parser.seen('T')) set_home_offset(A_AXIS, parser.value_linear_units()); // Theta
- if (parser.seen('P')) set_home_offset(B_AXIS, parser.value_linear_units()); // Psi
- #endif
-
- SYNC_PLAN_POSITION_KINEMATIC();
- report_current_position();
-}
-
-#endif // HAS_M206_COMMAND
diff --git a/Marlin/src/gcode/geometry/M428.cpp b/Marlin/src/gcode/geometry/M206_M428.cpp
similarity index 75%
rename from Marlin/src/gcode/geometry/M428.cpp
rename to Marlin/src/gcode/geometry/M206_M428.cpp
index 5ba3635110..a066692df2 100644
--- a/Marlin/src/gcode/geometry/M428.cpp
+++ b/Marlin/src/gcode/geometry/M206_M428.cpp
@@ -30,6 +30,27 @@
#include "../../libs/buzzer.h"
#include "../../Marlin.h" // for axis_homed
+/**
+ * M206: Set Additional Homing Offset (X Y Z). SCARA aliases T=X, P=Y
+ *
+ * *** @thinkyhead: I recommend deprecating M206 for SCARA in favor of M665.
+ * *** M206 for SCARA will remain enabled in 1.1.x for compatibility.
+ * *** In the 2.0 release, it will simply be disabled by default.
+ */
+void GcodeSuite::M206() {
+ LOOP_XYZ(i)
+ if (parser.seen(axis_codes[i]))
+ set_home_offset((AxisEnum)i, parser.value_linear_units());
+
+ #if ENABLED(MORGAN_SCARA)
+ if (parser.seen('T')) set_home_offset(A_AXIS, parser.value_linear_units()); // Theta
+ if (parser.seen('P')) set_home_offset(B_AXIS, parser.value_linear_units()); // Psi
+ #endif
+
+ SYNC_PLAN_POSITION_KINEMATIC();
+ report_current_position();
+}
+
/**
* M428: Set home_offset based on the distance between the
* current_position and the nearest "reference point."
diff --git a/Marlin/src/gcode/sdcard/M20-M30_M32-M34_M928.cpp b/Marlin/src/gcode/sdcard/M20-M30_M32-M34_M928.cpp
new file mode 100644
index 0000000000..001783585f
--- /dev/null
+++ b/Marlin/src/gcode/sdcard/M20-M30_M32-M34_M928.cpp
@@ -0,0 +1,191 @@
+/**
+ * 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 .
+ *
+ */
+
+#include "../../inc/MarlinConfig.h"
+
+#if ENABLED(SDSUPPORT)
+
+#include "../gcode.h"
+#include "../../sd/cardreader.h"
+#include "../../module/printcounter.h"
+#include "../../module/stepper.h"
+
+#if ENABLED(PARK_HEAD_ON_PAUSE)
+ #include "../../feature/pause.h"
+ #include "../queue.h"
+#endif
+
+/**
+ * M20: List SD card to serial output
+ */
+void GcodeSuite::M20() {
+ SERIAL_PROTOCOLLNPGM(MSG_BEGIN_FILE_LIST);
+ card.ls();
+ SERIAL_PROTOCOLLNPGM(MSG_END_FILE_LIST);
+}
+
+/**
+ * M21: Init SD Card
+ */
+void GcodeSuite::M21() { card.initsd(); }
+
+/**
+ * M22: Release SD Card
+ */
+void GcodeSuite::M22() { card.release(); }
+
+/**
+ * M23: Open a file
+ */
+void GcodeSuite::M23() {
+ // Simplify3D includes the size, so zero out all spaces (#7227)
+ for (char *fn = parser.string_arg; *fn; ++fn) if (*fn == ' ') *fn = '\0';
+ card.openFile(parser.string_arg, true);
+}
+
+/**
+ * M24: Start or Resume SD Print
+ */
+void GcodeSuite::M24() {
+ #if ENABLED(PARK_HEAD_ON_PAUSE)
+ resume_print();
+ #endif
+
+ card.startFileprint();
+ print_job_timer.start();
+}
+
+/**
+ * M25: Pause SD Print
+ */
+void GcodeSuite::M25() {
+ card.pauseSDPrint();
+ print_job_timer.pause();
+
+ #if ENABLED(PARK_HEAD_ON_PAUSE)
+ enqueue_and_echo_commands_P(PSTR("M125")); // Must be enqueued with pauseSDPrint set to be last in the buffer
+ #endif
+}
+
+/**
+ * M26: Set SD Card file index
+ */
+void GcodeSuite::M26() {
+ if (card.cardOK && parser.seenval('S'))
+ card.setIndex(parser.value_long());
+}
+
+/**
+ * M27: Get SD Card status
+ */
+void GcodeSuite::M27() { card.getStatus(); }
+
+/**
+ * M28: Start SD Write
+ */
+void GcodeSuite::M28() { card.openFile(parser.string_arg, false); }
+
+/**
+ * M29: Stop SD Write
+ * Processed in write to file routine
+ */
+void GcodeSuite::M29() {
+ // card.saving = false;
+}
+
+/**
+ * M30 : Delete SD Card file
+ */
+void GcodeSuite::M30() {
+ if (card.cardOK) {
+ card.closefile();
+ card.removeFile(parser.string_arg);
+ }
+}
+
+/**
+ * M32: Select file and start SD Print
+ */
+void GcodeSuite::M32() {
+ if (IS_SD_PRINTING)
+ stepper.synchronize();
+
+ char* namestartpos = parser.string_arg;
+ const bool call_procedure = parser.boolval('P');
+
+ if (card.cardOK) {
+ card.openFile(namestartpos, true, call_procedure);
+
+ if (parser.seenval('S'))
+ card.setIndex(parser.value_long());
+
+ card.startFileprint();
+
+ // Procedure calls count as normal print time.
+ if (!call_procedure) print_job_timer.start();
+ }
+}
+
+#if ENABLED(LONG_FILENAME_HOST_SUPPORT)
+
+ /**
+ * M33: Get the long full path of a file or folder
+ *
+ * Parameters:
+ * Case-insensitive DOS-style path to a file or folder
+ *
+ * Example:
+ * M33 miscel~1/armchair/armcha~1.gco
+ *
+ * Output:
+ * /Miscellaneous/Armchair/Armchair.gcode
+ */
+ void GcodeSuite::M33() {
+ card.printLongPath(parser.string_arg);
+ }
+
+#endif // LONG_FILENAME_HOST_SUPPORT
+
+#if ENABLED(SDCARD_SORT_ALPHA) && ENABLED(SDSORT_GCODE)
+
+ /**
+ * M34: Set SD Card Sorting Options
+ */
+ void GcodeSuite::M34() {
+ if (parser.seen('S')) card.setSortOn(parser.value_bool());
+ if (parser.seenval('F')) {
+ const int v = parser.value_long();
+ card.setSortFolders(v < 0 ? -1 : v > 0 ? 1 : 0);
+ }
+ //if (parser.seen('R')) card.setSortReverse(parser.value_bool());
+ }
+
+#endif // SDCARD_SORT_ALPHA && SDSORT_GCODE
+
+/**
+ * M928: Start SD Write
+ */
+void GcodeSuite::M928() {
+ card.openLogFile(parser.string_arg);
+}
+
+#endif // SDSUPPORT
diff --git a/Marlin/src/gcode/sdcard/M20.cpp b/Marlin/src/gcode/sdcard/M20.cpp
deleted file mode 100644
index a5916f5292..0000000000
--- a/Marlin/src/gcode/sdcard/M20.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * 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 .
- *
- */
-
-#include "../../inc/MarlinConfig.h"
-
-#if ENABLED(SDSUPPORT)
-
-#include "../gcode.h"
-#include "../../sd/cardreader.h"
-
-/**
- * M20: List SD card to serial output
- */
-void GcodeSuite::M20() {
- SERIAL_PROTOCOLLNPGM(MSG_BEGIN_FILE_LIST);
- card.ls();
- SERIAL_PROTOCOLLNPGM(MSG_END_FILE_LIST);
-}
-
-#endif // SDSUPPORT
diff --git a/Marlin/src/gcode/sdcard/M21.cpp b/Marlin/src/gcode/sdcard/M21.cpp
deleted file mode 100644
index 90bf3372a0..0000000000
--- a/Marlin/src/gcode/sdcard/M21.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- * 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 .
- *
- */
-
-#include "../../inc/MarlinConfig.h"
-
-#if ENABLED(SDSUPPORT)
-
-#include "../gcode.h"
-#include "../../sd/cardreader.h"
-
-/**
- * M21: Init SD Card
- */
-void GcodeSuite::M21() { card.initsd(); }
-
-#endif // SDSUPPORT
diff --git a/Marlin/src/gcode/sdcard/M22.cpp b/Marlin/src/gcode/sdcard/M22.cpp
deleted file mode 100644
index afb665ae64..0000000000
--- a/Marlin/src/gcode/sdcard/M22.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- * 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 .
- *
- */
-
-#include "../../inc/MarlinConfig.h"
-
-#if ENABLED(SDSUPPORT)
-
-#include "../gcode.h"
-#include "../../sd/cardreader.h"
-
-/**
- * M22: Release SD Card
- */
-void GcodeSuite::M22() { card.release(); }
-
-#endif // SDSUPPORT
diff --git a/Marlin/src/gcode/sdcard/M23.cpp b/Marlin/src/gcode/sdcard/M23.cpp
deleted file mode 100644
index 41211e988a..0000000000
--- a/Marlin/src/gcode/sdcard/M23.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * 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 .
- *
- */
-
-#include "../../inc/MarlinConfig.h"
-
-#if ENABLED(SDSUPPORT)
-
-#include "../gcode.h"
-#include "../../sd/cardreader.h"
-
-/**
- * M23: Open a file
- */
-void GcodeSuite::M23() {
- // Simplify3D includes the size, so zero out all spaces (#7227)
- for (char *fn = parser.string_arg; *fn; ++fn) if (*fn == ' ') *fn = '\0';
- card.openFile(parser.string_arg, true);
-}
-
-#endif // SDSUPPORT
diff --git a/Marlin/src/gcode/sdcard/M24.cpp b/Marlin/src/gcode/sdcard/M24.cpp
deleted file mode 100644
index b85b8864d7..0000000000
--- a/Marlin/src/gcode/sdcard/M24.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- * 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 .
- *
- */
-
-#include "../../inc/MarlinConfig.h"
-
-#if ENABLED(SDSUPPORT)
-
-#include "../gcode.h"
-#include "../../sd/cardreader.h"
-#include "../../module/printcounter.h"
-
-#if ENABLED(PARK_HEAD_ON_PAUSE)
- #include "../../feature/pause.h"
-#endif
-
-/**
- * M24: Start or Resume SD Print
- */
-void GcodeSuite::M24() {
- #if ENABLED(PARK_HEAD_ON_PAUSE)
- resume_print();
- #endif
-
- card.startFileprint();
- print_job_timer.start();
-}
-
-#endif // SDSUPPORT
diff --git a/Marlin/src/gcode/sdcard/M25.cpp b/Marlin/src/gcode/sdcard/M25.cpp
deleted file mode 100644
index 8de3364215..0000000000
--- a/Marlin/src/gcode/sdcard/M25.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- * 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 .
- *
- */
-
-#include "../../inc/MarlinConfig.h"
-
-#if ENABLED(SDSUPPORT)
-
-#include "../gcode.h"
-#include "../../sd/cardreader.h"
-#include "../../module/printcounter.h"
-
-#if ENABLED(PARK_HEAD_ON_PAUSE)
- #include "../queue.h"
-#endif
-
-/**
- * M25: Pause SD Print
- */
-void GcodeSuite::M25() {
- card.pauseSDPrint();
- print_job_timer.pause();
-
- #if ENABLED(PARK_HEAD_ON_PAUSE)
- enqueue_and_echo_commands_P(PSTR("M125")); // Must be enqueued with pauseSDPrint set to be last in the buffer
- #endif
-}
-
-#endif // SDSUPPORT
diff --git a/Marlin/src/gcode/sdcard/M26.cpp b/Marlin/src/gcode/sdcard/M26.cpp
deleted file mode 100644
index 5efbeb393c..0000000000
--- a/Marlin/src/gcode/sdcard/M26.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * 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 .
- *
- */
-
-#include "../../inc/MarlinConfig.h"
-
-#if ENABLED(SDSUPPORT)
-
-#include "../gcode.h"
-#include "../../sd/cardreader.h"
-
-/**
- * M26: Set SD Card file index
- */
-void GcodeSuite::M26() {
- if (card.cardOK && parser.seenval('S'))
- card.setIndex(parser.value_long());
-}
-
-#endif // SDSUPPORT
diff --git a/Marlin/src/gcode/sdcard/M27.cpp b/Marlin/src/gcode/sdcard/M27.cpp
deleted file mode 100644
index 439b976000..0000000000
--- a/Marlin/src/gcode/sdcard/M27.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- * 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 .
- *
- */
-
-#include "../../inc/MarlinConfig.h"
-
-#if ENABLED(SDSUPPORT)
-
-#include "../gcode.h"
-#include "../../sd/cardreader.h"
-
-/**
- * M27: Get SD Card status
- */
-void GcodeSuite::M27() { card.getStatus(); }
-
-#endif // SDSUPPORT
diff --git a/Marlin/src/gcode/sdcard/M28.cpp b/Marlin/src/gcode/sdcard/M28.cpp
deleted file mode 100644
index 82200e83ab..0000000000
--- a/Marlin/src/gcode/sdcard/M28.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-/**
- * 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 .
- *
- */
-
-#include "../../inc/MarlinConfig.h"
-
-#if ENABLED(SDSUPPORT)
-
-#include "../gcode.h"
-#include "../../sd/cardreader.h"
-
-/**
- * M28: Start SD Write
- */
-void GcodeSuite::M28() { card.openFile(parser.string_arg, false); }
-
-#endif // SDSUPPORT
diff --git a/Marlin/src/gcode/sdcard/M29.cpp b/Marlin/src/gcode/sdcard/M29.cpp
deleted file mode 100644
index c5e2081cd3..0000000000
--- a/Marlin/src/gcode/sdcard/M29.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * 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 .
- *
- */
-
-#include "../../inc/MarlinConfig.h"
-
-#if ENABLED(SDSUPPORT)
-
-#include "../gcode.h"
-#include "../../sd/cardreader.h"
-
-/**
- * M29: Stop SD Write
- * Processed in write to file routine above
- */
-void GcodeSuite::M29() {
- // card.saving = false;
-}
-
-#endif // SDSUPPORT
diff --git a/Marlin/src/gcode/sdcard/M30.cpp b/Marlin/src/gcode/sdcard/M30.cpp
deleted file mode 100644
index 94335fe0f5..0000000000
--- a/Marlin/src/gcode/sdcard/M30.cpp
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * 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 .
- *
- */
-
-#include "../../inc/MarlinConfig.h"
-
-#if ENABLED(SDSUPPORT)
-
-#include "../gcode.h"
-#include "../../sd/cardreader.h"
-
-/**
- * M30 : Delete SD Card file
- */
-void GcodeSuite::M30() {
- if (card.cardOK) {
- card.closefile();
- card.removeFile(parser.string_arg);
- }
-}
-
-#endif // SDSUPPORT
diff --git a/Marlin/src/gcode/sdcard/M32.cpp b/Marlin/src/gcode/sdcard/M32.cpp
deleted file mode 100644
index de864f9cb3..0000000000
--- a/Marlin/src/gcode/sdcard/M32.cpp
+++ /dev/null
@@ -1,55 +0,0 @@
-/**
- * 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 .
- *
- */
-
-#include "../../inc/MarlinConfig.h"
-
-#if ENABLED(SDSUPPORT)
-
-#include "../gcode.h"
-#include "../../sd/cardreader.h"
-#include "../../module/stepper.h"
-#include "../../module/printcounter.h"
-
-/**
- * M32: Select file and start SD Print
- */
-void GcodeSuite::M32() {
- if (IS_SD_PRINTING)
- stepper.synchronize();
-
- char* namestartpos = parser.string_arg;
- const bool call_procedure = parser.boolval('P');
-
- if (card.cardOK) {
- card.openFile(namestartpos, true, call_procedure);
-
- if (parser.seenval('S'))
- card.setIndex(parser.value_long());
-
- card.startFileprint();
-
- // Procedure calls count as normal print time.
- if (!call_procedure) print_job_timer.start();
- }
-}
-
-#endif // SDSUPPORT
diff --git a/Marlin/src/gcode/sdcard/M33.cpp b/Marlin/src/gcode/sdcard/M33.cpp
deleted file mode 100644
index 69933df999..0000000000
--- a/Marlin/src/gcode/sdcard/M33.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- * 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 .
- *
- */
-
-#include "../../inc/MarlinConfig.h"
-
-#if ENABLED(SDSUPPORT) && ENABLED(LONG_FILENAME_HOST_SUPPORT)
-
-#include "../gcode.h"
-#include "../../sd/cardreader.h"
-
-/**
- * M33: Get the long full path of a file or folder
- *
- * Parameters:
- * Case-insensitive DOS-style path to a file or folder
- *
- * Example:
- * M33 miscel~1/armchair/armcha~1.gco
- *
- * Output:
- * /Miscellaneous/Armchair/Armchair.gcode
- */
-void GcodeSuite::M33() {
- card.printLongPath(parser.string_arg);
-}
-
-#endif // SDSUPPORT && LONG_FILENAME_HOST_SUPPORT
diff --git a/Marlin/src/gcode/sdcard/M34.cpp b/Marlin/src/gcode/sdcard/M34.cpp
deleted file mode 100644
index 911539d408..0000000000
--- a/Marlin/src/gcode/sdcard/M34.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * 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 .
- *
- */
-
-#include "../../inc/MarlinConfig.h"
-
-#if ENABLED(SDSUPPORT) && ENABLED(SDCARD_SORT_ALPHA) && ENABLED(SDSORT_GCODE)
-
-#include "../gcode.h"
-#include "../../sd/cardreader.h"
-
-/**
- * M34: Set SD Card Sorting Options
- */
-void GcodeSuite::M34() {
- if (parser.seen('S')) card.setSortOn(parser.value_bool());
- if (parser.seenval('F')) {
- const int v = parser.value_long();
- card.setSortFolders(v < 0 ? -1 : v > 0 ? 1 : 0);
- }
- //if (parser.seen('R')) card.setSortReverse(parser.value_bool());
-}
-
-#endif // SDSUPPORT && SDCARD_SORT_ALPHA && SDSORT_GCODE
diff --git a/Marlin/src/gcode/sdcard/M928.cpp b/Marlin/src/gcode/sdcard/M928.cpp
deleted file mode 100644
index 069448f0b9..0000000000
--- a/Marlin/src/gcode/sdcard/M928.cpp
+++ /dev/null
@@ -1,37 +0,0 @@
-/**
- * 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 .
- *
- */
-
-#include "../../inc/MarlinConfig.h"
-
-#if ENABLED(SDSUPPORT)
-
-#include "../gcode.h"
-#include "../../sd/cardreader.h"
-
-/**
- * M928: Start SD Write
- */
-void GcodeSuite::M928() {
- card.openLogFile(parser.string_arg);
-}
-
-#endif // SDSUPPORT
diff --git a/Marlin/src/gcode/stats/M75-M77.cpp b/Marlin/src/gcode/stats/M75-M77.cpp
deleted file mode 100644
index 1f506d360e..0000000000
--- a/Marlin/src/gcode/stats/M75-M77.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * 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 .
- *
- */
-
-#include "../gcode.h"
-#include "../../module/printcounter.h"
-
-/**
- * M75: Start print timer
- */
-void GcodeSuite::M75() { print_job_timer.start(); }
-
-/**
- * M76: Pause print timer
- */
-void GcodeSuite::M76() { print_job_timer.pause(); }
-
-/**
- * M77: Stop print timer
- */
-void GcodeSuite::M77() { print_job_timer.stop(); }
diff --git a/Marlin/src/gcode/stats/M78.cpp b/Marlin/src/gcode/stats/M75-M78.cpp
similarity index 82%
rename from Marlin/src/gcode/stats/M78.cpp
rename to Marlin/src/gcode/stats/M75-M78.cpp
index 9ea79572c2..351efd10c7 100644
--- a/Marlin/src/gcode/stats/M78.cpp
+++ b/Marlin/src/gcode/stats/M75-M78.cpp
@@ -20,13 +20,26 @@
*
*/
-#include "../../inc/MarlinConfig.h"
-
-#if ENABLED(PRINTCOUNTER)
-
#include "../gcode.h"
#include "../../module/printcounter.h"
+/**
+ * M75: Start print timer
+ */
+void GcodeSuite::M75() { print_job_timer.start(); }
+
+/**
+ * M76: Pause print timer
+ */
+void GcodeSuite::M76() { print_job_timer.pause(); }
+
+/**
+ * M77: Stop print timer
+ */
+void GcodeSuite::M77() { print_job_timer.stop(); }
+
+#if ENABLED(PRINTCOUNTER)
+
/**
* M78: Show print statistics
*/
diff --git a/Marlin/src/gcode/temperature/M104.cpp b/Marlin/src/gcode/temperature/M104.cpp
deleted file mode 100644
index 025a6f0324..0000000000
--- a/Marlin/src/gcode/temperature/M104.cpp
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * 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 .
- *
- */
-
-#include "../gcode.h"
-#include "../../module/temperature.h"
-#include "../../module/motion.h"
-#include "../../module/planner.h"
-#include "../../lcd/ultralcd.h"
-
-#if ENABLED(PRINTJOB_TIMER_AUTOSTART)
- #include "../../module/printcounter.h"
-#endif
-
-/**
- * M104: Set hot end temperature
- */
-void GcodeSuite::M104() {
- if (get_target_extruder_from_command()) return;
- if (DEBUGGING(DRYRUN)) return;
-
- const uint8_t e = target_extruder;
-
- #if ENABLED(SINGLENOZZLE)
- if (e != active_extruder) return;
- #endif
-
- if (parser.seenval('S')) {
- const int16_t temp = parser.value_celsius();
- thermalManager.setTargetHotend(temp, e);
-
- #if ENABLED(DUAL_X_CARRIAGE)
- if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && e == 0)
- thermalManager.setTargetHotend(temp ? temp + duplicate_extruder_temp_offset : 0, 1);
- #endif
-
- #if ENABLED(PRINTJOB_TIMER_AUTOSTART)
- /**
- * Stop the timer at the end of print. Start is managed by 'heat and wait' M109.
- * We use half EXTRUDE_MINTEMP here to allow nozzles to be put into hot
- * standby mode, for instance in a dual extruder setup, without affecting
- * the running print timer.
- */
- if (parser.value_celsius() <= (EXTRUDE_MINTEMP) / 2) {
- print_job_timer.stop();
- LCD_MESSAGEPGM(WELCOME_MSG);
- }
- #endif
-
- if (parser.value_celsius() > thermalManager.degHotend(e))
- lcd_status_printf_P(0, PSTR("E%i %s"), e + 1, MSG_HEATING);
- }
-
- #if ENABLED(AUTOTEMP)
- planner.autotemp_M104_M109();
- #endif
-}
diff --git a/Marlin/src/gcode/temperature/M109.cpp b/Marlin/src/gcode/temperature/M104_M109.cpp
similarity index 83%
rename from Marlin/src/gcode/temperature/M109.cpp
rename to Marlin/src/gcode/temperature/M104_M109.cpp
index 58fe364e56..44bf51a997 100644
--- a/Marlin/src/gcode/temperature/M109.cpp
+++ b/Marlin/src/gcode/temperature/M104_M109.cpp
@@ -22,6 +22,7 @@
#include "../gcode.h"
#include "../../module/temperature.h"
+#include "../../module/motion.h"
#include "../../module/planner.h"
#include "../../lcd/ultralcd.h"
#include "../../Marlin.h"
@@ -30,14 +31,54 @@
#include "../../module/printcounter.h"
#endif
-#if ENABLED(DUAL_X_CARRIAGE)
- #include "../../module/motion.h"
-#endif
-
#if HAS_COLOR_LEDS
#include "../../feature/leds/leds.h"
#endif
+/**
+ * M104: Set hot end temperature
+ */
+void GcodeSuite::M104() {
+ if (get_target_extruder_from_command()) return;
+ if (DEBUGGING(DRYRUN)) return;
+
+ const uint8_t e = target_extruder;
+
+ #if ENABLED(SINGLENOZZLE)
+ if (e != active_extruder) return;
+ #endif
+
+ if (parser.seenval('S')) {
+ const int16_t temp = parser.value_celsius();
+ thermalManager.setTargetHotend(temp, e);
+
+ #if ENABLED(DUAL_X_CARRIAGE)
+ if (dual_x_carriage_mode == DXC_DUPLICATION_MODE && e == 0)
+ thermalManager.setTargetHotend(temp ? temp + duplicate_extruder_temp_offset : 0, 1);
+ #endif
+
+ #if ENABLED(PRINTJOB_TIMER_AUTOSTART)
+ /**
+ * Stop the timer at the end of print. Start is managed by 'heat and wait' M109.
+ * We use half EXTRUDE_MINTEMP here to allow nozzles to be put into hot
+ * standby mode, for instance in a dual extruder setup, without affecting
+ * the running print timer.
+ */
+ if (parser.value_celsius() <= (EXTRUDE_MINTEMP) / 2) {
+ print_job_timer.stop();
+ LCD_MESSAGEPGM(WELCOME_MSG);
+ }
+ #endif
+
+ if (parser.value_celsius() > thermalManager.degHotend(e))
+ lcd_status_printf_P(0, PSTR("E%i %s"), e + 1, MSG_HEATING);
+ }
+
+ #if ENABLED(AUTOTEMP)
+ planner.autotemp_M104_M109();
+ #endif
+}
+
/**
* M109: Sxxx Wait for extruder(s) to reach temperature. Waits only when heating.
* Rxxx Wait for extruder(s) to reach temperature. Waits when heating and cooling.
diff --git a/Marlin/src/gcode/temperature/M140.cpp b/Marlin/src/gcode/temperature/M140.cpp
deleted file mode 100644
index f30d04c163..0000000000
--- a/Marlin/src/gcode/temperature/M140.cpp
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * 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 .
- *
- */
-
-#include "../../inc/MarlinConfig.h"
-
-#if HAS_HEATER_BED && HAS_TEMP_BED
-
-#include "../gcode.h"
-#include "../../module/temperature.h"
-
-/**
- * M140: Set bed temperature
- */
-void GcodeSuite::M140() {
- if (DEBUGGING(DRYRUN)) return;
- if (parser.seenval('S')) thermalManager.setTargetBed(parser.value_celsius());
-}
-
-#endif // HAS_HEATER_BED && HAS_TEMP_BED
diff --git a/Marlin/src/gcode/temperature/M190.cpp b/Marlin/src/gcode/temperature/M140_M190.cpp
similarity index 96%
rename from Marlin/src/gcode/temperature/M190.cpp
rename to Marlin/src/gcode/temperature/M140_M190.cpp
index ef18a50ebe..b48dd44a33 100644
--- a/Marlin/src/gcode/temperature/M190.cpp
+++ b/Marlin/src/gcode/temperature/M140_M190.cpp
@@ -25,8 +25,8 @@
#if HAS_HEATER_BED && HAS_TEMP_BED
#include "../gcode.h"
-#include "../../module/motion.h"
#include "../../module/temperature.h"
+#include "../../module/motion.h"
#include "../../lcd/ultralcd.h"
#if ENABLED(PRINTJOB_TIMER_AUTOSTART)
@@ -39,6 +39,14 @@
#include "../../Marlin.h" // for wait_for_heatup and idle()
+/**
+ * M140: Set bed temperature
+ */
+void GcodeSuite::M140() {
+ if (DEBUGGING(DRYRUN)) return;
+ if (parser.seenval('S')) thermalManager.setTargetBed(parser.value_celsius());
+}
+
#ifndef MIN_COOLING_SLOPE_DEG_BED
#define MIN_COOLING_SLOPE_DEG_BED 1.50
#endif
diff --git a/Marlin/src/lcd/ultralcd.cpp b/Marlin/src/lcd/ultralcd.cpp
index 386b8aa9bc..b10eff5e3f 100644
--- a/Marlin/src/lcd/ultralcd.cpp
+++ b/Marlin/src/lcd/ultralcd.cpp
@@ -761,9 +761,7 @@ void kill_screen(const char* lcd_msg) {
#if ENABLED(MENU_ITEM_CASE_LIGHT)
- extern int case_light_brightness;
- extern bool case_light_on;
- extern void update_case_light();
+ #include "../feature/caselight.h"
void case_light_menu() {
START_MENU();
@@ -771,7 +769,7 @@ void kill_screen(const char* lcd_msg) {
// ^ Main
//
MENU_BACK(MSG_MAIN);
- MENU_ITEM_EDIT_CALLBACK(int3, MSG_CASE_LIGHT_BRIGHTNESS, &case_light_brightness, 0, 255, update_case_light, true);
+ MENU_ITEM_EDIT_CALLBACK(int8, MSG_CASE_LIGHT_BRIGHTNESS, &case_light_brightness, 0, 255, update_case_light, true);
MENU_ITEM_EDIT_CALLBACK(bool, MSG_CASE_LIGHT, (bool*)&case_light_on, update_case_light);
END_MENU();
}