Skip to content

Instantly share code, notes, and snippets.

@mwvent
Created July 29, 2023 14:33
Show Gist options
  • Save mwvent/6f3bd9c02986e9af2088bd0c257b71f9 to your computer and use it in GitHub Desktop.
Save mwvent/6f3bd9c02986e9af2088bd0c257b71f9 to your computer and use it in GitHub Desktop.
Klipper plotter LCD config and Macros
[gcode_macro PLOTTER_VARS]
variable_plotmode_on: 0
variable_xoffset: -5 ; distance from normal extruder on X axis
variable_yoffset: 18 ; distance from normal extruder on Y axis
variable_zoffset: 5
variable_zdown_offset: -1 ; match z distance gcode files use - for setup
variable_zup_offset: 10 ; distance from z home to lift
variable_zdeploy_offset: 30 ; distance from z for manual deploy
variable_plotting_mode: 0
gcode:
{% set plottervars = printer["gcode_macro PLOTTER_VARS"] %}
[gcode_macro PLOTTER_START]
gcode:
M106 S255 ; Ender3 MB has MB fan and part cooler linked
M104 S0 ;Turn-off hotend
M140 S0 ;Turn-off bed
M117 Homing
G28 ; home all
SET_GCODE_OFFSET X={printer["gcode_macro PLOTTER_VARS"].xoffset} MOVE=1
SET_GCODE_OFFSET Y={printer["gcode_macro PLOTTER_VARS"].yoffset} MOVE=1
SET_GCODE_OFFSET Z={printer["gcode_macro PLOTTER_VARS"].zoffset} MOVE=0
SET_GCODE_VARIABLE MACRO=PLOTTER_VARS VARIABLE=plotting_mode VALUE=1
M117 PLOT MODE READY
[gcode_macro PLOTTER_END]
gcode:
{% set MACHINE_DEPTH = params.MACHINE_DEPTH|default(235)|float %}
SET_GCODE_OFFSET X=0 MOVE=1
SET_GCODE_OFFSET Y=0 MOVE=1
G90 ;Absolute positioning
G1 X5 Y5 F3000 ;Wipe out
G1 Z26 F1000 ; Safe pen removal height
G1 X0 Y{MACHINE_DEPTH} ;Present print
M106 S0 ;Turn-off fan
M104 S0 ;Turn-off hotend
M140 S0 ;Turn-off bed
M84 X Y E Z ;Disable all steppers
SET_GCODE_VARIABLE MACRO=PLOTTER_VARS VARIABLE=plotting_mode VALUE=0
M117
[gcode_macro PLOTTER_TOUCH]
gcode:
SAVE_GCODE_STATE NAME=pre_pd_state
G90 ;Absolute positioning
G1 Z{printer["gcode_macro PLOTTER_VARS"].zdown_offset} F800
G4 P1000
G1 Z{printer["gcode_macro PLOTTER_VARS"].zup_offset} F800
RESTORE_GCODE_STATE NAME=pre_pd_state
[menu __main __plotter]
type: list
name: Plotting
[menu __main __plotter __getready]
type: command
name: Plotmode on
gcode:
PLOTTER_START
[menu __main __plotter __getunready]
type: command
name: Plotmode off
gcode:
PLOTTER_END
[menu __main __plotter __touchtest]
type: command
name: Touch test
gcode:
PLOTTER_TOUCH
[menu __main __plotter __offsetz]
type: input
name: Offset Z:{'%05.3f' % menu.input}
input: {printer.gcode_move.homing_origin.z}
input_min: -25
input_max: 25
input_step: 0.5
realtime: True
gcode:
SET_GCODE_OFFSET Z={'%.3f' % menu.input} MOVE=1
SET_GCODE_VARIABLE MACRO=PLOTTER_VARS VARIABLE=zoffset VALUE=1
[menu __main __plotter __offsety]
type: input
name: Offset Y:{'%05.3f' % menu.input}
input: {printer.gcode_move.homing_origin.y}
input_min: -50
input_max: 50
input_step: 1
realtime: True
gcode:
SET_GCODE_OFFSET Y={'%.3f' % menu.input} MOVE=1
SET_GCODE_VARIABLE MACRO=PLOTTER_VARS VARIABLE=yoffset VALUE=1
[menu __main __plotter __offsetx]
type: input
name: Offset X:{'%05.3f' % menu.input}
input: {printer.gcode_move.homing_origin.x}
input_min: -50
input_max: 50
input_step: 1
realtime: True
gcode:
SET_GCODE_OFFSET X={'%.3f' % menu.input} MOVE=1
SET_GCODE_VARIABLE MACRO=PLOTTER_VARS VARIABLE=xoffset VALUE=1
[menu __main __plotter __startprint]
type: command
enable: {('virtual_sdcard' in printer) and printer.virtual_sdcard.file_path and not printer.virtual_sdcard.is_active}
name: Start printing
gcode: M24
[menu __main __plotter _currentfile]
type: list
name: Current Print
[menu __main __plotter _currentfile __resume]
type: command
enable: {('virtual_sdcard' in printer) and printer.print_stats.state == "paused"}
name: Resume printing
gcode:
{% if "pause_resume" in printer %}
RESUME
{% else %}
M24
{% endif %}
[menu __main __plotter _currentfile __pause]
type: command
enable: {('virtual_sdcard' in printer) and printer.print_stats.state == "printing"}
name: Pause printing
gcode:
{% if "pause_resume" in printer %}
PAUSE
{% else %}
M25
{% endif %}
[menu __main __plotter _currentfile __cancel]
type: command
enable: {('virtual_sdcard' in printer) and (printer.print_stats.state == "printing" or printer.print_stats.state == "paused")}
name: Cancel printing
gcode:
{% if 'pause_resume' in printer %}
CANCEL_PRINT
{% else %}
M25
M27
M26 S0
TURN_OFF_HEATERS
{% if printer.toolhead.position.z <= printer.toolhead.axis_maximum.z - 5 %}
G91
G0 Z5 F1000
G90
{% endif %}
{% endif %}
[menu __main __plotter __sdcard]
type: vsdlist
enable: {('virtual_sdcard' in printer)}
name: Files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment