From 6be114d728b6a243bb7af990cf03a879ea74c0b8 Mon Sep 17 00:00:00 2001 From: Pedro Lamas Date: Mon, 4 Jul 2022 09:37:24 +0100 Subject: docs: fix rawparams example by truncating comments Signed-off-by: Pedro Lamas --- config/sample-macros.cfg | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'config/sample-macros.cfg') diff --git a/config/sample-macros.cfg b/config/sample-macros.cfg index 97e39016..3590268c 100644 --- a/config/sample-macros.cfg +++ b/config/sample-macros.cfg @@ -175,6 +175,29 @@ gcode: sensor.temperature, sensor.humidity))} +###################################################################### +# Override M117 command with rawparams +###################################################################### + +# The macro below will override the default M117 command to echo the message. +# +# It uses the rawparams pseudo-variable that contains the full unparsed +# parameters that was passed to the M117 command. +# +# As this can include comments, we are trimming the text when a `;` or `#` is +# found, and escaping any existing `"` + +[gcode_macro M117] +rename_existing: M117.1 +gcode: + {% if rawparams %} + {% set escaped_msg = rawparams.split(';', 1)[0].split('\x23', 1)[0]|replace('"', '\\"') %} + SET_DISPLAY_TEXT MSG="{escaped_msg}" + RESPOND TYPE=command MSG="{escaped_msg}" + {% else %} + SET_DISPLAY_TEXT + {% endif %} + # SDCard 'looping' (aka Marlin M808 commands) support # # Support SDCard looping -- cgit v1.2.3-70-g09d2