Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MACRO: better VAOC and START_PRINT skew profile handling #313

Merged
merged 1 commit into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions macros.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
19 changes: 18 additions & 1 deletion macros/idex/vaoc.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 %}
Expand All @@ -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 %}

Expand Down Expand Up @@ -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 %}
Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -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
Expand Down
28 changes: 28 additions & 0 deletions macros/overrides.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ gcode:
_IDEX_SINGLE INIT=1
{% endif %}

# clear skew profile
SET_SKEW CLEAR=1

# visual feedback
_LED_MOTORS_OFF

Expand Down Expand Up @@ -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 }
15 changes: 15 additions & 0 deletions macros/util.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Loading