From d36dbfebd17500f0af176abd88d8b258c7940e47 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Mon, 26 Apr 2021 12:44:51 -0400 Subject: [PATCH] docs: Prefer Jinja2 "set" directive to default_parameter_xxx in examples The "set" directive is more flexible and easier to understand. Signed-off-by: Kevin O'Connor --- config/printer-lulzbot-taz6-dual-v3-2017.cfg | 48 +++++--------------- config/sample-macros.cfg | 32 ++++++------- config/sample-raspberry-pi.cfg | 6 +-- docs/API_Server.md | 6 +-- 4 files changed, 32 insertions(+), 60 deletions(-) diff --git a/config/printer-lulzbot-taz6-dual-v3-2017.cfg b/config/printer-lulzbot-taz6-dual-v3-2017.cfg index 38248f0d..e7a43653 100644 --- a/config/printer-lulzbot-taz6-dual-v3-2017.cfg +++ b/config/printer-lulzbot-taz6-dual-v3-2017.cfg @@ -214,17 +214,16 @@ gcode: #NOTE: T0 is the default extruder, T1 is optional. #START block for use with dual or single extrusion prints [gcode_macro START_PRINT] -default_parameter_EXTRUDERS_ENABLED_COUNT: 1 -default_parameter_MATERIAL_STANDBY_TEMPERATURE_0: 175 -default_parameter_MATERIAL_STANDBY_TEMPERATURE_1: 175 -default_parameter_MATERIAL_BED_TEMPERATURE_LAYER_0: 65 -default_parameter_MATERIAL_PRINT_TEMPERATURE_LAYER_0_0: 210 -default_parameter_MATERIAL_PRINT_TEMPERATURE_LAYER_0_1: 210 -#configure the params below to tune the stage desired temperatures based on the standby temps -default_parameter_MATERIAL_SOFTEN_TEMP_OFFSET: 35 -default_parameter_MATERIAL_WIPE_TEMP_OFFSET: 35 -default_parameter_MATERIAL_PROBE_TEMP_OFFSET: 35 gcode: + {% set EXTRUDERS_ENABLED_COUNT = 1 %} + {% set MATERIAL_STANDBY_TEMPERATURE_0 = 175 %} + {% set MATERIAL_STANDBY_TEMPERATURE_1 = 175 %} + {% set MATERIAL_BED_TEMPERATURE_LAYER_0 = 65 %} + {% set MATERIAL_PRINT_TEMPERATURE_LAYER_0_0 = 210 %} + {% set MATERIAL_PRINT_TEMPERATURE_LAYER_0_1 = 210 %} + {% set MATERIAL_SOFTEN_TEMP_OFFSET = 35 %} + {% set MATERIAL_WIPE_TEMP_OFFSET = 35 %} + {% set MATERIAL_PROBE_TEMP_OFFSET = 35 %} ;This profile is designed specifically for LulzBot TAZ6 3D Printer with the Yellowfin Dual running Klipper M73 P0 ; clear GLCD progress bar M107 ; disable fans @@ -342,10 +341,10 @@ gcode: #END block for use with dual or single extrusion prints [gcode_macro END_PRINT] -default_parameter_EXTRUDERS_ENABLED_COUNT: 1 -default_parameter_MATERIAL_PART_REMOVAL_TEMPERATURE: 45 -default_parameter_MATERIAL_KEEP_PART_REMOVAL_TEMPERATURE_T: 0 gcode: + {% set EXTRUDERS_ENABLED_COUNT = 1 %} + {% set MATERIAL_PART_REMOVAL_TEMPERATURE = 45 %} + {% set MATERIAL_KEEP_PART_REMOVAL_TEMPERATURE_T = 0 %} M400 M104 S0 T0 ; T0 hotend off {% if EXTRUDERS_ENABLED_COUNT|int == 2 %} @@ -372,26 +371,3 @@ gcode: M84 ; steppers off G90 ; absolute positioning M117 Print Complete ; progress indicator message - -#--------------------------------------------------------------------------------------------------- -# ULTIMAKER CURA START AND END SCRIPTS - Replace default START and STOP scripts with the below GCODE -#--------------------------------------------------------------------------------------------------- -#---> Dual Extrusion Printer Profiles < --- -#; LulzBot Taz6 w/ Dual Extruder Klipper START gcode script (for Cura UE, tested on v4.3) -#; First, set START_PRINT Macro variables from Cura parameters -#SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=EXTRUDERS_ENABLED_COUNT VALUE={extruders_enabled_count} -#SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=MATERIAL_STANDBY_TEMPERATURE_0 VALUE={material_standby_temperature} -#SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=MATERIAL_STANDBY_TEMPERATURE_1 VALUE={material_standby_temperature, 1} -#SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=MATERIAL_BED_TEMPERATURE_LAYER_0 VALUE={material_bed_temperature_layer_0} -#SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=MATERIAL_PRINT_TEMPERATURE_LAYER_0_0 VALUE={material_print_temperature_layer_0} -#SET_GCODE_VARIABLE MACRO=START_PRINT VARIABLE=MATERIAL_PRINT_TEMPERATURE_LAYER_0_1 VALUE={material_print_temperature_layer_0, 1} -#; Execute START_PRINT GCODE defined in Klipper config file -#START_PRINT - -#; LulzBot Taz6 w/ Dual Extruder v3 Klipper END gcode script (for Cura UE, tested on v4.3) -#; First, set END_PRINT Macro variables from Cura parameters -#SET_GCODE_VARIABLE MACRO=END_PRINT VARIABLE=EXTRUDERS_ENABLED_COUNT VALUE={extruders_enabled_count} -#SET_GCODE_VARIABLE MACRO=END_PRINT VARIABLE=MATERIAL_PART_REMOVAL_TEMPERATURE VALUE=45 -#SET_GCODE_VARIABLE MACRO=END_PRINT VARIABLE=MATERIAL_KEEP_PART_REMOVAL_TEMPERATURE_T VALUE=0 -#; Execute END_PRINT GCODE defined in Klipper config file -#END_PRINT diff --git a/config/sample-macros.cfg b/config/sample-macros.cfg index de50541c..ea37c584 100644 --- a/config/sample-macros.cfg +++ b/config/sample-macros.cfg @@ -13,9 +13,9 @@ # START_PRINT and END_PRINT. [gcode_macro START_PRINT] -default_parameter_BED_TEMP: 60 -default_parameter_EXTRUDER_TEMP: 190 gcode: + {% set BED_TEMP = params.BED_TEMP|default(60)|float %} + {% set EXTRUDER_TEMP = params.EXTRUDER_TEMP|default(190)|float %} # Start bed heating M140 S{BED_TEMP} # Use absolute coordinates @@ -78,11 +78,11 @@ scale: 1000 # Although not pitch perfect. [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: + # Use a default 1kHz tone if S is omitted. + {% set S = params.S|default(1000)|int %} + # Use a 10ms duration is P is omitted. + {% set P = params.P|default(100)|int %} SET_PIN PIN=BEEPER_pin VALUE={S} G4 P{P} SET_PIN PIN=BEEPER_pin VALUE=0 @@ -101,10 +101,10 @@ gcode: [pause_resume] [gcode_macro M600] -default_parameter_X: 50 -default_parameter_Y: 0 -default_parameter_Z: 10 gcode: + {% set X = params.X|default(50)|float %} + {% set Y = params.Y|default(0)|float %} + {% set Z = params.Z|default(10)|float %} SAVE_GCODE_STATE NAME=M600_state PAUSE G91 @@ -138,15 +138,15 @@ gcode: # as well. [gcode_macro QUERY_BME280] -default_parameter_SENSOR: bme280 my_sensor gcode: + {% set sensor = printer["bme280 my_sensor"] %} {action_respond_info( "Temperature: %.2f C\n" "Pressure: %.2f hPa\n" "Humidity: %.2f%%" % ( - printer[SENSOR].temperature, - printer[SENSOR].pressure, - printer[SENSOR].humidity))} + sensor.temperature, + sensor.pressure, + sensor.humidity))} ###################################################################### # HTU21D family Environmental Sensor @@ -169,10 +169,10 @@ gcode: # as well. [gcode_macro QUERY_HTU21D] -default_parameter_SENSOR: htu21d my_sensor gcode: + {% set sensor = printer["htu21d my_sensor"] %} {action_respond_info( "Temperature: %.2f C\n" "Humidity: %.2f%%" % ( - printer[SENSOR].temperature, - printer[SENSOR].humidity))} + sensor.temperature, + sensor.humidity))} diff --git a/config/sample-raspberry-pi.cfg b/config/sample-raspberry-pi.cfg index 92f1c20e..77e5cdf8 100644 --- a/config/sample-raspberry-pi.cfg +++ b/config/sample-raspberry-pi.cfg @@ -30,13 +30,13 @@ i2c_bus: i2c.1 htu21d_hold_master: False [gcode_macro QUERY_ENCLOSURE] -default_parameter_SENSOR: htu21d enclosure_temp gcode: + {% set sensor = printer["htu21d enclosure_temp"] %} {action_respond_info( "Temperature: %.2f C\n" "Humidity: %.2f%%" % ( - printer[SENSOR].temperature, - printer[SENSOR].humidity))} + sensor.temperature, + sensor.humidity))} # Example 3:Using a pin on another gpiochip connected to the RPi # (in this case on an MCP23017) diff --git a/docs/API_Server.md b/docs/API_Server.md index c874365e..7c306a2a 100644 --- a/docs/API_Server.md +++ b/docs/API_Server.md @@ -163,12 +163,8 @@ that if the method takes parameters they should be provided as keyword arguments. Below is an example of how it may called from a gcode_macro: ``` [gcode_macro PANELDUE_BEEP] -default_parameter_FREQUENCY: 300 -default_parameter_DURATION: 1. gcode: - {action_call_remote_method("paneldue_beep", - frequency=FREQUENCY|int, - duration=DURATION|float)} + {action_call_remote_method("paneldue_beep", frequency=300, duration=1.0)} ``` When the PANELDUE_BEEP gcode macro is executed, Klipper would send something