Browse Source

Merge pull request #3672 from thinkyhead/rc_consolidate_probe_flags

Cleanup and consolidate probe conditionals for clarity
pull/1/head
Scott Lahteine 9 years ago
parent
commit
d32d9a3c5c
  1. 17
      Marlin/Conditionals.h
  2. 8
      Marlin/Marlin_main.cpp
  3. 79
      Marlin/SanityCheck.h
  4. 10
      Marlin/endstops.cpp
  5. 2
      Marlin/endstops.h
  6. 2
      Marlin/stepper.cpp

17
Marlin/Conditionals.h

@ -628,7 +628,7 @@
#define HAS_Z_MAX (PIN_EXISTS(Z_MAX)) #define HAS_Z_MAX (PIN_EXISTS(Z_MAX))
#define HAS_Z2_MIN (PIN_EXISTS(Z2_MIN)) #define HAS_Z2_MIN (PIN_EXISTS(Z2_MIN))
#define HAS_Z2_MAX (PIN_EXISTS(Z2_MAX)) #define HAS_Z2_MAX (PIN_EXISTS(Z2_MAX))
#define HAS_Z_PROBE (PIN_EXISTS(Z_MIN_PROBE)) #define HAS_Z_MIN_PROBE_PIN (PIN_EXISTS(Z_MIN_PROBE))
#define HAS_SOLENOID_1 (PIN_EXISTS(SOL1)) #define HAS_SOLENOID_1 (PIN_EXISTS(SOL1))
#define HAS_SOLENOID_2 (PIN_EXISTS(SOL2)) #define HAS_SOLENOID_2 (PIN_EXISTS(SOL2))
#define HAS_SOLENOID_3 (PIN_EXISTS(SOL3)) #define HAS_SOLENOID_3 (PIN_EXISTS(SOL3))
@ -742,16 +742,11 @@
#endif #endif
#endif #endif
#if ( (HAS_Z_MIN && ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN)) || HAS_Z_PROBE ) \ #define PROBE_SELECTED (ENABLED(FIX_MOUNTED_PROBE) || ENABLED(MECHANICAL_PROBE) || HAS_Z_ENDSTOP_SERVO || ENABLED(Z_PROBE_SLED))
&& ( \
ENABLED(FIX_MOUNTED_PROBE) \ #define PROBE_PIN_CONFIGURED (HAS_Z_MIN_PROBE_PIN || (HAS_Z_MIN && ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN)))
|| ENABLED(MECHANICAL_PROBE) \
|| HAS_Z_ENDSTOP_SERVO \ #define HAS_BED_PROBE (PROBE_SELECTED && PROBE_PIN_CONFIGURED)
|| ENABLED(Z_PROBE_ALLEN_KEY) \
|| ENABLED(Z_PROBE_SLED) \
)
#define HAS_Z_MIN_PROBE
#endif
/** /**
* Delta radius/rod trimmers * Delta radius/rod trimmers

8
Marlin/Marlin_main.cpp

@ -1681,7 +1681,7 @@ static void setup_for_endstop_move() {
refresh_cmd_timeout(); refresh_cmd_timeout();
} }
#if ENABLED(HAS_Z_MIN_PROBE) #if HAS_BED_PROBE
static void deploy_z_probe() { static void deploy_z_probe() {
@ -1878,7 +1878,7 @@ static void setup_for_endstop_move() {
endstops.enable_z_probe(false); endstops.enable_z_probe(false);
} }
#endif // HAS_Z_MIN_PROBE #endif // HAS_BED_PROBE
enum ProbeAction { enum ProbeAction {
ProbeStay = 0, ProbeStay = 0,
@ -3579,7 +3579,7 @@ inline void gcode_G28() {
} }
#endif #endif
enqueue_and_echo_commands_P(PSTR(Z_PROBE_END_SCRIPT)); enqueue_and_echo_commands_P(PSTR(Z_PROBE_END_SCRIPT));
#if ENABLED(HAS_Z_MIN_PROBE) #if HAS_BED_PROBE
endstops.enable_z_probe(false); endstops.enable_z_probe(false);
#endif #endif
stepper.synchronize(); stepper.synchronize();
@ -3942,7 +3942,7 @@ inline void gcode_M42() {
* Z_MIN_PROBE_PIN, but here for clarity. * Z_MIN_PROBE_PIN, but here for clarity.
*/ */
#if ENABLED(Z_MIN_PROBE_ENDSTOP) #if ENABLED(Z_MIN_PROBE_ENDSTOP)
#if !HAS_Z_PROBE #if !HAS_Z_MIN_PROBE_PIN
#error You must define Z_MIN_PROBE_PIN to enable Z probe repeatability calculation. #error You must define Z_MIN_PROBE_PIN to enable Z probe repeatability calculation.
#endif #endif
#elif !HAS_Z_MIN #elif !HAS_Z_MIN

79
Marlin/SanityCheck.h

@ -204,50 +204,55 @@
* Probes * Probes
*/ */
#if PROBE_SELECTED
/** /**
* A probe needs a pin * A probe needs a pin
*/ */
#if (!((HAS_Z_MIN && ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN)) || HAS_Z_PROBE )) && ( ENABLED(FIX_MOUNTED_PROBE) || defined(Z_ENDSTOP_SERVO_NR) || ENABLED(MECHANICAL_PROBE) || ENABLED(Z_PROBE_SLED)) #if !PROBE_PIN_CONFIGURED
#error A probe needs a pin! [Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN || HAS_Z_PROBE] #error A probe needs a pin! Use Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN or Z_MIN_PROBE_PIN.
#endif #endif
#if ((HAS_Z_MIN && ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN)) && HAS_Z_PROBE) && ( ENABLED(FIX_MOUNTED_PROBE) || defined(Z_ENDSTOP_SERVO_NR) || ENABLED(MECHANICAL_PROBE) || ENABLED(Z_PROBE_SLED)) /**
#error A probe should not be connected to more than one pin! [Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN || HAS_Z_PROBE] * Z_MIN_PIN and Z_MIN_PROBE_PIN can't co-exist when Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN
*/
#if HAS_Z_MIN && HAS_Z_MIN_PROBE_PIN && ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN)
#error A probe cannot have more than one pin! Use Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN or Z_MIN_PROBE_PIN.
#endif #endif
/** /**
* Require one kind of probe * Make sure the plug is enabled if it's used
*/ */
#if ENABLED(AUTO_BED_LEVELING_FEATURE) && !( ENABLED(FIX_MOUNTED_PROBE) || defined(Z_ENDSTOP_SERVO_NR) || ENABLED(MECHANICAL_PROBE) || ENABLED(Z_PROBE_SLED)) #if ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) && DISABLED(USE_ZMIN_PLUG)
#error For AUTO_BED_LEVELING_FEATURE define one kind of probe! [Servo | MECHANICAL_PROBE | Z_PROBE_SLED | FIX_MOUNTED_PROBE] #error You must enable USE_ZMIN_PLUG if any probe or endstop is connected to the ZMIN plug.
#endif #endif
// To do: Fail with more than one probe defined
/** /**
* Auto Bed Leveling * Only allow one probe option to be defined
*/ */
#if ENABLED(AUTO_BED_LEVELING_FEATURE) #if (ENABLED(FIX_MOUNTED_PROBE) && (ENABLED(MECHANICAL_PROBE) || HAS_Z_ENDSTOP_SERVO || ENABLED(Z_PROBE_SLED))) \
|| (ENABLED(MECHANICAL_PROBE) && (HAS_Z_ENDSTOP_SERVO || ENABLED(Z_PROBE_SLED))) \
|| (HAS_Z_ENDSTOP_SERVO && ENABLED(Z_PROBE_SLED))
#error Please define only one type of probe: Z Servo, MECHANICAL_PROBE, Z_PROBE_SLED, or FIX_MOUNTED_PROBE.
#endif
/** /**
* Require a Z min pin * Don't allow nonsense probe-pin settings
*/ */
#if !PIN_EXISTS(Z_MIN) #if ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) && ENABLED(Z_MIN_PROBE_ENDSTOP)
#if !PIN_EXISTS(Z_MIN_PROBE) || (DISABLED(Z_MIN_PROBE_ENDSTOP) || ENABLED(DISABLE_Z_MIN_PROBE_ENDSTOP)) // It's possible for someone to set a pin for the Z probe, but not enable it. #error You can't enable both Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN and Z_MIN_PROBE_ENDSTOP.
#if ENABLED(Z_MIN_PROBE_REPEATABILITY_TEST) #elif ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) && ENABLED(DISABLE_Z_MIN_PROBE_ENDSTOP)
#error You must have a Z_MIN or Z_PROBE endstop to enable Z_MIN_PROBE_REPEATABILITY_TEST. #error Don't enable DISABLE_Z_MIN_PROBE_ENDSTOP with Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN.
#else #elif ENABLED(DISABLE_Z_MIN_PROBE_ENDSTOP) && DISABLED(Z_MIN_PROBE_ENDSTOP)
#error AUTO_BED_LEVELING_FEATURE requires a Z_MIN or Z_PROBE endstop. Z_MIN_PIN or Z_MIN_PROBE_PIN must point to a valid hardware pin. #error DISABLE_Z_MIN_PROBE_ENDSTOP requires Z_MIN_PROBE_ENDSTOP to be set.
#endif
#endif
#endif #endif
/** /**
* Require a Z probe pin if Z_MIN_PROBE_ENDSTOP is enabled. * Require a Z probe pin if Z_MIN_PROBE_ENDSTOP is enabled.
*/ */
#if ENABLED(Z_MIN_PROBE_ENDSTOP) #if ENABLED(Z_MIN_PROBE_ENDSTOP)
#if !PIN_EXISTS(Z_MIN_PROBE) #if !HAS_Z_MIN_PROBE_PIN
#error You must have a Z_MIN_PROBE_PIN defined in your pins_XXXX.h file if you enable Z_MIN_PROBE_ENDSTOP. #error Z_MIN_PROBE_ENDSTOP requires a Z_MIN_PROBE_PIN in your board's pins_XXXX.h file.
#endif #endif
// Forcing Servo definitions can break some hall effect sensor setups. Leaving these here for further comment. // Forcing Servo definitions can break some hall effect sensor setups. Leaving these here for further comment.
//#ifndef NUM_SERVOS //#ifndef NUM_SERVOS
@ -263,6 +268,36 @@
// #error You must have SERVO_ENDSTOP_ANGLES defined for Z Extend and Retract to use Z_MIN_PROBE_ENDSTOP. // #error You must have SERVO_ENDSTOP_ANGLES defined for Z Extend and Retract to use Z_MIN_PROBE_ENDSTOP.
//#endif //#endif
#endif #endif
#else
/**
* Require some kind of probe for bed leveling
*/
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
#error AUTO_BED_LEVELING_FEATURE requires a probe! Define a Z Servo, MECHANICAL_PROBE, Z_PROBE_SLED, or FIX_MOUNTED_PROBE.
#endif
#endif
/**
* Auto Bed Leveling
*/
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
/**
* Require a Z min pin
*/
#if !PIN_EXISTS(Z_MIN)
#if !PIN_EXISTS(Z_MIN_PROBE) || (DISABLED(Z_MIN_PROBE_ENDSTOP) || ENABLED(DISABLE_Z_MIN_PROBE_ENDSTOP)) // It's possible for someone to set a pin for the Z probe, but not enable it.
#if ENABLED(Z_MIN_PROBE_REPEATABILITY_TEST)
#error You must have a Z_MIN or Z_PROBE endstop to enable Z_MIN_PROBE_REPEATABILITY_TEST.
#else
#error AUTO_BED_LEVELING_FEATURE requires a Z_MIN or Z_PROBE endstop. Z_MIN_PIN or Z_MIN_PROBE_PIN must point to a valid hardware pin.
#endif
#endif
#endif
/** /**
* Check if Probe_Offset * Grid Points is greater than Probing Range * Check if Probe_Offset * Grid Points is greater than Probing Range
*/ */

