Browse Source

Localize M119 in Endstops class

Scott Lahteine 8 years ago
parent
commit
5076d12344
3 changed files with 42 additions and 35 deletions
  1. 1
    35
      Marlin/Marlin_main.cpp
  2. 36
    0
      Marlin/endstops.cpp
  3. 5
    0
      Marlin/endstops.h

+ 1
- 35
Marlin/Marlin_main.cpp View File

@@ -4969,41 +4969,7 @@ inline void gcode_M117() {
4969 4969
 /**
4970 4970
  * M119: Output endstop states to serial output
4971 4971
  */
4972
-inline void gcode_M119() {
4973
-  SERIAL_PROTOCOLLN(MSG_M119_REPORT);
4974
-  #if HAS_X_MIN
4975
-    SERIAL_PROTOCOLPGM(MSG_X_MIN);
4976
-    SERIAL_PROTOCOLLN(((READ(X_MIN_PIN)^X_MIN_ENDSTOP_INVERTING) ? MSG_ENDSTOP_HIT : MSG_ENDSTOP_OPEN));
4977
-  #endif
4978
-  #if HAS_X_MAX
4979
-    SERIAL_PROTOCOLPGM(MSG_X_MAX);
4980
-    SERIAL_PROTOCOLLN(((READ(X_MAX_PIN)^X_MAX_ENDSTOP_INVERTING) ? MSG_ENDSTOP_HIT : MSG_ENDSTOP_OPEN));
4981
-  #endif
4982
-  #if HAS_Y_MIN
4983
-    SERIAL_PROTOCOLPGM(MSG_Y_MIN);
4984
-    SERIAL_PROTOCOLLN(((READ(Y_MIN_PIN)^Y_MIN_ENDSTOP_INVERTING) ? MSG_ENDSTOP_HIT : MSG_ENDSTOP_OPEN));
4985
-  #endif
4986
-  #if HAS_Y_MAX
4987
-    SERIAL_PROTOCOLPGM(MSG_Y_MAX);
4988
-    SERIAL_PROTOCOLLN(((READ(Y_MAX_PIN)^Y_MAX_ENDSTOP_INVERTING) ? MSG_ENDSTOP_HIT : MSG_ENDSTOP_OPEN));
4989
-  #endif
4990
-  #if HAS_Z_MIN
4991
-    SERIAL_PROTOCOLPGM(MSG_Z_MIN);
4992
-    SERIAL_PROTOCOLLN(((READ(Z_MIN_PIN)^Z_MIN_ENDSTOP_INVERTING) ? MSG_ENDSTOP_HIT : MSG_ENDSTOP_OPEN));
4993
-  #endif
4994
-  #if HAS_Z_MAX
4995
-    SERIAL_PROTOCOLPGM(MSG_Z_MAX);
4996
-    SERIAL_PROTOCOLLN(((READ(Z_MAX_PIN)^Z_MAX_ENDSTOP_INVERTING) ? MSG_ENDSTOP_HIT : MSG_ENDSTOP_OPEN));
4997
-  #endif
4998
-  #if HAS_Z2_MAX
4999
-    SERIAL_PROTOCOLPGM(MSG_Z2_MAX);
5000
-    SERIAL_PROTOCOLLN(((READ(Z2_MAX_PIN)^Z2_MAX_ENDSTOP_INVERTING) ? MSG_ENDSTOP_HIT : MSG_ENDSTOP_OPEN));
5001
-  #endif
5002
-  #if HAS_Z_PROBE
5003
-    SERIAL_PROTOCOLPGM(MSG_Z_PROBE);
5004
-    SERIAL_PROTOCOLLN(((READ(Z_MIN_PROBE_PIN)^Z_MIN_PROBE_ENDSTOP_INVERTING) ? MSG_ENDSTOP_HIT : MSG_ENDSTOP_OPEN));
5005
-  #endif
5006
-}
4972
+inline void gcode_M119() { endstops.M119(); }
5007 4973
 
5008 4974
 /**
5009 4975
  * M120: Enable endstops and set non-homing endstop state to "enabled"

+ 36
- 0
Marlin/endstops.cpp View File

@@ -157,6 +157,42 @@ void Endstops::report_state() {
157 157
   }
158 158
 } // Endstops::report_state
159 159
 
160
+void Endstops::M119() {
161
+  SERIAL_PROTOCOLLN(MSG_M119_REPORT);
162
+  #if HAS_X_MIN
163
+    SERIAL_PROTOCOLPGM(MSG_X_MIN);
164
+    SERIAL_PROTOCOLLN(((READ(X_MIN_PIN)^X_MIN_ENDSTOP_INVERTING) ? MSG_ENDSTOP_HIT : MSG_ENDSTOP_OPEN));
165
+  #endif
166
+  #if HAS_X_MAX
167
+    SERIAL_PROTOCOLPGM(MSG_X_MAX);
168
+    SERIAL_PROTOCOLLN(((READ(X_MAX_PIN)^X_MAX_ENDSTOP_INVERTING) ? MSG_ENDSTOP_HIT : MSG_ENDSTOP_OPEN));
169
+  #endif
170
+  #if HAS_Y_MIN
171
+    SERIAL_PROTOCOLPGM(MSG_Y_MIN);
172
+    SERIAL_PROTOCOLLN(((READ(Y_MIN_PIN)^Y_MIN_ENDSTOP_INVERTING) ? MSG_ENDSTOP_HIT : MSG_ENDSTOP_OPEN));
173
+  #endif
174
+  #if HAS_Y_MAX
175
+    SERIAL_PROTOCOLPGM(MSG_Y_MAX);
176
+    SERIAL_PROTOCOLLN(((READ(Y_MAX_PIN)^Y_MAX_ENDSTOP_INVERTING) ? MSG_ENDSTOP_HIT : MSG_ENDSTOP_OPEN));
177
+  #endif
178
+  #if HAS_Z_MIN
179
+    SERIAL_PROTOCOLPGM(MSG_Z_MIN);
180
+    SERIAL_PROTOCOLLN(((READ(Z_MIN_PIN)^Z_MIN_ENDSTOP_INVERTING) ? MSG_ENDSTOP_HIT : MSG_ENDSTOP_OPEN));
181
+  #endif
182
+  #if HAS_Z_MAX
183
+    SERIAL_PROTOCOLPGM(MSG_Z_MAX);
184
+    SERIAL_PROTOCOLLN(((READ(Z_MAX_PIN)^Z_MAX_ENDSTOP_INVERTING) ? MSG_ENDSTOP_HIT : MSG_ENDSTOP_OPEN));
185
+  #endif
186
+  #if HAS_Z2_MAX
187
+    SERIAL_PROTOCOLPGM(MSG_Z2_MAX);
188
+    SERIAL_PROTOCOLLN(((READ(Z2_MAX_PIN)^Z2_MAX_ENDSTOP_INVERTING) ? MSG_ENDSTOP_HIT : MSG_ENDSTOP_OPEN));
189
+  #endif
190
+  #if HAS_Z_PROBE
191
+    SERIAL_PROTOCOLPGM(MSG_Z_PROBE);
192
+    SERIAL_PROTOCOLLN(((READ(Z_MIN_PROBE_PIN)^Z_MIN_PROBE_ENDSTOP_INVERTING) ? MSG_ENDSTOP_HIT : MSG_ENDSTOP_OPEN));
193
+  #endif
194
+} // Endstops::M119
195
+
160 196
 // Check endstops - Called from ISR!
161 197
 void Endstops::update() {
162 198
 

+ 5
- 0
Marlin/endstops.h View File

@@ -70,6 +70,11 @@ class Endstops {
70 70
      */
71 71
     void report_state(); //call from somewhere to create an serial error message with the locations the endstops where hit, in case they were triggered
72 72
 
73
+    /**
74
+     * Report endstop positions in response to M119
75
+     */
76
+    void M119();
77
+
73 78
     // Enable / disable endstop checking globally
74 79
     FORCE_INLINE void enable_globally(bool onoff=true) { enabled_globally = enabled = onoff; }
75 80
 

Loading…
Cancel
Save