Skip to content

Commit

Permalink
idex.cfg updated
Browse files Browse the repository at this point in the history
  • Loading branch information
HelgeKeck committed Apr 16, 2024
1 parent 9711b9c commit 9fed3b4
Showing 1 changed file with 104 additions and 63 deletions.
167 changes: 104 additions & 63 deletions macros/idex/idex.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,17 @@
#####
# CONFIGURATION VARIABLES
#####

[gcode_macro RatOS]
variable_auto_center_subject: False # EXPERIMENTAL: auto center printed parts in x axis for idex copy and mirror mode

#####
# IDEX macros
#####
[gcode_macro IDEX_SINGLE]
gcode:
_IDEX_SWAP_TOOLHEADS ENABLE=False
_IDEX_SINGLE


[gcode_macro IDEX_SWAP]
gcode:
_IDEX_SWAP_TOOLHEADS ENABLE=True
_IDEX_REMAP_TOOLHEADS ENABLE=False
_IDEX_SINGLE


[gcode_macro _IDEX_SINGLE]
gcode:
# Handle toolhead settings
Expand Down Expand Up @@ -132,57 +127,6 @@ gcode:
# Handle toolhead settings
RESTORE_TOOLHEAD_SETTINGS


[gcode_macro _IDEX_SWAP_TOOLHEADS]
variable_enabled: False
gcode:
# parameters
{% set enable = true if params.ENABLE|default(false)|lower == 'true' else false %}

# config
{% set idex_mode = printer["dual_carriage"].carriage_1|lower %}

# store setting
{% if idex_mode != "copy" and idex_mode != "mirror" %}
{% if enable %}
RATOS_ECHO MSG="Toolhead swapping enabled for the next print!"
{% endif %}
SET_GCODE_VARIABLE MACRO=_IDEX_SWAP_TOOLHEADS VARIABLE=enabled VALUE={enable}
{% else %}
RATOS_ECHO MSG="Toolhead swapping not possible in copy and mirror mode!"
SET_GCODE_VARIABLE MACRO=_IDEX_SWAP_TOOLHEADS VARIABLE=enabled VALUE=False
{% endif %}


[gcode_macro _IDEX_SPOOL_JOIN]
variable_enabled: False
gcode:
# parameters
{% set enable = true if params.ENABLE|default(false)|lower == 'true' else false %}

# config
{% set idex_mode = printer["dual_carriage"].carriage_1|lower %}

# store setting
SET_GCODE_VARIABLE MACRO=_IDEX_SPOOL_JOIN VARIABLE=enabled VALUE=False
{% if idex_mode != "copy" and idex_mode != "mirror" %}
{% if enable %}
{% set has_t0_toolhead_filament_sensor = true if printer["filament_switch_sensor toolhead_filament_sensor_t0"] is defined else false %}
{% set has_t1_toolhead_filament_sensor = true if printer["filament_switch_sensor toolhead_filament_sensor_t0"] is defined else false %}
{% set has_t0_feeder_filament_sensor = true if printer["filament_switch_sensor feeder_filament_sensor_t0"] is defined else false %}
{% set has_t1_feeder_filament_sensor = true if printer["filament_switch_sensor feeder_filament_sensor_t1"] is defined else false %}
{% if (has_t0_toolhead_filament_sensor and has_t1_toolhead_filament_sensor) or (has_t0_feeder_filament_sensor and has_t1_feeder_filament_sensor) %}
SET_GCODE_VARIABLE MACRO=_IDEX_SPOOL_JOIN VARIABLE=enabled VALUE=True
RATOS_ECHO MSG="Spool join enabled!"
{% else %}
RATOS_ECHO MSG="Can not enable spool join! No filament sensors found."
{% endif %}
{% endif %}
{% else %}
RATOS_ECHO MSG="Spool join is not possible in copy and mirror mode!"
{% endif %}


[gcode_macro IDEX_COPY]
gcode:
_IDEX_COPY
Expand Down Expand Up @@ -473,7 +417,59 @@ gcode:

{% endif %}

[gcode_macro _SPOOL_JOIN]
#####
# IDEX spool joining
#####
[gcode_macro JOIN_SPOOLS]
gcode:
# parameters
{% set spools = params.SPOOLS|default("") %}

{% if spools == "" %}
_IDEX_JOIN_SPOOLS ENABLE=false
{% else %}
{% if spools != "0,1" and spools != "1,0" %}
RATOS_ECHO MSG="Wrong spool configuration!"
{% else %}
{% if spools == "0,1" or spools == "1,0" %}
_IDEX_JOIN_SPOOLS ENABLE=true
{% else %}
_IDEX_JOIN_SPOOLS ENABLE=false
{% endif %}
{% endif %}
{% endif %}

