2017-09-08 03:33:16 +00:00
|
|
|
/**
|
|
|
|
* Marlin 3D Printer Firmware
|
2020-02-03 14:00:57 +00:00
|
|
|
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
2017-09-08 03:33:16 +00:00
|
|
|
*
|
|
|
|
* Based on Sprinter and grbl.
|
2019-06-28 04:57:50 +00:00
|
|
|
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
2017-09-08 03:33:16 +00:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
2019-07-05 03:44:12 +00:00
|
|
|
#pragma once
|
2017-09-08 03:33:16 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* motion.h
|
|
|
|
*
|
|
|
|
* High-level motion commands to feed the planner
|
|
|
|
* Some of these methods may migrate to the planner class.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "../inc/MarlinConfig.h"
|
|
|
|
|
2019-09-17 23:16:28 +00:00
|
|
|
#if HAS_BED_PROBE
|
|
|
|
#include "probe.h"
|
|
|
|
#endif
|
|
|
|
|
2019-09-25 02:29:21 +00:00
|
|
|
#if IS_SCARA
|
|
|
|
#include "scara.h"
|
|
|
|
#endif
|
|
|
|
|
2018-10-31 22:07:52 +00:00
|
|
|
// Axis homed and known-position states
|
|
|
|
extern uint8_t axis_homed, axis_known_position;
|
|
|
|
constexpr uint8_t xyz_bits = _BV(X_AXIS) | _BV(Y_AXIS) | _BV(Z_AXIS);
|
2020-01-11 23:06:52 +00:00
|
|
|
FORCE_INLINE bool no_axes_homed() { return !axis_homed; }
|
2018-10-31 22:07:52 +00:00
|
|
|
FORCE_INLINE bool all_axes_homed() { return (axis_homed & xyz_bits) == xyz_bits; }
|
|
|
|
FORCE_INLINE bool all_axes_known() { return (axis_known_position & xyz_bits) == xyz_bits; }
|
|
|
|
FORCE_INLINE void set_all_unhomed() { axis_homed = 0; }
|
|
|
|
FORCE_INLINE void set_all_unknown() { axis_known_position = 0; }
|
|
|
|
|
2019-06-26 08:42:21 +00:00
|
|
|
FORCE_INLINE bool homing_needed() {
|
|
|
|
return !(
|
|
|
|
#if ENABLED(HOME_AFTER_DEACTIVATE)
|
|
|
|
all_axes_known()
|
|
|
|
#else
|
|
|
|
all_axes_homed()
|
|
|
|
#endif
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2018-08-22 04:33:55 +00:00
|
|
|
// Error margin to work around float imprecision
|
|
|
|
constexpr float slop = 0.0001;
|
|
|
|
|
2017-09-08 03:33:16 +00:00
|
|
|
extern bool relative_mode;
|
|
|
|
|
2019-09-29 09:25:39 +00:00
|
|
|
extern xyze_pos_t current_position, // High-level current tool position
|
|
|
|
destination; // Destination for a move
|
2017-09-08 20:35:25 +00:00
|
|
|
|
2020-01-07 19:52:19 +00:00
|
|
|
// G60/G61 Position Save and Return
|
|
|
|
#if SAVED_POSITIONS
|
2020-01-30 09:18:45 +00:00
|
|
|
extern uint8_t saved_slots[(SAVED_POSITIONS + 7) >> 3];
|
2020-01-07 19:52:19 +00:00
|
|
|
extern xyz_pos_t stored_position[SAVED_POSITIONS];
|
|
|
|
#endif
|
|
|
|
|
2017-09-08 20:35:25 +00:00
|
|
|
// Scratch space for a cartesian result
|
2019-09-29 09:25:39 +00:00
|
|
|
extern xyz_pos_t cartes;
|
2017-09-08 20:35:25 +00:00
|
|
|
|
|
|
|
// Until kinematics.cpp is created, declare this here
|
|
|
|
#if IS_KINEMATIC
|
2019-09-29 09:25:39 +00:00
|
|
|
extern abc_pos_t delta;
|
2017-09-08 20:35:25 +00:00
|
|
|
#endif
|
|
|
|
|
2019-02-25 02:29:03 +00:00
|
|
|
#if HAS_ABL_NOT_UBL
|
2017-09-08 20:35:25 +00:00
|
|
|
extern float xy_probe_feedrate_mm_s;
|
|
|
|
#define XY_PROBE_FEEDRATE_MM_S xy_probe_feedrate_mm_s
|
|
|
|
#elif defined(XY_PROBE_SPEED)
|
|
|
|
#define XY_PROBE_FEEDRATE_MM_S MMM_TO_MMS(XY_PROBE_SPEED)
|
|
|
|
#else
|
|
|
|
#define XY_PROBE_FEEDRATE_MM_S PLANNER_XY_FEEDRATE()
|
|
|
|
#endif
|
|
|
|
|
2019-09-29 09:25:39 +00:00
|
|
|
#if ENABLED(Z_SAFE_HOMING)
|
|
|
|
constexpr xy_float_t safe_homing_xy = { Z_SAFE_HOMING_X_POINT, Z_SAFE_HOMING_Y_POINT };
|
|
|
|
#endif
|
|
|
|
|
2017-09-08 20:35:25 +00:00
|
|
|
/**
|
|
|
|
* Feed rates are often configured with mm/m
|
|
|
|
* but the planner and stepper like mm/s units.
|
|
|
|
*/
|
2019-09-26 06:28:09 +00:00
|
|
|
extern const feedRate_t homing_feedrate_mm_s[XYZ];
|
|
|
|
FORCE_INLINE feedRate_t homing_feedrate(const AxisEnum a) { return pgm_read_float(&homing_feedrate_mm_s[a]); }
|
|
|
|
feedRate_t get_homing_bump_feedrate(const AxisEnum axis);
|
2017-09-08 03:33:16 +00:00
|
|
|
|
2019-09-26 06:28:09 +00:00
|
|
|
extern feedRate_t feedrate_mm_s;
|
2017-09-08 03:33:16 +00:00
|
|
|
|
2017-09-08 20:35:25 +00:00
|
|
|
/**
|
2019-09-26 06:28:09 +00:00
|
|
|
* Feedrate scaling
|
2017-09-08 20:35:25 +00:00
|
|
|
*/
|
|
|
|
extern int16_t feedrate_percentage;
|
|
|
|
|
2018-09-11 04:09:26 +00:00
|
|
|
// The active extruder (tool). Set with T<extruder> command.
|
|
|
|
#if EXTRUDERS > 1
|
|
|
|
extern uint8_t active_extruder;
|
|
|
|
#else
|
|
|
|
constexpr uint8_t active_extruder = 0;
|
|
|
|
#endif
|
2017-09-08 03:33:16 +00:00
|
|
|
|
2019-10-27 22:49:27 +00:00
|
|
|
#if ENABLED(LCD_SHOW_E_TOTAL)
|
|
|
|
extern float e_move_accumulator;
|
|
|
|
#endif
|
|
|
|
|
2018-11-02 05:42:16 +00:00
|
|
|
FORCE_INLINE float pgm_read_any(const float *p) { return pgm_read_float(p); }
|
|
|
|
FORCE_INLINE signed char pgm_read_any(const signed char *p) { return pgm_read_byte(p); }
|
2017-09-08 03:33:16 +00:00
|
|
|
|
2019-09-29 09:25:39 +00:00
|
|
|
#define XYZ_DEFS(T, NAME, OPT) \
|
|
|
|
extern const XYZval<T> NAME##_P; \
|
2019-10-09 01:36:26 +00:00
|
|
|
FORCE_INLINE T NAME(AxisEnum axis) { return pgm_read_any(&NAME##_P[axis]); }
|
2017-09-08 03:33:16 +00:00
|
|
|
|
|
|
|
XYZ_DEFS(float, base_min_pos, MIN_POS);
|
|
|
|
XYZ_DEFS(float, base_max_pos, MAX_POS);
|
|
|
|
XYZ_DEFS(float, base_home_pos, HOME_POS);
|
|
|
|
XYZ_DEFS(float, max_length, MAX_LENGTH);
|
|
|
|
XYZ_DEFS(float, home_bump_mm, HOME_BUMP_MM);
|
|
|
|
XYZ_DEFS(signed char, home_dir, HOME_DIR);
|
|
|
|
|
2018-11-03 08:56:33 +00:00
|
|
|
#if HAS_WORKSPACE_OFFSET
|
|
|
|
void update_workspace_offset(const AxisEnum axis);
|
|
|
|
#else
|
|
|
|
#define update_workspace_offset(x) NOOP
|
|
|
|
#endif
|
|
|
|
|
2019-03-09 04:13:24 +00:00
|
|
|
#if HAS_HOTEND_OFFSET
|
2019-09-29 09:25:39 +00:00
|
|
|
extern xyz_pos_t hotend_offset[HOTENDS];
|
2019-03-09 04:13:24 +00:00
|
|
|
void reset_hotend_offsets();
|
2019-09-29 09:25:39 +00:00
|
|
|
#elif HOTENDS
|
|
|
|
constexpr xyz_pos_t hotend_offset[HOTENDS] = { { 0 } };
|
2019-09-10 07:20:49 +00:00
|
|
|
#else
|
2019-09-29 09:25:39 +00:00
|
|
|
constexpr xyz_pos_t hotend_offset[1] = { { 0 } };
|
2019-03-09 04:13:24 +00:00
|
|
|
#endif
|
|
|
|
|
2019-09-29 09:25:39 +00:00
|
|
|
typedef struct { xyz_pos_t min, max; } axis_limits_t;
|
2017-09-08 03:33:16 +00:00
|
|
|
#if HAS_SOFTWARE_ENDSTOPS
|
|
|
|
extern bool soft_endstops_enabled;
|
2019-09-29 09:25:39 +00:00
|
|
|
extern axis_limits_t soft_endstop;
|
|
|
|
void apply_motion_limits(xyz_pos_t &target);
|
2019-03-09 04:13:24 +00:00
|
|
|
void update_software_endstops(const AxisEnum axis
|
|
|
|
#if HAS_HOTEND_OFFSET
|
|
|
|
, const uint8_t old_tool_index=0, const uint8_t new_tool_index=0
|
|
|
|
#endif
|
|
|
|
);
|
2017-09-08 03:33:16 +00:00
|
|
|
#else
|
2019-03-13 10:48:36 +00:00
|
|
|
constexpr bool soft_endstops_enabled = false;
|
2019-09-29 09:25:39 +00:00
|
|
|
//constexpr axis_limits_t soft_endstop = {
|
|
|
|
// { X_MIN_POS, Y_MIN_POS, Z_MIN_POS },
|
|
|
|
// { X_MAX_POS, Y_MAX_POS, Z_MAX_POS } };
|
2019-03-13 10:48:36 +00:00
|
|
|
#define apply_motion_limits(V) NOOP
|
2019-03-09 04:13:24 +00:00
|
|
|
#define update_software_endstops(...) NOOP
|
2017-09-08 03:33:16 +00:00
|
|
|
#endif
|
|
|
|
|
2017-09-08 20:35:25 +00:00
|
|
|
void report_current_position();
|
|
|
|
|
|
|
|
void get_cartesian_from_steppers();
|
|
|
|
void set_current_from_steppers_for_axis(const AxisEnum axis);
|
|
|
|
|
2017-09-08 03:33:16 +00:00
|
|
|
/**
|
|
|
|
* sync_plan_position
|
|
|
|
*
|
|
|
|
* Set the planner/stepper positions directly from current_position with
|
|
|
|
* no kinematic translation. Used for homing axes and cartesian/core syncing.
|
|
|
|
*/
|
|
|
|
void sync_plan_position();
|
|
|
|
void sync_plan_position_e();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Move the planner to the current position from wherever it last moved
|
|
|
|
* (or from wherever it has been told it is located).
|
|
|
|
*/
|
2019-09-26 06:28:09 +00:00
|
|
|
void line_to_current_position(const feedRate_t &fr_mm_s=feedrate_mm_s);
|
2017-09-08 03:33:16 +00:00
|
|
|
|
2019-09-26 06:28:09 +00:00
|
|
|
void prepare_move_to_destination();
|
|
|
|
|
|
|
|
void _internal_move_to_destination(const feedRate_t &fr_mm_s=0.0f
|
|
|
|
#if IS_KINEMATIC
|
|
|
|
, const bool is_fast=false
|
|
|
|
#endif
|
|
|
|
);
|
|
|
|
|
|
|
|
inline void prepare_internal_move_to_destination(const feedRate_t &fr_mm_s=0.0f) {
|
|
|
|
_internal_move_to_destination(fr_mm_s);
|
|
|
|
}
|
2017-09-08 03:33:16 +00:00
|
|
|
|
|
|
|
#if IS_KINEMATIC
|
2019-09-26 06:28:09 +00:00
|
|
|
void prepare_fast_move_to_destination(const feedRate_t &scaled_fr_mm_s=MMS_SCALED(feedrate_mm_s));
|
2017-09-08 03:33:16 +00:00
|
|
|
|
2019-09-26 06:28:09 +00:00
|
|
|
inline void prepare_internal_fast_move_to_destination(const feedRate_t &fr_mm_s=0.0f) {
|
|
|
|
_internal_move_to_destination(fr_mm_s, true);
|
|
|
|
}
|
|
|
|
#endif
|
2017-09-08 03:33:16 +00:00
|
|
|
|
2017-09-08 20:35:25 +00:00
|
|
|
/**
|
|
|
|
* Blocking movement and shorthand functions
|
|
|
|
*/
|
2019-09-26 06:28:09 +00:00
|
|
|
void do_blocking_move_to(const float rx, const float ry, const float rz, const feedRate_t &fr_mm_s=0.0f);
|
2019-10-07 04:58:19 +00:00
|
|
|
void do_blocking_move_to(const xy_pos_t &raw, const feedRate_t &fr_mm_s=0.0f);
|
|
|
|
void do_blocking_move_to(const xyz_pos_t &raw, const feedRate_t &fr_mm_s=0.0f);
|
|
|
|
void do_blocking_move_to(const xyze_pos_t &raw, const feedRate_t &fr_mm_s=0.0f);
|
2019-10-01 00:57:22 +00:00
|
|
|
|
|
|
|
void do_blocking_move_to_x(const float &rx, const feedRate_t &fr_mm_s=0.0f);
|
|
|
|
void do_blocking_move_to_y(const float &ry, const feedRate_t &fr_mm_s=0.0f);
|
|
|
|
void do_blocking_move_to_z(const float &rz, const feedRate_t &fr_mm_s=0.0f);
|
2018-10-14 04:08:20 +00:00
|
|
|
|
2019-10-07 04:58:19 +00:00
|
|
|
void do_blocking_move_to_xy(const float &rx, const float &ry, const feedRate_t &fr_mm_s=0.0f);
|
|
|
|
void do_blocking_move_to_xy(const xy_pos_t &raw, const feedRate_t &fr_mm_s=0.0f);
|
|
|
|
FORCE_INLINE void do_blocking_move_to_xy(const xyz_pos_t &raw, const feedRate_t &fr_mm_s=0.0f) { do_blocking_move_to_xy(xy_pos_t(raw), fr_mm_s); }
|
|
|
|
FORCE_INLINE void do_blocking_move_to_xy(const xyze_pos_t &raw, const feedRate_t &fr_mm_s=0.0f) { do_blocking_move_to_xy(xy_pos_t(raw), fr_mm_s); }
|
|
|
|
|
|
|
|
void do_blocking_move_to_xy_z(const xy_pos_t &raw, const float &z, const feedRate_t &fr_mm_s=0.0f);
|
|
|
|
FORCE_INLINE void do_blocking_move_to_xy_z(const xyz_pos_t &raw, const float &z, const feedRate_t &fr_mm_s=0.0f) { do_blocking_move_to_xy_z(xy_pos_t(raw), z, fr_mm_s); }
|
|
|
|
FORCE_INLINE void do_blocking_move_to_xy_z(const xyze_pos_t &raw, const float &z, const feedRate_t &fr_mm_s=0.0f) { do_blocking_move_to_xy_z(xy_pos_t(raw), z, fr_mm_s); }
|
|
|
|
|
2019-09-24 01:58:01 +00:00
|
|
|
void remember_feedrate_and_scaling();
|
|
|
|
void remember_feedrate_scaling_off();
|
|
|
|
void restore_feedrate_and_scaling();
|
2017-09-08 20:35:25 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Homing
|
|
|
|
//
|
|
|
|
|
2019-09-26 02:01:29 +00:00
|
|
|
uint8_t axes_need_homing(uint8_t axis_bits=0x07);
|
|
|
|
bool axis_unhomed_error(uint8_t axis_bits=0x07);
|
2017-09-08 20:35:25 +00:00
|
|
|
|
2017-10-02 02:34:58 +00:00
|
|
|
#if ENABLED(NO_MOTION_BEFORE_HOMING)
|
|
|
|
#define MOTION_CONDITIONS (IsRunning() && !axis_unhomed_error())
|
|
|
|
#else
|
|
|
|
#define MOTION_CONDITIONS IsRunning()
|
|
|
|
#endif
|
|
|
|
|
2017-09-08 20:35:25 +00:00
|
|
|
void set_axis_is_at_home(const AxisEnum axis);
|
|
|
|
|
2018-10-29 19:01:36 +00:00
|
|
|
void set_axis_is_not_at_home(const AxisEnum axis);
|
|
|
|
|
2017-09-08 20:35:25 +00:00
|
|
|
void homeaxis(const AxisEnum axis);
|
2018-03-01 07:37:31 +00:00
|
|
|
|
2018-02-23 06:42:42 +00:00
|
|
|
/**
|
|
|
|
* Workspace offsets
|
|
|
|
*/
|
2018-11-03 08:39:15 +00:00
|
|
|
#if HAS_HOME_OFFSET || HAS_POSITION_SHIFT
|
2017-09-08 03:33:16 +00:00
|
|
|
#if HAS_HOME_OFFSET
|
2019-09-29 09:25:39 +00:00
|
|
|
extern xyz_pos_t home_offset;
|
2017-09-08 03:33:16 +00:00
|
|
|
#endif
|
|
|
|
#if HAS_POSITION_SHIFT
|
2019-09-29 09:25:39 +00:00
|
|
|
extern xyz_pos_t position_shift;
|
2017-09-08 03:33:16 +00:00
|
|
|
#endif
|
2018-02-23 06:42:42 +00:00
|
|
|
#if HAS_HOME_OFFSET && HAS_POSITION_SHIFT
|
2019-09-29 09:25:39 +00:00
|
|
|
extern xyz_pos_t workspace_offset;
|
|
|
|
#define _WS workspace_offset
|
2018-02-23 06:42:42 +00:00
|
|
|
#elif HAS_HOME_OFFSET
|
2019-09-29 09:25:39 +00:00
|
|
|
#define _WS home_offset
|
2018-11-03 08:39:15 +00:00
|
|
|
#else
|
2019-09-29 09:25:39 +00:00
|
|
|
#define _WS position_shift
|
2018-02-23 06:42:42 +00:00
|
|
|
#endif
|
2019-09-29 09:25:39 +00:00
|
|
|
#define NATIVE_TO_LOGICAL(POS, AXIS) ((POS) + _WS[AXIS])
|
|
|
|
#define LOGICAL_TO_NATIVE(POS, AXIS) ((POS) - _WS[AXIS])
|
|
|
|
FORCE_INLINE void toLogical(xy_pos_t &raw) { raw += _WS; }
|
|
|
|
FORCE_INLINE void toLogical(xyz_pos_t &raw) { raw += _WS; }
|
|
|
|
FORCE_INLINE void toLogical(xyze_pos_t &raw) { raw += _WS; }
|
|
|
|
FORCE_INLINE void toNative(xy_pos_t &raw) { raw -= _WS; }
|
|
|
|
FORCE_INLINE void toNative(xyz_pos_t &raw) { raw -= _WS; }
|
|
|
|
FORCE_INLINE void toNative(xyze_pos_t &raw) { raw -= _WS; }
|
2017-09-08 03:33:16 +00:00
|
|
|
#else
|
2018-02-23 06:42:42 +00:00
|
|
|
#define NATIVE_TO_LOGICAL(POS, AXIS) (POS)
|
|
|
|
#define LOGICAL_TO_NATIVE(POS, AXIS) (POS)
|
2019-10-01 02:44:07 +00:00
|
|
|
FORCE_INLINE void toLogical(xy_pos_t&) {}
|
|
|
|
FORCE_INLINE void toLogical(xyz_pos_t&) {}
|
|
|
|
FORCE_INLINE void toLogical(xyze_pos_t&) {}
|
|
|
|
FORCE_INLINE void toNative(xy_pos_t&) {}
|
|
|
|
FORCE_INLINE void toNative(xyz_pos_t&) {}
|
|
|
|
FORCE_INLINE void toNative(xyze_pos_t&) {}
|
2017-09-08 03:33:16 +00:00
|
|
|
#endif
|
2018-02-23 06:42:42 +00:00
|
|
|
#define LOGICAL_X_POSITION(POS) NATIVE_TO_LOGICAL(POS, X_AXIS)
|
|
|
|
#define LOGICAL_Y_POSITION(POS) NATIVE_TO_LOGICAL(POS, Y_AXIS)
|
|
|
|
#define LOGICAL_Z_POSITION(POS) NATIVE_TO_LOGICAL(POS, Z_AXIS)
|
|
|
|
#define RAW_X_POSITION(POS) LOGICAL_TO_NATIVE(POS, X_AXIS)
|
|
|
|
#define RAW_Y_POSITION(POS) LOGICAL_TO_NATIVE(POS, Y_AXIS)
|
|
|
|
#define RAW_Z_POSITION(POS) LOGICAL_TO_NATIVE(POS, Z_AXIS)
|
2017-09-08 03:33:16 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* position_is_reachable family of functions
|
|
|
|
*/
|
|
|
|
|
|
|
|
#if IS_KINEMATIC // (DELTA or SCARA)
|
2020-01-03 23:46:26 +00:00
|
|
|
|
2018-11-03 08:56:33 +00:00
|
|
|
#if HAS_SCARA_OFFSET
|
2019-09-29 09:25:39 +00:00
|
|
|
extern abc_pos_t scara_home_offset; // A and B angular offsets, Z mm offset
|
2018-11-03 08:56:33 +00:00
|
|
|
#endif
|
|
|
|
|
2018-03-10 03:12:05 +00:00
|
|
|
// Return true if the given point is within the printable area
|
2018-03-13 06:15:22 +00:00
|
|
|
inline bool position_is_reachable(const float &rx, const float &ry, const float inset=0) {
|
2017-09-08 03:33:16 +00:00
|
|
|
#if ENABLED(DELTA)
|
2019-11-26 08:53:28 +00:00
|
|
|
return HYPOT2(rx, ry) <= sq(DELTA_PRINTABLE_RADIUS - inset + slop);
|
2017-09-08 03:33:16 +00:00
|
|
|
#elif IS_SCARA
|
2018-03-13 06:15:22 +00:00
|
|
|
const float R2 = HYPOT2(rx - SCARA_OFFSET_X, ry - SCARA_OFFSET_Y);
|
|
|
|
return (
|
|
|
|
R2 <= sq(L1 + L2) - inset
|
|
|
|
#if MIDDLE_DEAD_ZONE_R > 0
|
|
|
|
&& R2 >= sq(float(MIDDLE_DEAD_ZONE_R))
|
|
|
|
#endif
|
|
|
|
);
|
2017-09-08 03:33:16 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2019-09-29 09:25:39 +00:00
|
|
|
inline bool position_is_reachable(const xy_pos_t &pos, const float inset=0) {
|
|
|
|
return position_is_reachable(pos.x, pos.y, inset);
|
|
|
|
}
|
|
|
|
|
2018-03-13 06:15:22 +00:00
|
|
|
#if HAS_BED_PROBE
|
2020-01-03 23:46:26 +00:00
|
|
|
|
|
|
|
#if HAS_PROBE_XY_OFFSET
|
|
|
|
|
|
|
|
// Return true if the both nozzle and the probe can reach the given point.
|
|
|
|
// Note: This won't work on SCARA since the probe offset rotates with the arm.
|
|
|
|
inline bool position_is_reachable_by_probe(const float &rx, const float &ry) {
|
2020-02-01 10:21:36 +00:00
|
|
|
return position_is_reachable(rx - probe.offset_xy.x, ry - probe.offset_xy.y)
|
2020-01-03 23:46:26 +00:00
|
|
|
&& position_is_reachable(rx, ry, ABS(MIN_PROBE_EDGE));
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
FORCE_INLINE bool position_is_reachable_by_probe(const float &rx, const float &ry) {
|
|
|
|
return position_is_reachable(rx, ry, MIN_PROBE_EDGE);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif // HAS_BED_PROBE
|
2017-09-08 03:33:16 +00:00
|
|
|
|
|
|
|
#else // CARTESIAN
|
|
|
|
|
2018-08-22 04:33:55 +00:00
|
|
|
// Return true if the given position is within the machine bounds.
|
2017-11-03 04:59:42 +00:00
|
|
|
inline bool position_is_reachable(const float &rx, const float &ry) {
|
2018-08-22 04:33:55 +00:00
|
|
|
if (!WITHIN(ry, Y_MIN_POS - slop, Y_MAX_POS + slop)) return false;
|
2018-08-22 00:12:26 +00:00
|
|
|
#if ENABLED(DUAL_X_CARRIAGE)
|
2018-08-22 04:33:55 +00:00
|
|
|
if (active_extruder)
|
|
|
|
return WITHIN(rx, X2_MIN_POS - slop, X2_MAX_POS + slop);
|
|
|
|
else
|
|
|
|
return WITHIN(rx, X1_MIN_POS - slop, X1_MAX_POS + slop);
|
2018-08-22 00:12:26 +00:00
|
|
|
#else
|
2018-08-22 04:33:55 +00:00
|
|
|
return WITHIN(rx, X_MIN_POS - slop, X_MAX_POS + slop);
|
2018-08-22 00:12:26 +00:00
|
|
|
#endif
|
2017-09-08 03:33:16 +00:00
|
|
|
}
|
2019-09-29 09:25:39 +00:00
|
|
|
inline bool position_is_reachable(const xy_pos_t &pos) { return position_is_reachable(pos.x, pos.y); }
|
2017-09-08 03:33:16 +00:00
|
|
|
|
2018-03-13 06:15:22 +00:00
|
|
|
#if HAS_BED_PROBE
|
2020-01-03 23:46:26 +00:00
|
|
|
|
2018-03-13 06:15:22 +00:00
|
|
|
/**
|
|
|
|
* Return whether the given position is within the bed, and whether the nozzle
|
|
|
|
* can reach the position required to put the probe at the given position.
|
|
|
|
*
|
|
|
|
* Example: For a probe offset of -10,+10, then for the probe to reach 0,0 the
|
|
|
|
* nozzle must be be able to reach +10,-10.
|
|
|
|
*/
|
|
|
|
inline bool position_is_reachable_by_probe(const float &rx, const float &ry) {
|
2020-02-01 10:21:36 +00:00
|
|
|
return position_is_reachable(rx - probe.offset_xy.x, ry - probe.offset_xy.y)
|
|
|
|
&& WITHIN(rx, probe.min_x() - slop, probe.max_x() + slop)
|
|
|
|
&& WITHIN(ry, probe.min_y() - slop, probe.max_y() + slop);
|
2018-03-13 06:15:22 +00:00
|
|
|
}
|
2020-01-03 23:46:26 +00:00
|
|
|
|
|
|
|
#endif // HAS_BED_PROBE
|
2017-09-08 03:33:16 +00:00
|
|
|
|
|
|
|
#endif // CARTESIAN
|
|
|
|
|
2018-03-13 06:15:22 +00:00
|
|
|
#if !HAS_BED_PROBE
|
|
|
|
FORCE_INLINE bool position_is_reachable_by_probe(const float &rx, const float &ry) { return position_is_reachable(rx, ry); }
|
|
|
|
#endif
|
2019-09-29 09:25:39 +00:00
|
|
|
FORCE_INLINE bool position_is_reachable_by_probe(const xy_pos_t &pos) { return position_is_reachable_by_probe(pos.x, pos.y); }
|
2018-03-13 06:15:22 +00:00
|
|
|
|
2017-09-08 20:35:25 +00:00
|
|
|
/**
|
2019-03-13 05:42:50 +00:00
|
|
|
* Duplication mode
|
2017-09-08 20:35:25 +00:00
|
|
|
*/
|
2019-03-13 05:42:50 +00:00
|
|
|
#if HAS_DUPLICATION_MODE
|
2019-03-16 03:46:27 +00:00
|
|
|
extern bool extruder_duplication_enabled, // Used in Dual X mode 2
|
|
|
|
mirrored_duplication_mode; // Used in Dual X mode 3
|
2019-04-04 07:44:07 +00:00
|
|
|
#if ENABLED(MULTI_NOZZLE_DUPLICATION)
|
|
|
|
extern uint8_t duplication_e_mask;
|
|
|
|
#endif
|
2017-09-08 03:33:16 +00:00
|
|
|
#endif
|
|
|
|
|
2017-09-08 20:35:25 +00:00
|
|
|
/**
|
|
|
|
* Dual X Carriage
|
|
|
|
*/
|
2017-09-08 03:33:16 +00:00
|
|
|
#if ENABLED(DUAL_X_CARRIAGE)
|
|
|
|
|
2018-03-07 04:35:22 +00:00
|
|
|
enum DualXMode : char {
|
2018-09-17 06:06:22 +00:00
|
|
|
DXC_FULL_CONTROL_MODE,
|
|
|
|
DXC_AUTO_PARK_MODE,
|
|
|
|
DXC_DUPLICATION_MODE,
|
2019-03-16 03:46:27 +00:00
|
|
|
DXC_MIRRORED_MODE
|
2017-11-19 21:11:11 +00:00
|
|
|
};
|
|
|
|
|
2017-09-08 03:33:16 +00:00
|
|
|
extern DualXMode dual_x_carriage_mode;
|
2019-03-16 03:46:27 +00:00
|
|
|
extern float inactive_extruder_x_pos, // Used in mode 0 & 1
|
|
|
|
duplicate_extruder_x_offset; // Used in mode 2 & 3
|
2019-09-29 09:25:39 +00:00
|
|
|
extern xyz_pos_t raised_parked_position; // Used in mode 1
|
2019-03-16 03:46:27 +00:00
|
|
|
extern bool active_extruder_parked; // Used in mode 1, 2 & 3
|
|
|
|
extern millis_t delayed_move_time; // Used in mode 1
|
|
|
|
extern int16_t duplicate_extruder_temp_offset; // Used in mode 2 & 3
|
2017-09-08 03:33:16 +00:00
|
|
|
|
2018-09-17 06:06:22 +00:00
|
|
|
FORCE_INLINE bool dxc_is_duplicating() { return dual_x_carriage_mode >= DXC_DUPLICATION_MODE; }
|
|
|
|
|
2017-09-08 03:33:16 +00:00
|
|
|
float x_home_pos(const int extruder);
|
|
|
|
|
|
|
|
FORCE_INLINE int x_home_dir(const uint8_t extruder) { return extruder ? X2_HOME_DIR : X_HOME_DIR; }
|
|
|
|
|
2019-03-13 05:42:50 +00:00
|
|
|
#elif ENABLED(MULTI_NOZZLE_DUPLICATION)
|
2017-11-19 21:11:11 +00:00
|
|
|
|
2018-03-07 04:35:22 +00:00
|
|
|
enum DualXMode : char {
|
2017-11-19 21:11:11 +00:00
|
|
|
DXC_DUPLICATION_MODE = 2
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
2017-09-08 03:33:16 +00:00
|
|
|
|
2017-09-08 20:35:25 +00:00
|
|
|
#if HAS_M206_COMMAND
|
|
|
|
void set_home_offset(const AxisEnum axis, const float v);
|
|
|
|
#endif
|