Skip to content

Instantly share code, notes, and snippets.

@alienboyxp
Last active May 22, 2023 11:13
Show Gist options
  • Save alienboyxp/1cc0e0f0006bed2f22d17846a276db60 to your computer and use it in GitHub Desktop.
Save alienboyxp/1cc0e0f0006bed2f22d17846a276db60 to your computer and use it in GitHub Desktop.
# Current Version v_202305221109
### PAUSE AT LAYER
# Usage: SET_PAUSE_NEXT_LAYER [MACRO=<name>]
[gcode_macro SET_PAUSE_NEXT_LAYER]
description: Enable a pause if the next layer is reached
gcode: SET_GCODE_VARIABLE MACRO=SET_PRINT_STATS_INFO VARIABLE=pause_next_layer VALUE="{{'enable':True, 'call':params.MACRO|default("PAUSE")}}"
# Usage: SET_PAUSE_AT_LAYER [LAYER=<number>] [MACRO=<name>]
[gcode_macro SET_PAUSE_AT_LAYER]
description: Enable/disable a pause if a given layer number is reached
gcode:
{% if params.LAYER is defined %}
SET_GCODE_VARIABLE MACRO=SET_PRINT_STATS_INFO VARIABLE=pause_at_layer VALUE="{{'enable': True, 'layer':params.LAYER|int, 'call':params.MACRO|default("PAUSE")}}"
{% else %}
SET_GCODE_VARIABLE MACRO=SET_PRINT_STATS_INFO VARIABLE=pause_at_layer VALUE="{{'enable': False, 'layer':0, 'call':"PAUSE"}}"
{% endif %}
# Usage: SET_PRINT_STATS_INFO [TOTAL_LAYER=<total_layer_count>] [CURRENT_LAYER= <current_layer>]
[gcode_macro SET_PRINT_STATS_INFO]
rename_existing: SET_PRINT_STATS_INFO_BASE
description: Overwrite, to get pause_next_layer and pause_at_layer feature
variable_pause_next_layer: {'enable':False, 'call':"PAUSE"}
variable_pause_at_layer : {'enable':False, 'layer':0, 'call':"PAUSE"}
gcode:
{% if pause_next_layer.enable %}
{action_respond_info("%s, forced by pause_next_layer" % pause_next_layer.call)}
{pause_next_layer.call} ; execute the given gcode to pause, should be either M600 or PAUSE
SET_GCODE_VARIABLE MACRO=SET_PRINT_STATS_INFO VARIABLE=pause_next_layer VALUE="{{'enable': False, 'call':"PAUSE"}}"
{% elif pause_at_layer.enable and params.CURRENT_LAYER is defined and params.CURRENT_LAYER|int == pause_at_layer.layer %}
{action_respond_info("%s, forced by pause_at_layer [%d]" % (pause_at_layer.call, pause_at_layer.layer))}
{pause_at_layer.call} ; execute the given gcode to pause, should be either M600 or PAUSE
SET_GCODE_VARIABLE MACRO=SET_PRINT_STATS_INFO VARIABLE=pause_at_layer VALUE="{{'enable': False, 'layer': 0, 'call':"PAUSE"}}"
{% endif %}
SET_PRINT_STATS_INFO_BASE {rawparams}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment