BLTouch V3.0 support (#13406)

This commit is contained in:
InsanityAutomation
2019-03-17 06:57:25 -04:00
committed by Scott Lahteine
parent 49cf92dc36
commit 691e5c3bb8
108 changed files with 860 additions and 77 deletions

View File

@ -2578,7 +2578,7 @@ void MarlinSettings::reset() {
#endif
#elif ENABLED(SWITCHING_NOZZLE)
case SWITCHING_NOZZLE_SERVO_NR:
#elif defined(Z_SERVO_ANGLES) && defined(Z_PROBE_SERVO_NR)
#elif (ENABLED(BLTOUCH) && defined(BLTOUCH_ANGLES)) || (defined(Z_SERVO_ANGLES) && defined(Z_PROBE_SERVO_NR))
case Z_PROBE_SERVO_NR:
#endif
CONFIG_ECHO_START();

View File

@ -47,6 +47,10 @@
#include "../feature/bedlevel/bedlevel.h"
#endif
#if ENABLED(BLTOUCH)
#include "../feature/bltouch.h"
#endif
#if EITHER(ULTRA_LCD, EXTENSIBLE_UI)
#include "../lcd/ultralcd.h"
#endif
@ -1400,7 +1404,7 @@ void homeaxis(const AxisEnum axis) {
#if HOMING_Z_WITH_PROBE && ENABLED(BLTOUCH)
// BLTOUCH needs to be deployed every time
if (axis == Z_AXIS && set_bltouch_deployed(true)) return;
if (axis == Z_AXIS && bltouch.deploy()) return;
#endif
do_homing_move(axis, 1.5f * max_length(
@ -1414,7 +1418,7 @@ void homeaxis(const AxisEnum axis) {
#if HOMING_Z_WITH_PROBE && ENABLED(BLTOUCH)
// BLTOUCH needs to be stowed after trigger to rearm itself
if (axis == Z_AXIS) set_bltouch_deployed(false);
if (axis == Z_AXIS) bltouch.stow();
#endif
// When homing Z with probe respect probe clearance
@ -1440,14 +1444,14 @@ void homeaxis(const AxisEnum axis) {
#if HOMING_Z_WITH_PROBE && ENABLED(BLTOUCH)
// BLTOUCH needs to be deployed every time
if (axis == Z_AXIS && set_bltouch_deployed(true)) return;
if (axis == Z_AXIS && bltouch.deploy()) return;
#endif
do_homing_move(axis, 2 * bump, get_homing_bump_feedrate(axis));
#if HOMING_Z_WITH_PROBE && ENABLED(BLTOUCH)
// BLTOUCH needs to be stowed after trigger to rearm itself
if (axis == Z_AXIS) set_bltouch_deployed(false);
if (axis == Z_AXIS) bltouch.stow();
#endif
}

View File

@ -56,6 +56,10 @@
float zprobe_zoffset; // Initialized by settings.load()
#if ENABLED(BLTOUCH)
#include "../feature/bltouch.h"
#endif
#if HAS_Z_SERVO_PROBE
#include "servo.h"
#endif
@ -289,37 +293,6 @@ float zprobe_zoffset; // Initialized by settings.load()
}
#endif // QUIET_PROBING
#if ENABLED(BLTOUCH)
void bltouch_command(const int angle) {
MOVE_SERVO(Z_PROBE_SERVO_NR, angle); // Give the BL-Touch the command and wait
safe_delay(BLTOUCH_DELAY);
}
bool set_bltouch_deployed(const bool deploy) {
if (deploy && TEST_BLTOUCH()) { // If BL-Touch says it's triggered
bltouch_command(BLTOUCH_RESET); // try to reset it.
bltouch_command(BLTOUCH_DEPLOY); // Also needs to deploy and stow to
bltouch_command(BLTOUCH_STOW); // clear the triggered condition.
safe_delay(1500); // Wait for internal self-test to complete.
// (Measured completion time was 0.65 seconds
// after reset, deploy, and stow sequence)
if (TEST_BLTOUCH()) { // If it still claims to be triggered...
SERIAL_ERROR_MSG(MSG_STOP_BLTOUCH);
stop(); // punt!
return true;
}
}
bltouch_command(deploy ? BLTOUCH_DEPLOY : BLTOUCH_STOW);
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("set_bltouch_deployed(", deploy, ")");
return false;
}
#endif // BLTOUCH
/**
* Raise Z to a minimum height to make room for a probe to move
*/
@ -530,7 +503,7 @@ static bool do_probe_move(const float z, const float fr_mm_s) {
// Deploy BLTouch at the start of any probe
#if ENABLED(BLTOUCH)
if (set_bltouch_deployed(true)) return true;
if (bltouch.deploy()) return true;
#endif
// Disable stealthChop if used. Enable diag1 pin on driver.
@ -582,7 +555,7 @@ static bool do_probe_move(const float z, const float fr_mm_s) {
// Retract BLTouch immediately after a probe if it was triggered
#if ENABLED(BLTOUCH)
if (probe_triggered && set_bltouch_deployed(false)) return true;
if (probe_triggered && bltouch.stow()) return true;
#endif
// Clear endstop flags

View File

@ -57,13 +57,3 @@
#if QUIET_PROBING
void probing_pause(const bool p);
#endif
#if ENABLED(BLTOUCH)
void bltouch_command(int angle);
bool set_bltouch_deployed(const bool deploy);
FORCE_INLINE void bltouch_init() {
// Make sure any BLTouch error condition is cleared
bltouch_command(BLTOUCH_RESET);
set_bltouch_deployed(false);
}
#endif

View File

@ -44,9 +44,18 @@
#elif ENABLED(SWITCHING_NOZZLE)
#define SADATA SWITCHING_NOZZLE_SERVO_ANGLES
#define ASRC(N,E) (SWITCHING_NOZZLE_SERVO_NR == N ? asrc[E] : 0)
#elif defined(Z_SERVO_ANGLES) && defined(Z_PROBE_SERVO_NR)
#define SADATA Z_SERVO_ANGLES
#elif defined(Z_PROBE_SERVO_NR)
#define ASRC(N,E) (Z_PROBE_SERVO_NR == N ? asrc[E] : 0)
#if ENABLED(BLTOUCH)
#include "../feature/bltouch.h"
#endif
#ifdef BLTOUCH_ANGLES
#define SADATA BLTOUCH_ANGLES
#elif defined(Z_SERVO_ANGLES)
#define SADATA Z_SERVO_ANGLES
#else
#error "Servo angles are needed!"
#endif
#endif
#if ENABLED(EDITABLE_SERVO_ANGLES)