Kaynağa Gözat

♻️ Refactor, comment endstop/probe enums

Scott Lahteine 3 yıl önce
ebeveyn
işleme
92dea8e6cc

+ 1
- 1
Marlin/src/lcd/menu/menu_bed_corners.cpp Dosyayı Görüntüle

@@ -225,7 +225,7 @@ static void _lcd_level_bed_corners_get_next_position() {
225 225
     if (verify) do_blocking_move_to_z(current_position.z + LEVEL_CORNERS_Z_HOP); // do clearance if needed
226 226
     TERN_(BLTOUCH_SLOW_MODE, bltouch.deploy()); // Deploy in LOW SPEED MODE on every probe action
227 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 229
       endstops.hit_on_purpose();
230 230
       set_current_from_steppers_for_axis(Z_AXIS);
231 231
       sync_plan_position();

+ 9
- 0
Marlin/src/module/endstops.cpp Dosyayı Görüntüle

@@ -403,12 +403,21 @@ void Endstops::event_handler() {
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 411
 static void print_es_state(const bool is_hit, PGM_P const label=nullptr) {
407 412
   if (label) SERIAL_ECHOPGM_P(label);
408 413
   SERIAL_ECHOPGM(": ");
409 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 421
 void _O2 Endstops::report_states() {
413 422
   TERN_(BLTOUCH, bltouch._set_SW_mode());
414 423
   SERIAL_ECHOLNPGM(STR_M119_REPORT);

+ 19
- 5
Marlin/src/module/endstops.h Dosyayı Görüntüle

@@ -32,12 +32,15 @@
32 32
 #define _ES_ITEM(K,N) TERN_(K,DEFER4(__ES_ITEM)(N))
33 33
 
34 34
 enum EndstopEnum : char {
35
+  // Common XYZ (ABC) endstops. Defined according to USE_[XYZ](MIN|MAX)_PLUG settings.
35 36
   _ES_ITEM(HAS_X_MIN, X_MIN)
36 37
   _ES_ITEM(HAS_X_MAX, X_MAX)
37 38
   _ES_ITEM(HAS_Y_MIN, Y_MIN)
38 39
   _ES_ITEM(HAS_Y_MAX, Y_MAX)
39 40
   _ES_ITEM(HAS_Z_MIN, Z_MIN)
40 41
   _ES_ITEM(HAS_Z_MAX, Z_MAX)
42
+
43
+  // Extra Endstops for XYZ
41 44
   #if ENABLED(X_DUAL_ENDSTOPS)
42 45
     _ES_ITEM(HAS_X_MIN, X2_MIN)
43 46
     _ES_ITEM(HAS_X_MAX, X2_MAX)
@@ -58,13 +61,24 @@ enum EndstopEnum : char {
58 61
       _ES_ITEM(HAS_Z_MAX, Z4_MAX)
59 62
     #endif
60 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 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 83
 #undef __ES_ITEM
70 84
 #undef _ES_ITEM

+ 1
- 1
Marlin/src/module/probe.cpp Dosyayı Görüntüle

@@ -509,7 +509,7 @@ bool Probe::probe_down_to_z(const_float_t z, const_feedRate_t fr_mm_s) {
509 509
     #if BOTH(DELTA, SENSORLESS_PROBING)
510 510
       endstops.trigger_state() & (_BV(X_MAX) | _BV(Y_MAX) | _BV(Z_MAX))
511 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 513
     #endif
514 514
   ;
515 515
 

Loading…
İptal
Kaydet