Skip to content

Commit

Permalink
Revamped macro system for IDEX support
Browse files Browse the repository at this point in the history
  • Loading branch information
matti125 committed Aug 29, 2021
1 parent e74e669 commit 06ee354
Show file tree
Hide file tree
Showing 2 changed files with 164 additions and 40 deletions.
7 changes: 3 additions & 4 deletions extruders_titan/extruder0_titan_maxiwatt
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@ position_max: 220
#at position 17mm from standard left side, as otherwise the righ
#extruder will collide with the parked left extruder.

[stepper_x_disabled_for_now]
position_endstop: -62
position_max: 203
position_min: -63
#position_endstop: -62
#position_max: 203
#position_min: -63


[input_shaper]
Expand Down
197 changes: 161 additions & 36 deletions macros.cfg
Original file line number Diff line number Diff line change
@@ -1,18 +1,29 @@
# Helper script to park the carriage (called from T0 and T1 macros)
[gcode_macro PARK_extruder]
gcode:

SAVE_GCODE_STATE NAME=park0
G21
G90
G1 X-40 F3000
{% if not "x" in printer.toolhead.homed_axes %}
{ action_respond_info("Homing X" ) }
G28 X
{% endif %}
SET_GCODE_OFFSET X=0
G1 X{printer.configfile.settings.stepper_x.position_min} F3000
RESTORE_GCODE_STATE NAME=park0

[gcode_macro PARK_extruder1]
gcode:
SAVE_GCODE_STATE NAME=park1
G21
G90
G1 X265 F3000
{% if not "x" in printer.toolhead.homed_axes %}
{ action_respond_info("Homing X" ) }
G28 X
{% endif %}
SET_GCODE_OFFSET X=0
G1 X{printer.configfile.settings.dual_carriage.position_max} F3000
RESTORE_GCODE_STATE NAME=park1

# Activate the primary extruder
Expand All @@ -21,7 +32,14 @@ gcode:
PARK_{printer.toolhead.extruder}
ACTIVATE_EXTRUDER EXTRUDER=extruder
SET_DUAL_CARRIAGE CARRIAGE=0
SET_GCODE_OFFSET Y=0 X=0
{ action_respond_info("Is range already set: %s" % printer["gcode_macro set_stepper_x_range"].range_set) }

# run the range setting only once, in order to mis-set it after T1 target temp is set to zero
{% if printer["gcode_macro set_stepper_x_range"].range_set == 0 %}
set_stepper_x_range
{% endif %}
{ action_respond_info("xoffset %s" % printer["gcode_macro set_stepper_x_range"].xoffset) }
SET_GCODE_OFFSET Y=0 X={ printer["gcode_macro set_stepper_x_range"].xoffset }

[gcode_macro T1]
gcode:
Expand All @@ -30,55 +48,96 @@ gcode:
SET_DUAL_CARRIAGE CARRIAGE=1
SET_GCODE_OFFSET X=-0.2 Y=-0.03

[gcode_macro START_PRINT]
[gcode_macro set_stepper_x_range]
variable_xoffset: 0
variable_range_set: 0
gcode:
{% if printer.extruder1.target > 1 %}
{ action_respond_info("limited print area with right extruder ") }
{% set offset= 17 %}
{% else %}
{% set offset=0 %}
{% endif %}
SET_GCODE_VARIABLE MACRO=set_stepper_x_range VARIABLE=xoffset VALUE={offset}
#make it known that the range has been set for this print, and should not be re-evaluated again
SET_GCODE_VARIABLE MACRO=set_stepper_x_range VARIABLE=range_set VALUE=1


[gcode_macro START_PRINT_AFTER_TEMPERATURE_SET]
gcode:
{% set BED_TEMP = params.BED_TEMP|default(60)|float %}
{% set EXTRUDER_TEMP = params.EXTRUDER_TEMP|default(190)|float %}
{% set EXTRUDER1_TEMP = params.EXTRUDER1_TEMP|default(190)|float %}
{% set EXTRUDERS = params.EXTRUDERS|default(1) %}

# Start bed heating
M140 S{BED_TEMP}
# Use absolute coordinates
G90
#reset E
G92 E0
#Set extruder to relative mode
M83
# Reset the G-Code Z offset (adjust Z offset if needed)
#SET_GCODE_OFFSET Z=0.08
# Home the printer
G28 X Y
G28 Z
# Move the nozzle near the bed
G0 Z0.5 Y45 F3000
#G1 X2
# Wait for bed to reach temperature
M190 S{BED_TEMP}
{% if printer.toolhead.homed_axes != 'xyz' %}
G28 X Y
G28 Z
{% endif %}
# explicitly set the range at the start of each new pring
set_stepper_x_range
{% if printer.extruder.target > 1 %}
{ action_respond_info("Extruder0 will be prepared") }
T0
SAVE_GCODE_STATE NAME=prime_ext0
#Always print the prime line at the very left of the bed
SET_GCODE_OFFSET X=0 Y=0
G0 X-10 Y35 Z0.5 F3000
# prime in air
G1 E5 F300
PRIME_LINE X=3 Y=35 Z=0.25 YLINE=150
RESTORE_GCODE_STATE NAME=prime_ext0
{% endif %}
{% if printer.extruder1.target > 1 %}
{ action_respond_info("Extruder1 will be prepared ") }
T1
G0 X240 Y35 Z0.5 F3000
G1 E5 F300
PRIME_LINE X=201 Y=35 Z=0.2 YLINE=120 XLINE=-1
{% endif %}
#set extruder to abs mode
M82



