Skip to content

Instantly share code, notes, and snippets.

@rootiest
Last active May 13, 2022 09:12
Show Gist options
  • Save rootiest/5cf936f31b57c4ae3970a50fbc476823 to your computer and use it in GitHub Desktop.
Save rootiest/5cf936f31b57c4ae3970a50fbc476823 to your computer and use it in GitHub Desktop.
M73 with layer progress
[gcode_macro BEGIN_LAYER]
description: Start a new layer and notify system
gcode:
#Get layer details from Slicer GCode
{% set CUR_LAYER = params.NUM|default(0)|float + 1 %}
{% set NUM_LAYERS = params.COUNT|default(0)|float %}
{% set LAYER_Z = params.ZLAY|default(0)|float %}
SET_GCODE_VARIABLE MACRO=PREP_PRINT VARIABLE=cur_layer VALUE={CUR_LAYER}
SET_GCODE_VARIABLE MACRO=PREP_PRINT VARIABLE=num_layers VALUE={NUM_LAYERS}
SET_GCODE_VARIABLE MACRO=PREP_PRINT VARIABLE=layer_z VALUE={LAYER_Z}
[gcode_macro M73]
rename_existing: M73.1
gcode:
{% set NUM_LAYERS = printer["gcode_macro PREP_PRINT"].num_layers %}
{% set CUR_LAYER = printer["gcode_macro PREP_PRINT"].cur_layer %}
M117 { "%02d:%02d" % (params.R|int // 60, (params.R|int) % 60) } remaining Layer {CUR_LAYER|int} of {NUM_LAYERS|int}
BEGIN_LAYER NUM={layer_num} COUNT={total_layer_count} ZLAY={layer_z}; Increment layer in Klipper
@rootiest
Copy link
Author

rootiest commented Apr 17, 2022

This Klipper macro package tracks layer progress, stores the current layer to a variable, and responds to M73 commands by using M117 to display the print's remaining time and current of total layers.

For this macro package to function properly:

SuperSlicer must be configured to display print progress using M73.

My PREP_PRINT Klipper macros must also be installed.

@rootiest
Copy link
Author

Prints with manual filament swaps will cause this macro to output blank M117 commands due to them changing the M73 parameters.

I am working on a solution to include "Remaining Time to Filament Swap" in the status messages in those cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment