From 5076d123447108bda1782e2cee59ae679197e03c Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 27 Apr 2016 14:46:24 -0700 Subject: [PATCH] Localize M119 in Endstops class --- Marlin/Marlin_main.cpp | 36 +----------------------------------- Marlin/endstops.cpp | 36 ++++++++++++++++++++++++++++++++++++ Marlin/endstops.h | 5 +++++ 3 files changed, 42 insertions(+), 35 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 7cc7c028c..ce85e5091 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -4969,41 +4969,7 @@ inline void gcode_M117() { /** * M119: Output endstop states to serial output */ -inline void gcode_M119() { - SERIAL_PROTOCOLLN(MSG_M119_REPORT); - #if HAS_X_MIN - SERIAL_PROTOCOLPGM(MSG_X_MIN); - SERIAL_PROTOCOLLN(((READ(X_MIN_PIN)^X_MIN_ENDSTOP_INVERTING) ? MSG_ENDSTOP_HIT : MSG_ENDSTOP_OPEN)); - #endif - #if HAS_X_MAX - SERIAL_PROTOCOLPGM(MSG_X_MAX); - SERIAL_PROTOCOLLN(((READ(X_MAX_PIN)^X_MAX_ENDSTOP_INVERTING) ? MSG_ENDSTOP_HIT : MSG_ENDSTOP_OPEN)); - #endif - #if HAS_Y_MIN - SERIAL_PROTOCOLPGM(MSG_Y_MIN); - SERIAL_PROTOCOLLN(((READ(Y_MIN_PIN)^Y_MIN_ENDSTOP_INVERTING) ? MSG_ENDSTOP_HIT : MSG_ENDSTOP_OPEN)); - #endif - #if HAS_Y_MAX - SERIAL_PROTOCOLPGM(MSG_Y_MAX); - SERIAL_PROTOCOLLN(((READ(Y_MAX_PIN)^Y_MAX_ENDSTOP_INVERTING) ? MSG_ENDSTOP_HIT : MSG_ENDSTOP_OPEN)); - #endif - #if HAS_Z_MIN - SERIAL_PROTOCOLPGM(MSG_Z_MIN); - SERIAL_PROTOCOLLN(((READ(Z_MIN_PIN)^Z_MIN_ENDSTOP_INVERTING) ? MSG_ENDSTOP_HIT : MSG_ENDSTOP_OPEN)); - #endif - #if HAS_Z_MAX - SERIAL_PROTOCOLPGM(MSG_Z_MAX); - SERIAL_PROTOCOLLN(((READ(Z_MAX_PIN)^Z_MAX_ENDSTOP_INVERTING) ? MSG_ENDSTOP_HIT : MSG_ENDSTOP_OPEN)); - #endif - #if HAS_Z2_MAX - SERIAL_PROTOCOLPGM(MSG_Z2_MAX); - SERIAL_PROTOCOLLN(((READ(Z2_MAX_PIN)^Z2_MAX_ENDSTOP_INVERTING) ? MSG_ENDSTOP_HIT : MSG_ENDSTOP_OPEN)); - #endif - #if HAS_Z_PROBE - SERIAL_PROTOCOLPGM(MSG_Z_PROBE); - SERIAL_PROTOCOLLN(((READ(Z_MIN_PROBE_PIN)^Z_MIN_PROBE_ENDSTOP_INVERTING) ? MSG_ENDSTOP_HIT : MSG_ENDSTOP_OPEN)); - #endif -} +inline void gcode_M119() { endstops.M119(); } /** * M120: Enable endstops and set non-homing endstop state to "enabled" diff --git a/Marlin/endstops.cpp b/Marlin/endstops.cpp index e3d5f4b82..f87b4c9b6 100644 --- a/Marlin/endstops.cpp +++ b/Marlin/endstops.cpp @@ -157,6 +157,42 @@ void Endstops::report_state() { } } // Endstops::report_state +void Endstops::M119() { + SERIAL_PROTOCOLLN(MSG_M119_REPORT); + #if HAS_X_MIN + SERIAL_PROTOCOLPGM(MSG_X_MIN); + SERIAL_PROTOCOLLN(((READ(X_MIN_PIN)^X_MIN_ENDSTOP_INVERTING) ? MSG_ENDSTOP_HIT : MSG_ENDSTOP_OPEN)); + #endif + #if HAS_X_MAX + SERIAL_PROTOCOLPGM(MSG_X_MAX); + SERIAL_PROTOCOLLN(((READ(X_MAX_PIN)^X_MAX_ENDSTOP_INVERTING) ? MSG_ENDSTOP_HIT : MSG_ENDSTOP_OPEN)); + #endif + #if HAS_Y_MIN + SERIAL_PROTOCOLPGM(MSG_Y_MIN); + SERIAL_PROTOCOLLN(((READ(Y_MIN_PIN)^Y_MIN_ENDSTOP_INVERTING) ? MSG_ENDSTOP_HIT : MSG_ENDSTOP_OPEN)); + #endif + #if HAS_Y_MAX + SERIAL_PROTOCOLPGM(MSG_Y_MAX); + SERIAL_PROTOCOLLN(((READ(Y_MAX_PIN)^Y_MAX_ENDSTOP_INVERTING) ? MSG_ENDSTOP_HIT : MSG_ENDSTOP_OPEN)); + #endif + #if HAS_Z_MIN + SERIAL_PROTOCOLPGM(MSG_Z_MIN); + SERIAL_PROTOCOLLN(((READ(Z_MIN_PIN)^Z_MIN_ENDSTOP_INVERTING) ? MSG_ENDSTOP_HIT : MSG_ENDSTOP_OPEN)); + #endif + #if HAS_Z_MAX + SERIAL_PROTOCOLPGM(MSG_Z_MAX); + SERIAL_PROTOCOLLN(((READ(Z_MAX_PIN)^Z_MAX_ENDSTOP_INVERTING) ? MSG_ENDSTOP_HIT : MSG_ENDSTOP_OPEN)); + #endif + #if HAS_Z2_MAX + SERIAL_PROTOCOLPGM(MSG_Z2_MAX); + SERIAL_PROTOCOLLN(((READ(Z2_MAX_PIN)^Z2_MAX_ENDSTOP_INVERTING) ? MSG_ENDSTOP_HIT : MSG_ENDSTOP_OPEN)); + #endif + #if HAS_Z_PROBE + SERIAL_PROTOCOLPGM(MSG_Z_PROBE); + SERIAL_PROTOCOLLN(((READ(Z_MIN_PROBE_PIN)^Z_MIN_PROBE_ENDSTOP_INVERTING) ? MSG_ENDSTOP_HIT : MSG_ENDSTOP_OPEN)); + #endif +} // Endstops::M119 + // Check endstops - Called from ISR! void Endstops::update() { diff --git a/Marlin/endstops.h b/Marlin/endstops.h index 4cf6f5b08..c7e9c0a38 100644 --- a/Marlin/endstops.h +++ b/Marlin/endstops.h @@ -70,6 +70,11 @@ class Endstops { */ void report_state(); //call from somewhere to create an serial error message with the locations the endstops where hit, in case they were triggered + /** + * Report endstop positions in response to M119 + */ + void M119(); + // Enable / disable endstop checking globally FORCE_INLINE void enable_globally(bool onoff=true) { enabled_globally = enabled = onoff; }