Browse Source

♻️ Refactor, comment endstop/probe enums

vanilla_fb_2.0.x
Scott Lahteine 4 years ago
parent
commit
4dae5890e9
  1. 2
      Marlin/src/lcd/menu/menu_bed_corners.cpp
  2. 9
      Marlin/src/module/endstops.cpp
  3. 24
      Marlin/src/module/endstops.h
  4. 2
      Marlin/src/module/probe.cpp

2
Marlin/src/lcd/menu/menu_bed_corners.cpp

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

9
Marlin/src/module/endstops.cpp

@ -403,12 +403,21 @@ void Endstops::event_handler() {
}
}
#if GCC_VERSION <= 50000
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-function"
#endif
static void print_es_state(const bool is_hit, PGM_P const label=nullptr) {
if (label) SERIAL_ECHOPGM_P(label);
SERIAL_ECHOPGM(": ");
SERIAL_ECHOLNPGM_P(is_hit ? PSTR(STR_ENDSTOP_HIT) : PSTR(STR_ENDSTOP_OPEN));
}
#if GCC_VERSION <= 50000
#pragma GCC diagnostic pop
#endif
void _O2 Endstops::report_states() {
TERN_(BLTOUCH, bltouch._set_SW_mode());
SERIAL_ECHOLNPGM(STR_M119_REPORT);

24
Marlin/src/module/endstops.h

@ -32,12 +32,15 @@
#define _ES_ITEM(K,N) TERN_(K,DEFER4(__ES_ITEM)(N))
enum EndstopEnum : char {
// Common XYZ (ABC) endstops. Defined according to USE_[XYZ](MIN|MAX)_PLUG settings.
_ES_ITEM(HAS_X_MIN, X_MIN)
_ES_ITEM(HAS_X_MAX, X_MAX)
_ES_ITEM(HAS_Y_MIN, Y_MIN)
_ES_ITEM(HAS_Y_MAX, Y_MAX)
_ES_ITEM(HAS_Z_MIN, Z_MIN)
_ES_ITEM(HAS_Z_MAX, Z_MAX)
// Extra Endstops for XYZ
#if ENABLED(X_DUAL_ENDSTOPS)
_ES_ITEM(HAS_X_MIN, X2_MIN)
_ES_ITEM(HAS_X_MAX, X2_MAX)
@ -58,13 +61,24 @@ enum EndstopEnum : char {
_ES_ITEM(HAS_Z_MAX, Z4_MAX)
#endif
#endif
_ES_ITEM(HAS_Z_MIN_PROBE_PIN, Z_MIN_PROBE)
// Bed Probe state is distinct or shared with Z_MIN (i.e., when the probe is the only Z endstop)
_ES_ITEM(HAS_BED_PROBE, Z_MIN_PROBE IF_DISABLED(HAS_CUSTOM_PROBE_PIN, = Z_MIN))
// The total number of states
NUM_ENDSTOP_STATES
};
#define X_ENDSTOP TERN(X_HOME_TO_MAX, X_MAX, X_MIN)
#define Y_ENDSTOP TERN(Y_HOME_TO_MAX, Y_MAX, Y_MIN)
#define Z_ENDSTOP TERN(Z_HOME_TO_MAX, Z_MAX, TERN(HOMING_Z_WITH_PROBE, Z_MIN_PROBE, Z_MIN))
// Endstops can be either MIN or MAX but not both
#if HAS_X_MIN || HAS_X_MAX
, X_ENDSTOP = TERN(X_HOME_TO_MAX, X_MAX, X_MIN)
#endif
#if HAS_Y_MIN || HAS_Y_MAX
, Y_ENDSTOP = TERN(Y_HOME_TO_MAX, Y_MAX, Y_MIN)
#endif
#if HAS_Z_MIN || HAS_Z_MAX
, Z_ENDSTOP = TERN(Z_HOME_TO_MAX, Z_MAX, TERN(HOMING_Z_WITH_PROBE, Z_MIN_PROBE, Z_MIN))
#endif
};
#undef __ES_ITEM
#undef _ES_ITEM

2
Marlin/src/module/probe.cpp

@ -509,7 +509,7 @@ bool Probe::probe_down_to_z(const_float_t z, const_feedRate_t fr_mm_s) {
#if BOTH(DELTA, SENSORLESS_PROBING)
endstops.trigger_state() & (_BV(X_MAX) | _BV(Y_MAX) | _BV(Z_MAX))
#else
TEST(endstops.trigger_state(), TERN(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN, Z_MIN, Z_MIN_PROBE))
TEST(endstops.trigger_state(), Z_MIN_PROBE)
#endif
;

Loading…
Cancel
Save