garethky / PrusaSlicerPressureAdvanceCalibration

An web tool that modified PrusaSlicer GCode to add a Pressure Advance test pattern
https://garethky.github.io/PrusaSlicerPressureAdvanceCalibration/
GNU General Public License v3.0
5 stars 3 forks source link

Add Klipper Support #1

Closed garethky closed 10 months ago

garethky commented 10 months ago

Klipper is largely Marlin compatible and I already have code to emit the PRESSURE_ADVANCE gcode. But its not working with the function that updates the last M109 call's temperature.

Klipper machines are usually configured with a custom PRINT_START macro. Its common to pass this macro the bed and nozzle temps for the print. e.g. this is my print start gcode from my Voron 2.4:

M104 S0 ; Stops PS/SS from sending temp waits separately
M140 S0

PRINT_WARMUP EXTRUDER_TEMP=[first_layer_temperature] BED_TEMP=[first_layer_bed_temperature]
PRINT_START EXTRUDER_TEMP=[first_layer_temperature] BED_TEMP=[first_layer_bed_temperature] PRINT_START_X=[first_layer_print_min_0] PRINT_START_Y=[first_layer_print_min_1] PRINT_END_X=[first_layer_print_max_0] PRINT_END_Y=[first_layer_print_max_1]

This raw code is in the config that Prusa Slicer emits. I think I could parse that and substitute in the required variables. It doesn't have any of the lanugage features like conditionals, loops, expressions etc. This is simple s/[first_layer_temperature]/240/ stuff that should be quick to prototype.

Also, the checking for/modifying of M109 needs to not result in an exception if its not found for klipper machines.

garethky commented 10 months ago

Made some progress:

Implementing a parser for Prusa's start Gcode language is not something I think I have time for right now.

garethky commented 10 months ago

This needs to be verified with testing but klipper should be supported now.

I implemented a minimal variable templating engine for the prusa gcode templates so the start_gcode can be re-evaluated. A very minimal set of values is provided, just temperatures and print location and size. If you used anything else more exotic its going to fail with an exception.

Object markers have also been added if the emitted gcode had an object marker present. This dive the plugin version of adaptive bed meshing.

garethky commented 10 months ago

I'm closing this for now. If klipper users have issues with their start gcode being processed we can open a new issue about the specifics.