From 10fab24e508147a2e6921f1e2372eca68f8c8e8d Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 16 Sep 2017 03:42:05 -0500 Subject: [PATCH] Move M42 to cpp --- Marlin/src/Marlin.cpp | 4 +--- Marlin/src/Marlin.h | 2 ++ Marlin/src/gcode/control/{M42.h => M42.cpp} | 6 +++++- Marlin/src/gcode/gcode.cpp | 4 +--- 4 files changed, 9 insertions(+), 7 deletions(-) rename Marlin/src/gcode/control/{M42.h => M42.cpp} (92%) diff --git a/Marlin/src/Marlin.cpp b/Marlin/src/Marlin.cpp index 1d25ee8f06..34a7f9ce12 100644 --- a/Marlin/src/Marlin.cpp +++ b/Marlin/src/Marlin.cpp @@ -363,15 +363,13 @@ void suicide() { /** * Sensitive pin test for M42, M226 */ -static bool pin_is_protected(const int8_t pin) { +bool pin_is_protected(const int8_t pin) { static const int8_t sensitive_pins[] PROGMEM = SENSITIVE_PINS; for (uint8_t i = 0; i < COUNT(sensitive_pins); i++) if (pin == (int8_t)pgm_read_byte(&sensitive_pins[i])) return true; return false; } -#include "gcode/control/M42.h" - #if ENABLED(PINS_DEBUGGING) #include "gcode/config/M43.h" #endif diff --git a/Marlin/src/Marlin.h b/Marlin/src/Marlin.h index 7695f03e5b..3918e38a1e 100644 --- a/Marlin/src/Marlin.h +++ b/Marlin/src/Marlin.h @@ -228,4 +228,6 @@ extern volatile bool wait_for_heatup; void calculate_volumetric_multipliers(); +bool pin_is_protected(const int8_t pin); + #endif // __MARLIN_H__ diff --git a/Marlin/src/gcode/control/M42.h b/Marlin/src/gcode/control/M42.cpp similarity index 92% rename from Marlin/src/gcode/control/M42.h rename to Marlin/src/gcode/control/M42.cpp index ec559d6911..44a1892ec3 100644 --- a/Marlin/src/gcode/control/M42.h +++ b/Marlin/src/gcode/control/M42.cpp @@ -20,13 +20,17 @@ * */ +#include "../gcode.h" +#include "../../Marlin.h" // for pin_is_protected +#include "../../inc/MarlinConfig.h" + /** * M42: Change pin status via GCode * * P Pin number (LED if omitted) * S Pin status from 0 - 255 */ -void gcode_M42() { +void GcodeSuite::M42() { if (!parser.seenval('S')) return; const byte pin_status = parser.value_byte(); diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index 8b886593ee..547b03b242 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -117,7 +117,6 @@ void GcodeSuite::dwell(millis_t time) { // Placeholders for non-migrated codes // extern void gcode_M18_M84(); -extern void gcode_M42(); extern void gcode_M43(); extern void gcode_M48(); extern void gcode_M75(); @@ -433,8 +432,7 @@ void GcodeSuite::process_next_command() { case 31: M31(); break; // M31: Report time since the start of SD print or last M109 - case 42: // M42: Change pin state - gcode_M42(); break; + case 42: M42(); break; // M42: Change pin state #if ENABLED(PINS_DEBUGGING) case 43: // M43: Read pin state