diff --git a/macros.cfg b/macros.cfg index 14d286a8..985a750e 100644 --- a/macros.cfg +++ b/macros.cfg @@ -1174,9 +1174,8 @@ gcode: # Handle toolhead settings RESTORE_TOOLHEAD_SETTINGS KEY="start_print_after_heating_extruder" - {% if printer["gcode_macro RatOS"].skew_profile is defined %} - SKEW_PROFILE LOAD={printer["gcode_macro RatOS"].skew_profile} - {% endif %} + # load RatOS skew profile + _LOAD_RATOS_SKEW_PROFILE [gcode_macro _PRIME] diff --git a/macros/idex/vaoc.cfg b/macros/idex/vaoc.cfg index 7dd2db17..9443c81e 100644 --- a/macros/idex/vaoc.cfg +++ b/macros/idex/vaoc.cfg @@ -24,6 +24,7 @@ variable_t0_toolhead_sensor_enabled: 0 # internal use only. Do not touch variable_t1_toolhead_sensor_enabled: 0 # internal use only. Do not touch! variable_t0_bowden_sensor_enabled: 0 # internal use only. Do not touch! variable_t1_bowden_sensor_enabled: 0 # internal use only. Do not touch! +variable_loaded_skew_profile: "" # internal use only. Do not touch! gcode: _ECHO_VAOC_VARS @@ -32,7 +33,7 @@ gcode: # VAOC COMMON ##### [gcode_macro _VAOC_START] -description: Called from the front end. If T0_TEMP, T0_TEMP and BED_TEMP parameter are specified, VAOC calibration will start under real conditions at printing temp. +description: Called from the front end. If T0_TEMP, T1_TEMP and BED_TEMP parameter are specified, VAOC calibration will start under real conditions at printing temp. gcode: # parameters {% set t0_temp = params.T0_TEMP|default(0)|int %} @@ -47,6 +48,10 @@ gcode: # vaoc config {% set is_fixed = true if printer["gcode_macro _VAOC"].is_fixed|default(true)|lower == 'true' else false %} + # cache current skew profile + {% set loaded_skew_profile = printer["gcode_macro SKEW_PROFILE"].loaded_profile|default("") %} + SET_GCODE_VARIABLE MACRO=_VAOC VARIABLE=loaded_skew_profile VALUE='"{loaded_skew_profile}"' + # vaoc calibration under real if needed parameters are specified {% if t0_temp > 0 and t1_temp > 0 and bed_temp > 0 %} @@ -107,6 +112,7 @@ gcode: [gcode_macro _START_VAOC] +description: Called from _VAOC_START. Do not call it manually. gcode: # parameters {% set auto_z_offset = true if params.AUTO_Z_OFFSET|default(false)|lower == 'true' else false %} @@ -192,6 +198,9 @@ gcode: MAYBE_HOME M400 + # load RatOS skew profile + _LOAD_RATOS_SKEW_PROFILE + # move to safe z if needed {% if printer.toolhead.position.z|float < safe_z %} G1 Z{safe_z} F{z_speed} @@ -298,6 +307,14 @@ gcode: {% endif %} {% endif %} + # reset skew profile + {% set loaded_skew_profile = printer["gcode_macro _VAOC"].loaded_skew_profile|default("") %} + {% if loaded_skew_profile != "" %} + SKEW_PROFILE LOAD={loaded_skew_profile} + {% else %} + SET_SKEW CLEAR=1 + {% endif %} + # reset VAOC state SET_GCODE_VARIABLE MACRO=_VAOC VARIABLE=is_started VALUE=False SET_GCODE_VARIABLE MACRO=_VAOC VARIABLE=is_started_at_temp VALUE=False diff --git a/macros/overrides.cfg b/macros/overrides.cfg index 1eadbf56..9f9660b2 100644 --- a/macros/overrides.cfg +++ b/macros/overrides.cfg @@ -29,6 +29,9 @@ gcode: _IDEX_SINGLE INIT=1 {% endif %} + # clear skew profile + SET_SKEW CLEAR=1 + # visual feedback _LED_MOTORS_OFF @@ -221,3 +224,28 @@ gcode: {% else %} SDCARD_PRINT_FILE_BASE { rawparams } {% endif %} + + +[gcode_macro SKEW_PROFILE] +rename_existing: SKEW_PROFILE_BASE +variable_loaded_profile: "" # internal use only. Do not touch! +gcode: + {% if params.LOAD is defined %} + {% if printer.configfile.settings["skew_correction %s" % params.LOAD] is defined %} + SET_GCODE_VARIABLE MACRO=SKEW_PROFILE VARIABLE=loaded_profile VALUE='"{params.LOAD}"' + {% endif %} + {% endif %} + + SKEW_PROFILE_BASE { rawparams } + + +[gcode_macro SET_SKEW] +rename_existing: SET_SKEW_BASE +gcode: + {% if params.CLEAR is defined %} + {% if params.CLEAR|default(0)|int == 1 %} + SET_GCODE_VARIABLE MACRO=SKEW_PROFILE VARIABLE=loaded_profile VALUE='""' + {% endif %} + {% endif %} + + SET_SKEW_BASE { rawparams } diff --git a/macros/util.cfg b/macros/util.cfg index b433fa6d..0a2ae913 100644 --- a/macros/util.cfg +++ b/macros/util.cfg @@ -379,3 +379,18 @@ gcode: {% else %} Z_OFFSET_APPLY_PROBE {% endif %} + + +[gcode_macro _LOAD_RATOS_SKEW_PROFILE] +gcode: + {% set ratos_skew_profile = printer["gcode_macro RatOS"].skew_profile|default("") %} + {% if ratos_skew_profile != "" %} + {% if printer.configfile.settings["skew_correction %s" % ratos_skew_profile] is defined %} + SKEW_PROFILE LOAD={ratos_skew_profile} + GET_CURRENT_SKEW + {% else %} + {% set line_1 = '"Could not find skew profile %s!_N_Clearing skew correction."' % ratos_skew_profile %} + CONSOLE_ECHO TITLE="Missing skew profile!" TYPE="warning" MSG={line_1} + SET_SKEW CLEAR=1 + {% endif %} + {% endif %}