Merge pull request #12313 from thinkyhead/bf2_scara_home_offset

Revive SCARA home offset (not fully implemented)
This commit is contained in:
Scott Lahteine 2018-11-03 07:05:24 -05:00 committed by GitHub
commit 8696f882a9
Signed by: GitHub
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 211 additions and 164 deletions

View file

@ -66,32 +66,43 @@
* S[segments-per-second] - Segments-per-second * S[segments-per-second] - Segments-per-second
* P[theta-psi-offset] - Theta-Psi offset, added to the shoulder (A/X) angle * P[theta-psi-offset] - Theta-Psi offset, added to the shoulder (A/X) angle
* T[theta-offset] - Theta offset, added to the elbow (B/Y) angle * T[theta-offset] - Theta offset, added to the elbow (B/Y) angle
* Z[z-offset] - Z offset, added to Z
* *
* A, P, and X are all aliases for the shoulder angle * A, P, and X are all aliases for the shoulder angle
* B, T, and Y are all aliases for the elbow angle * B, T, and Y are all aliases for the elbow angle
*/ */
void GcodeSuite::M665() { void GcodeSuite::M665() {
if (parser.seen('S')) delta_segments_per_second = parser.value_float(); if (parser.seenval('S')) delta_segments_per_second = parser.value_float();
const bool hasA = parser.seen('A'), hasP = parser.seen('P'), hasX = parser.seen('X'); #if HAS_SCARA_OFFSET
const uint8_t sumAPX = hasA + hasP + hasX;
if (sumAPX == 1)
home_offset[A_AXIS] = parser.value_float();
else if (sumAPX > 1) {
SERIAL_ERROR_START();
SERIAL_ERRORLNPGM("Only one of A, P, or X is allowed.");
return;
}
const bool hasB = parser.seen('B'), hasT = parser.seen('T'), hasY = parser.seen('Y'); if (parser.seenval('Z')) scara_home_offset[Z_AXIS] = parser.value_linear_units();
const uint8_t sumBTY = hasB + hasT + hasY;
if (sumBTY == 1) const bool hasA = parser.seenval('A'), hasP = parser.seenval('P'), hasX = parser.seenval('X');
home_offset[B_AXIS] = parser.value_float(); const uint8_t sumAPX = hasA + hasP + hasX;
else if (sumBTY > 1) { if (sumAPX) {
SERIAL_ERROR_START(); if (sumAPX == 1)
SERIAL_ERRORLNPGM("Only one of B, T, or Y is allowed."); scara_home_offset[A_AXIS] = parser.value_float();
return; else {
} SERIAL_ERROR_START();
SERIAL_ERRORLNPGM("Only one of A, P, or X is allowed.");
return;
}
}
const bool hasB = parser.seenval('B'), hasT = parser.seenval('T'), hasY = parser.seenval('Y');
const uint8_t sumBTY = hasB + hasT + hasY;
if (sumBTY) {
if (sumBTY == 1)
scara_home_offset[B_AXIS] = parser.value_float();
else {
SERIAL_ERROR_START();
SERIAL_ERRORLNPGM("Only one of B, T, or Y is allowed.");
return;
}
}
#endif // HAS_SCARA_OFFSET
} }
#endif #endif

View file

@ -20,6 +20,10 @@
* *
*/ */
#include "../../inc/MarlinConfigPre.h"
#if HAS_SOFTWARE_ENDSTOPS
#include "../gcode.h" #include "../gcode.h"
#include "../../module/motion.h" #include "../../module/motion.h"
@ -46,3 +50,5 @@ void GcodeSuite::M211() {
SERIAL_ECHOPAIR(" " MSG_Y, LOGICAL_Y_POSITION(soft_endstop_max[Y_AXIS])); SERIAL_ECHOPAIR(" " MSG_Y, LOGICAL_Y_POSITION(soft_endstop_max[Y_AXIS]));
SERIAL_ECHOLNPAIR(" " MSG_Z, LOGICAL_Z_POSITION(soft_endstop_max[Z_AXIS])); SERIAL_ECHOLNPAIR(" " MSG_Z, LOGICAL_Z_POSITION(soft_endstop_max[Z_AXIS]));
} }
#endif

