2018-11-08 16:12:07 +03:00
|
|
|
# This file provides examples of Klipper G-Code macros. The snippets
|
2019-05-31 17:01:54 +03:00
|
|
|
# in this file may be copied into the main printer.cfg file and
|
|
|
|
# customized.
|
2018-11-08 16:12:07 +03:00
|
|
|
#
|
|
|
|
# See the "example.cfg" file for description of common config parameters.
|
|
|
|
|
|
|
|
|
2019-05-31 17:08:49 +03:00
|
|
|
######################################################################
|
|
|
|
# Start Print and End Print
|
|
|
|
######################################################################
|
|
|
|
|
|
|
|
# Replace the slicer's custom start and end g-code scripts with
|
|
|
|
# START_PRINT and END_PRINT.
|
|
|
|
|
|
|
|
[gcode_macro START_PRINT]
|
|
|
|
default_parameter_BED_TEMP: 60
|
|
|
|
default_parameter_EXTRUDER_TEMP: 190
|
|
|
|
gcode:
|
|
|
|
# Start bed heating
|
|
|
|
M140 S{BED_TEMP}
|
|
|
|
# Use absolute coordinates
|
|
|
|
G90
|
|
|
|
# Reset the G-Code Z offset (adjust Z offset if needed)
|
|
|
|
SET_GCODE_OFFSET Z=0.0
|
|
|
|
# Home the printer
|
|
|
|
G28
|
|
|
|
# Move the nozzle near the bed
|
|
|
|
G1 Z5 F3000
|
|
|
|
# Move the nozzle very close to the bed
|
|
|
|
G1 Z0.15 F300
|
|
|
|
# Wait for bed to reach temperature
|
|
|
|
M190 S{BED_TEMP}
|
|
|
|
# Set and wait for nozzle to reach temperature
|
|
|
|
M109 S{EXTRUDER_TEMP}
|
|
|
|
|
|
|
|
[gcode_macro END_PRINT]
|
|
|
|
gcode:
|
|
|
|
# Turn off bed, extruder, and fan
|
|
|
|
M140 S0
|
|
|
|
M104 S0
|
|
|
|
M106 S0
|
|
|
|
# Move nozzle away from print while retracting
|
|
|
|
G91
|
|
|
|
G1 X-2 Y-2 E-3 F300
|
|
|
|
# Raise nozzle by 10mm
|
|
|
|
G1 Z10 F3000
|
|
|
|
G90
|
|
|
|
# Disable steppers
|
|
|
|
M84
|
|
|
|
|
|
|
|
|
2019-05-31 17:01:54 +03:00
|
|
|
######################################################################
|
|
|
|
# Beeper
|
|
|
|
######################################################################
|
|
|
|
|
|
|
|
# M300 : Play tone. Beeper support, as commonly found on usual LCD
|
|
|
|
# displays (i.e. RepRapDiscount 2004 Smart Controller, RepRapDiscount
|
|
|
|
# 12864 Full Graphic). This defines a custom I/O pin and a custom
|
|
|
|
# GCODE macro. Usage:
|
|
|
|
# M300 [P<ms>] [S<Hz>]
|
|
|
|
# P is the tone duration, S the tone frequency.
|
|
|
|
# The frequency won't be pitch perfect.
|
|
|
|
|
|
|
|
[output_pin BEEPER_pin]
|
|
|
|
pin: ar37
|
2018-11-08 16:12:07 +03:00
|
|
|
# Beeper pin. This parameter must be provided.
|
|
|
|
# ar37 is the default RAMPS/MKS pin.
|
2019-05-31 17:01:54 +03:00
|
|
|
pwm: True
|
2018-11-08 16:12:07 +03:00
|
|
|
# A piezo beeper needs a PWM signal, a DC buzzer doesn't.
|
2019-05-31 17:01:54 +03:00
|
|
|
value: 0
|
2018-11-08 16:12:07 +03:00
|
|
|
# Silent at power on, set to 1 if active low.
|
2019-05-31 17:01:54 +03:00
|
|
|
shutdown_value: 0
|
2018-11-08 16:12:07 +03:00
|
|
|
# Disable at emergency shutdown (no PWM would be available anyway).
|
2019-05-31 17:01:54 +03:00
|
|
|
cycle_time: 0.001
|
2018-11-08 16:12:07 +03:00
|
|
|
# PWM frequency : 0.001 = 1ms will give a base tone of 1kHz
|
2019-05-31 17:01:54 +03:00
|
|
|
scale: 1000
|
2018-11-08 16:12:07 +03:00
|
|
|
# PWM parameter will be in the range of (0-1000 Hz).
|
|
|
|
# Although not pitch perfect.
|
2019-05-31 17:01:54 +03:00
|
|
|
|
|
|
|
[gcode_macro M300]
|
|
|
|
default_parameter_S: 1000
|
|
|
|
# Use a default 1kHz tone if S is omitted.
|
|
|
|
default_parameter_P: 100
|
|
|
|
# Use a 10ms duration is P is omitted.
|
|
|
|
gcode:
|
|
|
|
SET_PIN PIN=BEEPER_pin VALUE={S}
|
|
|
|
G4 P{P}
|
|
|
|
SET_PIN PIN=BEEPER_pin VALUE=0
|
|
|
|
|
|
|
|
|
|
|
|
######################################################################
|
|
|
|
# Filament Change
|
|
|
|
######################################################################
|
|
|
|
|
|
|
|
# M600: Filament Change. This macro will pause the printer, move the
|
|
|
|
# tool to the change position, and retract the filament 50mm. Adjust
|
|
|
|
# the retraction settings for your own extruder. After filament has
|
|
|
|
# been changed, the print can be resumed from its previous position
|
|
|
|
# with the "RESUME" gcode.
|
|
|
|
|
2019-05-31 17:26:44 +03:00
|
|
|
[pause_resume]
|
|
|
|
|
2019-05-31 17:01:54 +03:00
|
|
|
[gcode_macro M600]
|
|
|
|
default_parameter_X: 50
|
|
|
|
default_parameter_Y: 0
|
|
|
|
default_parameter_Z: 10
|
|
|
|
gcode:
|
2019-05-31 17:26:44 +03:00
|
|
|
SAVE_GCODE_STATE NAME=M600_state
|
2019-05-31 17:01:54 +03:00
|
|
|
PAUSE
|
|
|
|
G91
|
|
|
|
G1 E-.8 F2700
|
|
|
|
G1 Z{Z}
|
|
|
|
G90
|
|
|
|
G1 X{X} Y{Y} F3000
|
|
|
|
G91
|
|
|
|
G1 E-50 F1000
|
2019-05-31 17:26:44 +03:00
|
|
|
RESTORE_GCODE_STATE NAME=M600_state
|
2020-01-12 04:17:14 +03:00
|
|
|
|
|
|
|
######################################################################
|
|
|
|
# BME280 Environmental Sensor
|
|
|
|
######################################################################
|
|
|
|
|
|
|
|
# The macro below assumes you have a BME280 sensor_type defined in one
|
|
|
|
# of the applicable sections in printer.cfg, such as:
|
|
|
|
#
|
|
|
|
#[temperature_sensor my_sensor]
|
|
|
|
#sensor_type: BME280
|
|
|
|
#gcode_id: AMB
|
|
|
|
#
|
|
|
|
# Note the format of the parameter SENSOR in the macro below. The BME280
|
|
|
|
# sensor status can be accessed using the format "bme280 <section_name>".
|
|
|
|
# The example section above is named "my_sensor", thus the bme280 can be
|
|
|
|
# queried as follows:
|
|
|
|
#
|
|
|
|
# QUERY_BME280 SENSOR='bme280 my_sensor'
|
|
|
|
#
|
|
|
|
# Since a default parameter is defined one could simply enter QUERY_BME280
|
|
|
|
# as well.
|
|
|
|
|
|
|
|
[gcode_macro QUERY_BME280]
|
|
|
|
default_parameter_SENSOR: bme280 my_sensor
|
|
|
|
gcode:
|
|
|
|
{printer.gcode.action_respond_info(
|
|
|
|
"Temperature: %.2f C\n"
|
|
|
|
"Pressure: %.2f hPa\n"
|
|
|
|
"Humidity: %.2f%%" % (
|
|
|
|
printer[SENSOR].temperature,
|
|
|
|
printer[SENSOR].pressure,
|
|
|
|
printer[SENSOR].humidity))}
|