|
|
|
@ -28,6 +28,8 @@
|
|
|
|
|
|
|
|
|
|
BLTouch bltouch;
|
|
|
|
|
|
|
|
|
|
bool BLTouch::last_written_mode; // Initialized by settings.load, 0 = Open Drain; 1 = 5V Drain
|
|
|
|
|
|
|
|
|
|
#include "../module/servo.h"
|
|
|
|
|
|
|
|
|
|
void stop();
|
|
|
|
@ -38,21 +40,53 @@ void stop();
|
|
|
|
|
bool BLTouch::command(const BLTCommand cmd, const millis_t &ms) {
|
|
|
|
|
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPAIR("BLTouch Command :", cmd);
|
|
|
|
|
MOVE_SERVO(Z_PROBE_SERVO_NR, cmd);
|
|
|
|
|
safe_delay(MAX(ms, BLTOUCH_DELAY)); // BLTOUCH_DELAY is also the *minimum* delay
|
|
|
|
|
safe_delay(MAX(ms, (uint32_t)BLTOUCH_DELAY)); // BLTOUCH_DELAY is also the *minimum* delay
|
|
|
|
|
return triggered();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BLTouch::init() {
|
|
|
|
|
// This is called by marlin.cpp on initialization
|
|
|
|
|
// SET_5V_MODE (if enabled). OD_MODE is the default on power on.
|
|
|
|
|
// This mode will stay active until manual SET_OD_MODE or power cycle
|
|
|
|
|
#if ENABLED(BLTOUCH_FORCE_5V_MODE)
|
|
|
|
|
_set_5V_mode(); // Set 5V mode if explicitely demanded (V3 upwards)
|
|
|
|
|
// Init the class and device. Call from setup().
|
|
|
|
|
void BLTouch::init(const bool set_voltage/*=false*/) {
|
|
|
|
|
// Voltage Setting (if enabled). At every Marlin initialization:
|
|
|
|
|
// BLTOUCH < V3.0 and clones: This will be ignored by the probe
|
|
|
|
|
// BLTOUCH V3.0: SET_5V_MODE or SET_OD_MODE (if enabled).
|
|
|
|
|
// OD_MODE is the default on power on, but setting it does not hurt
|
|
|
|
|
// This mode will stay active until manual SET_OD_MODE or power cycle
|
|
|
|
|
// BLTOUCH V3.1: SET_5V_MODE or SET_OD_MODE (if enabled).
|
|
|
|
|
// At power on, the probe will default to the eeprom settings configured by the user
|
|
|
|
|
#if ENABLED(BLTOUCH_FORCE_MODE_SET)
|
|
|
|
|
|
|
|
|
|
constexpr bool should_set = true;
|
|
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
|
|
if (DEBUGGING(LEVELING)) {
|
|
|
|
|
DEBUG_ECHOLNPAIR("last_written_mode - ", (int)last_written_mode);
|
|
|
|
|
DEBUG_ECHOLNPGM("config mode - "
|
|
|
|
|
#if ENABLED(BLTOUCH_SET_5V_MODE)
|
|
|
|
|
"BLTOUCH_SET_5V_MODE"
|
|
|
|
|
#else
|
|
|
|
|
"OD"
|
|
|
|
|
#endif
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const bool should_set = last_written_mode != (false
|
|
|
|
|
#if ENABLED(BLTOUCH_SET_5V_MODE)
|
|
|
|
|
|| true
|
|
|
|
|
#endif
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
if (should_set && set_voltage)
|
|
|
|
|
mode_conv_proc((false
|
|
|
|
|
#if ENABLED(BLTOUCH_SET_5V_MODE)
|
|
|
|
|
|| true
|
|
|
|
|
#endif
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
_reset();
|
|
|
|
|
_stow();
|
|
|
|
|
// There really should be no alarm outstanding now, and no triggered condition. But if there is,
|
|
|
|
|
// there is no need to worry people here on init right at the start of the printer.
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BLTouch::clear() {
|
|
|
|
@ -97,6 +131,11 @@ bool BLTouch::deploy_proc() {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// One of the recommended ANTClabs ways to probe, using SW MODE
|
|
|
|
|
#if ENABLED(BLTOUCH_FORCE_SW_MODE)
|
|
|
|
|
_set_SW_mode();
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
// Now the probe is ready to issue a 10ms pulse when the pin goes up.
|
|
|
|
|
// The trigger STOW (see motion.cpp for example) will pull up the probes pin as soon as the pulse
|
|
|
|
|
// is registered.
|
|
|
|
@ -159,4 +198,19 @@ bool BLTouch::status_proc() {
|
|
|
|
|
return !tr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BLTouch::mode_conv_proc(const bool M5V) {
|
|
|
|
|
/**
|
|
|
|
|
* BLTOUCH pre V3.0 and clones: No reaction at all to this sequence apart from a DEPLOY -> STOW
|
|
|
|
|
* BLTOUCH V3.0: This will set the mode (twice) and sadly, a STOW is needed at the end, because of the deploy
|
|
|
|
|
* BLTOUCH V3.1: This will set the mode and store it in the eeprom. The STOW is not needed but does not hurt
|
|
|
|
|
*/
|
|
|
|
|
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("BLTouch Set Mode - ", (int)M5V);
|
|
|
|
|
_deploy();
|
|
|
|
|
if (M5V) _set_5V_mode(); else _set_OD_mode();
|
|
|
|
|
_mode_store();
|
|
|
|
|
if (M5V) _set_5V_mode(); else _set_OD_mode();
|
|
|
|
|
_stow();
|
|
|
|
|
last_written_mode = M5V;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif // BLTOUCH
|
|
|
|
|