From bba57548d2df9bb2f8282d684e7972bb51762346 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 18 Jun 2023 18:02:10 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=B8=20Revert=20M206=20Home=20Offset=20?= =?UTF-8?q?behavior?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Configuration_adv.h | 13 ++++--- Marlin/src/MarlinCore.cpp | 2 +- Marlin/src/feature/powerloss.cpp | 13 +++---- Marlin/src/feature/powerloss.h | 4 +-- Marlin/src/gcode/calibrate/G28.cpp | 9 +---- Marlin/src/gcode/gcode.cpp | 4 +-- Marlin/src/gcode/gcode.h | 4 +-- Marlin/src/gcode/geometry/G53-G59.cpp | 7 +--- Marlin/src/gcode/geometry/G92.cpp | 12 +++---- Marlin/src/gcode/geometry/M206_M428.cpp | 4 +-- Marlin/src/gcode/probe/M951.cpp | 4 +-- Marlin/src/inc/Conditionals_adv.h | 1 + Marlin/src/inc/Conditionals_post.h | 12 +++---- Marlin/src/lcd/menu/menu_advanced.cpp | 2 +- Marlin/src/module/delta.cpp | 2 +- Marlin/src/module/delta.h | 2 +- Marlin/src/module/motion.cpp | 28 ++++----------- Marlin/src/module/motion.h | 45 +++++++++---------------- Marlin/src/module/settings.cpp | 7 ++-- Marlin/src/module/tool_change.cpp | 23 ++++--------- ini/features.ini | 2 +- 21 files changed, 70 insertions(+), 130 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index f97f9d01736e..6c29900cdf47 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -3835,14 +3835,17 @@ //#define REPETIER_GCODE_M360 // Add commands originally from Repetier FW /** - * Enable this option for a leaner build of Marlin that removes all - * workspace offsets, simplifying coordinate transformations, leveling, etc. - * - * - M206 and M428 are disabled. - * - G92 will revert to its behavior from Marlin 1.0. + * Enable this option for a leaner build of Marlin that removes + * workspace offsets to slightly optimize performance. + * G92 will revert to its behavior from Marlin 1.0. */ //#define NO_WORKSPACE_OFFSETS +/** + * Disable M206 and M428 if you don't need home offsets. + */ +//#define NO_HOME_OFFSETS + /** * CNC G-code options * Support CNC-style G-code dialects used by laser cutters, drawing machine cams, etc. diff --git a/Marlin/src/MarlinCore.cpp b/Marlin/src/MarlinCore.cpp index 03b5e8c7a996..43a3cf04a870 100644 --- a/Marlin/src/MarlinCore.cpp +++ b/Marlin/src/MarlinCore.cpp @@ -1337,7 +1337,7 @@ void setup() { SETUP_RUN(touchBt.init()); #endif - TERN_(HAS_M206_COMMAND, current_position += home_offset); // Init current position based on home_offset + TERN_(HAS_HOME_OFFSET, current_position += home_offset); // Init current position based on home_offset sync_plan_position(); // Vital to init stepper/planner equivalent for current_position diff --git a/Marlin/src/feature/powerloss.cpp b/Marlin/src/feature/powerloss.cpp index 7c49aee2477e..7fb60349c6e5 100644 --- a/Marlin/src/feature/powerloss.cpp +++ b/Marlin/src/feature/powerloss.cpp @@ -207,7 +207,7 @@ void PrintJobRecovery::save(const bool force/*=false*/, const float zraise/*=POW TERN_(GCODE_REPEAT_MARKERS, info.stored_repeat = repeat); TERN_(HAS_HOME_OFFSET, info.home_offset = home_offset); - TERN_(HAS_POSITION_SHIFT, info.position_shift = position_shift); + TERN_(HAS_WORKSPACE_OFFSET, info.workspace_offset = workspace_offset); E_TERN_(info.active_extruder = active_extruder); #if DISABLED(NO_VOLUMETRICS) @@ -552,10 +552,7 @@ void PrintJobRecovery::resume() { TERN_(GCODE_REPEAT_MARKERS, repeat = info.stored_repeat); TERN_(HAS_HOME_OFFSET, home_offset = info.home_offset); - TERN_(HAS_POSITION_SHIFT, position_shift = info.position_shift); - #if HAS_HOME_OFFSET || HAS_POSITION_SHIFT - LOOP_NUM_AXES(i) update_workspace_offset((AxisEnum)i); - #endif + TERN_(HAS_WORKSPACE_OFFSET, workspace_offset = info.workspace_offset); // Relative axis modes gcode.axis_relative = info.axis_relative; @@ -600,11 +597,11 @@ void PrintJobRecovery::resume() { DEBUG_EOL(); #endif - #if HAS_POSITION_SHIFT - DEBUG_ECHOPGM("position_shift: "); + #if HAS_WORKSPACE_OFFSET + DEBUG_ECHOPGM("workspace_offset: "); LOOP_NUM_AXES(i) { if (i) DEBUG_CHAR(','); - DEBUG_ECHO(info.position_shift[i]); + DEBUG_ECHO(info.workspace_offset[i]); } DEBUG_EOL(); #endif diff --git a/Marlin/src/feature/powerloss.h b/Marlin/src/feature/powerloss.h index df46545825ec..a69862b25957 100644 --- a/Marlin/src/feature/powerloss.h +++ b/Marlin/src/feature/powerloss.h @@ -67,8 +67,8 @@ typedef struct { #if HAS_HOME_OFFSET xyz_pos_t home_offset; #endif - #if HAS_POSITION_SHIFT - xyz_pos_t position_shift; + #if HAS_WORKSPACE_OFFSET + xyz_pos_t workspace_offset; #endif #if HAS_MULTI_EXTRUDER uint8_t active_extruder; diff --git a/Marlin/src/gcode/calibrate/G28.cpp b/Marlin/src/gcode/calibrate/G28.cpp index 33a8ed76e606..b364c0382c09 100644 --- a/Marlin/src/gcode/calibrate/G28.cpp +++ b/Marlin/src/gcode/calibrate/G28.cpp @@ -120,14 +120,7 @@ * (Z is already at the right height) */ constexpr xy_float_t safe_homing_xy = { Z_SAFE_HOMING_X_POINT, Z_SAFE_HOMING_Y_POINT }; - #if HAS_HOME_OFFSET && DISABLED(Z_SAFE_HOMING_POINT_ABSOLUTE) - xy_float_t okay_homing_xy = safe_homing_xy; - okay_homing_xy -= home_offset; - #else - constexpr xy_float_t okay_homing_xy = safe_homing_xy; - #endif - - destination.set(okay_homing_xy, current_position.z); + destination.set(safe_homing_xy, current_position.z); TERN_(HOMING_Z_WITH_PROBE, destination -= probe.offset_xy); diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index 16847eb1f1f7..fd2a78d1fd26 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -715,7 +715,7 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 204: M204(); break; // M204: Set acceleration case 205: M205(); break; // M205: Set advanced settings - #if HAS_M206_COMMAND + #if HAS_HOME_OFFSET case 206: M206(); break; // M206: Set home offsets #endif @@ -881,7 +881,7 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) { case 425: M425(); break; // M425: Tune backlash compensation #endif - #if HAS_M206_COMMAND + #if HAS_HOME_OFFSET case 428: M428(); break; // M428: Apply current_position to home_offset #endif diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index 23f245faa17f..f9ee81f2eb0c 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -860,7 +860,7 @@ class GcodeSuite { static void M205(); static void M205_report(const bool forReplay=true); - #if HAS_M206_COMMAND + #if HAS_HOME_OFFSET static void M206(); static void M206_report(const bool forReplay=true); #endif @@ -1043,7 +1043,7 @@ class GcodeSuite { static void M425_report(const bool forReplay=true); #endif - #if HAS_M206_COMMAND + #if HAS_HOME_OFFSET static void M428(); #endif diff --git a/Marlin/src/gcode/geometry/G53-G59.cpp b/Marlin/src/gcode/geometry/G53-G59.cpp index c51c29f4233f..017b54a084a4 100644 --- a/Marlin/src/gcode/geometry/G53-G59.cpp +++ b/Marlin/src/gcode/geometry/G53-G59.cpp @@ -37,12 +37,7 @@ bool GcodeSuite::select_coordinate_system(const int8_t _new) { xyz_float_t new_offset{0}; if (WITHIN(_new, 0, MAX_COORDINATE_SYSTEMS - 1)) new_offset = coordinate_system[_new]; - LOOP_NUM_AXES(i) { - if (position_shift[i] != new_offset[i]) { - position_shift[i] = new_offset[i]; - update_workspace_offset((AxisEnum)i); - } - } + workspace_offset = new_offset; return true; } diff --git a/Marlin/src/gcode/geometry/G92.cpp b/Marlin/src/gcode/geometry/G92.cpp index dfe4170620ec..626441f4e25c 100644 --- a/Marlin/src/gcode/geometry/G92.cpp +++ b/Marlin/src/gcode/geometry/G92.cpp @@ -63,10 +63,7 @@ void GcodeSuite::G92() { #if ENABLED(CNC_COORDINATE_SYSTEMS) && !IS_SCARA case 1: // G92.1 - Zero the Workspace Offset - LOOP_NUM_AXES(i) if (position_shift[i]) { - position_shift[i] = 0; - update_workspace_offset((AxisEnum)i); - } + workspace_offset.reset(); break; #endif @@ -92,10 +89,9 @@ void GcodeSuite::G92() { v = TERN0(HAS_EXTRUDERS, i == E_AXIS) ? l : LOGICAL_TO_NATIVE(l, i), // Axis position in NATIVE space (applying the existing offset) d = v - current_position[i]; // How much is the current axis position altered by? if (!NEAR_ZERO(d)) { - #if HAS_POSITION_SHIFT && NONE(IS_SCARA, POLARGRAPH) // When using workspaces... + #if HAS_WORKSPACE_OFFSET && NONE(IS_SCARA, POLARGRAPH) // When using workspaces... if (TERN1(HAS_EXTRUDERS, i != E_AXIS)) { - position_shift[i] += d; // ...most axes offset the workspace... - update_workspace_offset((AxisEnum)i); + workspace_offset[i] += d; // ...most axes offset the workspace... } else { #if HAS_EXTRUDERS @@ -120,7 +116,7 @@ void GcodeSuite::G92() { #if ENABLED(CNC_COORDINATE_SYSTEMS) // Apply Workspace Offset to the active coordinate system if (WITHIN(active_coordinate_system, 0, MAX_COORDINATE_SYSTEMS - 1)) - coordinate_system[active_coordinate_system] = position_shift; + coordinate_system[active_coordinate_system] = workspace_offset; #endif if (sync_XYZE) sync_plan_position(); diff --git a/Marlin/src/gcode/geometry/M206_M428.cpp b/Marlin/src/gcode/geometry/M206_M428.cpp index b055f0e20734..7017eabbdc3e 100644 --- a/Marlin/src/gcode/geometry/M206_M428.cpp +++ b/Marlin/src/gcode/geometry/M206_M428.cpp @@ -22,7 +22,7 @@ #include "../../inc/MarlinConfig.h" -#if HAS_M206_COMMAND +#if HAS_HOME_OFFSET #include "../gcode.h" #include "../../module/motion.h" @@ -101,4 +101,4 @@ void GcodeSuite::M428() { OKAY_BUZZ(); } -#endif // HAS_M206_COMMAND +#endif // HAS_HOME_OFFSET diff --git a/Marlin/src/gcode/probe/M951.cpp b/Marlin/src/gcode/probe/M951.cpp index 7a06400e3336..93feffdce999 100644 --- a/Marlin/src/gcode/probe/M951.cpp +++ b/Marlin/src/gcode/probe/M951.cpp @@ -46,7 +46,7 @@ void mpe_settings_init() { mpe_settings.parking_xpos[0] = pex[0]; // M951 L mpe_settings.parking_xpos[1] = pex[1]; // M951 R mpe_settings.grab_distance = PARKING_EXTRUDER_GRAB_DISTANCE; // M951 I - TERN_(HAS_HOME_OFFSET, set_home_offset(X_AXIS, mpe_settings.grab_distance * -1)); + TERN_(HAS_HOME_OFFSET, set_home_offset(X_AXIS, -mpe_settings.grab_distance)); mpe_settings.slow_feedrate = MMM_TO_MMS(MPE_SLOW_SPEED); // M951 J mpe_settings.fast_feedrate = MMM_TO_MMS(MPE_FAST_SPEED); // M951 H mpe_settings.travel_distance = MPE_TRAVEL_DISTANCE; // M951 D @@ -59,7 +59,7 @@ void GcodeSuite::M951() { if (parser.seenval('R')) mpe_settings.parking_xpos[1] = parser.value_linear_units(); if (parser.seenval('I')) { mpe_settings.grab_distance = parser.value_linear_units(); - TERN_(HAS_HOME_OFFSET, set_home_offset(X_AXIS, mpe_settings.grab_distance * -1)); + TERN_(HAS_HOME_OFFSET, set_home_offset(X_AXIS, -mpe_settings.grab_distance)); } if (parser.seenval('J')) mpe_settings.slow_feedrate = MMM_TO_MMS(parser.value_linear_units()); if (parser.seenval('H')) mpe_settings.fast_feedrate = MMM_TO_MMS(parser.value_linear_units()); diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index eac9e2111048..25050d972f32 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -97,6 +97,7 @@ #if !HAS_X_AXIS //#define LCD_SHOW_E_TOTAL #define NO_WORKSPACE_OFFSETS + #define NO_HOME_OFFSETS #undef AUTOTEMP #undef CALIBRATION_MEASURE_LEFT #undef CALIBRATION_MEASURE_RIGHT diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 8cc3f6bc2db8..442fcfbafdb8 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -3140,15 +3140,15 @@ #undef MOTOR_CURRENT #endif -// Updated G92 behavior shifts the workspace +// G92 shifts the workspace #if DISABLED(NO_WORKSPACE_OFFSETS) - #define HAS_POSITION_SHIFT 1 + #define HAS_WORKSPACE_OFFSET 1 +#endif +#if DISABLED(NO_HOME_OFFSETS) #if IS_CARTESIAN - #define HAS_HOME_OFFSET 1 // The home offset also shifts the coordinate space - #define HAS_WORKSPACE_OFFSET 1 // Cumulative offset to workspace to save some calculation - #define HAS_M206_COMMAND 1 // M206 sets the home offset for Cartesian machines + #define HAS_HOME_OFFSET 1 // M206 affects the Native Machine Space on G28 #elif IS_SCARA - #define HAS_SCARA_OFFSET 1 // The SCARA home offset applies only on G28 + #define HAS_SCARA_OFFSET 1 // The SCARA home offset applies only on G28 #endif #endif diff --git a/Marlin/src/lcd/menu/menu_advanced.cpp b/Marlin/src/lcd/menu/menu_advanced.cpp index 7c142d839085..7cf4d34cb706 100644 --- a/Marlin/src/lcd/menu/menu_advanced.cpp +++ b/Marlin/src/lcd/menu/menu_advanced.cpp @@ -695,7 +695,7 @@ void menu_advanced_settings() { } #endif - #if HAS_M206_COMMAND + #if HAS_HOME_OFFSET // M428 - Set Home Offsets ACTION_ITEM(MSG_SET_HOME_OFFSETS, []{ queue.inject(F("M428")); ui.return_to_status(); }); #endif diff --git a/Marlin/src/module/delta.cpp b/Marlin/src/module/delta.cpp index 58dc13972cb2..cfa134860b86 100644 --- a/Marlin/src/module/delta.cpp +++ b/Marlin/src/module/delta.cpp @@ -101,7 +101,7 @@ void recalc_delta_settings() { * * Suggested optimizations include: * - * - Disable the home_offset (M206) and/or position_shift (G92) + * - Disable the home_offset (M206) and/or workspace_offset (G92) * features to remove up to 12 float additions. */ diff --git a/Marlin/src/module/delta.h b/Marlin/src/module/delta.h index 0a0c6124eecf..041094fd7fcb 100644 --- a/Marlin/src/module/delta.h +++ b/Marlin/src/module/delta.h @@ -64,7 +64,7 @@ void recalc_delta_settings(); * * Suggested optimizations include: * - * - Disable the home_offset (M206) and/or position_shift (G92) + * - Disable the home_offset (M206) and/or workspace_offset (G92) * features to remove up to 12 float additions. * * - Use a fast-inverse-sqrt function and add the reciprocal. diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index c97523cbd316..cd768d9e40fd 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -177,16 +177,12 @@ xyz_pos_t cartes; * The workspace can be offset by some commands, or * these offsets may be omitted to save on computation. */ -#if HAS_POSITION_SHIFT - // The distance that XYZ has been offset by G92. Reset by G28. - xyz_pos_t position_shift{0}; -#endif #if HAS_HOME_OFFSET // This offset is added to the configured home position. // Set by M206, M428, or menu item. Saved to EEPROM. xyz_pos_t home_offset{0}; #endif -#if HAS_HOME_OFFSET && HAS_POSITION_SHIFT +#if HAS_WORKSPACE_OFFSET // The above two are combined to save on computes xyz_pos_t workspace_offset{0}; #endif @@ -2468,7 +2464,7 @@ void set_axis_is_at_home(const AxisEnum axis) { #if ENABLED(DUAL_X_CARRIAGE) if (axis == X_AXIS && (active_extruder == 1 || dual_x_carriage_mode == DXC_DUPLICATION_MODE)) { - current_position.x = x_home_pos(active_extruder); + current_position.x = SUM_TERN(HAS_HOME_OFFSET, x_home_pos(active_extruder), home_offset.x); return; } #endif @@ -2478,7 +2474,7 @@ void set_axis_is_at_home(const AxisEnum axis) { #elif ENABLED(DELTA) current_position[axis] = (axis == Z_AXIS) ? DIFF_TERN(HAS_BED_PROBE, delta_height, probe.offset.z) : base_home_pos(axis); #else - current_position[axis] = base_home_pos(axis); + current_position[axis] = SUM_TERN(HAS_HOME_OFFSET, base_home_pos(axis), home_offset[axis]); #endif /** @@ -2499,10 +2495,7 @@ void set_axis_is_at_home(const AxisEnum axis) { TERN_(BABYSTEP_DISPLAY_TOTAL, babystep.reset_total(axis)); - #if HAS_POSITION_SHIFT - position_shift[axis] = 0; - update_workspace_offset(axis); - #endif + TERN_(HAS_WORKSPACE_OFFSET, workspace_offset[axis] = 0); if (DEBUGGING(LEVELING)) { #if HAS_HOME_OFFSET @@ -2513,20 +2506,11 @@ void set_axis_is_at_home(const AxisEnum axis) { } } -#if HAS_WORKSPACE_OFFSET - void update_workspace_offset(const AxisEnum axis) { - workspace_offset[axis] = home_offset[axis] + position_shift[axis]; - if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Axis ", AS_CHAR(AXIS_CHAR(axis)), " home_offset = ", home_offset[axis], " position_shift = ", position_shift[axis]); - } -#endif - -#if HAS_M206_COMMAND +#if HAS_HOME_OFFSET /** - * Change the home offset for an axis. - * Also refreshes the workspace offset. + * Set the home offset for an axis. */ void set_home_offset(const AxisEnum axis, const_float_t v) { home_offset[axis] = v; - update_workspace_offset(axis); } #endif diff --git a/Marlin/src/module/motion.h b/Marlin/src/module/motion.h index 9d5da849e5a9..fceeffa70748 100644 --- a/Marlin/src/module/motion.h +++ b/Marlin/src/module/motion.h @@ -147,12 +147,6 @@ inline float home_bump_mm(const AxisEnum axis) { return pgm_read_any(&home_bump_mm_P[axis]); } -#if HAS_WORKSPACE_OFFSET - void update_workspace_offset(const AxisEnum axis); -#else - inline void update_workspace_offset(const AxisEnum) {} -#endif - #if HAS_HOTEND_OFFSET extern xyz_pos_t hotend_offset[HOTENDS]; void reset_hotend_offsets(); @@ -484,32 +478,23 @@ void home_if_needed(const bool keeplev=false); #define BABYSTEP_ALLOWED() ((ENABLED(BABYSTEP_WITHOUT_HOMING) || all_axes_trusted()) && (ENABLED(BABYSTEP_ALWAYS_AVAILABLE) || printer_busy())) +#if HAS_HOME_OFFSET + extern xyz_pos_t home_offset; +#endif + /** * Workspace offsets */ -#if HAS_HOME_OFFSET || HAS_POSITION_SHIFT - #if HAS_HOME_OFFSET - extern xyz_pos_t home_offset; - #endif - #if HAS_POSITION_SHIFT - extern xyz_pos_t position_shift; - #endif - #if HAS_HOME_OFFSET && HAS_POSITION_SHIFT - extern xyz_pos_t workspace_offset; - #define _WS workspace_offset - #elif HAS_HOME_OFFSET - #define _WS home_offset - #else - #define _WS position_shift - #endif - #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; } +#if HAS_WORKSPACE_OFFSET + extern xyz_pos_t workspace_offset; + #define NATIVE_TO_LOGICAL(POS, AXIS) ((POS) + workspace_offset[AXIS]) + #define LOGICAL_TO_NATIVE(POS, AXIS) ((POS) - workspace_offset[AXIS]) + FORCE_INLINE void toLogical(xy_pos_t &raw) { raw += workspace_offset; } + FORCE_INLINE void toLogical(xyz_pos_t &raw) { raw += workspace_offset; } + FORCE_INLINE void toLogical(xyze_pos_t &raw) { raw += workspace_offset; } + FORCE_INLINE void toNative(xy_pos_t &raw) { raw -= workspace_offset; } + FORCE_INLINE void toNative(xyz_pos_t &raw) { raw -= workspace_offset; } + FORCE_INLINE void toNative(xyze_pos_t &raw) { raw -= workspace_offset; } #else #define NATIVE_TO_LOGICAL(POS, AXIS) (POS) #define LOGICAL_TO_NATIVE(POS, AXIS) (POS) @@ -633,7 +618,7 @@ void home_if_needed(const bool keeplev=false); #endif -#if HAS_M206_COMMAND +#if HAS_HOME_OFFSET void set_home_offset(const AxisEnum axis, const_float_t v); #endif diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index c8ce84cd83e4..c125577f5ce9 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -670,10 +670,7 @@ void MarlinSettings::postprocess() { #endif // Software endstops depend on home_offset - LOOP_NUM_AXES(i) { - update_workspace_offset((AxisEnum)i); - update_software_endstops((AxisEnum)i); - } + LOOP_NUM_AXES(i) update_software_endstops((AxisEnum)i); TERN_(ENABLE_LEVELING_FADE_HEIGHT, set_z_fade_height(new_z_fade_height, false)); // false = no report @@ -3701,7 +3698,7 @@ void MarlinSettings::reset() { // // M206 Home Offset // - TERN_(HAS_M206_COMMAND, gcode.M206_report(forReplay)); + TERN_(HAS_HOME_OFFSET, gcode.M206_report(forReplay)); // // M218 Hotend offsets diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index d65b3fb32ab5..4c286c81a0ad 100644 --- a/Marlin/src/module/tool_change.cpp +++ b/Marlin/src/module/tool_change.cpp @@ -1417,19 +1417,13 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { #if ANY(TC_GCODE_USE_GLOBAL_X, TC_GCODE_USE_GLOBAL_Y, TC_GCODE_USE_GLOBAL_Z) // G0/G1/G2/G3/G5 moves are relative to the active tool. // Shift the workspace to make custom moves relative to T0. - xyz_pos_t old_position_shift; + xyz_pos_t old_workspace_offset; if (new_tool > 0) { - old_position_shift = position_shift; + old_workspace_offset = workspace_offset; const xyz_pos_t &he = hotend_offset[new_tool]; - #if ENABLED(TC_GCODE_USE_GLOBAL_X) - position_shift.x -= he.x; update_workspace_offset(X_AXIS); - #endif - #if ENABLED(TC_GCODE_USE_GLOBAL_Y) - position_shift.y -= he.y; update_workspace_offset(Y_AXIS); - #endif - #if ENABLED(TC_GCODE_USE_GLOBAL_Z) - position_shift.z -= he.z; update_workspace_offset(Z_AXIS); - #endif + TERN_(TC_GCODE_USE_GLOBAL_X, workspace_offset.x -= he.x); + TERN_(TC_GCODE_USE_GLOBAL_Y, workspace_offset.y -= he.y); + TERN_(TC_GCODE_USE_GLOBAL_Z, workspace_offset.z -= he.z); } #endif @@ -1462,12 +1456,7 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { } #if ANY(TC_GCODE_USE_GLOBAL_X, TC_GCODE_USE_GLOBAL_Y, TC_GCODE_USE_GLOBAL_Z) - if (new_tool > 0) { - position_shift = old_position_shift; - TERN_(TC_GCODE_USE_GLOBAL_X, update_workspace_offset(X_AXIS)); - TERN_(TC_GCODE_USE_GLOBAL_Y, update_workspace_offset(Y_AXIS)); - TERN_(TC_GCODE_USE_GLOBAL_Z, update_workspace_offset(Z_AXIS)); - } + if (new_tool > 0) workspace_offset = old_workspace_offset; #endif // If using MECHANICAL_SWITCHING extruder/nozzle, set HOTEND_OFFSET in Z axis after running EVENT_GCODE_TOOLCHANGE diff --git a/ini/features.ini b/ini/features.ini index 2b1d09e20f25..1a3546e575fd 100644 --- a/ini/features.ini +++ b/ini/features.ini @@ -318,7 +318,7 @@ PARK_HEAD_ON_PAUSE = build_src_filter=+ CNC_WORKSPACE_PLANES = build_src_filter=+ CNC_COORDINATE_SYSTEMS = build_src_filter=+ -HAS_M206_COMMAND = build_src_filter=+ +HAS_HOME_OFFSET = build_src_filter=+ EXPECTED_PRINTER_CHECK = build_src_filter=+ HOST_KEEPALIVE_FEATURE = build_src_filter=+ AUTO_REPORT_POSITION = build_src_filter=+