Skip to content

Commit

Permalink
Make M42 optional
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Oct 9, 2020
1 parent 10543dc commit e3b4367
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 5 deletions.
5 changes: 5 additions & 0 deletions Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
//
Expand Down
6 changes: 6 additions & 0 deletions Marlin/src/gcode/control/M226.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -50,3 +54,5 @@ void GcodeSuite::M226() {
} // pin_state -1 0 1 && pin > -1
} // parser.seen('P')
}

#endif // DIRECT_PIN_CONTROL
7 changes: 6 additions & 1 deletion Marlin/src/gcode/control/M42.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -96,3 +99,5 @@ void GcodeSuite::M42() {
extDigitalWrite(pin, pin_status);
analogWrite(pin, pin_status);
}

#endif // DIRECT_PIN_CONTROL
5 changes: 4 additions & 1 deletion Marlin/src/gcode/gcode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions Marlin/src/gcode/gcode.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<pin> S<value>. LED pin assumed if P is omitted.
* M42 - Change pin status via gcode: M42 P<pin> S<value>. 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<points> X<pos> Y<pos> V<level> E<engage> L<legs> S<chizoid>. (Requires Z_MIN_PROBE_REPEATABILITY_TEST)
* M73 - Set the progress percentage. (Requires LCD_SET_PROGRESS_MANUALLY)
Expand Down Expand Up @@ -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());
Expand Down
2 changes: 2 additions & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ default_src_filter = +<src/*> -<src/config> -<src/HAL> +<src/HAL/shared>
-<src/gcode/calibrate/M425.cpp>
-<src/gcode/calibrate/M666.cpp>
-<src/gcode/calibrate/M852.cpp>
-<src/gcode/control/M42.cpp> -<src/gcode/control/M226.cpp>
-<src/gcode/config/M43.cpp>
-<src/gcode/config/M217.cpp>
-<src/gcode/config/M218.cpp>
Expand Down Expand Up @@ -321,6 +322,7 @@ BACKLASH_GCODE = src_filter=+<src/gcode/calibrate/M425.cpp>
IS_KINEMATIC = src_filter=+<src/gcode/calibrate/M665.cpp>
HAS_EXTRA_ENDSTOPS = src_filter=+<src/gcode/calibrate/M666.cpp>
SKEW_CORRECTION_GCODE = src_filter=+<src/gcode/calibrate/M852.cpp>
DIRECT_PIN_CONTROL = src_filter=+<src/gcode/control/M42.cpp> +<src/gcode/control/M226.cpp>
PINS_DEBUGGING = src_filter=+<src/gcode/config/M43.cpp>
NO_VOLUMETRICS = src_filter=-<src/gcode/config/M200-M205.cpp>
HAS_MULTI_EXTRUDER = src_filter=+<src/gcode/config/M217.cpp>
Expand Down

0 comments on commit e3b4367

Please sign in to comment.