Browse Source

♻️ Refactor, comment endstop/probe enums

Scott Lahteine 3 years ago
parent
commit
92dea8e6cc

+ 1
- 1
Marlin/src/lcd/menu/menu_bed_corners.cpp View File

225
     if (verify) do_blocking_move_to_z(current_position.z + LEVEL_CORNERS_Z_HOP); // do clearance if needed
225
     if (verify) do_blocking_move_to_z(current_position.z + LEVEL_CORNERS_Z_HOP); // do clearance if needed
226
     TERN_(BLTOUCH_SLOW_MODE, bltouch.deploy()); // Deploy in LOW SPEED MODE on every probe action
226
     TERN_(BLTOUCH_SLOW_MODE, bltouch.deploy()); // Deploy in LOW SPEED MODE on every probe action
227
     do_blocking_move_to_z(last_z - LEVEL_CORNERS_PROBE_TOLERANCE, MMM_TO_MMS(Z_PROBE_FEEDRATE_SLOW)); // Move down to lower tolerance
227
     do_blocking_move_to_z(last_z - LEVEL_CORNERS_PROBE_TOLERANCE, MMM_TO_MMS(Z_PROBE_FEEDRATE_SLOW)); // Move down to lower tolerance
228
-    if (TEST(endstops.trigger_state(), TERN(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN, Z_MIN, Z_MIN_PROBE))) { // check if probe triggered
228
+    if (TEST(endstops.trigger_state(), Z_MIN_PROBE)) { // check if probe triggered
229
       endstops.hit_on_purpose();
229
       endstops.hit_on_purpose();
230
       set_current_from_steppers_for_axis(Z_AXIS);
230
       set_current_from_steppers_for_axis(Z_AXIS);
231
       sync_plan_position();
231
       sync_plan_position();

+ 9
- 0
Marlin/src/module/endstops.cpp View File

403
   }
403
   }
404
 }
404
 }
405
 
405
 
406
+#if GCC_VERSION <= 50000
407
+  #pragma GCC diagnostic push
408
+  #pragma GCC diagnostic ignored "-Wunused-function"
409
+#endif
410
+
406
 static void print_es_state(const bool is_hit, PGM_P const label=nullptr) {
411
 static void print_es_state(const bool is_hit, PGM_P const label=nullptr) {
407
   if (label) SERIAL_ECHOPGM_P(label);
412
   if (label) SERIAL_ECHOPGM_P(label);
408
   SERIAL_ECHOPGM(": ");
413
   SERIAL_ECHOPGM(": ");
409
   SERIAL_ECHOLNPGM_P(is_hit ? PSTR(STR_ENDSTOP_HIT) : PSTR(STR_ENDSTOP_OPEN));
414
   SERIAL_ECHOLNPGM_P(is_hit ? PSTR(STR_ENDSTOP_HIT) : PSTR(STR_ENDSTOP_OPEN));
410
 }
415
 }
411
 
416
 
