Code Monkey home page Code Monkey logo

klipper-macros's Introduction

klipper-macros

This is a collection of macros for the Klipper 3D printer firmware. I originally created this repo just to have a consistent set of macros shared between my own 3D printers. But since I've found them useful, I thought other people might as well.

What can I do with these?

Most of these macros improve basic functionality (e.g. selectable build sheets ) and Klipper compatability with g-code targeting Marlin printers. However, there are also some nice extras:

  • Schedule commands at heights and layer changes - This is similar to what your slicer can already do, but I find it simpler, and you can schedule these commands while a print is active. As an example of usage, I added an LCD menu item to pause the print at the next layer change. This way the pause won't mar the print by e.g. pausing inside an external perimeter.
  • Dynamically scale heaters and fans - This makes it easy to do things like persistently adjust fan settings during a live print, or maintain simpler slicer profiles by moving things like a heater bump for a hardened steel nozzle into state stored on the printer.
  • Cleaner LCD menu interface - I've simplified the menus and provided a much easier way to customize materials in the LCD menu (or at least I think so). I've also added confirmation dialogs for commands that would abort an active print.
  • Optimized mesh bed leveling - Probes only within the printed area, which can save a lot of time on smaller prints.
  • Automated purge lines - Set the desired extrusion length as variable_start_purge_length in your config and a correctly sized set of purge lines will be extruded in front of the print area immediately before the print starts.

A few warnings...

  • BACK UP YOUR FULL CONFIG BEFORE MAKING ANY CHANGES!!! I've seen so many newcomers desperately looking for help on public forums because they didn't have a good config to fall back to after messing up their current config while experimenting with other people's macros. You'll save yourself and everyone else a whole lot of time and nuisance if you just make sure you always have a working config backed up.
  • You really should avoid custom macros like this until you're comfortable using Klipper with a basic config. Advanced Klipper macros tend to rely extensively on monkey patching, which can lead to problems with unusual configurations or when mixing macros from various sources. So, you really want to know what you're doing before including someone else's macros—particularly when including macros with overlapping functionality from different sources.
  • You must have a heater_bed, extruder, and other sections listed below configured, otherwise the macros will force a printer shutdown at startup. Unfortunately, the Klipper macro system doesn't have a more graceful way of handling this sort of thing.
  • The multi-extruder and chamber heater functionality is very under-tested and may have bugs, since I haven't used it much at all. Patches welcome.
  • There's probably other stuff I haven't used enough to test thoroughly, so use these macros at your own risk.

Troubleshooting

  • Double check that you followed the installation instructions and are not seeing any console or log errors.
  • Ensure that you're running the most current version of stock Klipper, and not a fork or otherwise altered or outdated copy.
  • Ensure you're using the most current version of these macros and haven't made changes to any files in the klipper-macros directory.
  • Ensure that you've restarted Klipper after any updates or config changes.
  • Run CHECK_KM_CONFIG in the Klipper console and fix any errors it reports to the console and/or logs (it won't output anything if no config errors were detected).
  • Run _INIT_SURFACES in the Klipper console to validate that bed surfaces are being initialized without any errors reported to the console and/or logs.
  • Verify your slicer settings and review that the gcode output is correct. Pay particular attention the initialization portions of the gcode and the parameters passed to PRINT_START.
  • Look for similar issues and post troubleshooting questions in the Github Q&A Discussion.

Reporting Bugs

If you've followed the troubleshooting steps and were unable to resolve the issue you can report a bug via Github. I will probably respond within a few days (almost certainly within a week). I probably won't respond through other channels (e.g. Discord, Twitter), because I don't find them useful for handling bug reports.

Some important things to remember when reporting bugs:

  • Paste the full text of the command that triggered the error, along with any error messages printed to the console and relevant sections of the klipper logs if appropriate (and please format this text as code, otherwise Github will format it like a ransom note).
  • Attach your config to the bug report. There's generally no way to diagnose anything without the configs.
  • Verify that your issue reproduces on the current, stock installation of Klipper and klipper-macros. Non-stock configurations and outdated versions make diagnosis nearly impossible.
  • Please don't treat bug reports as a substitute for following the installation and troubleshooting instructions.
  • Please direct feature requests to the Github Ideas Discussion.

Note: Reports that do not follow the above guidelines will likely be closed without any other action taken.

Contributing

I'm happy to accept bugfix PRs. I'm also potentially open to accepting new features or additions. However, I may decline the PR if it's something I'm not interested in or just looks like it would be a hassle for me to maintain.

Formatting

There's no standard style for Klipper macros, so please just try to follow the style in the files. That stated, here are a few rules to remember:

  • Wrap at 80 characters if at all possible
  • Indent 2 spaces, and in line with the logical block when wrapping (no tabs)
  • Prefix internal macros with _ or _km_
  • Prefix any sort of global state with _KM_ (e.g. _KM_SAVE_GCODE_STATE)

Commit Messages

These are the rules for commit messages, but you can also just look at the commit log and follow the observed pattern:

  • Use the 50/72 rule for commit messages: No more than 50 characters in the title and break lines in the description at 72 characters.
  • Begin the title with the module name (usually the main file being modified, minus any extension) followed by a colon.
  • Title-only commit messages are fine for simple commits, but be sure to include a blank line after the title.
  • Squash multiple commits if what you're working on makes more sense as a single logical commit. This might require you to do a force push on an open PR.

Installation

To install the macros, first clone this repository inside of your printer_data/config directory with the following command.

git clone https://github.com/jschuh/klipper-macros.git

Then paste the below sections into your printer.cfg to get started. Or even better, paste all of it into a seperate file in the same path as your config, and include that file. That will make it easier if you want to remove these macros in the future.

You may need to customize some settings for your own config. All configurable settings are in globals.cfg, and can be overridden by creating a corresponding variable with a new value in your [gcode_macro _km_options] section. Do not directly modify the variable declarations in globals.cfg. The macro initialization assumes certain default values, and direct modifications are likely to break things in very unexpected ways.

Note: The paths in this README follow Moonraker's data folder structure. You may need to change them if you are using a different structure.

Note: Make sure you don't currently have any macros that provide the same basic function as the macros in this repository (e.g. the default Mainsail or fluidd macros). As a rule, you should avoid using multiple sets of macros that override the same base macro (unless you really know what you're doing) because conflicting macros can cause all sorts of weird and frustrating problems.