10
Marlin/endstops.cpp

@ -45,7 +45,7 @@ Endstops::Endstops() {
#endif #endif
); );
enable(true); enable(true);
#if ENABLED(HAS_Z_MIN_PROBE) #if HAS_BED_PROBE
enable_z_probe(false); enable_z_probe(false);
#endif #endif
} // Endstops::Endstops } // Endstops::Endstops
@ -108,7 +108,7 @@ void Endstops::init() {
#endif #endif
#endif #endif
#if HAS_Z_PROBE && ENABLED(Z_MIN_PROBE_ENDSTOP) // Check for Z_MIN_PROBE_ENDSTOP so we don't pull a pin high unless it's to be used. #if HAS_Z_MIN_PROBE_PIN && ENABLED(Z_MIN_PROBE_ENDSTOP) // Check for Z_MIN_PROBE_ENDSTOP so we don't pull a pin high unless it's to be used.
SET_INPUT(Z_MIN_PROBE_PIN); SET_INPUT(Z_MIN_PROBE_PIN);
#if ENABLED(ENDSTOPPULLUP_ZMIN_PROBE) #if ENABLED(ENDSTOPPULLUP_ZMIN_PROBE)
WRITE(Z_MIN_PROBE_PIN,HIGH); WRITE(Z_MIN_PROBE_PIN,HIGH);
@ -195,7 +195,7 @@ void Endstops::M119() {
SERIAL_PROTOCOLPGM(MSG_Z2_MAX); SERIAL_PROTOCOLPGM(MSG_Z2_MAX);
SERIAL_PROTOCOLLN(((READ(Z2_MAX_PIN)^Z2_MAX_ENDSTOP_INVERTING) ? MSG_ENDSTOP_HIT : MSG_ENDSTOP_OPEN)); SERIAL_PROTOCOLLN(((READ(Z2_MAX_PIN)^Z2_MAX_ENDSTOP_INVERTING) ? MSG_ENDSTOP_HIT : MSG_ENDSTOP_OPEN));
#endif #endif
#if HAS_Z_PROBE #if HAS_Z_MIN_PROBE_PIN
SERIAL_PROTOCOLPGM(MSG_Z_PROBE); SERIAL_PROTOCOLPGM(MSG_Z_PROBE);
SERIAL_PROTOCOLLN(((READ(Z_MIN_PROBE_PIN)^Z_MIN_PROBE_ENDSTOP_INVERTING) ? MSG_ENDSTOP_HIT : MSG_ENDSTOP_OPEN)); SERIAL_PROTOCOLLN(((READ(Z_MIN_PROBE_PIN)^Z_MIN_PROBE_ENDSTOP_INVERTING) ? MSG_ENDSTOP_HIT : MSG_ENDSTOP_OPEN));
#endif #endif
@ -317,7 +317,7 @@ void Endstops::update() {
#else // !Z_DUAL_ENDSTOPS #else // !Z_DUAL_ENDSTOPS
#if ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) && ENABLED(HAS_Z_MIN_PROBE) #if HAS_BED_PROBE && ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN)
if (z_probe_enabled) UPDATE_ENDSTOP(Z, MIN); if (z_probe_enabled) UPDATE_ENDSTOP(Z, MIN);
#else #else
UPDATE_ENDSTOP(Z, MIN); UPDATE_ENDSTOP(Z, MIN);
@ -327,7 +327,7 @@ void Endstops::update() {
#endif // HAS_Z_MIN #endif // HAS_Z_MIN
#if ENABLED(Z_MIN_PROBE_ENDSTOP) && DISABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) && ENABLED(HAS_Z_MIN_PROBE) #if HAS_BED_PROBE && ENABLED(Z_MIN_PROBE_ENDSTOP) && DISABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN)
if (z_probe_enabled) { if (z_probe_enabled) {
UPDATE_ENDSTOP(Z, MIN_PROBE); UPDATE_ENDSTOP(Z, MIN_PROBE);
if (TEST_ENDSTOP(Z_MIN_PROBE)) SBI(endstop_hit_bits, Z_MIN_PROBE); if (TEST_ENDSTOP(Z_MIN_PROBE)) SBI(endstop_hit_bits, Z_MIN_PROBE);

2
Marlin/endstops.h

@ -88,7 +88,7 @@ class Endstops {
FORCE_INLINE void hit_on_purpose() { endstop_hit_bits = 0; } FORCE_INLINE void hit_on_purpose() { endstop_hit_bits = 0; }
// Enable / disable endstop z-probe checking // Enable / disable endstop z-probe checking
#if ENABLED(HAS_Z_MIN_PROBE) #if HAS_BED_PROBE
volatile bool z_probe_enabled = false; volatile bool z_probe_enabled = false;
FORCE_INLINE void enable_z_probe(bool onoff=true) { z_probe_enabled = onoff; } FORCE_INLINE void enable_z_probe(bool onoff=true) { z_probe_enabled = onoff; }
#endif #endif

2
Marlin/stepper.cpp

@ -282,7 +282,7 @@ void Stepper::isr() {
if (current_block != NULL) { if (current_block != NULL) {
// Update endstops state, if enabled // Update endstops state, if enabled
#if ENABLED(HAS_Z_MIN_PROBE) #if HAS_BED_PROBE
if (endstops.enabled || endstops.z_probe_enabled) endstops.update(); if (endstops.enabled || endstops.z_probe_enabled) endstops.update();
#else #else
if (endstops.enabled) endstops.update(); if (endstops.enabled) endstops.update();

Loading…
Cancel
Save