Merge pull request #3672 from thinkyhead/rc_consolidate_probe_flags

Cleanup and consolidate probe conditionals for clarity
This commit is contained in:
Scott Lahteine 2016-05-08 16:42:22 -07:00
commit d32d9a3c5c
6 changed files with 89 additions and 59 deletions

View File

@ -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

View File

@ -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

View File

@ -204,25 +204,81 @@
* 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
#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]
#endif #endif
/** /**
* Require one kind of probe * Z_MIN_PIN and Z_MIN_PROBE_PIN can't co-exist when Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN
*/ */
#if ENABLED(AUTO_BED_LEVELING_FEATURE) && !( ENABLED(FIX_MOUNTED_PROBE) || defined(Z_ENDSTOP_SERVO_NR) || ENABLED(MECHANICAL_PROBE) || ENABLED(Z_PROBE_SLED)) #if HAS_Z_MIN && HAS_Z_MIN_PROBE_PIN && ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN)
#error For AUTO_BED_LEVELING_FEATURE define one kind of probe! [Servo | MECHANICAL_PROBE | Z_PROBE_SLED | FIX_MOUNTED_PROBE] #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
// To do: Fail with more than one probe defined /**
* Make sure the plug is enabled if it's used
*/
#if ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) && DISABLED(USE_ZMIN_PLUG)
#error You must enable USE_ZMIN_PLUG if any probe or endstop is connected to the ZMIN plug.
#endif
/**
* Only allow one probe option to be defined
*/
#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
/**
* Don't allow nonsense probe-pin settings
*/
#if ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) && ENABLED(Z_MIN_PROBE_ENDSTOP)
#error You can't enable both Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN and Z_MIN_PROBE_ENDSTOP.
#elif ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) && ENABLED(DISABLE_Z_MIN_PROBE_ENDSTOP)
#error Don't enable DISABLE_Z_MIN_PROBE_ENDSTOP with Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN.
#elif ENABLED(DISABLE_Z_MIN_PROBE_ENDSTOP) && DISABLED(Z_MIN_PROBE_ENDSTOP)
#error DISABLE_Z_MIN_PROBE_ENDSTOP requires Z_MIN_PROBE_ENDSTOP to be set.
#endif
/**
* Require a Z probe pin if Z_MIN_PROBE_ENDSTOP is enabled.
*/
#if ENABLED(Z_MIN_PROBE_ENDSTOP)
#if !HAS_Z_MIN_PROBE_PIN
#error Z_MIN_PROBE_ENDSTOP requires a Z_MIN_PROBE_PIN in your board's pins_XXXX.h file.
#endif
// Forcing Servo definitions can break some hall effect sensor setups. Leaving these here for further comment.
//#ifndef NUM_SERVOS
// #error You must have NUM_SERVOS defined and there must be at least 1 configured to use Z_MIN_PROBE_ENDSTOP.
//#endif
//#if defined(NUM_SERVOS) && NUM_SERVOS < 1
// #error You must have at least 1 servo defined for NUM_SERVOS to use Z_MIN_PROBE_ENDSTOP.
//#endif
//#if Z_ENDSTOP_SERVO_NR < 0
// #error You must have Z_ENDSTOP_SERVO_NR set to at least 0 or above to use Z_MIN_PROBE_ENDSTOP.
//#endif
//#ifndef SERVO_ENDSTOP_ANGLES
// #error You must have SERVO_ENDSTOP_ANGLES defined for Z Extend and Retract to use Z_MIN_PROBE_ENDSTOP.
//#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 * Auto Bed Leveling
@ -242,27 +298,6 @@
#endif #endif
#endif #endif
/**
* Require a Z probe pin if Z_MIN_PROBE_ENDSTOP is enabled.
*/
#if ENABLED(Z_MIN_PROBE_ENDSTOP)
#if !PIN_EXISTS(Z_MIN_PROBE)
#error You must have a Z_MIN_PROBE_PIN defined in your pins_XXXX.h file if you enable Z_MIN_PROBE_ENDSTOP.
#endif
// Forcing Servo definitions can break some hall effect sensor setups. Leaving these here for further comment.
//#ifndef NUM_SERVOS
// #error You must have NUM_SERVOS defined and there must be at least 1 configured to use Z_MIN_PROBE_ENDSTOP.
//#endif
//#if defined(NUM_SERVOS) && NUM_SERVOS < 1
// #error You must have at least 1 servo defined for NUM_SERVOS to use Z_MIN_PROBE_ENDSTOP.
//#endif
//#if Z_ENDSTOP_SERVO_NR < 0
// #error You must have Z_ENDSTOP_SERVO_NR set to at least 0 or above to use Z_MIN_PROBE_ENDSTOP.
//#endif
//#ifndef SERVO_ENDSTOP_ANGLES
// #error You must have SERVO_ENDSTOP_ANGLES defined for Z Extend and Retract to use Z_MIN_PROBE_ENDSTOP.
//#endif
#endif
/** /**
* Check if Probe_Offset * Grid Points is greater than Probing Range * Check if Probe_Offset * Grid Points is greater than Probing Range
*/ */

View File

@ -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);

View File

@ -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

View File

@ -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();