View file

@ -483,7 +483,9 @@ void GcodeSuite::process_parsed_command(
#endif #endif
#endif #endif
case 211: M211(); break; // M211: Enable, Disable, and/or Report software endstops #if HAS_SOFTWARE_ENDSTOPS
case 211: M211(); break; // M211: Enable, Disable, and/or Report software endstops
#endif
#if EXTRUDERS > 1 #if EXTRUDERS > 1
case 217: M217(); break; // M217: Set filament swap parameters case 217: M217(); break; // M217: Set filament swap parameters

View file

@ -44,7 +44,7 @@ bool GcodeSuite::select_coordinate_system(const int8_t _new) {
const float diff = new_offset[i] - old_offset[i]; const float diff = new_offset[i] - old_offset[i];
if (diff) { if (diff) {
position_shift[i] += diff; position_shift[i] += diff;
update_software_endstops((AxisEnum)i); update_workspace_offset((AxisEnum)i);
} }
} }
return true; return true;

View file

@ -42,7 +42,7 @@ void GcodeSuite::G92() {
const float v = position_shift[i]; const float v = position_shift[i];
if (v) { if (v) {
position_shift[i] = 0; position_shift[i] = 0;
update_software_endstops((AxisEnum)i); update_workspace_offset((AxisEnum)i);
} }
} }
#endif // Not SCARA #endif // Not SCARA
@ -79,7 +79,7 @@ void GcodeSuite::G92() {
} }
else { else {
position_shift[i] += d; // Other axes simply offset the coordinate space position_shift[i] += d; // Other axes simply offset the coordinate space
update_software_endstops((AxisEnum)i); update_workspace_offset((AxisEnum)i);
} }
#endif #endif
} }

View file

@ -1527,11 +1527,13 @@
// Updated G92 behavior shifts the workspace // Updated G92 behavior shifts the workspace
#define HAS_POSITION_SHIFT DISABLED(NO_WORKSPACE_OFFSETS) #define HAS_POSITION_SHIFT DISABLED(NO_WORKSPACE_OFFSETS)
// The home offset also shifts the coordinate space // The home offset also shifts the coordinate space
#define HAS_HOME_OFFSET (DISABLED(NO_WORKSPACE_OFFSETS) && DISABLED(DELTA)) #define HAS_HOME_OFFSET (DISABLED(NO_WORKSPACE_OFFSETS) && IS_CARTESIAN)
// Either offset yields extra calculations on all moves // The SCARA home offset applies only on G28
#define HAS_WORKSPACE_OFFSET (HAS_POSITION_SHIFT || HAS_HOME_OFFSET) #define HAS_SCARA_OFFSET (DISABLED(NO_WORKSPACE_OFFSETS) && IS_SCARA)
// M206 doesn't apply to DELTA // Cumulative offset to workspace to save some calculation
#define HAS_M206_COMMAND (HAS_HOME_OFFSET && DISABLED(DELTA)) #define HAS_WORKSPACE_OFFSET (HAS_POSITION_SHIFT && HAS_HOME_OFFSET)
// M206 sets the home offset for Cartesian machines
#define HAS_M206_COMMAND (HAS_HOME_OFFSET && !IS_SCARA)
// LCD timeout to status screen default is 15s // LCD timeout to status screen default is 15s
#ifndef LCD_TIMEOUT_TO_STATUS #ifndef LCD_TIMEOUT_TO_STATUS

View file