[gcode_macro _IDEX_JOIN_SPOOLS]
variable_enabled: False
gcode:
# parameters
{% set enable = true if params.ENABLE|default(false)|lower == 'true' else false %}

# config
{% set idex_mode = printer["dual_carriage"].carriage_1|lower %}

# store setting
SET_GCODE_VARIABLE MACRO=_IDEX_JOIN_SPOOLS VARIABLE=enabled VALUE=False
{% if idex_mode != "copy" and idex_mode != "mirror" %}
{% if enable %}
{% set has_t0_toolhead_filament_sensor = true if printer["filament_switch_sensor toolhead_filament_sensor_t0"] is defined else false %}
{% set has_t1_toolhead_filament_sensor = true if printer["filament_switch_sensor toolhead_filament_sensor_t0"] is defined else false %}
{% set has_t0_feeder_filament_sensor = true if printer["filament_switch_sensor feeder_filament_sensor_t0"] is defined else false %}
{% set has_t1_feeder_filament_sensor = true if printer["filament_switch_sensor feeder_filament_sensor_t1"] is defined else false %}
{% if (has_t0_toolhead_filament_sensor and has_t1_toolhead_filament_sensor) or (has_t0_feeder_filament_sensor and has_t1_feeder_filament_sensor) %}
SET_GCODE_VARIABLE MACRO=_IDEX_JOIN_SPOOLS VARIABLE=enabled VALUE=True
RATOS_ECHO MSG="Spool joining enabled for the next print!"
{% else %}
RATOS_ECHO MSG="Can not enable spool joining! No filament sensors found."
{% endif %}
{% else %}
RATOS_ECHO MSG="Spool joining deactivated!"
{% endif %}
{% else %}
RATOS_ECHO MSG="Spool joining is not possible in copy and mirror mode!"
{% endif %}

[gcode_macro _JOIN_SPOOL]
gcode:
# parameter
{% set old_toolhead = params.TOOLHEAD|int %}
Expand All @@ -483,7 +479,7 @@ gcode:
{% set speed = printer["gcode_macro RatOS"].toolchange_travel_speed|float * 60 %}
{% set purge_after_load = printer["gcode_macro T%s" % new_toolhead].purge_after_load|float %}

DEBUG_ECHO PREFIX="_SPOOL_JOIN" MSG="toolhead={new_toolhead}"
DEBUG_ECHO PREFIX="_JOIN_SPOOL" MSG="toolhead={new_toolhead}"

{% set has_filament = true %}
{% set has_new_toolhead_filament_sensor = true if printer["filament_switch_sensor toolhead_filament_sensor_t%s" % new_toolhead] is defined else false %}
Expand Down Expand Up @@ -543,8 +539,53 @@ gcode:
RESUME TOOLHEAD={new_toolhead}

# deactivate join spool feature since there is no filament anymore in the old toolhead
_IDEX_SPOOL_JOIN ENABLE=false
_IDEX_JOIN_SPOOLS ENABLE=false

{% else %}
{ action_raise_error("Spool join failed! No filament found or filament sensor is disabled.") }
{% endif %}

#####
# IDEX toolhead remapping
#####
[gcode_macro REMAP_TOOLHEADS]
gcode:
# parameters
{% set toolheads = params.TOOLHEADS|default("") %}

{% if toolheads == "" %}
_IDEX_REMAP_TOOLHEADS ENABLE=false
{% else %}
{% if toolheads != "0,1" and toolheads != "1,0" %}
RATOS_ECHO MSG="Wrong toolhead configuration!"
{% else %}
{% if toolheads == "0,1" or toolheads == "1,0" %}
_IDEX_REMAP_TOOLHEADS ENABLE=true
_IDEX_SINGLE
{% else %}
_IDEX_REMAP_TOOLHEADS ENABLE=false
{% endif %}
{% endif %}
{% endif %}

[gcode_macro _IDEX_REMAP_TOOLHEADS]
variable_enabled: False
gcode:
# parameters
{% set enable = true if params.ENABLE|default(false)|lower == 'true' else false %}

# config
{% set idex_mode = printer["dual_carriage"].carriage_1|lower %}

# store setting
{% if idex_mode != "copy" and idex_mode != "mirror" %}
{% if enable %}
RATOS_ECHO MSG="Toolhead remapping enabled for the next print!"
{% else %}
RATOS_ECHO MSG="Toolhead remapping deactivated!"
{% endif %}
SET_GCODE_VARIABLE MACRO=_IDEX_REMAP_TOOLHEADS VARIABLE=enabled VALUE={enable}
{% else %}
RATOS_ECHO MSG="Toolhead remapping not possible in copy and mirror mode!"
SET_GCODE_VARIABLE MACRO=_IDEX_REMAP_TOOLHEADS VARIABLE=enabled VALUE=False
{% endif %}

0 comments on commit 9fed3b4

Please sign in to comment.