Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates and a couple of fixes for add servo support to magnetic probe #3

Open
wants to merge 2 commits into
base: add-servo-support-to-magnetic-probe
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -1544,6 +1544,9 @@
//#define MAG_MOUNTED_PROBE_SERVO_NR 0 // Set to servo number to use
#ifdef MAG_MOUNTED_PROBE_SERVO_NR
#define MAG_MOUNTED_PROBE_SERVO_ANGLES { 90, 0 } // Mag servo Deploy and Stow angles

#define MAG_MOUNTED_PRE_DEPLOY { PROBE_DEPLOY_FEEDRATE, { 15, 160, 30 } } // Move to safe position before servo is activated
#define MAG_MOUNTED_PRE_STOW { PROBE_DEPLOY_FEEDRATE, { 15, 160, 30 } } // Move to safe position before servo is activated
#endif

#define MAG_MOUNTED_DEPLOY_1 { PROBE_DEPLOY_FEEDRATE, { 245, 114, 30 } } // Move to side Dock & Attach probe
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -980,7 +980,7 @@ static_assert(NUM_SERVOS <= NUM_SERVO_PLUGS, "NUM_SERVOS (or some servo index) i
/**
* Servo deactivation depends on servo endstops, switching nozzle, or switching extruder
*/
#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE) && NONE(HAS_Z_SERVO_PROBE, POLARGRAPH) && !defined(SWITCHING_NOZZLE_SERVO_NR) && !defined(SWITCHING_EXTRUDER_SERVO_NR) && !defined(SWITCHING_TOOLHEAD_SERVO_NR)
#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE) && NONE(HAS_Z_SERVO_PROBE, POLARGRAPH) && !defined(SWITCHING_NOZZLE_SERVO_NR) && !defined(SWITCHING_EXTRUDER_SERVO_NR) && !defined(SWITCHING_TOOLHEAD_SERVO_NR) && !defined(MAG_MOUNTED_PROBE_SERVO_NR)
#error "Z_PROBE_SERVO_NR, switching nozzle, switching toolhead, switching extruder, or POLARGRAPH is required for DEACTIVATE_SERVOS_AFTER_MOVE."
#endif

Expand Down
10 changes: 9 additions & 1 deletion Marlin/src/module/probe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,10 @@ xyz_pos_t Probe::offset; // Initialized by settings.load
typedef struct { float fr_mm_min; xyz_pos_t where; } mag_probe_move_t;

inline void run_deploy_moves() {
#ifdef MAG_MOUNTED_PRE_DEPLOY
constexpr mag_probe_move_t pre_deploy = MAG_MOUNTED_PRE_DEPLOY;
do_blocking_move_to(pre_deploy.where, MMM_TO_MMS(pre_deploy.fr_mm_min));
#endif
#if HAS_MAG_MOUNTED_SERVO_PROBE
servo[MAG_MOUNTED_PROBE_SERVO_NR].move(servo_angles[MAG_MOUNTED_PROBE_SERVO_NR][0]);
#endif
Expand Down Expand Up @@ -301,6 +305,10 @@ xyz_pos_t Probe::offset; // Initialized by settings.load
}

inline void run_stow_moves() {
#ifdef MAG_MOUNTED_PRE_STOW
constexpr mag_probe_move_t pre_stow = MAG_MOUNTED_PRE_STOW;
do_blocking_move_to(pre_stow.where, MMM_TO_MMS(pre_stow.fr_mm_min));
#endif
#if HAS_MAG_MOUNTED_SERVO_PROBE
servo[MAG_MOUNTED_PROBE_SERVO_NR].move(servo_angles[MAG_MOUNTED_PROBE_SERVO_NR][0]);
#endif
Expand Down Expand Up @@ -553,7 +561,7 @@ bool Probe::set_deployed(const bool deploy, const bool no_return/*=false*/) {
#if ENABLED(PROBE_TRIGGERED_WHEN_STOWED_TEST)

// Only deploy/stow if needed
if (PROBE_TRIGGERED() == deploy) {
if (PROBE_TRIGGERED() == deploy || !deploy) {
if (!deploy) endstops.enable_z_probe(false); // Switch off triggered when stowed probes early
// otherwise an Allen-Key probe can't be stowed.
probe_specific_action(deploy);
Expand Down