@ -200,7 +200,7 @@ namespace UI {
max = current_position[axis] + 1000; max = current_position[axis] + 1000;
// Limit to software endstops, if enabled // Limit to software endstops, if enabled
#if ENABLED(MIN_SOFTWARE_ENDSTOPS) || ENABLED(MAX_SOFTWARE_ENDSTOPS) #if HAS_SOFTWARE_ENDSTOPS
if (soft_endstops_enabled) switch (axis) { if (soft_endstops_enabled) switch (axis) {
case X_AXIS: case X_AXIS:
#if ENABLED(MIN_SOFTWARE_ENDSTOP_X) #if ENABLED(MIN_SOFTWARE_ENDSTOP_X)
@ -227,7 +227,7 @@ namespace UI {
#endif #endif
default: break; default: break;
} }
#endif // MIN_SOFTWARE_ENDSTOPS || MAX_SOFTWARE_ENDSTOPS #endif // HAS_SOFTWARE_ENDSTOPS
// Delta limits XY based on the current offset from center // Delta limits XY based on the current offset from center
// This assumes the center is 0,0 // This assumes the center is 0,0

View file

@ -88,7 +88,7 @@ static void _lcd_move_xyz(PGM_P name, AxisEnum axis) {
max = current_position[axis] + 1000; max = current_position[axis] + 1000;
// Limit to software endstops, if enabled // Limit to software endstops, if enabled
#if ENABLED(MIN_SOFTWARE_ENDSTOPS) || ENABLED(MAX_SOFTWARE_ENDSTOPS) #if HAS_SOFTWARE_ENDSTOPS
if (soft_endstops_enabled) switch (axis) { if (soft_endstops_enabled) switch (axis) {
case X_AXIS: case X_AXIS:
#if ENABLED(MIN_SOFTWARE_ENDSTOP_X) #if ENABLED(MIN_SOFTWARE_ENDSTOP_X)
@ -115,7 +115,7 @@ static void _lcd_move_xyz(PGM_P name, AxisEnum axis) {
#endif #endif
default: break; default: break;
} }
#endif // MIN_SOFTWARE_ENDSTOPS || MAX_SOFTWARE_ENDSTOPS #endif // HAS_SOFTWARE_ENDSTOPS
// Delta limits XY based on the current offset from center // Delta limits XY based on the current offset from center
// This assumes the center is 0,0 // This assumes the center is 0,0

View file

@ -124,7 +124,7 @@ typedef struct SettingsDataStruct {
float planner_max_jerk[XYZE], // M205 XYZE planner.max_jerk[XYZE] float planner_max_jerk[XYZE], // M205 XYZE planner.max_jerk[XYZE]
planner_junction_deviation_mm; // M205 J planner.junction_deviation_mm planner_junction_deviation_mm; // M205 J planner.junction_deviation_mm
float home_offset[XYZ]; // M206 XYZ float home_offset[XYZ]; // M206 XYZ / M665 TPZ
#if HAS_HOTEND_OFFSET #if HAS_HOTEND_OFFSET
float hotend_offset[XYZ][HOTENDS - 1]; // M218 XYZ float hotend_offset[XYZ][HOTENDS - 1]; // M218 XYZ
@ -309,10 +309,11 @@ void MarlinSettings::postprocess() {
planner.refresh_e_factor(i); planner.refresh_e_factor(i);
#endif #endif
#if HAS_HOME_OFFSET || ENABLED(DUAL_X_CARRIAGE) // Software endstops depend on home_offset
// Software endstops depend on home_offset LOOP_XYZ(i) {
LOOP_XYZ(i) update_software_endstops((AxisEnum)i); update_workspace_offset((AxisEnum)i);
#endif update_software_endstops((AxisEnum)i);
}
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
set_z_fade_height(new_z_fade_height, false); // false = no report set_z_fade_height(new_z_fade_height, false); // false = no report
@ -453,10 +454,14 @@ void MarlinSettings::postprocess() {
_FIELD_TEST(home_offset); _FIELD_TEST(home_offset);
#if !HAS_HOME_OFFSET #if HAS_SCARA_OFFSET
const float home_offset[XYZ] = { 0 }; EEPROM_WRITE(scara_home_offset);
#else
#if !HAS_HOME_OFFSET
const float home_offset[XYZ] = { 0 };
#endif
EEPROM_WRITE(home_offset);
#endif #endif
EEPROM_WRITE(home_offset);
#if HAS_HOTEND_OFFSET #if HAS_HOTEND_OFFSET
// Skip hotend 0 which must be 0 // Skip hotend 0 which must be 0
@ -1062,15 +1067,19 @@ void MarlinSettings::postprocess() {
} }
// //
// Home Offset (M206) // Home Offset (M206 / M665)
// //
{ {
_FIELD_TEST(home_offset); _FIELD_TEST(home_offset);
#if !HAS_HOME_OFFSET #if HAS_SCARA_OFFSET
float home_offset[XYZ]; EEPROM_READ(scara_home_offset);
#else
#if !HAS_HOME_OFFSET
float home_offset[XYZ];
#endif
EEPROM_READ(home_offset);
#endif #endif
EEPROM_READ(home_offset);
} }
// //
@ -1826,7 +1835,9 @@ void MarlinSettings::reset(PORTARG_SOLO) {
planner.junction_deviation_mm = float(JUNCTION_DEVIATION_MM); planner.junction_deviation_mm = float(JUNCTION_DEVIATION_MM);
#endif #endif
#if HAS_HOME_OFFSET #if HAS_SCARA_OFFSET
ZERO(scara_home_offset);
#elif HAS_HOME_OFFSET
ZERO(home_offset); ZERO(home_offset);
#endif #endif
@ -2430,7 +2441,20 @@ void MarlinSettings::reset(PORTARG_SOLO) {
#endif // HAS_SERVOS && EDITABLE_SERVO_ANGLES #endif // HAS_SERVOS && EDITABLE_SERVO_ANGLES
#if ENABLED(DELTA) #if HAS_SCARA_OFFSET
if (!forReplay) {
CONFIG_ECHO_START;
SERIAL_ECHOLNPGM_P(port, "SCARA settings: S<seg-per-sec> P<theta-psi-offset> T<theta-offset>");
}
CONFIG_ECHO_START;
SERIAL_ECHOPAIR_P(port, " M665 S", delta_segments_per_second);
SERIAL_ECHOPAIR_P(port, " P", scara_home_offset[A_AXIS]);
SERIAL_ECHOPAIR_P(port, " T", scara_home_offset[B_AXIS]);
SERIAL_ECHOPAIR_P(port, " Z", LINEAR_UNIT(scara_home_offset[Z_AXIS]));
SERIAL_EOL_P(port);
#elif ENABLED(DELTA)
if (!forReplay) { if (!forReplay) {
CONFIG_ECHO_START; CONFIG_ECHO_START;

View file

@ -129,29 +129,30 @@ const float homing_feedrate_mm_s[4] PROGMEM = {
// Cartesian conversion result goes here: // Cartesian conversion result goes here:
float cartes[XYZ]; float cartes[XYZ];
// Until kinematics.cpp is created, create this here
#if IS_KINEMATIC #if IS_KINEMATIC
float delta[ABC]; float delta[ABC];
#endif #endif
#if HAS_SCARA_OFFSET
float scara_home_offset[ABC];
#endif
/** /**
* The workspace can be offset by some commands, or * The workspace can be offset by some commands, or
* these offsets may be omitted to save on computation. * these offsets may be omitted to save on computation.
*/ */
#if HAS_WORKSPACE_OFFSET #if HAS_POSITION_SHIFT
#if HAS_POSITION_SHIFT // The distance that XYZ has been offset by G92. Reset by G28.
// The distance that XYZ has been offset by G92. Reset by G28. float position_shift[XYZ] = { 0 };
float position_shift[XYZ] = { 0 }; #endif
#endif #if HAS_HOME_OFFSET
#if HAS_HOME_OFFSET // This offset is added to the configured home position.
// This offset is added to the configured home position. // Set by M206, M428, or menu item. Saved to EEPROM.
// Set by M206, M428, or menu item. Saved to EEPROM. float home_offset[XYZ] = { 0 };
float home_offset[XYZ] = { 0 }; #endif
#endif #if HAS_HOME_OFFSET && HAS_POSITION_SHIFT
#if HAS_HOME_OFFSET && HAS_POSITION_SHIFT // The above two are combined to save on computes
// The above two are combined to save on computes float workspace_offset[XYZ] = { 0 };
float workspace_offset[XYZ] = { 0 };
#endif
#endif #endif
#if OLDSCHOOL_ABL #if OLDSCHOOL_ABL
@ -454,15 +455,14 @@ void bracket_probe_move(const bool before) {
void setup_for_endstop_or_probe_move() { bracket_probe_move(true); } void setup_for_endstop_or_probe_move() { bracket_probe_move(true); }
void clean_up_after_endstop_or_probe_move() { bracket_probe_move(false); } void clean_up_after_endstop_or_probe_move() { bracket_probe_move(false); }
// Software Endstops are based on the configured limits.
float soft_endstop_min[XYZ] = { X_MIN_BED, Y_MIN_BED, Z_MIN_POS },
soft_endstop_max[XYZ] = { X_MAX_BED, Y_MAX_BED, Z_MAX_POS };
#if HAS_SOFTWARE_ENDSTOPS #if HAS_SOFTWARE_ENDSTOPS
// Software Endstops are based on the configured limits.
bool soft_endstops_enabled = true; bool soft_endstops_enabled = true;
// Software Endstops are based on the configured limits.
float soft_endstop_min[XYZ] = { X_MIN_BED, Y_MIN_BED, Z_MIN_POS },
soft_endstop_max[XYZ] = { X_MAX_BED, Y_MAX_BED, Z_MAX_POS };
#if IS_KINEMATIC #if IS_KINEMATIC
float soft_endstop_radius, soft_endstop_radius_2; float soft_endstop_radius, soft_endstop_radius_2;
#endif #endif
@ -504,6 +504,79 @@ float soft_endstop_min[XYZ] = { X_MIN_BED, Y_MIN_BED, Z_MIN_POS },
#endif #endif
} }
/**
* Software endstops can be used to monitor the open end of
* an axis that has a hardware endstop on the other end. Or
* they can prevent axes from moving past endstops and grinding.
*
* To keep doing their job as the coordinate system changes,
* the software endstop positions must be refreshed to remain
* at the same positions relative to the machine.
*/
void update_software_endstops(const AxisEnum axis) {
#if ENABLED(DUAL_X_CARRIAGE)
if (axis == X_AXIS) {
// In Dual X mode hotend_offset[X] is T1's home position
const float dual_max_x = MAX(hotend_offset[X_AXIS][1], X2_MAX_POS);
if (active_extruder != 0) {
// T1 can move from X2_MIN_POS to X2_MAX_POS or X2 home position (whichever is larger)
soft_endstop_min[X_AXIS] = X2_MIN_POS;
soft_endstop_max[X_AXIS] = dual_max_x;
}
else if (dxc_is_duplicating()) {
// In Duplication Mode, T0 can move as far left as X1_MIN_POS
// but not so far to the right that T1 would move past the end
soft_endstop_min[X_AXIS] = X1_MIN_POS;
soft_endstop_max[X_AXIS] = MIN(X1_MAX_POS, dual_max_x - duplicate_extruder_x_offset);
}
else {
// In other modes, T0 can move from X1_MIN_POS to X1_MAX_POS
soft_endstop_min[X_AXIS] = X1_MIN_POS;
soft_endstop_max[X_AXIS] = X1_MAX_POS;
}
}
#elif ENABLED(DELTA)
soft_endstop_min[axis] = base_min_pos(axis);
soft_endstop_max[axis] = (axis == Z_AXIS ? delta_height
#if HAS_BED_PROBE
- zprobe_zoffset + Z_PROBE_OFFSET_FROM_EXTRUDER
#endif
: base_max_pos(axis));
switch (axis) {
case X_AXIS:
case Y_AXIS:
// Get a minimum radius for clamping
soft_endstop_radius = MIN(ABS(MAX(soft_endstop_min[X_AXIS], soft_endstop_min[Y_AXIS])), soft_endstop_max[X_AXIS], soft_endstop_max[Y_AXIS]);
soft_endstop_radius_2 = sq(soft_endstop_radius);
break;
case Z_AXIS:
delta_clip_start_height = soft_endstop_max[axis] - delta_safe_distance_from_top();
default: break;
}
#else
soft_endstop_min[axis] = base_min_pos(axis);
soft_endstop_max[axis] = base_max_pos(axis);
#endif
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOPAIR("For ", axis_codes[axis]);
SERIAL_ECHOPAIR(" axis:\n soft_endstop_min = ", soft_endstop_min[axis]);
SERIAL_ECHOLNPAIR("\n soft_endstop_max = ", soft_endstop_max[axis]);
}
#endif
}
#endif #endif
#if !UBL_SEGMENTED #if !UBL_SEGMENTED
@ -1156,7 +1229,7 @@ void set_axis_is_at_home(const AxisEnum axis) {
#if HAS_POSITION_SHIFT #if HAS_POSITION_SHIFT
position_shift[axis] = 0; position_shift[axis] = 0;
update_software_endstops(axis); update_workspace_offset(axis);
#endif #endif
#if ENABLED(DUAL_X_CARRIAGE) #if ENABLED(DUAL_X_CARRIAGE)
@ -1506,89 +1579,18 @@ void homeaxis(const AxisEnum axis) {
#endif #endif
} // homeaxis() } // homeaxis()
#if HAS_WORKSPACE_OFFSET || ENABLED(DUAL_X_CARRIAGE) || ENABLED(DELTA) #if HAS_WORKSPACE_OFFSET
void update_workspace_offset(const AxisEnum axis) {
/** workspace_offset[axis] = home_offset[axis] + position_shift[axis];
* Software endstops can be used to monitor the open end of
* an axis that has a hardware endstop on the other end. Or
* they can prevent axes from moving past endstops and grinding.
*
* To keep doing their job as the coordinate system changes,
* the software endstop positions must be refreshed to remain
* at the same positions relative to the machine.
*/
void update_software_endstops(const AxisEnum axis) {
#if HAS_HOME_OFFSET && HAS_POSITION_SHIFT
workspace_offset[axis] = home_offset[axis] + position_shift[axis];
#endif
#if ENABLED(DUAL_X_CARRIAGE)
if (axis == X_AXIS) {
// In Dual X mode hotend_offset[X] is T1's home position
const float dual_max_x = MAX(hotend_offset[X_AXIS][1], X2_MAX_POS);
if (active_extruder != 0) {
// T1 can move from X2_MIN_POS to X2_MAX_POS or X2 home position (whichever is larger)
soft_endstop_min[X_AXIS] = X2_MIN_POS;
soft_endstop_max[X_AXIS] = dual_max_x;
}
else if (dxc_is_duplicating()) {
// In Duplication Mode, T0 can move as far left as X1_MIN_POS
// but not so far to the right that T1 would move past the end
soft_endstop_min[X_AXIS] = X1_MIN_POS;
soft_endstop_max[X_AXIS] = MIN(X1_MAX_POS, dual_max_x - duplicate_extruder_x_offset);
}
else {
// In other modes, T0 can move from X1_MIN_POS to X1_MAX_POS
soft_endstop_min[X_AXIS] = X1_MIN_POS;
soft_endstop_max[X_AXIS] = X1_MAX_POS;
}
}
#elif ENABLED(DELTA)
soft_endstop_min[axis] = base_min_pos(axis);
soft_endstop_max[axis] = (axis == Z_AXIS ? delta_height
#if HAS_BED_PROBE
- zprobe_zoffset + Z_PROBE_OFFSET_FROM_EXTRUDER
#endif
: base_max_pos(axis));
#else
soft_endstop_min[axis] = base_min_pos(axis);
soft_endstop_max[axis] = base_max_pos(axis);
#endif
#if ENABLED(DEBUG_LEVELING_FEATURE) #if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) { if (DEBUGGING(LEVELING)) {
SERIAL_ECHOPAIR("For ", axis_codes[axis]); SERIAL_ECHOPAIR("For ", axis_codes[axis]);
#if HAS_HOME_OFFSET SERIAL_ECHOPAIR(" axis:\n home_offset = ", home_offset[axis]);
SERIAL_ECHOPAIR(" axis:\n home_offset = ", home_offset[axis]); SERIAL_ECHOLNPAIR("\n position_shift = ", position_shift[axis]);
#endif
#if HAS_POSITION_SHIFT
SERIAL_ECHOPAIR("\n position_shift = ", position_shift[axis]);
#endif
SERIAL_ECHOPAIR("\n soft_endstop_min = ", soft_endstop_min[axis]);
SERIAL_ECHOLNPAIR("\n soft_endstop_max = ", soft_endstop_max[axis]);
}
#endif
#if ENABLED(DELTA)
switch (axis) {
#if HAS_SOFTWARE_ENDSTOPS
case X_AXIS:
case Y_AXIS:
// Get a minimum radius for clamping
soft_endstop_radius = MIN(ABS(MAX(soft_endstop_min[X_AXIS], soft_endstop_min[Y_AXIS])), soft_endstop_max[X_AXIS], soft_endstop_max[Y_AXIS]);
soft_endstop_radius_2 = sq(soft_endstop_radius);
break;
#endif
case Z_AXIS:
delta_clip_start_height = soft_endstop_max[axis] - delta_safe_distance_from_top();
default: break;
} }
#endif #endif
} }
#endif
#endif // HAS_WORKSPACE_OFFSET || DUAL_X_CARRIAGE || DELTA
#if HAS_M206_COMMAND #if HAS_M206_COMMAND
/** /**
@ -1597,6 +1599,6 @@ void homeaxis(const AxisEnum axis) {
*/ */
void set_home_offset(const AxisEnum axis, const float v) { void set_home_offset(const AxisEnum axis, const float v) {
home_offset[axis] = v; home_offset[axis] = v;
update_software_endstops(axis); update_workspace_offset(axis);
} }
#endif // HAS_M206_COMMAND #endif // HAS_M206_COMMAND

View file

@ -93,8 +93,6 @@ extern int16_t feedrate_percentage;
extern float hotend_offset[XYZ][HOTENDS]; extern float hotend_offset[XYZ][HOTENDS];
#endif #endif
extern float soft_endstop_min[XYZ], soft_endstop_max[XYZ];
FORCE_INLINE float pgm_read_any(const float *p) { return pgm_read_float(p); } 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); } FORCE_INLINE signed char pgm_read_any(const signed char *p) { return pgm_read_byte(p); }
@ -110,12 +108,23 @@ XYZ_DEFS(float, max_length, MAX_LENGTH);
XYZ_DEFS(float, home_bump_mm, HOME_BUMP_MM); XYZ_DEFS(float, home_bump_mm, HOME_BUMP_MM);
XYZ_DEFS(signed char, home_dir, HOME_DIR); XYZ_DEFS(signed char, home_dir, HOME_DIR);
#if HAS_WORKSPACE_OFFSET
void update_workspace_offset(const AxisEnum axis);
#else
#define update_workspace_offset(x) NOOP
#endif
#if HAS_SOFTWARE_ENDSTOPS #if HAS_SOFTWARE_ENDSTOPS
extern bool soft_endstops_enabled; extern bool soft_endstops_enabled;
extern float soft_endstop_min[XYZ], soft_endstop_max[XYZ];
void clamp_to_software_endstops(float target[XYZ]); void clamp_to_software_endstops(float target[XYZ]);
void update_software_endstops(const AxisEnum axis);
#else #else
constexpr bool soft_endstops_enabled = false; constexpr bool soft_endstops_enabled = false;
constexpr float soft_endstop_min[XYZ] = { X_MIN_BED, Y_MIN_BED, Z_MIN_POS },
soft_endstop_max[XYZ] = { X_MAX_BED, Y_MAX_BED, Z_MAX_POS };
#define clamp_to_software_endstops(x) NOOP #define clamp_to_software_endstops(x) NOOP
#define update_software_endstops(x) NOOP
#endif #endif
void report_current_position(); void report_current_position();
@ -211,14 +220,10 @@ void homeaxis(const AxisEnum axis);
void sensorless_homing_per_axis(const AxisEnum axis, const bool enable=true); void sensorless_homing_per_axis(const AxisEnum axis, const bool enable=true);
#endif #endif
//
// Macros
//
/** /**
* Workspace offsets * Workspace offsets
*/ */
#if HAS_WORKSPACE_OFFSET #if HAS_HOME_OFFSET || HAS_POSITION_SHIFT
#if HAS_HOME_OFFSET #if HAS_HOME_OFFSET
extern float home_offset[XYZ]; extern float home_offset[XYZ];
#endif #endif
@ -230,7 +235,7 @@ void homeaxis(const AxisEnum axis);
#define WORKSPACE_OFFSET(AXIS) workspace_offset[AXIS] #define WORKSPACE_OFFSET(AXIS) workspace_offset[AXIS]
#elif HAS_HOME_OFFSET #elif HAS_HOME_OFFSET
#define WORKSPACE_OFFSET(AXIS) home_offset[AXIS] #define WORKSPACE_OFFSET(AXIS) home_offset[AXIS]
#elif HAS_POSITION_SHIFT #else
#define WORKSPACE_OFFSET(AXIS) position_shift[AXIS] #define WORKSPACE_OFFSET(AXIS) position_shift[AXIS]
#endif #endif
#define NATIVE_TO_LOGICAL(POS, AXIS) ((POS) + WORKSPACE_OFFSET(AXIS)) #define NATIVE_TO_LOGICAL(POS, AXIS) ((POS) + WORKSPACE_OFFSET(AXIS))
@ -256,6 +261,10 @@ void homeaxis(const AxisEnum axis);
extern const float L1, L2; extern const float L1, L2;
#endif #endif
#if HAS_SCARA_OFFSET
extern float scara_home_offset[ABC]; // A and B angular offsets, Z mm offset
#endif
// Return true if the given point is within the printable area // Return true if the given point is within the printable area
inline bool position_is_reachable(const float &rx, const float &ry, const float inset=0) { inline bool position_is_reachable(const float &rx, const float &ry, const float inset=0) {
#if ENABLED(DELTA) #if ENABLED(DELTA)
@ -358,10 +367,6 @@ void homeaxis(const AxisEnum axis);
#endif #endif
#if HAS_WORKSPACE_OFFSET || ENABLED(DUAL_X_CARRIAGE) || ENABLED(DELTA)
void update_software_endstops(const AxisEnum axis);
#endif
#if HAS_M206_COMMAND #if HAS_M206_COMMAND
void set_home_offset(const AxisEnum axis, const float v); void set_home_offset(const AxisEnum axis, const float v);
#endif #endif

View file

@ -60,12 +60,7 @@ void scara_set_axis_is_at_home(const AxisEnum axis) {
current_position[axis] = cartes[axis]; current_position[axis] = cartes[axis];
/** update_software_endstops(axis);
* SCARA home positions are based on configuration since the actual
* limits are determined by the inverse kinematic transform.
*/
soft_endstop_min[axis] = base_min_pos(axis); // + (cartes[axis] - base_home_pos(axis));
soft_endstop_max[axis] = base_max_pos(axis); // + (cartes[axis] - base_home_pos(axis));
} }
} }

View file

@ -623,7 +623,7 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
feedrate_mm_s = old_feedrate_mm_s; feedrate_mm_s = old_feedrate_mm_s;
#if HAS_SOFTWARE_ENDSTOPS && ENABLED(DUAL_X_CARRIAGE) #if ENABLED(DUAL_X_CARRIAGE)
update_software_endstops(X_AXIS); update_software_endstops(X_AXIS);
#endif #endif