diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 8cc71ceb86325..59a1813610ff9 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -3559,6 +3559,11 @@ // //#define M100_FREE_MEMORY_WATCHER +// +// M42 - Set pin states +// +//#define DIRECT_PIN_CONTROL + // // M43 - display pin status, toggle pins, watch pins, watch endstops & toggle LED, test servo probe // diff --git a/Marlin/src/gcode/control/M226.cpp b/Marlin/src/gcode/control/M226.cpp index 52e0e57a87f07..0ab89644dd9ed 100644 --- a/Marlin/src/gcode/control/M226.cpp +++ b/Marlin/src/gcode/control/M226.cpp @@ -20,6 +20,10 @@ * */ +#include "../../MarlinConfig.h" + +#if ENABLED(DIRECT_PIN_CONTROL) + #include "../gcode.h" #include "../../MarlinCore.h" // for pin_is_protected and idle() #include "../../module/stepper.h" @@ -50,3 +54,5 @@ void GcodeSuite::M226() { } // pin_state -1 0 1 && pin > -1 } // parser.seen('P') } + +#endif // DIRECT_PIN_CONTROL diff --git a/Marlin/src/gcode/control/M42.cpp b/Marlin/src/gcode/control/M42.cpp index c88113db49df0..c635c06ec63bd 100644 --- a/Marlin/src/gcode/control/M42.cpp +++ b/Marlin/src/gcode/control/M42.cpp @@ -20,9 +20,12 @@ * */ +#include "../../inc/MarlinConfig.h" + +#if ENABLED(DIRECT_PIN_CONTROL) + #include "../gcode.h" #include "../../MarlinCore.h" // for pin_is_protected -#include "../../inc/MarlinConfig.h" #if HAS_FAN #include "../../module/temperature.h" @@ -96,3 +99,5 @@ void GcodeSuite::M42() { extDigitalWrite(pin, pin_status); analogWrite(pin, pin_status); } + +#endif // DIRECT_PIN_CONTROL diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index 1de54259beb78..c93d5c6e888d0 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -445,7 +445,10 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { #endif // SDSUPPORT case 31: M31(); break; // M31: Report time since the start of SD print or last M109 - case 42: M42(); break; // M42: Change pin state + + #if ENABLED(DIRECT_PIN_CONTROL) + case 42: M42(); break; // M42: Change pin state + #endif #if ENABLED(PINS_DEBUGGING) case 43: M43(); break; // M43: Read pin state diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index 026083bcfc7ba..53ec07b15a8ed 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -109,7 +109,7 @@ * The '#' is necessary when calling from within sd files, as it stops buffer prereading * M33 - Get the longname version of a path. (Requires LONG_FILENAME_HOST_SUPPORT) * M34 - Set SD Card sorting options. (Requires SDCARD_SORT_ALPHA) - * M42 - Change pin status via gcode: M42 P S. LED pin assumed if P is omitted. + * M42 - Change pin status via gcode: M42 P S. LED pin assumed if P is omitted. (Requires DIRECT_PIN_CONTROL) * M43 - Display pin status, watch pins for changes, watch endstops & toggle LED, Z servo probe test, toggle pins * M48 - Measure Z Probe repeatability: M48 P X Y V E L S. (Requires Z_MIN_PROBE_REPEATABILITY_TEST) * M73 - Set the progress percentage. (Requires LCD_SET_PROGRESS_MANUALLY) @@ -541,8 +541,7 @@ class GcodeSuite { #endif #endif - static void M42(); - + TERN_(DIRECT_PIN_CONTROL, static void M42()); TERN_(PINS_DEBUGGING, static void M43()); TERN_(Z_MIN_PROBE_REPEATABILITY_TEST, static void M48()); diff --git a/platformio.ini b/platformio.ini index 4628baec9a2fc..ea94fa04a7155 100644 --- a/platformio.ini +++ b/platformio.ini @@ -119,6 +119,7 @@ default_src_filter = + - - + - - - + - - - - - @@ -321,6 +322,7 @@ BACKLASH_GCODE = src_filter=+ IS_KINEMATIC = src_filter=+ HAS_EXTRA_ENDSTOPS = src_filter=+ SKEW_CORRECTION_GCODE = src_filter=+ +DIRECT_PIN_CONTROL = src_filter=+ + PINS_DEBUGGING = src_filter=+ NO_VOLUMETRICS = src_filter=- HAS_MULTI_EXTRUDER = src_filter=+