417
+#if GCC_VERSION <= 50000
418
+  #pragma GCC diagnostic pop
419
+#endif
420
+
412
 void _O2 Endstops::report_states() {
421
 void _O2 Endstops::report_states() {
413
   TERN_(BLTOUCH, bltouch._set_SW_mode());
422
   TERN_(BLTOUCH, bltouch._set_SW_mode());
414
   SERIAL_ECHOLNPGM(STR_M119_REPORT);
423
   SERIAL_ECHOLNPGM(STR_M119_REPORT);

+ 19
- 5
Marlin/src/module/endstops.h View File

32
 #define _ES_ITEM(K,N) TERN_(K,DEFER4(__ES_ITEM)(N))
32
 #define _ES_ITEM(K,N) TERN_(K,DEFER4(__ES_ITEM)(N))
33
 
33
 
34
 enum EndstopEnum : char {
34
 enum EndstopEnum : char {
35
+  // Common XYZ (ABC) endstops. Defined according to USE_[XYZ](MIN|MAX)_PLUG settings.
35
   _ES_ITEM(HAS_X_MIN, X_MIN)
36
   _ES_ITEM(HAS_X_MIN, X_MIN)
36
   _ES_ITEM(HAS_X_MAX, X_MAX)
37
   _ES_ITEM(HAS_X_MAX, X_MAX)
37
   _ES_ITEM(HAS_Y_MIN, Y_MIN)
38
   _ES_ITEM(HAS_Y_MIN, Y_MIN)
38
   _ES_ITEM(HAS_Y_MAX, Y_MAX)
39
   _ES_ITEM(HAS_Y_MAX, Y_MAX)
39
   _ES_ITEM(HAS_Z_MIN, Z_MIN)
40
   _ES_ITEM(HAS_Z_MIN, Z_MIN)
40
   _ES_ITEM(HAS_Z_MAX, Z_MAX)
41
   _ES_ITEM(HAS_Z_MAX, Z_MAX)
42
+
43
+  // Extra Endstops for XYZ
41
   #if ENABLED(X_DUAL_ENDSTOPS)
44
   #if ENABLED(X_DUAL_ENDSTOPS)
42
     _ES_ITEM(HAS_X_MIN, X2_MIN)
45
     _ES_ITEM(HAS_X_MIN, X2_MIN)
43
     _ES_ITEM(HAS_X_MAX, X2_MAX)
46
     _ES_ITEM(HAS_X_MAX, X2_MAX)
58
       _ES_ITEM(HAS_Z_MAX, Z4_MAX)
61
       _ES_ITEM(HAS_Z_MAX, Z4_MAX)
59
     #endif
62
     #endif
60
   #endif
63
   #endif
61
-  _ES_ITEM(HAS_Z_MIN_PROBE_PIN, Z_MIN_PROBE)
64
+
65
+  // Bed Probe state is distinct or shared with Z_MIN (i.e., when the probe is the only Z endstop)
66
+  _ES_ITEM(HAS_BED_PROBE, Z_MIN_PROBE IF_DISABLED(HAS_CUSTOM_PROBE_PIN, = Z_MIN))
67
+
68
+  // The total number of states
62
   NUM_ENDSTOP_STATES
69
   NUM_ENDSTOP_STATES
63
-};
64
 
70
 
65
-#define X_ENDSTOP TERN(X_HOME_TO_MAX, X_MAX, X_MIN)
66
-#define Y_ENDSTOP TERN(Y_HOME_TO_MAX, Y_MAX, Y_MIN)
67
-#define Z_ENDSTOP TERN(Z_HOME_TO_MAX, Z_MAX, TERN(HOMING_Z_WITH_PROBE, Z_MIN_PROBE, Z_MIN))
71
+  // Endstops can be either MIN or MAX but not both
72
+  #if HAS_X_MIN || HAS_X_MAX
73
+    , X_ENDSTOP = TERN(X_HOME_TO_MAX, X_MAX, X_MIN)
74
+  #endif
75
+  #if HAS_Y_MIN || HAS_Y_MAX
76
+    , Y_ENDSTOP = TERN(Y_HOME_TO_MAX, Y_MAX, Y_MIN)
77
+  #endif
78
+  #if HAS_Z_MIN || HAS_Z_MAX
79
+    , Z_ENDSTOP = TERN(Z_HOME_TO_MAX, Z_MAX, TERN(HOMING_Z_WITH_PROBE, Z_MIN_PROBE, Z_MIN))
80
+  #endif
81
+};
68
 
82
 
69
 #undef __ES_ITEM
83
 #undef __ES_ITEM
70
 #undef _ES_ITEM
84
 #undef _ES_ITEM

+ 1
- 1
Marlin/src/module/probe.cpp View File

509
     #if BOTH(DELTA, SENSORLESS_PROBING)
509
     #if BOTH(DELTA, SENSORLESS_PROBING)
510
       endstops.trigger_state() & (_BV(X_MAX) | _BV(Y_MAX) | _BV(Z_MAX))
510
       endstops.trigger_state() & (_BV(X_MAX) | _BV(Y_MAX) | _BV(Z_MAX))
511
     #else
511
     #else
512
-      TEST(endstops.trigger_state(), TERN(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN, Z_MIN, Z_MIN_PROBE))
512
+      TEST(endstops.trigger_state(), Z_MIN_PROBE)
513
     #endif
513
     #endif
514
   ;
514
   ;
515
 
515
 

Loading…
Cancel
Save