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 <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor
2021-04-26 12:44:51 -04:00
parent 61a25d2fb2
commit d36dbfebd1
4 changed files with 32 additions and 60 deletions

View File

@@ -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))}