Skip to content

Commit

Permalink
start_print selects the tool the slicer chose
Browse files Browse the repository at this point in the history
  • Loading branch information
matti125 committed Sep 3, 2021
1 parent d971dd7 commit 1bcec00
Showing 1 changed file with 50 additions and 58 deletions.
108 changes: 50 additions & 58 deletions macros.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ gcode:
SAVE_GCODE_STATE NAME=park0
G90
SET_GCODE_OFFSET X=0
G1 X{printer.configfile.settings.stepper_x.position_min} F3000
G1 X{printer.configfile.settings.stepper_x.position_min} F12000
RESTORE_GCODE_STATE NAME=park0

[gcode_macro PARK_extruder1]
Expand All @@ -26,9 +26,35 @@ gcode:
SAVE_GCODE_STATE NAME=park1
G90
SET_GCODE_OFFSET X=0
G1 X{printer.configfile.settings.dual_carriage.position_max} F3000
G1 X{printer.configfile.settings.dual_carriage.position_max} F12000
RESTORE_GCODE_STATE NAME=park1


[gcode_macro x_xoffset]
# helper script, needed as the variable xoffset will be changed during macro execution
# and macro expansion happens before that

gcode:
{ action_respond_info("Xoffset will be set to %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 set_stepper_x_range]
variable_xoffset: 0
variable_range_set: 0
gcode:
{ action_respond_info("Setting leftmost extruder x-axis origin") }
{ action_respond_info("Extruder1 temperature target: %s" % printer.extruder1.target ) }
{% if printer.extruder1.target|int > 0 %}
{ action_respond_info("Right hand side extruder active") }
{% 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
{ action_respond_info("X origin is set to %s mm from left end of bed" % offset) }

# Activate the primary extruder
[gcode_macro T0]
gcode:
Expand All @@ -42,32 +68,16 @@ gcode:
{ action_respond_info("Lefttmost extruder X-direction movement range not yet set, setting it now") }
set_stepper_x_range
{% endif %}
SET_GCODE_OFFSET Y=0 X={ printer["gcode_macro set_stepper_x_range"].xoffset }
x_xoffset

[gcode_macro T1]
gcode:
{ action_respond_info("Selecting tool T1" ) }
PARK_{printer.toolhead.extruder}
ACTIVATE_EXTRUDER EXTRUDER=extruder1
SET_DUAL_CARRIAGE CARRIAGE=1
SET_GCODE_OFFSET X=-0.2 Y=-0.03
SET_GCODE_OFFSET X=0.14 Y=-0.03

[gcode_macro set_stepper_x_range]
variable_xoffset: 0
variable_range_set: 0
gcode:
{ action_respond_info("Setting leftmost extruder x-axis printing range") }
{ action_respond_info("Extruder1 temperature target: %s" % printer.extruder1.target ) }
{% if printer.extruder1.target|int > 0 %}
{ action_respond_info("Right hand side extruder active") }
{% 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
{ action_respond_info("Prints can extend to %s mm from left end of bed" % offset) }

[gcode_macro clear_stepper_x_range]
gcode:
Expand Down Expand Up @@ -98,20 +108,29 @@ gcode:
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
G0 X-10 Y35 Z0.5 F9000
# prime in air
G1 E5 F300
PRIME_LINE X=3 Y=35 Z=0.25 YLINE=150
PRIME_LINE X=3 Y=35 Z=0.25 YLINE=100
RESTORE_GCODE_STATE NAME=prime_ext0
{ action_respond_info("Extruder0 was prepared") }
{% endif %}
{% if printer.extruder1.target|int > 0 %}
{ action_respond_info("Extruder1 will be prepared ") }
T1
G0 X240 Y35 Z0.5 F3000
G0 X225 Y35 Z0.5 F9000
G1 E5 F300
PRIME_LINE X=201 Y=35 Z=0.2 YLINE=120 XLINE=-1
{ action_respond_info("Extruder0 was prepared") }
PRIME_LINE X=200 Y=35 Z=0.25 YLINE=100
{% endif %}
#set the Tooolhead to what it was when the macro was called.
# At least Ideamaker sets the T0/T1 before calling the user-defined macro,
# so we need to be know which toolhead was set and switch to that before continuing
#Jinja expansion happens befor macro is actually executed, so printer.toolhead.extrude in the conditional
#statement will NOT have been dynamically changed, but is instead the original value at call time.

{% if printer.toolhead.extruder == "extruder1" %}
T1
{% else %}
T0
{% endif %}
#set extruder to abs mode
M82
Expand Down Expand Up @@ -140,7 +159,7 @@ gcode:
{% set z = params.Z|default(0.2)|float %}
{% set xline = params.XLINE|default(1)|float %}
{% set yline = params.YLINE|default(120)|float %}

{% set eMultiplier = 0.15 * z %}
SAVE_GCODE_STATE NAME=prime_line

M117 Prime Line
Expand All @@ -150,11 +169,11 @@ gcode:
# move z axis
G1 Z0.5 F3000 ;Move Z Axis up
# move to prime position
G0 Y{y} Z{z} F1500
G0 Y{y} Z{z}
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 Y{y + yline} E{eMultiplier * yline} ;Draw the first line
G1 X{x + xline} E{eMultiplier * xline} ;Move to side a little
G1 Y{y + 20} E{eMultiplier * (yline - 20)} ;Draw the second line, but do not go back to origin to avoid picking the wipeouts
G1 E-0.5 F300
G1 Z1 F3000 ;Move Z Axis up

Expand Down Expand Up @@ -213,31 +232,4 @@ gcode:
{% 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 1bcec00

Please sign in to comment.