[gcode_macro START_PRINT]
gcode:
# {% set BED_TEMP = params.BED_TEMP|default(60)|float %}
# {% set EXTRUDER0_TEMP = params.EXTRUDER1_TEMP|default(0)|float %}
# {% set EXTRUDER1_TEMP = params.EXTRUDER2_TEMP|default(0)|float %}

# Start bed heating
# M140 S{BED_TEMP}
# Set and wait for nozzle to reach temperature
M109 S{EXTRUDER_TEMP}
#Prime
G28 X
G1 E5 F300
PRIME_LINE

# M109 S{EXTRUDER_TEMP}
# M190 S{BED_TEMP}
START_PRINT_AFTER_TEMPERATURE_SET

[gcode_macro PRIME_LINE]
gcode:
M117 Prime Line
{% set x = params.X|default(2)|float %}
{% set y = params.Y|default(50)|float %}
{% set z = params.Z|default(0.2)|float %}
{% set xline = params.XLINE|default(1)|float %}
{% set yline = params.YLINE|default(120)|float %}

SAVE_GCODE_STATE NAME=prime_line

M117 Prime Line
G90 ; XYZ to abs mode
M83 ; set E to rel mode
# move z axis
G1 Z2 F3000 ;Move Z Axis up
G1 Z0.5 F3000 ;Move Z Axis up
# move to prime position
G0 Y50 Z0.28 F1500
G0 X2 ;Move to start position
G1 Y200 E10 ;Draw the first line
G0 X3 ;Move to side a little
G1 Y70 E10 ;Draw the second line
G0 Y{y} Z{z} F1500
G0 X{x} ;Move to start position. Do square move to avoid hitting the bed's corner clips
G1 Y{y + yline} E10 ;Draw the first line
G1 X{x + xline} ;Move to side a little
G1 Y{y + 20} E10 ;Draw the second line, but do not go back to origin to avoid picking the wipeouts
G1 Z1 F3000 ;Move Z Axis up
M82 ;set e to abs mode
G92 E0 ;Reset E

RESTORE_GCODE_STATE NAME=prime_line

[gcode_macro END_PRINT]
gcode:
Expand All @@ -94,3 +153,69 @@ gcode:
M140 S0 ; turn bed heating off
M107 ; turn fan off
M84 ; steppers off

[gcode_macro SEARCH_VARS]
gcode:
{% set search = params.S|lower %}
{% set ns = namespace() %}
{% for item in printer %}
{% if ' ' in item %}
{% set ns.path = ['printer', "['%s']" % (item), ''] %}
{% else %}
{% set ns.path = ['printer.', item, ''] %}
{% endif %}

{% if search in ns.path|lower %}
{ action_respond_info(ns.path|join) }
{% endif %}

{% if printer[item].items() %}
{% for childkey, child in printer[item].items() recursive %}
{% set ns.path = ns.path[:loop.depth|int + 1] %}

{% if ' ' in childkey %}
{% set null = ns.path.append("['%s']" % (childkey)) %}
{% else %}
{% set null = ns.path.append(".%s" % (childkey)) %}
{% endif %}

{% if child is mapping %}
{ loop(child.items()) }
{% else %}
{% if search in ns.path|lower %}
{ action_respond_info("%s : %s" % (ns.path|join, child)) }
{% endif %}
{% endif %}

{% endfor %}
{% endif %}
{% endfor %}

[gcode_macro huihai]
variable_muuttuja: 0
gcode:
{ action_respond_info("%s " % (printer.configfile.settings.stepper_x.position_min)) }
{ action_respond_info("max %s " % (printer.toolhead.axis_maximum.x)) }
{ action_respond_info("min %s " % printer.toolhead.axis_minimum.x) }


{% if not "x" in printer.toolhead.homed_axes %}
{ action_respond_info("ei homed %s" % printer.toolhead.homed_axes ) }
{% else %}
{ action_respond_info("on jo homed %s" % printer.toolhead.homed_axes ) }
{% endif %}
{% if printer.extruder1.target > 0 %}
{ action_respond_info(" extxxxx is in use") }
{% endif %}
{% if printer.extruder.target > 0 %}
{ action_respond_info(" ext0 is in use") }
{% endif %}
SET_GCODE_VARIABLE MACRO=huihai VARIABLE=muuttuja VALUE=33
{% set a=44 %}
{ action_respond_info("a %s" % a )}

[gcode_macro ohoi]
gcode:
{ action_respond_info("var xxx %s" % printer["gcode_macro huihai"].muuttuja) }


0 comments on commit 06ee354

Please sign in to comment.