Merge pull request #3672 from thinkyhead/rc_consolidate_probe_flags

Cleanup and consolidate probe conditionals for clarity
master
Scott Lahteine 9 years ago
commit d32d9a3c5c

@ -628,7 +628,7 @@
#define HAS_Z_MAX (PIN_EXISTS(Z_MAX))
#define HAS_Z2_MIN (PIN_EXISTS(Z2_MIN))
#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_2 (PIN_EXISTS(SOL2))
#define HAS_SOLENOID_3 (PIN_EXISTS(SOL3))
@ -742,16 +742,11 @@
#endif
#endif
#if ( (HAS_Z_MIN && ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN)) || HAS_Z_PROBE ) \
&& ( \
ENABLED(FIX_MOUNTED_PROBE) \
|| ENABLED(MECHANICAL_PROBE) \
|| HAS_Z_ENDSTOP_SERVO \
|| ENABLED(Z_PROBE_ALLEN_KEY) \
|| ENABLED(Z_PROBE_SLED) \
)
#define HAS_Z_MIN_PROBE
#endif
#define PROBE_SELECTED (ENABLED(FIX_MOUNTED_PROBE) || ENABLED(MECHANICAL_PROBE) || HAS_Z_ENDSTOP_SERVO || ENABLED(Z_PROBE_SLED))
#define PROBE_PIN_CONFIGURED (HAS_Z_MIN_PROBE_PIN || (HAS_Z_MIN && ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN)))
#define HAS_BED_PROBE (PROBE_SELECTED && PROBE_PIN_CONFIGURED)
/**
* Delta radius/rod trimmers

@ -1681,7 +1681,7 @@ static void setup_for_endstop_move() {
refresh_cmd_timeout();
}
#if ENABLED(HAS_Z_MIN_PROBE)
#if HAS_BED_PROBE
static void deploy_z_probe() {
@ -1878,7 +1878,7 @@ static void setup_for_endstop_move() {
endstops.enable_z_probe(false);
}
#endif // HAS_Z_MIN_PROBE
#endif // HAS_BED_PROBE
enum ProbeAction {
ProbeStay = 0,
@ -3579,7 +3579,7 @@ inline void gcode_G28() {
}
#endif
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);
#endif
stepper.synchronize();
@ -3942,7 +3942,7 @@ inline void gcode_M42() {
* Z_MIN_PROBE_PIN, but here for clarity.
*/
#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.
#endif
#elif !HAS_Z_MIN

@ -204,50 +204,55 @@
* Probes
*/
/**
* 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))
#error A probe needs a pin! [Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN || HAS_Z_PROBE]
#endif
#if PROBE_SELECTED
#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
/**
* A probe needs a pin
*/
#if !PROBE_PIN_CONFIGURED
#error A probe needs a pin! Use Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN or Z_MIN_PROBE_PIN.
#endif
/**
* Require one kind of probe
*/
#if ENABLED(AUTO_BED_LEVELING_FEATURE) && !( ENABLED(FIX_MOUNTED_PROBE) || defined(Z_ENDSTOP_SERVO_NR) || ENABLED(MECHANICAL_PROBE) || ENABLED(Z_PROBE_SLED))
#error For AUTO_BED_LEVELING_FEATURE define one kind of probe! [Servo | MECHANICAL_PROBE | Z_PROBE_SLED | FIX_MOUNTED_PROBE]
#endif
/**
* 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
// 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
/**
* Auto Bed Leveling
*/
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
/**
* 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
/**
* Require a Z min pin
* Don't allow nonsense probe-pin settings
*/
#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
#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 !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.
#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
@ -263,6 +268,36 @@
// #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
*/
#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
*/

@ -45,7 +45,7 @@ Endstops::Endstops() {
#endif
);
enable(true);
#if ENABLED(HAS_Z_MIN_PROBE)
#if HAS_BED_PROBE
enable_z_probe(false);
#endif
} // Endstops::Endstops
@ -108,7 +108,7 @@ void Endstops::init() {
#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);
#if ENABLED(ENDSTOPPULLUP_ZMIN_PROBE)
WRITE(Z_MIN_PROBE_PIN,HIGH);
@ -195,7 +195,7 @@ void Endstops::M119() {
SERIAL_PROTOCOLPGM(MSG_Z2_MAX);
SERIAL_PROTOCOLLN(((READ(Z2_MAX_PIN)^Z2_MAX_ENDSTOP_INVERTING) ? MSG_ENDSTOP_HIT : MSG_ENDSTOP_OPEN));
#endif
#if HAS_Z_PROBE
#if HAS_Z_MIN_PROBE_PIN
SERIAL_PROTOCOLPGM(MSG_Z_PROBE);
SERIAL_PROTOCOLLN(((READ(Z_MIN_PROBE_PIN)^Z_MIN_PROBE_ENDSTOP_INVERTING) ? MSG_ENDSTOP_HIT : MSG_ENDSTOP_OPEN));
#endif
@ -317,7 +317,7 @@ void Endstops::update() {
#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);
#else
UPDATE_ENDSTOP(Z, MIN);
@ -327,7 +327,7 @@ void Endstops::update() {
#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) {
UPDATE_ENDSTOP(Z, MIN_PROBE);
if (TEST_ENDSTOP(Z_MIN_PROBE)) SBI(endstop_hit_bits, Z_MIN_PROBE);

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

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

Loading…
Cancel
Save