Browse Source

Show all endstops on LCD in checkHitEndstops

Scott Lahteine 8 years ago
parent
commit
7c16e774ca
2 changed files with 30 additions and 16 deletions
  1. 3
    0
      Marlin/language_en.h
  2. 27
    16
      Marlin/stepper.cpp

+ 3
- 0
Marlin/language_en.h View File

@@ -49,6 +49,9 @@
49 49
 #ifndef MSG_SD_REMOVED
50 50
   #define MSG_SD_REMOVED                      "Card removed"
51 51
 #endif
52
+#ifndef MSG_LCD_ENDSTOPS
53
+  #define MSG_LCD_ENDSTOPS                    "Endstops" // Max length 8 characters
54
+#endif
52 55
 #ifndef MSG_MAIN
53 56
   #define MSG_MAIN                            "Main"
54 57
 #endif

+ 27
- 16
Marlin/stepper.cpp View File

@@ -291,28 +291,39 @@ void endstops_hit_on_purpose() { endstop_hit_bits = 0; }
291 291
 
292 292
 void checkHitEndstops() {
293 293
   if (endstop_hit_bits) {
294
+    #if ENABLED(ULTRA_LCD)
295
+      char chrX = ' ', chrY = ' ', chrZ = ' ', chrP = ' ';
296
+      #define _SET_STOP_CHAR(A,C) (chr## A = C)
297
+    #else
298
+      #define _SET_STOP_CHAR(A,C) ;
299
+    #endif
300
+
301
+    #define _ENDSTOP_HIT(A,C) do{ \
302
+      SERIAL_ECHOPAIR(" " STRINGIFY(A) ":", endstops_trigsteps[A ##_AXIS] / axis_steps_per_unit[A ##_AXIS]); \
303
+      _SET_STOP_CHAR(A,C); }while(0)
304
+
305
+    #define _ENDSTOP_HIT_TEST(A,C) \
306
+      if (TEST(endstop_hit_bits, A ##_MIN) || TEST(endstop_hit_bits, A ##_MAX)) \
307
+        _ENDSTOP_HIT(A,C)
308
+
294 309
     SERIAL_ECHO_START;
295 310
     SERIAL_ECHOPGM(MSG_ENDSTOPS_HIT);
296
-    if (TEST(endstop_hit_bits, X_MIN)) {
297
-      SERIAL_ECHOPAIR(" X:", endstops_trigsteps[X_AXIS] / axis_steps_per_unit[X_AXIS]);
298
-      LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT "X");
299
-    }
300
-    if (TEST(endstop_hit_bits, Y_MIN)) {
301
-      SERIAL_ECHOPAIR(" Y:", endstops_trigsteps[Y_AXIS] / axis_steps_per_unit[Y_AXIS]);
302
-      LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT "Y");
303
-    }
304
-    if (TEST(endstop_hit_bits, Z_MIN)) {
305
-      SERIAL_ECHOPAIR(" Z:", endstops_trigsteps[Z_AXIS] / axis_steps_per_unit[Z_AXIS]);
306
-      LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT "Z");
307
-    }
311
+    _ENDSTOP_HIT_TEST(X, 'X');
312
+    _ENDSTOP_HIT_TEST(Y, 'Y');
313
+    _ENDSTOP_HIT_TEST(Z, 'Z');
314
+
308 315
     #if ENABLED(Z_MIN_PROBE_ENDSTOP)
309
-      if (TEST(endstop_hit_bits, Z_MIN_PROBE)) {
310
-        SERIAL_ECHOPAIR(" Z_MIN_PROBE:", endstops_trigsteps[Z_AXIS] / axis_steps_per_unit[Z_AXIS]);
311
-        LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT "ZP");
312
-      }
316
+      #define P_AXIS Z_AXIS
317
+      if (TEST(endstop_hit_bits, Z_MIN_PROBE)) _ENDSTOP_HIT(P, 'P');
313 318
     #endif
314 319
     SERIAL_EOL;
315 320
 
321
+    #if ENABLED(ULTRA_LCD)
322
+      char msg[3 * strlen(MSG_LCD_ENDSTOPS) + 8 + 1]; // Room for a UTF 8 string
323
+      sprintf_P(msg, PSTR(MSG_LCD_ENDSTOPS " %c %c %c %c"), chrX, chrY, chrZ, chrP);
324
+      lcd_setstatus(msg);
325
+    #endif
326
+
316 327
     endstops_hit_on_purpose();
317 328
 
318 329
     #if ENABLED(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED) && ENABLED(SDSUPPORT)

Loading…
Cancel
Save