inline void _move_nozzle_servo(const uint8_t e, const uint8_t angle_index) { constexpr int8_t sns_index[2] = { SWITCHING_NOZZLE_SERVO_NR, SWITCHING_NOZZLE_E1_SERVO_NR }; constexpr int16_t sns_angles[2] = SWITCHING_NOZZLE_SERVO_ANGLES; planner.synchronize(); MOVE_SERVO(sns_index[e], sns_angles[angle_index]); safe_delay(500); }
void move_extruder_servo(const uint8_t e) { planner.synchronize(); #if EXTRUDERS & 1 if (e < EXTRUDERS - 1) #endif { MOVE_SERVO(_SERVO_NR(e), servo_angles[_SERVO_NR(e)][e]); safe_delay(500); } }
inline void switching_toolhead_tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool no_move/*=false*/) { if (no_move) return; constexpr uint16_t angles[2] = SWITCHING_TOOLHEAD_SERVO_ANGLES; const float toolheadposx[] = SWITCHING_TOOLHEAD_X_POS, placexpos = toolheadposx[active_extruder], grabxpos = toolheadposx[tmp_extruder]; /** * 1. Raise Z to give enough clearance * 2. Move to switch position of current toolhead * 3. Unlock tool and drop it in the dock * 4. Move to the new toolhead * 5. Grab and lock the new toolhead */ // 1. Raise Z to give enough clearance if (DEBUGGING(LEVELING)) DEBUG_POS("Starting Toolhead change", current_position); current_position[Z_AXIS] += toolchange_settings.z_raise; if (DEBUGGING(LEVELING)) DEBUG_POS("(1) Raise Z-Axis", current_position); fast_line_to_current(Z_AXIS); planner.synchronize(); // 2. Move to switch position of current toolhead current_position[X_AXIS] = placexpos; if (DEBUGGING(LEVELING)) { DEBUG_ECHOLNPAIR("(2) Place old tool ", int(active_extruder)); DEBUG_POS("Move X SwitchPos", current_position); } fast_line_to_current(X_AXIS); planner.synchronize(); current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS - SWITCHING_TOOLHEAD_Y_SECURITY; if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos + Security", current_position); fast_line_to_current(Y_AXIS); planner.synchronize(); // 3. Unlock tool and drop it in the dock if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("(3) Unlock and Place Toolhead"); MOVE_SERVO(SWITCHING_TOOLHEAD_SERVO_NR, angles[1]); safe_delay(500); current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS; if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos", current_position); planner.buffer_line(current_position,(planner.settings.max_feedrate_mm_s[Y_AXIS] * 0.5), active_extruder); planner.synchronize(); safe_delay(200); current_position[Y_AXIS] -= SWITCHING_TOOLHEAD_Y_CLEAR; if (DEBUGGING(LEVELING)) DEBUG_POS("Move back Y clear", current_position); fast_line_to_current(Y_AXIS); // move away from docked toolhead planner.synchronize(); // 4. Move to the new toolhead if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("(4) Move to new toolhead position"); current_position[X_AXIS] = grabxpos; if (DEBUGGING(LEVELING)) DEBUG_POS("Move to new toolhead X", current_position); fast_line_to_current(X_AXIS); planner.synchronize(); current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS - SWITCHING_TOOLHEAD_Y_SECURITY; if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos + Security", current_position); fast_line_to_current(Y_AXIS); planner.synchronize(); // 5. Grab and lock the new toolhead if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("(5) Grab and lock new toolhead "); current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS; if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos", current_position); planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Y_AXIS] * 0.5, active_extruder); planner.synchronize(); safe_delay(200); MOVE_SERVO(SWITCHING_TOOLHEAD_SERVO_NR, angles[0]); safe_delay(500); current_position[Y_AXIS] -= SWITCHING_TOOLHEAD_Y_CLEAR; if (DEBUGGING(LEVELING)) DEBUG_POS("Move back Y clear", current_position); fast_line_to_current(Y_AXIS); // move away from docked toolhead planner.synchronize(); if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Toolhead change done."); }
void move_nozzle_servo(const uint8_t angle_index) { planner.synchronize(); MOVE_SERVO(SWITCHING_NOZZLE_SERVO_NR, servo_angles[SWITCHING_NOZZLE_SERVO_NR][e]); safe_delay(500); }
// returns false for ok and true for failure bool set_probe_deployed(const bool deploy) { // Can be extended to servo probes, if needed. #if ENABLED(PROBE_IS_TRIGGERED_WHEN_STOWED_TEST) #if ENABLED(Z_MIN_PROBE_ENDSTOP) #define _TRIGGERED_WHEN_STOWED_TEST (READ(Z_MIN_PROBE_PIN) != Z_MIN_PROBE_ENDSTOP_INVERTING) #else #define _TRIGGERED_WHEN_STOWED_TEST (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING) #endif #endif #if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) { DEBUG_POS("set_probe_deployed", current_position); SERIAL_ECHOLNPAIR("deploy: ", deploy); } #endif if (endstops.z_probe_enabled == deploy) return false; // Make room for probe do_probe_raise(_Z_CLEARANCE_DEPLOY_PROBE); #if ENABLED(Z_PROBE_SLED) || ENABLED(Z_PROBE_ALLEN_KEY) #if ENABLED(Z_PROBE_SLED) #define _AUE_ARGS true, false, false #else #define _AUE_ARGS #endif if (axis_unhomed_error(_AUE_ARGS)) { SERIAL_ERROR_START(); SERIAL_ERRORLNPGM(MSG_STOP_UNHOMED); stop(); return true; } #endif const float oldXpos = current_position[X_AXIS], oldYpos = current_position[Y_AXIS]; #ifdef _TRIGGERED_WHEN_STOWED_TEST // If endstop is already false, the Z probe is deployed if (_TRIGGERED_WHEN_STOWED_TEST == deploy) { // closed after the probe specific actions. // Would a goto be less ugly? //while (!_TRIGGERED_WHEN_STOWED_TEST) idle(); // would offer the opportunity // for a triggered when stowed manual probe. if (!deploy) endstops.enable_z_probe(false); // Switch off triggered when stowed probes early // otherwise an Allen-Key probe can't be stowed. #endif #if ENABLED(SOLENOID_PROBE) #if HAS_SOLENOID_1 WRITE(SOL1_PIN, deploy); #endif #elif ENABLED(Z_PROBE_SLED) dock_sled(!deploy); #elif HAS_Z_SERVO_ENDSTOP && DISABLED(BLTOUCH) MOVE_SERVO(Z_ENDSTOP_SERVO_NR, z_servo_angle[deploy ? 0 : 1]); #elif ENABLED(Z_PROBE_ALLEN_KEY) deploy ? run_deploy_moves_script() : run_stow_moves_script(); #endif #ifdef _TRIGGERED_WHEN_STOWED_TEST } // _TRIGGERED_WHEN_STOWED_TEST == deploy if (_TRIGGERED_WHEN_STOWED_TEST == deploy) { // State hasn't changed? if (IsRunning()) { SERIAL_ERROR_START(); SERIAL_ERRORLNPGM("Z-Probe failed"); LCD_ALERTMESSAGEPGM("Err: ZPROBE"); } stop(); return true; } // _TRIGGERED_WHEN_STOWED_TEST == deploy #endif do_blocking_move_to(oldXpos, oldYpos, current_position[Z_AXIS]); // return to position before deploy endstops.enable_z_probe(deploy); return false; }
void bltouch_command(const int angle) { MOVE_SERVO(Z_ENDSTOP_SERVO_NR, angle); // Give the BL-Touch the command and wait safe_delay(BLTOUCH_DELAY); }