Note: If you have a [homing_override] section you will need to update any G28 commands in the gcode part to use G28.6245197 instead (which is the renamed version of Klipper's built-in G28). Failure to do this will cause G28 commands to error out with the message Macro G28 called recursively.

Klipper Setup

# All customizations are documented in globals.cfg. Just copy a variable from
# there into the section below, and change the value to meet your needs.

[gcode_macro _km_options]
# These are examples of some likely customizations:
# Any sheets in the below list will be available with a configurable offset.
#variable_bed_surfaces: ['smooth_1','texture_1']
# Length (in mm) of filament to load (bowden tubes will be longer).
#variable_load_length: 90.0
# Hide the Octoprint LCD menu since I don't use it.
#variable_menu_show_octoprint: False
# Customize the filament menus (up to 10 entries).
#variable_menu_temperature: [
#  {'name' : 'PLA',  'extruder' : 200.0, 'bed' : 60.0},
#  {'name' : 'PETG', 'extruder' : 230.0, 'bed' : 85.0},
#  {'name' : 'ABS',  'extruder' : 245.0, 'bed' : 110.0, 'chamber' : 60}]
# Length of filament (in millimeters) to purge at print start.
#variable_start_purge_length: 30 # This value works for most setups.
gcode: # This line is required by Klipper.
# Any code you put here will run at klipper startup, after the initialization
# for these macros. For example, you could uncomment the following line to
# automatically adjust your bed surface offsets to account for any changes made
# to your Z endstop or probe offset.
#  ADJUST_SURFACE_OFFSETS

# This line includes all the standard macros.
[include klipper-macros/*.cfg]
# Uncomment to include features that require specific hardware support.
# LCD menu support for features like bed surface selection and pause next layer.
#[include klipper-macros/optional/lcd_menus.cfg]
# Optimized bed leveling
#[include klipper-macros/optional/bed_mesh.cfg]

# The sections below here are required for the macros to work. If your config
# already has some of these sections you should merge the duplicates into one
# (or if they are identical just remove one of them).
[idle_timeout]
gcode:
  _KM_IDLE_TIMEOUT # This line must be in your idle_timeout section.

[pause_resume]

[respond]

[save_variables]
filename: ~/printer_data/variables.cfg # UPDATE THIS FOR YOUR PATH!!!

[virtual_sdcard]
path: ~/gcode_files # UPDATE THIS FOR YOUR PATH!!!
on_error_gcode: CANCEL_PRINT

[display_status]

Slicer Configuration

PrusaSlicer / SuperSlicer

PrusaSlicer and its variants are fairly easy to configure. Just open Printer Settings → Custom G-code for your Klipper printer and paste the below text into the relevant sections.

Start G-code

M190 S0 ; Remove this if autoemit_temperature_commands is off in Prusa Slicer 2.6 and later
M109 S0 ; Remove this if autoemit_temperature_commands is off in Prusa Slicer 2.6 and later
_PRINT_START_PHASE_INIT EXTRUDER={first_layer_temperature[initial_tool]} BED=[first_layer_bed_temperature] MESH_MIN={first_layer_print_min[0]},{first_layer_print_min[1]} MESH_MAX={first_layer_print_max[0]},{first_layer_print_max[1]} LAYERS={total_layer_count} NOZZLE_SIZE={nozzle_diameter[0]}
; Insert custom gcode here.
_PRINT_START_PHASE_PREHEAT
; Insert custom gcode here.
_PRINT_START_PHASE_PROBING
; Insert custom gcode here.
_PRINT_START_PHASE_EXTRUDER
; Insert custom gcode here.
_PRINT_START_PHASE_PURGE

; This is the place to put slicer purge lines if you haven't set a non-zero
; variable_start_purge_length to have START_PRINT automatically calculate and 
; perform the purge (e.g. if using a Mosaic Palette, which requires the slicer
; to generate the purge).

Additional SuperSlicer Start G-code

If you're using SuperSlicer you can add the following immediately before the PRINT_START line from above. This will perform some added bounds checking and will allow you to use the random print relocation feature without requiring exclude_object entries in the print file.

PRINT_START_SET MODEL_MIN={bounding_box[0]},{bounding_box[1]} MODEL_MAX={bounding_box[3]},{bounding_box[4]}

End G-code

PRINT_END

Before layer change G-code

;BEFORE_LAYER_CHANGE
;[layer_z]
BEFORE_LAYER_CHANGE HEIGHT=[layer_z] LAYER=[layer_num]

After layer change G-code

;AFTER_LAYER_CHANGE
;[layer_z]
AFTER_LAYER_CHANGE

Ultimaker Cura

Cura is a bit more difficult to configure, and it comes with the following known issues:

  • Cura doesn't have proper placeholders for before and after layer changes, so the before triggers all fire and are followed immediately by the after triggers, all of which happens inside the layer change. This probably doesn't matter, but it does mean that you can't use the before and after triggers to avoid running code in the layer change.
  • Cura doesn't provide the Z-height of the current layer, so it's inferred from the current nozzle position, which will include the Z-hop if the nozzle is currently raised. This means height based gcode triggers may fire earlier than expected.
  • Cura's Insert at layer change fires the After trigger and then the Before trigger (i.e before or after the layer, versus before or after the layer change). These macros and PrusaSlicer do the opposite, which is something to keep in mind if you're used to how Cura does it. Note that these macros do use an Insert at layer change script to force LAYER comment generation, but that doesn't affect the trigger ordering.
  • Cura does not provide the first layer bounding rectangle, only the model bounding volume. This means the XY bounding box used to speed up mesh probing may be larger than it needs to be, resulting in bed probing that's not as fast as it could be.

Accepting the caveats, the macros work quite well with Cura if you follow the configuration steps listed below.

Start G-code

M190 S0
M109 S0
_PRINT_START_PHASE_INIT EXTRUDER={material_print_temperature_layer_0} BED={material_bed_temperature_layer_0} NOZZLE_SIZE={machine_nozzle_size}
; Insert custom gcode here.
_PRINT_START_PHASE_PREHEAT
; Insert custom gcode here.
_PRINT_START_PHASE_PROBING
; Insert custom gcode here.
_PRINT_START_PHASE_EXTRUDER
; Insert custom gcode here.
_PRINT_START_PHASE_PURGE

; This is the place to put slicer purge lines if you haven't set a non-zero
; variable_start_purge_length to have START_PRINT automatically calculate and 
; perform the purge (e.g. if using a Mosaic Palette, which requires the slicer
; to generate the purge).

End G-code

PRINT_END

Post Processing Plugin

Use the menu item for Extensions → Post Processing → Modify G-Code to open the Post Processing Plugin and add the following four scripts. The scripts must be run in the order listed below and be sure to copy the strings exactly, with no leading or trailing spaces.

Search and Replace
  • Search: (\n;(MIN|MAX)X:([^\n]+)\n;\2Y:([^\n]+))
  • Replace: \1\nPRINT_START_SET MESH_\2=\3,\4
  • Use Regular Expressions: ☑️
Search and Replace
  • Search: (\n;LAYER_COUNT:([^\n]+))
  • Replace: \1\nINIT_LAYER_GCODE LAYERS=\2\nPRINT_START_SET LAYERS=\2
  • Use Regular Expressions: ☑️
Insert at layer change
  • When to insert: Before
  • G-code to insert: ;BEFORE_LAYER_CHANGE
Search and Replace
  • Search: (\n;LAYER:([^\n]+))
  • Replace: \1\nBEFORE_LAYER_CHANGE LAYER=\2\nAFTER_LAYER_CHANGE
  • Use Regular Expressions: ☑️

Moonraker Configuration

Once you have the macros working and are comfortable using them, you can have Moonraker keep them up to date by adding the following into your moonraker.conf.

[update_manager klipper-macros]
type: git_repo
origin: https://github.com/jschuh/klipper-macros.git
path: ~/printer_data/config/klipper-macros # UPDATE THIS FOR YOUR PATH!!!
primary_branch: main
is_system_service: False
managed_services: klipper

Note: I'd advise against adding the auto-update entries to Moonraker until you have everything working well, because it can make uninstallation a bit harder due to Moonraker's autoupdate behavior.

Removal

If you choose to uninstall these macros you basically need to reverse the installation steps. However, the most critical parts are listed below.

Klipper Configuration Removal

Ensure that you remove the following from your Klipper config (and any included configs):

  • The full [gcode_macro _km_options] section
  • Any include sections with klipper-macros in the path
  • _KM_IDLE_TIMEOUT in the [idle_timeout] section

If you do not have Moonraker autoupdates configured you can delete the klipper-macros directory with something like the following command (adjusted for your own paths):

rm -rf ~/printer_data/config/klipper-macros

Slicer Configuration Removal

If you do not want to change your slicer config, you should be able to leave it as is, because it generates only a small amount of additional gcode, and the basic parameters should work with any other PRINT_START macros.

Moonraker Configuration Removal

If you've configured Moonraker auto-updates you will need to remove the entire [update_manager klipper-macros] section and restart moonraker prior to deleting the klipper-macros directory, otherwise Moonraker may attempt to recreate it. You may also find that it takes a few Moonraker update checks and restarts before the klipper-macros section disappears from the UI.

Command Reference

Customization

All features are configured by setting variable_ values in the [gcode_macro _km_options] section. All available variables and their purpose are listed in globals.cfg.

Note: PRINT_START specific customizations are covered in more detail below.

Bed Mesh Improvements

BED_MESH_CALIBRATE_FAST

Wraps the Klipper BED_MESH_CALIBRATE command to scale and redistribute the probe points so that only the appropriate area in MESH_MIN and MESH_MAX is probed. This can dramatically reduce probing times for anything that doesn't fill the first layer of the bed. If the MESH_MIN and MESH_MAX arguments are provided to PRINT_START it will automatically use this for bed mesh calibration (so long as a [bed_mesh] section is detected in your config).

The following additional configuration options are available from globals.cfg.

  • variable_probe_mesh_padding - Extra padding around the rectangle defined by MESH_MIN and MESH_MAX.
  • variable_probe_min_count - Minimum number of probes for partial probing of a bed mesh.
  • variable_probe_count_scale - Scaling factor to increase probe count for partial bed probes.

Note: See the optional section for additional macros.

Note: The bed mesh optimizations are silently disabled for delta printers.

Note: If the bed_mesh config includes a relative_reference_index then the index point selected in the optimized mesh will be the point closest to the index point in the mesh from the config. However, if a RELATIVE_REFERENCE_INDEX parameter is supplied directly to this macro it will be used unmodified.

BED_MESH_CHECK

  • ABORT - Set to a non-zero value to abort macro processing on an error.
  • MESH_MIN - See Klipper documentation for BED_MESH_CALIBRATE.
  • MESH_MAX - See Klipper documentation for BED_MESH_CALIBRATE.

Checks the [bed_mesh] config and optionally supplied parameters. Will warn (or optionally abort) if mesh_min or mesh_max could allow a move out of range during BED_MESH_CALIBRATE. This is run implictily at Klipper startup and as part of BED_MESH_CALIBRATE_FAST.

Bed Surface

Provides a set of macros for selecting different bed surfaces with corresponding Z offset adjustments to compensate for their thickness. All available surfaces must be listed in the variable_bed_surfaces array. Corresponding LCD menus for sheet selection and babystepping will be added to Setup and Tune if lcd_menus.cfg is included. Any Z offset adjustments made in the LCD menus, console, or other clients (e.g. Mainsail, Fluidd) will be applied to the current sheet and persisted across restarts.

ADJUST_SURFACE_OFFSETS

Adjusts surface offsets to account for changes in the Z endstop position or probe Z offset. A message to invoke this command will be shown in the console when a relevant change is made to printer.cfg.

  • IGNORE - Set to 1 to reset the saved offsets without adjusting the surfaces.

LOAD_SURFACE_MESH

Attempts to load a mesh associated with the specified surface.

  • SURFACE (default: current surface) - Bed surface.

MAKE_SURFACE_MESH

Generates a mesh associated with the specified surface. If variable_start_try_saved_surface_mesh is true then START_PRINT will load this mesh when the surface is selected (and skip the mesh leveling step if it was specified).

  • BED - (default: 70) Bed temperature when probing the bed.
  • EXTRUDER - (default: variable_start_extruder_probing_temp) Extruder temperature when probing the bed.
  • SURFACE (default: current surface) - Bed surface.
  • MESH_MULTIPLIER (default: 2) - Increases the mesh density by the specified integer value while preserving the existing mesh points and relative reference index. A value of 1 leaves the mesh unmodified, 2 doubles the density, 3 triples it, etc. (I.e. if bed_mesh specifies probe_count: 5,5 and MESH_MULTIPLIER=2 then this macro will generate a 9x9 grid, whereas MESH_MULTIPLIER=3 will generate a 13x13 grid.)
  • See Klipper BED_MESH_CALIBRATE documentation for additional arguments.

SET_SURFACE_ACTIVE

Sets the provided surface active (from one listed in listed in variable_bed_surfaces) and adjusts the current Z offset to match the offset for the surface. If no SURFACE argument is provided the available surfaces are listed, with active surface preceded by a *.

  • SURFACE - Bed surface with an associated offset.

SET_SURFACE_OFFSET

Directly sets the the Z offset of SURFACE to the value of OFFSET. If no argument for SURFACE is provided the current active surface is used. If no argument for OFFSET is provided the current offset is displayed.

  • OFFSET - New Z offset for the given surface.
  • SURFACE (default: current surface) - Bed surface.

Note: The SET_GCODE_OFFSET macro is overridden to update the offset for the active surface. This makes the bed surface work with Z offset adjustments made via any interface or client.

Beep

Implements the M300 command (if a corresponding pwm_cycle_time beeper or [output_pin beeper] section is present). This command causes the speaker to emit an audible tone.

M300

Emits an audible tone.

  • P (default: 100) - Duration of tone (in milliseconds).
  • S (default: 1000) - Frequency of tone.

Draw

Provides convenience methods for extruding along a path and drawing purge lines.

Note: The drawing macros require every extruder config(s) to have correct nozzle_diameter and filament_diameter settings.

DRAW_LINE_TO

Extrudes a line of filament at the specified height and width from the current coordinate to the supplied XY coordinate (using the currently active extruder).

  • X (default: current X position) - Absolute X coordinate to draw to.
  • Y (default: current Y position) - Absolute Y coordinate to draw to.
  • HEIGHT (default: set via SET_DRAW_PARAMS) - Height (in mm) used to calculate extrusion volume.
  • WIDTH (default: set via SET_DRAW_PARAMS) - Extrusion width in mm.
  • FEEDRATE (default: set via SET_DRAW_PARAMS) - Drawing feedrate in mm/m.

Note: The Z axis position must be set prior to caling this macro. The HEIGHT parameter is used only to calculate the extrusion volume.

SET_DRAW_PARAMS

Sets the default parameters used by DRAW_LINE_TO. This is helpful in reducing DRAW_LINE_TO command line lengths (particluarly important when debugging in the console).

  • HEIGHT (optional; 0.2mm at startup) - Height (in mm) used to calculate extrusion volume.
  • WIDTH (optional; nozzle diameter at startup) - Extrusion width in mm.
  • FEEDRATE (optional; 1200mm/m at startup) - Drawing feedrate in mm/m.

DRAW_PURGE_LINE

Moves to a position at the front edge of the first print layer and purges the specified length of filament as a line (or rows of lines) in front of the supplied print area. If no print area is specified the purge lines are drawn at the front edge of the maximum printable area. If no printable area is set it defaults to the respective axis limits.

  • PRINT_MIN (default: variable_print_min) - Upper boundary of print.
  • PRINT_MAX (default: variable_print_max) - Lower boundary of print.
  • HEIGHT (default: 62.5% of nozzle diameter) - Extrusion height in mm.
  • WIDTH (default: 125% of nozzle diameter) - Extrusion width in mm.
  • LENGTH (default: variable_start_purge_length) - Length of filament to purge. The default in variable_start_purge_length is also the amount that is automatically purged at print start.

Note: You must set variable_print_min and variable_print_max if the X and Y axis limits in your config allow your toolhead to move outside the printable area (e.g. for dockable probes or purge buckets).

Note: If your print touches the front edge of the bed it will overlap with with the extrusions from DRAW_PURGE_LINE.

Fans

Implements scaling parameters that alter the behavior of the M106 command. Once set, these parameters apply to any fan speed until they are cleared (by default this happens at the start and end of the print).

SET_FAN_SCALING

Sets scaling parameters for the extruder fan.

  • BOOST (default: 0) - Added to the fan speed.
  • SCALE (default: 1.0) - The BOOST value is added an then the fan speed is multiplied by SCALE.
  • MAXIMUM (default: 255) - The fan speed is clamped to no larger than MAXIMUM.
  • MINIMUM (default: 0) - The fan speed is clamped to no less than MINIMUM; if this is a non-zero value the fan can be stopped only via the M107 command.
  • SPEED (optional) - This specifies a new speed target, otherwise any new adjustments will be applied to the unadjusted value of the last set fan speed.

RESET_FAN_SCALING

  • Clears all existing fan scaling factors.

Filament

LOAD_FILAMENT / UNLOAD_FILAMENT

Loads or unloads filament to the nozzle.

  • LENGTH (default: variable_load_length) - The length of filament to load or unload.
  • SPEED (default: variable_load_speed) - Speed (in mm/m) to feed the filament.
  • MINIMUM (default: variable_load_min_temp) - Ensures the extruder is heated to at least the specified temperature.

Marlin Compatibility

  • The M701 and M702 commands are implemented with a default filament length of variable_load_length.

Heaters

Adds scaling parameters that can alter the behavior of the specified heater. Once set, these parameters apply to any temperature target on that heater until the scalaing parameters are cleared. A zero target temperature will turn the heater off regardless of scaling parameters.

SET_HEATER_SCALING

Sets scaling parameters for the specified heater. If run without any arguments any currently scaled heaters and thier scaling parameters will be listed. By default the scaling is cleared at the start and end of a print.

  • HEATER - The name of the heater to scale.
  • BOOST (default: 0.0) - Added to a non-zero target temperature.
  • SCALE (default: 1.0) - Multiplied with the boosted target temperature.
  • MAXIMUM (default: max_temp) - The target temperature is clamped to no larger than MAXIMUM. This value must be between min_temp and min_temp, inclusive.
  • MINIMUM (default: min_temp) - A non-zero target temperature is clamped to no less than MINIMUM. This value must be between min_temp and min_temp, inclusive.
  • TARGET (optional) - This specifies a new target temperature, otherwise any new adjustments will be applied to the unadjusted value of the last set target temperature.

Note: a zero target temperature will turn the heater off regardless of scaling parameters.

RESET_HEATER_SCALING

Clears current heater scaling.

  • HEATER (optional) - The name of the heater to reset.

Note: if no HEATER argument is specified scaling parameters will be reset for all heaters.

SET_HEATER_TEMPERATURE_SCALED

The scaled version of Klipper's SET_HEATER_TEMPERATURE. All arguments are the same and the function is identical, except that scaling values are applied.

TEMPERATURE_WAIT_SCALED

The scaled version of Klipper's TEMPERATURE_WAIT. All arguments are the same and the function is identical, except that scaling values are applied.

Marlin Compatibility

  • The chamber heating commands M141 and M191 are implemented if a corresponding [heater_generic chamber] section is defined in the config.
  • The R temperature parameter from Marlin is implemented for the M109 and M190 commands. This parameter will cause a wait until the target temperature stabilizes (i.e. the normal Klipper behavior for S).
  • The S parameter for the M109 and M190 commands is altered to behave as it does in Marlin. Rather than causing a wait until the temperature stabilizes, the wait will complete as soon as the temperature target is exceeded.
  • The M109, M190, M191, M104, M140, and M141 are all overridden to implement the heater scaling described above.

Note: Both SET_HEATER_TEMPERATURE and TEMPERATURE_WAIT are not overriden and will not scale values. This means that heater scaling adjustments made in clients like Mainsail and Fluidd will not be scaled (because that seemed like the clearest behavior). The custom LCD menus will also replace the temperature controls with non-scaling versions. If you use the stock menus you'll get scaled values.

Kinematics

G28

Extends the G28 command to add lazy homing by not re-homing already homed axes when the O argument is included (equivalent to the same argument in Marlin). See Klipper G28 documentation for general information and detail on the other arguments.

  • O - Omits already homed axes from the homing procedure.

Note: If you have a [homing_override] section you will need to update any G28 commands in the gcode part to use G28.6245197 instead (which is the renamed version of Klipper's built-in G28). Failure to do this will cause G28 commands to error out with the message Macro G28 called recursively.

LAZY_HOME

Homes the specified axes; by default omits any axes that are already homed.

  • AXES (default: XYZ) - List of axes to home.
  • LAZY (default: 1) - Omits already homed axes from the homing procedure.

Layer Triggers

Provides the capability to run user-specified g-code commands at arbitrary layer changes.

GCODE_AT_LAYER

Runs abritrary, user-provided g-code commands at the user-specified layer or height. If no arguments are specified it will display all currently scheduled g-code commands along with their associated layer or height.

  • HEIGHT - Z height (in mm) to run the command. Exactly one of HEIGHT or LAYER must be specified.
  • LAYER - Layer number (zero indexed) to run the command. Exactly one of HEIGHT or LAYER must be specified. The special value next may be specified run the command at the next layer change.
  • COMMAND - The command to run at layer change. Take care to properly quote spaces and escape any special characters.
  • CANCEL (default: 0) - Cancel the commands previously scheduled at the given layer or height. If no COMMAND argument is provided all commands at the specified LAYER or HEIGHT are cancelled.

CANCEL_ALL_LAYER_GCODE

Cancels all g-code commands previously scheduled at any layer or height.

Convenient Layer Change Macros

  • PAUSE_NEXT_LAYER ...
    • Schedules the current print to pause at the next layer change. See PAUSE macro for additional arguments.
  • PAUSE_AT_LAYER { HEIGHT=<pos> | LAYER=<layer> } ...
    • Schedules the current print to pause at the specified layer change. See PAUSE for additional arguments.
  • SPEED_AT_LAYER { HEIGHT=<pos> | LAYER=<layer> } SPEED=<percentage>
    • Schedules a feedrate adjustment at the specified layer change. (SPEED parameter behaves the same as the M220 S parameter.)
  • FLOW_AT_LAYER { HEIGHT=<pos> | LAYER=<layer> } FLOW=<percentage>
    • Schedules a flow-rate adjustment at the specified layer change. (FLOW parameter behaves the same as the M221 S parameter.)
  • FAN_AT_LAYER { HEIGHT=<pos> | LAYER=<layer> } ...
    • Schedules a fan adjustment at the specified layer change. See SET_FAN_SCALING for additional arguments.
  • HEATER_AT_LAYER { HEIGHT=<pos> | LAYER=<layer> } ...
    • Schedules a heater adjustment at the specified layer change. See SET_HEATER_SCALING for additional arguments.

Note: If any triggers cause an exception the current print will abort. The convenience macros above validate their arguments as much as is possible to reduce the chances of an aborted print, but they cannot entirely eliminate the risk of a macro doing something that aborts the print.

Park

Implements toolhead parking.

PARK

Parks the toolhead.

  • P (default: 2) - Parking mode
    • P=0 - If current Z-pos is lower than Z-park then the nozzle will be raised to reach Z-park height
    • P=1 - No matter the current Z-pos, the nozzle will be raised/lowered to reach Z-park height.
    • P=2 - The nozzle height will be raised by Z-park amount but never going over the machine’s Z height limit.
  • X (default: variable_park_x) - Absolute X parking coordinate.
  • Y (default: variable_park_y) - Absolute Y parking coordinate.
  • Z (default: variable_park_z) - Z parking coordinate applied according to the P parameter.
  • LAZY (default: 1) - Will home any unhomed axes if needed and will not move any axis if already homed and parked (even if P=2).

Note: If a print is in progress the larger of the tallest printed layer or the current Z position will be used as the current Z position, to avoid collisions with already printed objects during a sequential print.

Marlin Compatibility

  • The G27 command is implemented with a default P0 argument.

Pause, Resume, Cancel

PAUSE

Pauses the current print.

  • X (default: variable_park_x) - Absolute X parking coordinate.
  • Y (default: variable_park_y) - Absolute Y parking coordinate.
  • Z (default: variable_park_z) - Relative Z parking coordinate
  • E (default: 5) - Retraction length to prevent ooze.
  • B (default: 10) - Number of beeps to emit (if M300 is enabled).

RESUME

  • E (default: 5) - Retraction length to prevent ooze.

CANCEL_PRINT

Cancels the print and performs all the same functions as PRINT_END.

Marlin Compatibility

  • The M24, M25, M600, M601, and M602 commands are all implemented by wrapping the above commands.

Print Start and End

PRINT_START

Sets up the printer prior to starting a print (called from the slicer's print start g-code). A target CHAMBER temperature may be provided if a [heater_generic chamber] section is present in the klipper config. If MESH_MIN and MESH_MAX are provided, then BED_MESH_CALIBRATE will probe only the area within the specified rectangle, and will scale the number of probes to the appropriate density (this can dramatically reduce probe times for smaller prints).

  • BED - Bed heater starting temperature.
  • EXTRUDER - Extruder heater starting temperature.
  • CHAMBER (optional) - Chamber heater starting temperature.
  • MESH_MIN (optional) - Minimum x,y coordinate of the first layer.
  • MESH_MAX (optional) - Maximum x,y coordinate of the first layer.
  • NOZZLE_SIZE (default: nozzle_diameter) - Nozzle diameter of the primary extruder.
  • LAYERS (optional) - Total number of layers in the print.

These are the customization options you can add to your [gcode_macro _km_options] section to alter PRINT_START behavior:

  • variable_start_bed_heat_delay (default: 2000) - This delay (in microseconds) is used to allow the bed to stabilize after it reaches it's target temperature. This is present to account for the fact that the temperature sensors for most beds are located close to the heating element, and thus will register as being at the target temperature before the surface of the bed is. For larger or thicker beds you may want to increase this value. For smaller or thinner beds you may want to disable this entirely by setting it to 0.

  • variable_start_bed_heat_overshoot (default: 2.0) - This value (in degrees Celsius) is added to the supplied target bed temperature and use as the initial target temperature when preheating the bed. After the bed preheats to this target it there is a brief delay before the final target is set. This allows the bed to stabilize at it's final temperature more quickly. For smaller or thinner beds you may want to reduce this value or disable it entirely by setting it to 0.0.

  • variable_start_end_park_y (default: max) - The final Y position of the toolhead in the PRINT_END macro, to ensure that the toolhead is out of the way when the bed is presented for print removal. This can be set to a Y coordinate (e.g. 0.0), max to use stepper_y.position_max, or min to use stepper_y.position_min.

  • variable_start_extruder_preheat_scale (default: 0.5) - This value is multiplied by the target extruder temperature and the result is used as the preheat value for the extruder while the bed is heating. This is done to reduce oozing from the extruder while the bed is heating or being probed. Set to 1.0 to preheat the extruder to the full target temperature, or to 0.0 to not preheat the extruder at all until the bed reaches temperature.

  • variable_start_extruder_probing_temp (default: 0) - If set to a non-zero value the extruder will be stabilized at the supplied temperature prior to bed probing. This is useful for Voron TAP, load cells, and other forms of probing that use the nozzle directly. When this value is provided variable_start_extruder_preheat_scale is ignored.

  • variable_start_level_bed_at_temp (default: True if bed_mesh configured ) - If true the PRINT_START macro will run BED_MESH_CALIBRATE_FAST after the bed has stabilized at its target temperature.

  • variable_start_home_z_at_temp (default: True if probe:z_virtual_endstop configured) - Rehomes the Z axis once the bed reaches its target temperature, to account for movement during heating.

  • variable_start_clear_adjustments_at_end (default: True) - Clears temporary adjustments after the print completes or is cancelled (e.g. feedrate, flow percentage).

  • variable_start_purge_clearance (default: 5.0) - Distance (in millimeters) between the purge lines and the print area (if a start_purge_length is provided).

  • variable_start_purge_length (default: 0.0) - Length of filament (in millimeters) to purge after the extruder finishes heating and prior to starting the print. For most setups 30 is a good starting point.

  • variable_start_purge_prime_length (default: 10.0) - Length of filament (in millimeters) to prime the extruder before drawing the purge lines.

  • variable_start_quad_gantry_level_at_temp (default: True if quad_gantry_level configured) - If true the PRINT_START macro will run QUAD_GANTRY_LEVEL after the bed has stabilized at its target temperature.

  • variable_start_random_placement_max (default: 0) - A positive value specifies the +/- distance in the XY axes that the print can be randomly relocated (assuming the bed has sufficient space). This can help reduce bed wear from repeatedly printing in the same spot. Note that this feature requires additional information to determine the proper bounds of the relocated print. As such, START_PRINT must have valid MESH_MIN/MESH_MAX parameters, and either MODEL_MIN/MODEL_MAX must be set or the print file must include EXCLUDE_OBJECT_DEFINE statements with POLYGON lists that define the bounds of the objects (see exclude_object for more information).

  • variable_start_random_placement_padding (default: 10.0) - The minimum distance the relocated print will be placed from the printable edge of the bed.

  • variable_start_try_saved_surface_mesh (default: False) - If enabled and bed_mesh.profiles contains a matching mesh for the currently select bed surface, then the mesh will be loaded from the saved profile (and BED_MESH_CALIBRATE_FAST will be skipped if it would have been run otherwise).

  • variable_start_z_tilt_adjust_at_temp (default: True if z_tilt configured) - If true the PRINT_START macro will run Z_TILT_ADJUST after the bed has stabilized at its target temperature.

You can further customize the PRINT_START macro by declaring your own override wrapper. This can be useful for things like loading mesh/skew profiles, or any other setup that may need to be performed prior to printing.

Here's a skeleton of a PRINT_START override wrapper:

[gcode_macro PRINT_START]
rename_existing: KM_PRINT_START
gcode:

  # Put macro code here to run before PRINT_START.

  KM_PRINT_START {rawparams}

  # Put macro code here to run after PRINT_START but before the print gcode

Note: You can use this same pattern to wrap other macros in order to account for customizations specific to your printer. E.g. If you have a dockable probe you may choose to wrap BED_MESH_CALIBRATE with the appropriate docking/undocking commands.

PRINT_START Phases

The recommended slicer start gcode breaks PRINT_START into the phases below. This approach allows for pausing or cancelling, and inserting custom gcode between the phases (e.g. to set status LEDs, deploy/dock probes, load filament). The phases are described in order below:

  • _PRINT_START_PHASE_INIT - Initializes the PRINT_START settings, and begins heating the bed and chamber.
  • _PRINT_START_PHASE_PREHEAT - Stabilizes the bed and (if applicable) chamber at the target temperatures. Also homes the axes while heating is in progress.
  • _PRINT_START_PHASE_PROBING - Performs probing operations, including mesh bed calibration, quad gantry leveling, etc.
  • _PRINT_START_PHASE_EXTRUDER - Stabilizes the extruder at the target temperature.
  • _PRINT_START_PHASE_PURGE - Extrudes a purge line in front of the print area.

PRINT_END

Parks the printhead, shuts down heaters, fans, etc, and performs general state housekeeping at the end of the print (called from the slicer's print end g-code).

Print Status Events

Note: This is a brand new feature that will likely evolve in the near future. Statuses will probably be added and/or removed as I get a better sense of how they're being used. Keep that in mind as you integrate this into your own setup.

The following events are fired during during the printing process, and the GCODE_ON_PRINT_STATUS command associates custom gcode with these events. This custom gcode can be used to set LEDs, emit beeps, or perform any other operations you may want to run at a given status in the printing process.

  • ready - Printer is ready to receive a job
  • filament_load - Loading filament
  • filament_unload - Unloading filament
  • bed_heating - Waiting for the bed to reach target
  • chamber_heating - Waiting for the chamber to reach target
  • homing - Homing any axis
  • leveling_gantry - Performing quad gantry-leveling
  • calibrating_z - Performing z-tilt adjustment
  • meshing - Calibrating a bed mesh
  • extruder_heating - Waiting for the extruder to reach target
  • purging - Printing purge line
  • printing - Actively printing
  • pausing - Print is paused
  • cancelling - Print is being cancelled
  • completing - Print completing (does not fire on a cancelled print)

GCODE_ON_PRINT_STATUS

Associates a gcode command with a specific status and sets the parameters for when and how the status event fires.

  • STATUS - A comma seperated list of status events this command is associated with. Passing the value all will associate the gcode with all statuses.
  • COMMAND - The text of the command.
  • ARGS (default: 0) - Set to 1 to enable passing the following status arguments to the macro: TYPE, WHEN, LAST_STATUS, and NEXT_STATUS. This is useful if calling a custom macro that determines its behavior based on the exact details of the state transition.
  • FILTER_ENTER - An optional list of statuses that, if provided, will prevent the command from firing unless the last status matches a status in the list.
  • FILTER_LEAVE - An optional list of statuses that, if provided, will prevent the command from firing unless the next status matches a status in the list.
  • TYPE (default: ENTER) - If set to ENTER the command is run when entering the specified status. If set to LEAVE the command is run when leaving the specified status. If set to BOTH the command is run when entering and leaving. The LEAVE commands are processed first, followed by the ENTER commands, all in the order they were originally set.
  • WHEN (default: PRINTING) - Set to PRINTING to fire the status event only when printing, IDLE when not printing, and ALWAYS for both.

Print Status Event Example

Below is a simple example of how to set up a status event config. The calls to GCODE_ON_PRINT_STATUS are placed in the gcode of the [gcode_macro _km_options] config section, so that they will be run once at printer start. When the printer enters the ready state at startup the command will echo TYPE=LEAVE WHEN=IDLE LAST_STATUS=none NEXT_STATUS=ready to the console, and when it leaves the ready state to begin printing it will echo TYPE=ENTER WHEN=PRINTING LAST_STATUS=ready NEXT_STATUS=homing.

[gcode_macro _km_options]
# Any options variables declared here
gcode:
  GCODE_ON_PRINT_STATUS STATUS=ready COMMAND="STATUS_TEST" ARGS=1 WHEN=ALWAYS TYPE=BOTH

[gcode_macro status_test]
variable_extruder: 0
gcode:
  M118 STATUS_TEST {rawparams}

Velocity

These are some basic wrappers for Klipper's analogs to some of Marlin's velocity related commands, such as accelleration, jerk, and linear advance.

Marlin Compatibility

  • The M201, M203, M204, and M205 commands are implemented by calling Klipper's SET_VELOCITY_LIMIT command.
  • The M900 command is implemented by calling Klipper's SET_PRESSURE_ADVANCE command. The K factor is scaled by variable_pressure_advance_scale (default: -1.0). If the scaling value is negative the M900 command has no effect.

Optional Configs

Bed Mesh

BED_MESH_CALIBRATE and G29

Overrides the default BED_MESH_CALIBRATE to use BED_MESH_CALIBRATE_FAST instead, and adds the G29 command.

Configuration:

[include klipper-macros/optional/bed_mesh.cfg]

Requirements: A properly configured bed_mesh section.

LCD Menus

Adds relevant menu items to an LCD display and improves some existing functionality. See the customization section above for more information on how to configure specific behaviors.

  • Confirmation added for cancelling the print or disabling steppers during a print.
  • Several temperature menu changes:
    • Up to 10 filaments and their corresponding temperatures can be set via variable_menu_temperature.
    • Per filament chamber temperature controls are available if a [heater_generic chamber] section is configured.
    • The cooldown commands are moved to the top level temperature menu.
  • The filament loading commands are replaced with macros that use the lengths and speeds specified in variable_load_length and variable_load_speed, which includes a priming phase at the end of the load (controlled via variable_load_priming_length and variable_load_priming_speed).
  • Bed surface management is integrated into the setup and tuning menus.
  • The SD card menu has been streamlined for printing and non-printing modes.
  • The setup menu includes host shutdown, host restart, speed, and flow controls.
  • You can hide the Octoprint or SD card menus if you don't use them (via variable_menu_show_octoprint and variable_menu_show_sdcard, respectively).

Configuration:

[include klipper-macros/optional/lcd_menus.cfg]

Requirements: A properly configured display section.

klipper-macros's People

Contributors

dtk1985 avatar jschuh avatar kirill578 avatar kll avatar krtac avatar olivierberthomme avatar turnero avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

klipper-macros's Issues

Z offset Issue

Hi,

I'm receiving "Error evaluating 'gcode_macro set_gcode_offset:gcode': jinja2.exceptions.UndefinedError: 'dict object' has no attribute 'bed_surfaces' " when I tried to click to the z offset buttons on dashboard.

204156617-aaa85874-a2bd-4f2c-bc0f-8e06c478fd6b

Could you please help?

Printer: Ender 3 v2
Mainboard: SKR Mini E3 V3

Best Regards.

[PRINT_START] extruder gets to final temperature and start oozing before leveling the bed

I think it would be better to bring the extruder to printing temp after having the bed leveled, since in the current state it would start oozing for a while if the mesh to probe is big.

I suggest going from

[gcode_macro print_start]
gcode:
...
    {% if km.start_level_bed_at_temp %}
        M104 S{EXTRUDER} # set the final extruder target temperature
        G28 Z # Re-home only the Z axis now that the bed has stabilized.
        BED_MESH_CALIBRATE{% if MESH_MIN %} MESH_MIN={MESH_MIN}{% endif
                        %}{% if MESH_MAX %} MESH_MAX={MESH_MAX}{% endif %}
        PARK
    {% endif %}

to

[gcode_macro print_start]
gcode:
...
    {% if km.start_level_bed_at_temp %}
        G28 Z # Re-home only the Z axis now that the bed has stabilized.
        BED_MESH_CALIBRATE{% if MESH_MIN %} MESH_MIN={MESH_MIN}{% endif
                        %}{% if MESH_MAX %} MESH_MAX={MESH_MAX}{% endif %}
        M104 S{EXTRUDER} # set the final extruder target temperature
        PARK
    {% endif %}

Problem with variable_bed_surfaces

I recently add a klicky probe now every time I enable the variable_bed_surfaces. I'm getting this error: Error evaluating 'gcode_macro set_surface_active:gcode': TypeError: a float is required

[Variables]
bed_surfaces = {'active': u'smooth', 'available': {u'smooth': {'offset': '0'}, u'texture': {'offset': 0.0}}}

Add support for heater-less chambers

I finally had the time to install a chamber thermistor on my printer, without a dedicated heater. My printing process now is as follows:

  • preheat bed to 100C
  • preheat nozzle to 169C
  • start my nevermore air filter to circulate air around
  • manually check the printer after a while and wait until my chamber temp reaches X degrees

Now, the preheating and nevermore spinup is all done through a temperature preset, so it's not really an issue for now, but what could be improved in the print start macros is add support for heater-less chambers, where the user only uses the bed for heating them.

To me this would require:

  • a preheat temp for nozzle and bed, which will be different form actual printing temps (for example I chose 169 for the extruder since it doesn't start melting filament and the hotend fan still moves heat around)
  • spin up chosen auxiliary fans (one nevermore filter in my case but I also heard people spinning up par cooling fans or two nevermores for more air circulation)
  • wait for the chamber thermistor to reach the desired chamber temperature, using a simple TEMPERATURE_WAIT command and then start printing

As I see it nozzle and bed temps for heatup should be global vars, where chamber temp is passed as usual in the PRINT_START command. Chamber commands won't work since you don't have a proper chamber element in your printer.cfg, so it needs to be its own.

Let me know if it sounds feasible, happy to help if needed

Support/Feature Request: M600 with Telegram bot message

Hi,

I am trying to add a message to the Telegram Bot when a Filament Change is triggered. Basically I would need something like this to work:

# Overwrite the M600 in jshuh klipper-macros to add telegram message to Filament Change
[gcode_macro m600]
rename_existing: M600.284564
gcode:
  RESPOND PREFIX=tgalarm MSG=Print paused for Filament change!
  M600.284564

I added this after the import of the klipper-macros in my printer.cfg. But I throws an error because M600 is not defined. Sadly I could not find my answers in the klipper manual.

Is there any way to extend the M600 macro (or all macros) to send messages via respond to telegram bot? Any directions are highly appreciated. If not it would be great to have some configuration option to send messages on some g-codes for user interaction.

Best Klaas

[BUG]Grinding with direct drive extruders on pause and finish

I have three printers using these macros. I started with an ender 3 pro with an skr mini e3 v3 board, and I have no issues with that printer. I then installed them on a sovol sv03 (with same skr mainboard) and just today on an ender 3 v2 with a creality 4.2.7 board. The sovol comes stock with a direct drive, but on my ender 3 v2 I have a micro swiss ng installed. Both these printers are having the same issue where when I pause/cancel a print, where the printer will grind when parking the head. Same when a print finishes, but it only does it once. The ender 3 pro which has a bowden set up does not have this issue. Here's a video of what happens when a print is paused and canceled:
https://www.youtube.com/shorts/m60P4iKn_JA

any help would be appreciated.
ender3v2 config:
printer.cfg.zip
sovol sv03 config:
printer (1).cfg.zip
ender 3 pro config (no issue with this printer):
printer (2).cfg.zip

[BUG] Unable to start print due to "bed_surfaces" error

Describe the bug
Please provide a clear and concise description of what the bug is.
When starting a print, I get the below error after bed_mesh is completed.
Printer is Ender 3 Pro w/ Duet 2 Wifi. Prints start w/o issue if klipper-macros is not loaded.

Klipper error messages
Paste any error Klipper error messages you observed when encountering the bug.
Error evaluating 'gcode_macro _apply_bed_surface_offset:gcode': jinja2.exceptions.UndefinedError: 'dict object' has no attribute 'bed_surfaces'

Klipper config
Paste any relevant sections from your Klipper config, or attach the full config if you prefer. Please also note any other macros you are including as part of your config.

printer.cfg has basics for functions.

[gcode_macro _km_options]
# These are examples of some likely customizations:
# Any sheets in the below list will be available with a configurable offset.
variable_bed_surfaces: ['smooth_1','texture_1']
# Length (in mm) of filament to load (bowden tubes will be longer).
variable_load_length: 250.0
# Hide the Octoprint LCD menu since I don't use it.
#variable_menu_show_octoprint: False
# Customize the filament menus (up to 10 entries).
#variable_menu_temperature: [
#  {'name' : 'PLA',  'extruder' : 200.0, 'bed' : 60.0},
#  {'name' : 'PETG', 'extruder' : 230.0, 'bed' : 85.0},
#  {'name' : 'ABS',  'extruder' : 245.0, 'bed' : 110.0, 'chamber' : 60}]
# Length of filament (in millimeters) to purge at print start.
variable_start_purge_length: 30 # This value works for most setups.
gcode: # This line is required by Klipper.
# Any code you put here will run at klipper startup, after the initialization
# for these macros. For example, you could uncomment the following line to
# automatically adjust your bed surface offsets to account for any changes made
# to your Z endstop or probe offset.
#  ADJUST_SURFACE_OFFSETS

# This line includes all the standard macros.
[include klipper-macros/*.cfg]
# Uncomment to include features that require specific hardware support.
# LCD menu support for features like bed surface selection and pause next layer.
#[include klipper-macros/optional/lcd_menus.cfg]
# Optimized bed leveling
[include klipper-macros/optional/bed_mesh.cfg]

# The sections below here are required for the macros to work.
[idle_timeout]
gcode:
  _KM_IDLE_TIMEOUT

M300

I tried to install the scripts on an Ender 6 with a Hemera XS modificatation. The base setup is from 3dprintingforbeginners. I get the following error, after starting the firmware:

gcode command M300 already registered

Once the underlying issue is corrected, use the "RESTART"
command to reload the config and restart the host software.
Printer is halted

I cannot find any M300 command defined, beside in the beep.cfg

Setup was done by git cloning in the path ~/printer_data/config/klipper-macros.

As I am a newbie to 3d printing and klipper, I am lost where to search in my configurations. Can you help and provide some directions?

My printer.cfg:

# This file contains pin mappings for the stock 2020 Creality Ender 6.
# To use this config, during "make menuconfig" select the
# STM32F103 with a "28KiB bootloader" and with "Use USB for
# communication" disabled.

# Because this printer has factory wiring, mounts, and firmware for
# a BLTouch, but does not ship with one at this time, default values
# for the sensor have been specified, but disabled, in anticipation of
# future revisions or user modification. User should take care to
# customize the offsets, particularly z-offset, for their specific unit.

# If you prefer a direct serial connection, in "make menuconfig"
# select "Enable extra low-level configuration options" and select the
# USART3 serial port, which is broken out on the 10 pin IDC cable used
# for the LCD module as follows:
# 3: Tx, 4: Rx, 9: GND, 10: VCC

# Flash this firmware by copying "out/klipper.bin" to a SD card and
# turning on the printer with the card inserted. The firmware
# filename must end in ".bin" and must not match the last filename
# that was flashed.

# See docs/Config_Reference.md for a description of parameters.

################
# Klipper macros personal config
##
# All customizations are documented in globals.cfg. Just copy a variable from
# there into the section below, and change the value to meet your needs.

[gcode_macro _km_options]
# These are examples of some likely customizations:
# Any sheets in the below list will be available with a configurable offset.
#variable_bed_surfaces: ['smooth_1','texture_1']
# Length (in mm) of filament to load (bowden tubes will be longer).
variable_load_length: 5.0
# Hide the Octoprint LCD menu since I don't use it.
#variable_menu_show_octoprint: False
# Customize the filament menus (up to 10 entries).
variable_menu_temperature: [
  {'name' : 'PLA',  'extruder' : 200.0, 'bed' : 60.0},
  {'name' : 'PETG', 'extruder' : 230.0, 'bed' : 85.0}]
gcode: # This line is required by Klipper.
# Any code you put here will run at klipper startup, after the initialization
# for these macros. For example, you could uncomment the following line to
# automatically adjust your bed surface offsets to account for any changes made
# to your Z endstop or probe offset.
#  ADJUST_SURFACE_OFFSETS

# This line includes all the standard macros.
[include klipper-macros/*.cfg]
# Uncomment to include features that require specific hardware support.
# LCD menu support for features like bed surface selection and pause next layer.
[include klipper-macros/optional/lcd_menus.cfg]
# Optimized bed leveling
#[include klipper-macros/optional/bed_mesh.cfg]

# The sections below here are required for the macros to work.
[idle_timeout]
gcode:
  _KM_IDLE_TIMEOUT

[pause_resume]

[respond]

[save_variables]
filename: ~/printer_data/config/variables.cfg # UPDATE THIS FOR YOUR PATH!!!

[virtual_sdcard]
path: ~/gcode_files

[display_status]

# Uncomment the sections below if Fluidd complains (because it's confused).
#
#[gcode_macro CANCEL_PRINT]
#rename_existing: CANCEL_PRINT_BASE
#gcode: CANCEL_PRINT_BASE{% for k in params %}{' '~k~'='~params[k]}{% endfor %}
################
### End klipper-macros personal config
################



# Some additionals temperatures to show in graph
[temperature_sensor raspberry_pi]
sensor_type: temperature_host
min_temp: 10
max_temp: 100

[temperature_sensor mcu_temp]
sensor_type: temperature_mcu
min_temp: 0
max_temp: 100

### manual bed leveling (Klipper config with new Hemera XS screw positions
[bed_screws]
screw1: 46, 39
screw2: 233, 39
screw3: 46, 228
screw4: 233, 228

#####
#####
# the original printer file config

[stepper_x]
step_pin: PB8
dir_pin: PB7
enable_pin: !PC3
microsteps: 16
rotation_distance: 40
endstop_pin: ^PA5
position_endstop: 257
position_max: 257
homing_speed: 50

[stepper_y]
step_pin: PC2
dir_pin: !PB9
enable_pin: !PC3
microsteps: 16
rotation_distance: 40
endstop_pin: ^PA6
position_endstop: 250
position_max: 250
homing_speed: 50

[stepper_z]
step_pin: PB6
dir_pin: PB5
enable_pin: !PC3
microsteps: 16
rotation_distance: 8
position_endstop: 0.0                     # disable to use BLTouch
endstop_pin: ^PA7                         # disable to use BLTouch
# endstop_pin: probe:z_virtual_endstop    # enable to use BLTouch
# position_min: -5                        # enable to use BLTouch
position_max: 400
position_min: -2

# [safe_z_home]                           # enable for BLTouch
# home_xy_position: 150.7, 137
# speed: 100
# z_hop: 10
# z_hop_speed: 5

# [bltouch]                               # enable for BLTouch
# sensor_pin: ^PB1
# control_pin: PB0
# x_offset: 20.7
# y_offset: 7
# z_offset: 2.4
# speed: 3.0

# [bed_mesh]                              # enable for BLTouch
# speed: 100
# mesh_min: 10, 10
# mesh_max: 250, 250
# algorithm: bicubic
# probe_count: 5,5

[extruder]
max_extrude_only_distance: 500.0
step_pin: PB4
dir_pin: !PB3
enable_pin: !PC3
microsteps: 16
rotation_distance: 7.6
nozzle_diameter: 0.400
filament_diameter: 1.750
pressure_advance: 0.05 # (always in the range of 0.05) from comment https://www.reddit.com/r/klippers/comments/gsrotv/anyone_using_pressure_advance_with_direct_drive/
heater_pin: PA1
sensor_type: ATC Semitec 104GT-2
sensor_pin: PC5
#control: pid
#pid_Kp: 26.949
#pid_Ki: 1.497
#pid_Kd: 121.269
min_extrude_temp: 170
min_temp: 0
max_temp: 300

[heater_bed]
heater_pin: PA2
sensor_type: EPCOS 100K B57560G104F
sensor_pin: PC4
#control: pid
#pid_Kp: 327.11
#pid_Ki: 19.20
#pid_Kd: 1393.45
min_temp: 0
max_temp: 100

[fan]
pin: PA0

[filament_switch_sensor e0_sensor]
switch_pin: PA4

[mcu]
serial: /dev/serial/by-id/usb-1a86_USB_Serial-if00-port0
restart_method: command

[printer]
kinematics: corexy
max_velocity: 500
max_accel: 2000
max_z_velocity: 10
max_z_accel: 100

[t5uid1]
firmware: dgus_reloaded
machine_name: Ender 6
# volume: 0
brightness: 100
z_min: 0
z_max: 400

[virtual_sdcard]
path: ~/printer_data/gcodes

[display_status]

[gcode_macro POWEROFF]
gcode:
  RESPOND TYPE=command MSG=action:poweroff
  
[gcode_macro CANCEL_PRINT]
rename_existing: BASE_CANCEL_PRINT
gcode:
    TURN_OFF_HEATERS
    CLEAR_PAUSE
    SDCARD_RESET_FILE
    BASE_CANCEL_PRINT

#*# <---------------------- SAVE_CONFIG ---------------------->
#*# DO NOT EDIT THIS BLOCK OR BELOW. The contents are auto-generated.
#*#
#*# [extruder]
#*# control = pid
#*# pid_kp = 30.765
#*# pid_ki = 2.972
#*# pid_kd = 79.604
#*#
#*# [heater_bed]
#*# control = pid
#*# pid_kp = 61.787
#*# pid_ki = 0.851
#*# pid_kd = 1121.439

[FEATURE REQUEST] Z_TILT_ADJUST before BED_MESH_CALIBRATE_FAST.

I have issues w/ z_tilt on one of my printers. I have added Z_TILT_ADJUST just before the BED_MESH_CALIBRATE_FAST line. But update manager is saying it's dirty due to this change. Is there a way to have a variable that would allow this to be enabled ?

Macro for loading and unloading of filament is not working

2:41 PM - Error evaluating 'gcode_macro _load_unload:gcode': TypeError: '<' not supported between instances of 'str' and 'int'
2:41 PM - load_filament LENGTH=150 SPEED=1500 EXTRUDER=extruder MINIMUM=250

I guess there is a problem with type conversion.

M300 macro fails if no `scale` parameter is defined in the `[output_pin beeper]` printer section

I have a printer with a beeper available, and I can trigger it from my mainsail interface just fine. When calling the M300 command it fails, with the error

Error evaluating 'gcode_macro m300:gcode': UndefinedError: 'dict object' has no attribute 'scale'

The macro seems to be looking for a scale parameter in the beeper printer section, and if it's not defined the macro crashes. I would either update the README by mentioning that a scale paramter must be set or provide a default value for the parameter in the macro

Bed mesh process produces points that cannot be reached (move out of range)

Haven't had issues with mesh bed leveling until today, and it looks like that for large enough prints the mesh leveling doesn't work properly.I have a 300x300 bed and while trying to print a piece covering almost all width of it I got errors when the macro generated the probing points:

PRINT_START command:

PRINT_START  EXTRUDER=215 BED=60 MESH_MIN=7.99438,99.422 MESH_MAX=292.006,200.578 LAYERS=495

generated points as taken from the console:

Move out of range: -40.006 83.422 8.000 [0.000]
Move out of range: -40.006 83.422 8.000 [0.000]

35 | (-40.0, 184.6) | (8.0, 200.6)
34 | (16.8, 184.6) | (64.8, 200.6)
33 | (73.6, 184.6) | (121.6, 200.6)
32 | (130.4, 184.6) | (178.4, 200.6)
31 | (187.2, 184.6) | (235.2, 200.6)
30 | (244.0, 184.6) | (292.0, 200.6)
29 | (244.0, 164.3) | (292.0, 180.3)
28 | (187.2, 164.3) | (235.2, 180.3)
27 | (130.4, 164.3) | (178.4, 180.3)
26 | (73.6, 164.3) | (121.6, 180.3)
25 | (16.8, 164.3) | (64.8, 180.3)
24 | (-40.0, 164.3) | (8.0, 180.3)
23 | (-40.0, 144.1) | (8.0, 160.1)
22 | (16.8, 144.1) | (64.8, 160.1)
21 | (73.6, 144.1) | (121.6, 160.1)
20 | (130.4, 144.1) | (178.4, 160.1)
19 | (187.2, 144.1) | (235.2, 160.1)
18 | (244.0, 144.1) | (292.0, 160.1)
17 | (244.0, 123.9) | (292.0, 139.9)
16 | (187.2, 123.9) | (235.2, 139.9)
15 | (130.4, 123.9) | (178.4, 139.9)
14 | (73.6, 123.9) | (121.6, 139.9)
13 | (16.8, 123.9) | (64.8, 139.9)
12 | (-40.0, 123.9) | (8.0, 139.9)
11 | (-40.0, 103.7) | (8.0, 119.7)
10 | (16.8, 103.7) | (64.8, 119.7)
9 | (73.6, 103.7) | (121.6, 119.7)
8 | (130.4, 103.7) | (178.4, 119.7)
7 | (187.2, 103.7) | (235.2, 119.7)
6 | (244.0, 103.7) | (292.0, 119.7)
5 | (244.0, 83.4) | (292.0, 99.4)
4 | (187.2, 83.4) | (235.2, 99.4)
3 | (130.4, 83.4) | (178.4, 99.4)
2 | (73.6, 83.4) | (121.6, 99.4)
1 | (16.8, 83.4) | (64.8, 99.4)
0 | (-40.0, 83.4) | (8.0, 99.4)

bed_mesh: generated points
Index | Tool Adjusted | Probe

This error never occurred with smaller prints, so I think it's just an edge case that needs to be figured out.
I tried to set variable_probe_mesh_padding to 0.0 to try and mitigate the issue without luck

Lemme know if you need other info

Load existing bed mesh instead of probing

Apart from overriding PRINT_START, is there a way to load an existing bed mesh instead of probing the bed before each print? Especially with shorter prints, this greatly reduces the overall time

Nozzle temperature doesn't return to original value after cooling down waiting for filament replacement

Happened to me tonight: my printer stopped as the filament ran out mid print, and I only noticed it this morning. The printer sat idle long enough to enter cooldown, so the bed stayed at temperature while the nozzle stopped heating. I loaded the filament using the provided macro and resumed the print, and I noticed that the nozzle temp stayed at the filament loading temperature, and not the printing temperature.
Happy to provide more details if needed

note about relative_reference_index

no issue, just a note for the warning section:

let's say you use 5x5 mesh and enable relative_reference_index in the [bed_mesh] section of printer.cfg and set it to 12 so it references the middle of the bed (##FOLLOW THE FORUMULA FOR relative_reference_index, for example: [(5x5)-1] / 2 = 12), when you want to print something it starts the heatup process, printhead goes to the safe_z_home position and after probing the point klipper throws 3 internal errors for the macros and shuts down. I guess because I was trying to print a small object and your macro switched to 3x3 mesh mode, but still wanted to use the "relative_reference_index: 12" (12th point - non-existent in this case) and the macros could not handle that. I could not figure out for a day what is happening, reinstalled the whole OS lol

Error when triggering a M600 command

I'm getting this error when my filament runout sensor triggers a M600

Error evaluating 'gcode_macro _load_unload:gcode': CommandError: Command not valid during printing.

What could be the problem?

BUG: Malformed commmand _gcode_wait_wrapper

Issueing a M109 T1 S205 or M104 T1 S205 (etc)

fails with error
Malformed command '_GCODE_WAIT_WRAPPER HEATER={'pressure_advance': 0.0, 'target': 0.0, 'power': 0.0, 'can_extrude': True, 'smooth_time': 0.04, 'temperature': 16.18} S="20" M="109" T="1"'

Will disable heaters.cfg by renaming it to heaters.cfg.backup to bypass this section.

max_accel values get reset

I'm new to all this and not sure what I'm doing, so sorry if I'm asking in the wrong place. long story short, tried to set up input shaping using an adxl345, but after I set up the new max values in the printer.cfg, when I start a new print using your macros the console shows:
max_velocity: 500.000000
max_accel: 500.000000
max_accel_to_decel: 250.000000
square_corner_velocity: 8.000000

I have no idea what I'm doing so I don't know why the values I put in the printer.cfg get overridden (if I type m201 in the console after a restart before a print, it gives me the values in the printer.cfg). Using prusaslicer and the printer limits reflect what I have in the printer.cfg. Any help would be appreciated. Thanks.

edit:
after tinkering around a bit, I noticed I left a value in prusaslicer in the print settings (acceleration control>default). However, now I get this:

max_velocity: 500.000000
max_accel: 2500.000000
max_accel_to_decel: 1250.000000
square_corner_velocity: 8.000000

so something is still changing square_corner and halving max accel to decel.

Upcoming klipper changes for bed mesh

Just a heads up for the upcoming changes in klipper regarding bed mesh, here is the message as displayed on mainsail:

Klipper changes to [bed_mesh] module
In an upcoming change to Klipper, the default bed_mesh configuration will no longer be automatically loaded at startup. If you are using a bed_mesh configuration today then it is recommended to add an explicit BED_MESH_PROFILE LOAD=default command to your START_PRINT macro (or equivalent print start commands in your slicer). This change to Klipper is planned for February 1st 2023.

link to the klipper announcement

Not sure if it also applies to adaptive bed mesh, but better safe than sorry!

Custom Start_Print

Trying to adopt this new setup and I'm unsure how to incorporate my normal start print macro. I run a Z_TILT_ADJUST and CALIBRATE_Z job before each print. I don't see where it'd make sense to drop this in. I'm also using a Euclid Probe, so I need to include M401 to pick up the probe and M402 to stow it.

[gcode_macro G32]
gcode: 
	G28
	QUERY_PROBE
	M401
	Z_TILT_ADJUST
	CALIBRATE_Z

[gcode_macro PRINT_START]
gcode: 

	{% set BED_TEMP = params.BED|default(60)|float %}
	{% set EXTRUDER_TEMP = params.EXTRUDER|default(245)|float %}
	{% set CHAMBER_TEMP = params.CHAMBER|default(21)|float %}
        {% set PREHEAT = (EXTRUDER_TEMP * 0.6)|default(120)|float %}
  	M104 S{PREHEAT} 
	M190 S{BED_TEMP}    
  	G32 
        G90         
	M220 S100     
	M221 S100  
  	M190 S{BED_TEMP}  
        M109 S{EXTRUDER_TEMP}  
        G92 E0      
	QUERY_PROBE
	M402

LCD menu Offset tune

Looks like when you fix the G-Code offset for the klicky probe breaks something in the LCD Menu. Every time I want to adjust the offset from the LCD the offset reset by -5 in my case. Thanks

Bed heating wait duration

Hello,

This is not an issue with your macros. Everything's been working great. I'm trying to turn off the delay between the bed reaching temperature and the print starting.

I tried setting variable_start_bed_heat_delay: 0 but it still waits for an amount of time after the bed has reached temp to start the print.

How can I turn this feature off for some prints?

Thanks!

[BUG] Is there a way to cancel PRINT_START?

Describe the bug
I find myself having to use the emergency stop (M112?) to stop the PRINT_START macro. On my printer, it takes a while to warm up and complete the bed mesh (10-20 minutes), meanwhile I find a reason to stop it but the only way I can is to use the E-Stop. I then have to restart the firmware.

Hitting cancel print does not work until the macro finished.

Is there another way to stop the PRINT_START Macro?

Print_Start has no attribute 'EXTRUDER_TEMP

removed all macros from my config, (also removed Mainsail.CFG)
using superslicer and set as recommended
receiving the below error:

Error evaluating 'gcode_macro print_start:gcode': jinja2.exceptions.UndefinedError: 'dict object' has no attribute 'EXTRUDER_TEMP'

cant find anything in my config that is called Print_Start, i do see a file called start_endcfg in the macros area but did not modify in any way.

[BUG] ADJUST_SURFACE_OFFSETS IGNORE malformed command

Describe the bug
Please provide a clear and concise description of what the bug is.
When attempting to run ADJUST_SURFACE_OFFSETS IGNORE I get a malformed command error.

Klipper error messages
Paste any error Klipper error messages you observed when encountering the bug.

10:05 AM
Malformed command 'ADJUST_SURFACE_OFFSETS ignore'
10:05 AM
ADJUST_SURFACE_OFFSETS ignore
10:03 AM
Malformed command 'ADJUST_SURFACE_OFFSETS IGNORE'
10:03 AM
ADJUST_SURFACE_OFFSETS IGNORE
10:03 AM
Unknown command:"ADJUST_SURFACE_OFFSETS0"
10:03 AM
ADJUST_SURFACE_OFFSETS 0
10:03 AM
Malformed command 'ADJUST_SURFACE_OFFSETS IGNORE'
10:03 AM
ADJUST_SURFACE_OFFSETS IGNORE
10:02 AM
Active bed surface: default; offset: 0.744
10:02 AM
Z probe offset or endstop position changed. Run ADJUST_SURFACE_OFFSETS to adjust the offset for all saved surfaces by the change differential, or run ADJUST_SURFACE_OFFSETS IGNORE to hide this message without making changes.
10:01 AM
Klipper state: Disconnect
10:01 AM
SAVE_CONFIG
10:01 AM
bltouch: z_offset: 0.475
The SAVE_CONFIG command will update the printer config file
with the above and restart the printer.
10:01 AM
Z_OFFSET_APPLY_PROBE
9:25 AM
Active bed surface: default; offset: 0.744
9:25 AM
- Type HELP to get a list of available commands.
- Click on the "?" button to get a searchable list.
- Commands in the console are clickable and will be placed into the input field.
- Use the tab key to complete your inputs. If there are several options, a list is displayed.
- Use the ⇵ arrow keys to navigate through the previous entries.

Klipper config
Paste any relevant sections from your Klipper config, or attach the full config if you prefer. Please also note any other macros you are including as part of your config.
-- variables.cfg --

bed_surfaces = {'active': 'default', 'available': {'default': {'offset': 0.744}}, 'endstop_z': 0.0, 'probe_z': 1.219}

-- printer.cfg --

#[include addons/neopixel.cfg]
#[include addons/runout.cfg]

# This file contains common pin mappings for the BIGTREETECH Manta E3EZ
# To use this config, the firmware should be compiled for the
# STM32G0B1 with a "8KiB bootloader" "8 MHz crystal"
# and "USB (on PA11/PA12)" or "CAN bus (on PB12/PB13)".

# See docs/Config_Reference.md for a description of parameters.

[temperature_sensor raspberry_pi]
sensor_type: temperature_host
min_temp: 10
max_temp: 100

[temperature_sensor mcu_temp]
sensor_type: temperature_mcu
min_temp: 0
max_temp: 100

[force_move]
enable_force_move: True

[mcu rpi]
serial: /tmp/klipper_host_mcu

# All customizations are documented in globals.cfg. Just copy a variable from
# there into the section below, and change the value to meet your needs.

[gcode_macro _km_options]
# These are examples of some likely customizations:
# Any sheets in the below list will be available with a configurable offset.
#variable_bed_surfaces: ['smooth_1','texture_1']
# Length (in mm) of filament to load (bowden tubes will be longer).
variable_load_length: 250.0
# Minimum printable XY coordinate. Defaults to X and Y position_min.
variable_print_min: (0, 0) # example: (0, 0)
# Maximum printable XY coordinate. Defaults to X and Y position_max.
variable_print_max: (220, 220) # example: (220, 220)
# Scaling factor for M900 command (negative values make M900 a no-op).
#variable_pressure_advance_scale: -1.0
# Distance (in millimeters) between the purge lines and the print area.
variable_start_purge_clearance: -15.0
# Level gantry in PRINT_START after bed temp stabilizes; False to disable.
variable_start_quad_gantry_level_at_temp: False
# Hide the Octoprint LCD menu since I don't use it.
#variable_menu_show_octoprint: False
# Customize the filament menus (up to 10 entries).
#variable_menu_temperature: [
#  {'name' : 'PLA',  'extruder' : 200.0, 'bed' : 60.0},
#  {'name' : 'PETG', 'extruder' : 230.0, 'bed' : 85.0},
#  {'name' : 'ABS',  'extruder' : 245.0, 'bed' : 110.0, 'chamber' : 60}]
# Length of filament (in millimeters) to purge at print start.
variable_start_purge_length: 30 # This value works for most setups.
gcode: # This line is required by Klipper.
# Any code you put here will run at klipper startup, after the initialization
# for these macros. For example, you could uncomment the following line to
# automatically adjust your bed surface offsets to account for any changes made
# to your Z endstop or probe offset.
#  ADJUST_SURFACE_OFFSETS

# This line includes all the standard macros.
[include klipper-macros/*.cfg]
# Uncomment to include features that require specific hardware support.
# LCD menu support for features like bed surface selection and pause next layer.
#[include klipper-macros/optional/lcd_menus.cfg]
# Optimized bed leveling
[include klipper-macros/optional/bed_mesh.cfg]

# The sections below here are required for the macros to work. If your config
# already has some of these sections you should merge the duplicates into one
# (or if they are identical just remove one of them).
[idle_timeout]
gcode:
  _KM_IDLE_TIMEOUT # This line must be in your idle_timeout section.

[pause_resume]

[respond]

[save_variables]
filename: /home/pi/printer_data/variables.cfg # UPDATE THIS FOR YOUR PATH!!!

[virtual_sdcard]
path: ~/printer_data/gcodes # UPDATE THIS FOR YOUR PATH!!!

[display_status]

# Uncomment the sections below if Fluidd complains (because it's confused).
#[gcode_macro CANCEL_PRINT]
#rename_existing: CANCEL_PRINT_FAKE_BASE
#gcode: CANCEL_PRINT_FAKE_BASE {rawparams}

[stepper_x]
step_pin: PA14
dir_pin: !PA10
enable_pin: !PA13
microsteps: 16
rotation_distance: 40
endstop_pin: ^PC4
#endstop_pin: !PC4
position_endstop: 0
#position_max: 235
position_max: 250
homing_speed: 50

[stepper_y]
step_pin: PC8
dir_pin: !PA15
enable_pin: !PC14
microsteps: 16
rotation_distance: 40
endstop_pin: ^PB0
#endstop_pin: PB0
position_endstop: 0
position_max: 235
homing_speed: 50

[stepper_z]
step_pin: PD2
dir_pin: !PD4
enable_pin: !PD3
microsteps: 16
rotation_distance: 8
#endstop_pin: ^PC6
#position_endstop: 0
position_min: -3.5
position_max: 220
endstop_pin: probe:z_virtual_endstop


[stepper_z1]
step_pin: PB7
dir_pin: PB6
enable_pin: !PB4
microsteps: 16
rotation_distance: 8

[extruder]
step_pin: PD5
dir_pin: PD6
enable_pin: !PB3
microsteps: 16
rotation_distance: 33.500
gear_ratio: 50:17
nozzle_diameter: 0.400
filament_diameter: 1.750
heater_pin: PB11 #HE0
#sensor_type: EPCOS 100K B57560G104F
sensor_type: ATC Semitec 104GT-2
sensor_pin: PA4 #TH0
#control: pid
#pid_Kp: 21.527
#pid_Ki: 1.063
#pid_Kd: 108.982
min_temp: 0
max_temp: 275
max_extrude_only_distance: 300

[heater_bed]
heater_pin: PB2 #HB
sensor_type: EPCOS 100K B57560G104F #Generic 3950
sensor_pin: PA3 #TB
#control: pid
# tuned for stock hardware with 50 degree Celsius target
#pid_Kp: 54.027
#pid_Ki: 0.770
#pid_Kd: 948.182
min_temp: 0
max_temp: 130

[fan]
pin: PA8

[heater_fan heatbreak_cooling_fan]
pin: PB15

[heater_fan board_cooling_fan]
pin: PB14
heater: extruder, heater_bed

[filament_switch_sensor E0Stop]
switch_pin: PC5
pause_on_runout: false #pause handled by macro
runout_gcode:
  M600 #calls a macro with the name M600 (so it can be called by slicers too)

[mcu]
serial: /dev/serial/by-id/usb-Klipper_stm32g0b1xx_3F00350012504B4B38383620-if00

[printer]
kinematics: cartesian
max_velocity: 300
max_accel: 3000
max_z_velocity: 5
max_z_accel: 100

########################################
# TMC2209 configuration
########################################

[tmc2209 stepper_x]
uart_pin: PB8
#diag_pin: PC4
run_current: 0.800
stealthchop_threshold: 999999

[tmc2209 stepper_y]
uart_pin: PC9
#diag_pin: PB0
run_current: 0.800
stealthchop_threshold: 999999

[tmc2209 stepper_z]
uart_pin: PD0
#diag_pin: PC6
run_current: 0.650
stealthchop_threshold: 999999

[tmc2209 stepper_z1]
uart_pin: PB5
run_current: 0.650
stealthchop_threshold: 999999

[tmc2209 extruder]
uart_pin: PD1
run_current: 0.800
stealthchop_threshold: 999999

[board_pins]
aliases:
    # EXP1 header
    EXP1_1=PC1, EXP1_3=PC3, EXP1_5=PC0, EXP1_7=PA2, EXP1_9=<GND>,
    EXP1_2=PC2,  EXP1_4=<RST>, EXP1_6=PA0, EXP1_8=PA1, EXP1_10=<5V>

[bltouch]
sensor_pin: PA6
control_pin: PA7
set_output_mode: 5V
pin_move_time: 0.675
stow_on_each_sample: False
probe_with_touch_mode: True
pin_up_touch_mode_reports_triggered: False
x_offset: -42.0
y_offset: -8.0
#z_offset: 1.000
speed: 10
lift_speed: 20
samples: 2
sample_retract_dist:5
samples_tolerance_retries: 3

[safe_z_home]
home_xy_position: 117, 117
speed: 150
z_hop: 10
z_hop_speed: 20

[bed_mesh]
algorithm: bicubic
speed: 150
horizontal_move_z: 10
mesh_min: 35,35
#mesh_max: 220,220
#mesh_min: 30,30
mesh_max: 195,195
probe_count: 7,7
fade_end: 10
mesh_pps: 2,2
fade_start: 0.6
fade_end: 10
fade_target: 0
; relative_reference_index = ()(x points * y points) - 1) / 2
relative_reference_index: 24

[z_tilt]
# Ender screw edge offsets are 35,35
# z_positions = IRL position of the stepper itself, in nozzle coords so will be off the bed at the back
# points = probe locations = nozzle + probe offset
# stepper X are 30mm off bed edge left & right
# stepper Y is 80 off the back when nozzle at Y=230 = 230+80
z_positions:
	-30, 310       ##Stepper Location Z0, as if the nozzle were in the screw
	265, 310       ##Stepper Location Z1, as if the nozzle were in the screw
points:
    73, 117
    238, 117
speed: 200
horizontal_move_z: 10
retries: 20
#retry_tolerance:0.010
retry_tolerance:0.005

#[output_pin PS_ON]
#pin: PA9

#[output_pin pb9_pin]
#pin: PB9

#[neopixel my_neopixel]
#pin: PC7

#[adxl345]
#cs_pin: PC15
#spi_software_miso_pin: PC11
#spi_software_mosi_pin: PC12
#spi_software_sclk_pin: PC10

[bed_screws]
screw1: 30.5, 37
screw1_name: front left screw
screw2: 30.5, 207
screw2_name: rear left screw
screw3: 204.5, 207
screw3_name: rear right screw
screw4: 204.5, 37
screw4_name: front right screw

[screws_tilt_adjust]
screw1: 75,205
screw1_name: rear left screw
screw2: 75,35
screw2_name: front left screw
screw3: 245,205
screw3_name: rear right screw
screw4: 245,35
screw4_name: front right screw
horizontal_move_z: 5
speed: 50
screw_thread: CW-M4

#[display]
#lcd_type: st7920
#cs_pin: EXP1_7
#sclk_pin: EXP1_6
#sid_pin: EXP1_8
#encoder_pins: ^EXP1_5, ^EXP1_3
#click_pin: ^!EXP1_2

[output_pin beeper]
pin: EXP1_1

[gcode_arcs]
resolution: 0.05

[gcode_macro DUMP_VARIABLES]
gcode:
    {% set filter_name = params.NAME|default('')|string|lower %}
    {% set filter_value = params.VALUE|default('')|string|lower %}
    {% set show_cfg = params.SHOW_CFG|default(0)|int %}
    
    {% set out = [] %}

    {% for key1 in printer %}
        {% for key2 in printer[key1] %}
            {% if (show_cfg or not (key1|lower == 'configfile' and key2|lower in ['config', 'settings'])) and (filter_name in key1|lower or filter_name in key2|lower) and filter_value in printer[key1][key2]|string|lower %}
                {% set dummy = out.append("printer['%s'].%s = %s" % (key1, key2, printer[key1][key2])) %}
            {% endif %}
        {% else %}
            {% if filter_name in key1|lower and filter_value in printer[key1]|string|lower %}
                {% set dummy = out.append("printer['%s'] = %s" % (key1, printer[key1])) %}
            {% endif %}
        {% endfor %}
    {% endfor %}
    
    {action_respond_info(out|join("\n"))}

[delayed_gcode bed_mesh_init]
initial_duration: .01
gcode:
  BED_MESH_PROFILE LOAD=default

#*# <---------------------- SAVE_CONFIG ---------------------->
#*# DO NOT EDIT THIS BLOCK OR BELOW. The contents are auto-generated.
#*#
#*# [extruder]
#*# control = pid
#*# pid_kp = 31.050
#*# pid_ki = 1.784
#*# pid_kd = 135.067
#*#
#*# [heater_bed]
#*# control = pid
#*# pid_kp = 68.251
#*# pid_ki = 1.143
#*# pid_kd = 1018.640
#*#
#*# [bltouch]
#*# z_offset = 0.475

Layers.cfg file calls a macro that doesn't exist

A macro in Layers.cfg calls SET_PRINT_STATS_INFO which throws an error on my system. Should this macro be included somewhere? It looks like it is not a command that Klipper recognizes at this time.

"No trigger on probe after full movement" and BED_MESH_CHECK does nothing

BED_MESH_CALIBRATE seems to generate points outside the set mesh_min:
0 | (87.0, 5.0) | (46.0, 21.0)

This is (a part of) my config:

[bed_mesh]
speed: 200
mesh_min: 46, 21 #X-Offset + 5, Y-Offset + 5
mesh_max: 209, 224
probe_count: 3,3
horizontal_move_z: 5
algorithm: lagrange

[bltouch]
sensor_pin: ^PB7
control_pin: PB6
x_offset: -41
y_offset: 16
speed: 5.0
pin_up_touch_mode_reports_triggered: False

Secondly, I tried to check my config with BED_MESH_CHECK. This does nothing (or at least it displays nothing in the console). Am I doing something wrong?

klipper crashed when pressing lcd button

Klipper will crash when pressing the button on my lcd. The screen is a default ender 3 screen. I am only using the lcd macro, and I can add any more info if needed

When the filament runs out, the M600 command is not executed

I would like some advice, I use your macros and
when executing the M600 command, when the filament sensor reports that the filament is running out, it reports this error...

!! Error evaluating 'gcode_macro _load_unload:gcode': CommandError: Command not valid during printing.

i use this filament sensor setup:

[filament_switch_sensor filament_sensor]
pause_on_runout: True
switch_pin: PG12
runout_gcode: M600

m109/m190 temps

For some reaon my m109 and m190 temps seem odd. Can you tell me where this info is being pulled from? For extruder is is 108 and for bed it is 62. I don't think I have thoses values set anywhere in my slicers. My goal is to higher the extruder and also I would prefer if they both preheat at the same time. As of now, it is doing the bed first. Any assistance would be great! I appreciate this plugin.

LCD setup menu error related to bed mesh

Do I need custom hardware to use your LCD menus? I'm using stock display from ender3 (12864)

Error evaluating 'menu __main __setup __bed_surface:input': ValueError: '' is not in list                                                                                                     
Traceback (most recent call last):                                                                                                                                                            
  File "/home/printer/klipper/klipper/klippy/extras/gcode_macro.py", line 61, in render                                                                                                       
    return str(self.template.render(context))                                                                                                                                                 
  File "/home/printer/klipper/venv/lib/python3.9/site-packages/jinja2/environment.py", line 1090, in render                                                                                   
    self.environment.handle_exception()                                                                                                                                                       
  File "/home/printer/klipper/venv/lib/python3.9/site-packages/jinja2/environment.py", line 832, in handle_exception                                                                          
    reraise(*rewrite_traceback_stack(source=source))                                                                                                                                          
  File "/home/printer/klipper/venv/lib/python3.9/site-packages/jinja2/_compat.py", line 28, in reraise                                                                                        
    raise value.with_traceback(tb)                                                                                                                                                            
  File "<template>", line 2, in top-level template code                                                                                                                                       
ValueError: '' is not in list
List drawing error
Traceback (most recent call last):
  File "/home/printer/klipper/klipper/klippy/extras/gcode_macro.py", line 61, in render
    return str(self.template.render(context))
  File "/home/printer/klipper/venv/lib/python3.9/site-packages/jinja2/environment.py", line 1090, in render
    self.environment.handle_exception()
  File "/home/printer/klipper/venv/lib/python3.9/site-packages/jinja2/environment.py", line 832, in handle_exception
    reraise(*rewrite_traceback_stack(source=source))
  File "/home/printer/klipper/venv/lib/python3.9/site-packages/jinja2/_compat.py", line 28, in reraise
    raise value.with_traceback(tb)
  File "<template>", line 2, in top-level template code
ValueError: '' is not in list

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/printer/klipper/klipper/klippy/extras/display/menu.py", line 625, in draw_container
    text = current.render_name(selected)
  File "/home/printer/klipper/klipper/klippy/extras/display/menu.py", line 164, in render_name
    name = str(self._render_name())
  File "/home/printer/klipper/klipper/klippy/extras/display/menu.py", line 66, in _render_name
    context = self.get_context()
  File "/home/printer/klipper/klipper/klippy/extras/display/menu.py", line 488, in get_context
    value = (self._eval_value(context) if self._input_value is None
  File "/home/printer/klipper/klipper/klippy/extras/display/menu.py", line 521, in _eval_value
    self._input_tpl.render(context)))
  File "/home/printer/klipper/klipper/klippy/extras/gcode_macro.py", line 66, in render
    raise self.gcode.error(msg)
gcode.CommandError: Error evaluating 'menu __main __setup __bed_surface:input': ValueError: '' is not in list

printer.cfg

# This file contains common pin mappings for the 2018 Creality
# Ender 3. To use this config, the firmware should be compiled for the
# AVR atmega1284p.

# Note, a number of Melzi boards are shipped with a bootloader that
# requires the following command to flash the board:
#  avrdude -p atmega1284p -c arduino -b 57600 -P /dev/ttyUSB0 -U out/klipper.elf.hex
# If the above command does not work and "make flash" does not work
# then one may need to flash a bootloader to the board - see the
# Klipper docs/Bootloaders.md file for more information.

# See docs/Config_Reference.md for a description of parameters.

[stepper_x]
step_pin: ar54
dir_pin: !ar55
enable_pin: !ar38
microsteps: 16
rotation_distance: 40
endstop_pin: ^ar3
position_min: -3
position_endstop: -3
position_max: 250
homing_speed: 50

[stepper_y]
step_pin: ar60
dir_pin: !ar61
enable_pin: !ar56
microsteps: 16
rotation_distance: 40
endstop_pin: ^ar14
position_min: -6
position_endstop: -6
position_max: 235
homing_speed: 50

[stepper_z]
step_pin: ar46
dir_pin: ar48
enable_pin: !ar62
microsteps: 16
rotation_distance: 7.96
endstop_pin: probe:z_virtual_endstop
position_max: 250
position_min: -3

[extruder]
step_pin: ar26
dir_pin: !ar28
enable_pin: !ar24
max_extrude_only_distance: 420.0
min_extrude_temp: 170
microsteps: 16
rotation_distance: 7.71
nozzle_diameter: 0.400
filament_diameter: 1.750
heater_pin: ar10
sensor_type: EPCOS 100K B57560G104F
sensor_pin: analog13
pressure_advance = 0.5
min_temp: 0
max_temp: 250

[heater_bed]
heater_pin: ar8
sensor_type: EPCOS 100K B57560G104F
sensor_pin: analog14
min_temp: 0
max_temp: 130

[tmc2208 stepper_x]
uart_pin: ar40
interpolate: True
run_current: 0.580
sense_resistor: 0.11
stealthchop_threshold: 150

[tmc2208 stepper_y]
uart_pin: ar59
interpolate: True
run_current: 0.580
sense_resistor: 0.11
stealthchop_threshold: 150

[tmc2208 stepper_z]
uart_pin: ar42
interpolate: True
run_current: 0.580
sense_resistor: 0.11
stealthchop_threshold: 150

[tmc2208 extruder]
uart_pin: ar44
interpolate: True
run_current: 0.650
sense_resistor: 0.11
stealthchop_threshold: 150

[fan]
pin: ar9

[heater_fan my_nozzle_fan]
pin: ar7
heater: extruder
heater_temp: 50.0

[mcu]
serial: /dev/serial/by-id/usb-1a86_USB2.0-Serial-if00-port0

[printer]
kinematics: cartesian
max_velocity: 300
max_accel: 3000
max_z_velocity: 5
max_z_accel: 100

[bed_screws]
screw1: 31.7, 31.7
screw2: 31.7, 201
screw3: 201, 201
screw4: 201, 31.7

[display]
lcd_type: st7920
cs_pin: ar27
sclk_pin: ar25
sid_pin: ar29
encoder_pins: ^ar23, ^ar17
click_pin: ^!ar35

[bltouch]
sensor_pin: ^ar18
control_pin: ar11
x_offset: -60.5
y_offset: -16.6
pin_move_time: 0.4
samples: 1
sample_retract_dist: 2

[safe_z_home]
home_xy_position: 177.5, 133.6
speed: 50.0
z_hop: 10.0
z_hop_speed: 10.0

[bed_mesh]
speed: 50
horizontal_move_z: 5
mesh_min: 31.7, 31.7
mesh_max: 189, 201
probe_count: 3, 3
fade_start: 1.0
mesh_pps: 2, 2

[screws_tilt_adjust]
screw1: 250, 48.3
screw1_name: front right screw
screw2: 250, 217.6
screw2_name: rear right screw
screw3: 92.2, 217.6
screw3_name: rear left screw
screw4: 92.2, 48.3
screw4_name: front left screw
horizontal_move_z: 10
speed: 50.0
screw_thread: CW-M3

[input_shaper]
#shaper_freq_x: 29.62
#shaper_freq_y: 29.41
shaper_freq_x: 37.56
shaper_freq_y: 41.09
shaper_type: mzv

[virtual_sdcard]
path: ~/klipper/gcodes

[display_status]

[pause_resume]

[gcode_macro PRINTER_OFF]
gcode:
    tuya_off

[include macros.cfg]

[output_pin beeper]
pin: EXP1_1
pwm: True
value: 0
shutdown_value: 0
cycle_time: 0.001 # PWM frequency : 0.001 = 1ms will give a tone of 1kHz (not pitch perfect).

[include timelapse.cfg]

# Common EXP1 / EXP2 (display) pins
[board_pins]
aliases:
    # Common EXP1 header found on many "all-in-one" ramps clones
    EXP1_1=ar37, EXP1_3=ar17, EXP1_5=ar23, EXP1_7=ar27, EXP1_9=<GND>,
    EXP1_2=ar35, EXP1_4=ar16, EXP1_6=ar25, EXP1_8=ar29, EXP1_10=<5V>,
    # EXP2 header
    EXP2_1=ar50, EXP2_3=ar31, EXP2_5=ar33, EXP2_7=ar49, EXP2_9=<GND>,
    EXP2_2=ar52, EXP2_4=ar53, EXP2_6=ar51, EXP2_8=ar41, EXP2_10=<RST>,
    # Pins EXP2_1, EXP2_6, EXP2_2 are also MISO, MOSI, SCK of bus "spi"
    # Note, some boards wire: EXP2_8=<RST>, EXP2_10=ar41
    # Marlin pin map
    ar0=PE0, ar1=PE1, ar2=PE4, ar3=PE5, ar4=PG5,
    ar5=PE3, ar6=PH3, ar7=PH4, ar8=PH5, ar9=PH6,
    ar10=PB4, ar11=PB5, ar12=PB6, ar13=PB7, ar14=PJ1,
    ar15=PJ0, ar16=PH1, ar17=PH0, ar18=PD3, ar19=PD2,
    ar20=PD1, ar21=PD0, ar22=PA0, ar23=PA1, ar24=PA2,
    ar25=PA3, ar26=PA4, ar27=PA5, ar28=PA6, ar29=PA7,
    ar30=PC7, ar31=PC6, ar32=PC5, ar33=PC4, ar34=PC3,
    ar35=PC2, ar36=PC1, ar37=PC0, ar38=PD7, ar39=PG2,
    ar40=PG1, ar41=PG0, ar42=PL7, ar43=PL6, ar44=PL5,
    ar45=PL4, ar46=PL3, ar47=PL2, ar48=PL1, ar49=PL0,
    ar50=PB3, ar51=PB2, ar52=PB1, ar53=PB0, ar54=PF0,
    ar55=PF1, ar56=PF2, ar57=PF3, ar58=PF4, ar59=PF5,
    ar60=PF6, ar61=PF7, ar62=PK0, ar63=PK1, ar64=PK2,
    ar65=PK3, ar66=PK4, ar67=PK5, ar68=PK6, ar69=PK7,
    analog0=PF0, analog1=PF1, analog2=PF2, analog3=PF3, analog4=PF4,
    analog5=PF5, analog6=PF6, analog7=PF7, analog8=PK0, analog9=PK1,
    analog10=PK2, analog11=PK3, analog12=PK4, analog13=PK5, analog14=PK6,
    analog15=PK7,
    # Additional aliases
    ml70=PG4, ml71=PG3, ml72=PJ2, ml73=PJ3, ml74=PJ7,
    ml75=PJ4, ml76=PJ5, ml77=PJ6, ml78=PE2, ml79=PE6,
    ml80=PE7, ml81=PD4, ml82=PD5, ml83=PD6, ml84=PH2,
    ml85=PH7

#*# <---------------------- SAVE_CONFIG ---------------------->
#*# DO NOT EDIT THIS BLOCK OR BELOW. The contents are auto-generated.
#*#
#*# [bed_mesh default]
#*# version = 1
#*# points =
#*# 	  0.097500, 0.077500, 0.082500
#*# 	  0.055000, -0.005000, -0.045000
#*# 	  0.037500, 0.002500, 0.020000
#*# x_count = 3
#*# y_count = 3
#*# mesh_x_pps = 2
#*# mesh_y_pps = 2
#*# algo = lagrange
#*# tension = 0.2
#*# min_x = 30.0
#*# max_x = 173.0
#*# min_y = 30.0
#*# max_y = 205.0
#*#
#*# [bltouch]
#*# z_offset = 1.301
#*#
#*# [extruder]
#*# control = pid
#*# pid_kp = 26.134
#*# pid_ki = 1.405
#*# pid_kd = 121.525
#*#
#*# [heater_bed]
#*# control = pid
#*# pid_kp = 61.15
#*# pid_ki = 10.39
#*# pid_kd = 247.78

macros.cfg

[gcode_macro _km_options]
variable_load_length: 420.0
variable_load_speed: 480.0
variable_menu_show_octoprint: False
variable_menu_show_sdcard: False
variable_menu_temperature: [
  {'name' : 'PLA',  'extruder' : 190.0, 'bed' : 40.0},
  {'name' : 'TPU', 'extruder' : 200.0, 'bed' : 40.0},
  {'name' : 'PETG',  'extruder' : 230.0, 'bed' : 65.0}]
variable_start_purge_length: 20
gcode: # This line is required by Klipper.
# Any code you put here will run at klipper startup, after the initialization
# for these macros. For example, you could uncomment the following line to
# automatically adjust your bed surface offsets to account for any changes made
# to your Z endstop or probe offset.
#  ADJUST_SURFACE_OFFSETS

# This line includes all the standard macros.
[include macros/*.cfg]
# Uncomment to include features that require specific hardware support.
# LCD menu support for features like bed surface selection and pause next layer.
[include macros/optional/lcd_menus.cfg]
# Optimized bed leveling
[include macros/optional/bed_mesh.cfg]

# The sections below here are required for the macros to work. If your config
# already has some of these sections you should merge the duplicates into one
# (or if they are identical just remove one of them).
[idle_timeout]
gcode:
  _KM_IDLE_TIMEOUT # This line must be in your idle_timeout section.

[respond]

[save_variables]
filename: ~/klipper/config/variables.cfg # UPDATE THIS FOR YOUR PATH!!!

# Uncomment the sections below if Fluidd complains (because it's confused).
#[gcode_macro CANCEL_PRINT]
#rename_existing: CANCEL_PRINT_FAKE_BASE
#gcode: CANCEL_PRINT_FAKE_BASE {rawparams}

Move out of range

I am getting a move out of range error every time I start a print. It is attempting to move it to X 245 and my max is set to X 235. Where can I resolve this? I have looked all over and tried to get help elsewhere (discord server) but no one is able to decipher the macros. I believe it has something to do with the draw purge line process, because it happens immediately after the print area mesh probe.

Cannot override variable_print_max

I recently added a dockable probe and set variable_print_max.

[gcode_macro _km_options]
variable_print_max: (120, 115)

I'm getting this error: Error evaluating 'gcode_macro _km_globals:gcode': CommandError: print_max is not a valid type for _KM_OPTIONS.

[BUG] Internal error during connect: unexpected EOF while parsing

Before making a report please ensure you've followed the troubleshooting steps at:
https://github.com/jschuh/klipper-macros#troubleshooting

Describe the bug
Upon starting Mainsail i get the following error:

"Klipper reports: ERROR

Internal error during connect: unexpected EOF while parsing (, line 0)

Once the underlying issue is corrected, use the "RESTART"
command to reload the config and restart the host software.
Printer is halted"

If i remove [include klipper-macros/*.cfg] the Printer doesn't display any errors, except for the basic macros missing.
Was working fine until i updated this morning. I have removed the entire klipper-macros and re-pulled it.

Klipper errors
No commands fired except for "startup" or what the initialization does when the printer is turned on.

Klipper config
Attached Klippy log with configs.
klippy (3).log

PRINT_END Issue

Hi,

When my prints finish and the PRINT_END macro executes my bed goes out beyond it's limits to present the finished print and makes a grinding noise. Do you know what I can modify so it doesn't go as far? Thanks!

[BUG] Print fails using raft for buildplate adhesion

Describe the bug
I slice my models with Cura 5.1
Using brim or skirt as buildplate adhesion works a s aspected.
If i choose Raft (in my Case 4 Layers) i get this error and print fails.

Klipper error messages
00:30
SDCARD_RESET_FILE cannot be run from the sdcard
00:30
Error on 'SET_PRINT_STATS_INFO CURRENT_LAYER="-4"': CURRENT_LAYER must have minimum of 0
00:30
Error on 'SET_PRINT_STATS_INFO CURRENT_LAYER="-4"': CURRENT_LAYER must have minimum of 0

Klipper config
config (2).zip
CFFFP_mandibula.zip

Mistake in providet "add to moonraker.conf"

I copied the code as in the box and pasted it to my moonraker.conf.
The Button showed me an error.

To solve the problem i simply switched the lines "path: ..." and "origin: ...", as the rest of the configs where written like this.

'''
[update_manager klipper-macros]
type: git_repo
path: ~/printer_data/config/klipper-macros # UPDATE THIS FOR YOUR PATH!!!
origin: https://github.com/jschuh/klipper-macros.git
primary_branch: main
is_system_service: False
managed_services: klipper
'''

Now everything's ok.

Thanks for your awesome work, try to figure out all of the functionality!
Greetings from Austria!
Markus

Allow setting an offset from the print end parking position

My Voron 0.2 uses sensorless homing, and for this to work the stepper needs to push the toolhead towards the frame until it touches it, resulting in the stepper driver understanding that it has reached its max position.
The PRINT_END macro parks the toolhead at (park_x, max_y), which is fine if it wasn't for homing when a new print is triggered. The printer needs some buffer space when sensorless homing in order to "feel" the frame, but for y homing the toolhead is already at max_y, resulting in a audible bump into it. For now I just updated the PARK macro call with {max_y - 10} instead of {max_y}, but it would be nice to be able to set the x and y positions for the final parking using a variable.
the x parking position is fine, since one could define it in globals.cfg

Readme correction

First of all thank you these Macros are amazing I don't understand the magic behind them but they work for example when is probing the bed it only probe where is going to print? that's genius. I have to play with changing the surfaces because I have been looking for that for a long time.

There is a warning in the Read me that you need to have bed_heater configured I think you mean heater_bed.

Error "TOTAL_LAYER must have minimum of 0" after updating to latest layers.cfg

I am getting the following errors after getting the latest version. Unfortunately, I am much too new in klipper to even understand how to correct/circumvent this issue. I have reverted to the previous version of layers.cfg in the meantime.

Extrude below minimum temp
6:22 PM
Extrude below minimum temp
See the 'min_extrude_temp' config option for details
6:22 PM
Error on 'SET_PRINT_STATS_INFO TOTAL_LAYER="-1"': TOTAL_LAYER must have minimum of 0

Error when running bed_mesh_calibrate_fast

Error evaluating 'gcode_macro bed_mesh_calibrate_fast:gcode': jinja2.exceptions.UndefinedError: 'extras.gcode_macro.GetStatusWrapper object' has no attribute 'gcode_macro bed_mesh_calibrate'

Unusual (intermittent) error while using Z-TILT and bed_mesh_fast in Print Start

Let me start by saying congratulations on an amazing collection of Macros,
I love the At Layer/ Next Layer macros, it allows for so many options, keep up the great work.

I have my Printer.cfg set to use the temps provided from slicer,
Heat Bed and preheat Extruder, Run Z-Tilt to sync both stepper motors, do a fast bed mesh calibrate,
finish heating extruder and start printing.
It worked perfectly for 10+ prints yesterday, pausing at layer X to do a filament swap, changing settings at layers,
I was delighted with life and thought I found my ideal solution, but the gremlins got in last night while I slept,

I am using a BLTouch for vitrual Z-Endstop and have noticed some intermittent Errors cropping up.

First print this morning I got a BLTouch failed to deploy Error.
I restarted everything (complete power-down and reboot)
BLTouch ran its self test ok and next print ran without issue.

Several (successful) prints later I got another BLTouch failed to deploy Error.
But manually checking with BLTOUCH_Debug reveals no issues.
Console output:
13:43 File opened:First layer calibration_0.2mm_PETG_I3MEGAS_5m.gcode Size:132373
13:43 File selected
13:47 BLTouch failed to deploy
13:47 BLTouch failed to deploy
13:47 BLTouch failed to deploy
13:47 BLTOUCH_DEBUG COMMAND=pin_down
13:47 Sending BLTOUCH_DEBUG COMMAND=pin_down
13:47 BLTOUCH_DEBUG COMMAND=pin_up
13:47 Sending BLTOUCH_DEBUG COMMAND=pin_up

Once I reset and try again it homes, then probes Z after Bed Heating,
then I have received errors during Z-Tilt
See Console Output below:
13:49 Retries: 10/20 Probed points range: 0.006250 tolerance: 0.002500
13:49 probe at 0.000,125.000 is z=2.545837
13:49 probe at 145.000,125.000 is z=2.554587
stepper_z = -0.010584
stepper_z1 = -0.001845
13:49 Making the following Z adjustments:
13:49 Retries: 11/20 Probed points range: 0.008750 tolerance: 0.002500
13:49 Retries aborting: Probed points range is increasing.

It appears the wrong results are getting logged, If I immediately manually re-run a Z-Tilt
I get the following:
13:49 Z_TILT_ADJUST
13:49 probe at 0.000,125.000 is z=2.551834
13:49 probe at 145.000,125.000 is z=2.554334
13:49 Making the following Z adjustments:
stepper_z = -0.003690
stepper_z1 = -0.001200
13:49 Retries: 0/20 Probed points range: 0.002500 tolerance: 0.002500

If I re-run after doing a manual Z-Tilt, it will happily probe the bed for the bed_mesh_fast and complete the print:
13:51 Generating new points...
13:51 bed_mesh: generated points
Index | Tool Adjusted | Probe
13:51 0 | (1.0, 24.0) | (30.0, 5.0)
13:51 1 | (43.5, 24.0) | (72.5, 5.0)
blah ......
blah ......
13:51 23 | (128.5, 209.0) | (157.5, 190.0)
13:51 24 | (171.0, 209.0) | (200.0, 190.0)
13:52 Mesh Bed Leveling Complete
13:52 Bed Mesh state has been saved to profile [default]
for the current session. The SAVE_CONFIG command will
update the printer config file and restart the printer.
13:52 Active bed surface: default; offset: 0.000
13:57 Done printing file

Config File:
printer.cfg.txt

The only possible difference I can think of is the bed was already at temp when I got the last error, (can't remember what setting this morning during first error), is there some sort of timing issue with macro calling the BLTouch to action?

Thanks for any help / suggestions

cura slicer issue - first_layer_print_min

Hello,

Thanks for putting this up!

Quick question, I am using cura and trying to get this to print. I get this error when using the PRINT_START macro

Unable to parse parameter 'MESH_MIN'

Any idea how I can get around this?

Thanks!

bed mesh calibration error

When trying to print I get the following error. Any idea why?

gcode_macro bed_mesh_calibrate_fast:gcode': jinja2.exceptions.UndefinedError: 'extras.gcode_macro.GetStatusWrapper object' has no attribute 'gcode_macro bed_mesh_calibrate'

ERROR evaluaton `gcode_macro check .....[BUG]

Describe the bug
I installed the macro in the correct directory and called it in the printer. cfg and when I restarted it pops up with an Error I have absolutely no idea what that means... my klipper is literally stock except for configuring and tuning my printer so nothing else is conflicting with it...

Klipper error messages
Error evaluating gcode_macro check_km_config:gcode: gcode.CommandError:park_y is invalid

Klipper config
My config is stock board config with tuned features like pressure advance PID tuned etc.... no other macros installed except PID hotend and bed...

[BUG] Error evaluating 'gcode_macro bed_mesh_calibrate_fast

After uploading the file to print I get the following error.

Error evaluating 'gcode_macro bed_mesh_calibrate_fast:gcode': jinja2.exceptions.UndefinedError: 'extras.gcode_macro.GetStatusWrapper object' has no attribute 'gcode_macro bed_mesh_calibrate'

I add in Slicer

BED_MESH_PROFILE LOAD=default

What does this error mean and how to fix it?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.