Skip to content

Instantly share code, notes, and snippets.

@pedrolamas
Created July 18, 2022 23:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pedrolamas/b745c58693608146ffe291abbbd354cb to your computer and use it in GitHub Desktop.
Save pedrolamas/b745c58693608146ffe291abbbd354cb to your computer and use it in GitHub Desktop.
[gcode_macro M117]
description: Set LCD Message
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}"
_SET_MARQUEE MSG="{escaped_msg}"
{% else %}
SET_DISPLAY_TEXT
_SET_MARQUEE
{% endif %}
[display_template _print_status]
text:
{% set msg = printer["gcode_macro _SET_MARQUEE"].msg %}
{% if msg %}
{ msg }
{% elif printer.idle_timeout.printing_time %}
{% set pos = printer.toolhead.position %}
{ "X%-4.0fY%-4.0fZ%-5.2f" % (pos.x, pos.y, pos.z) }
{% else %}
Ready
{% endif %}
[gcode_macro _SET_MARQUEE]
variable_msg: ''
gcode:
{% set msg = params.MSG | default("") | replace('"', '') %}
{% if msg | length > 16 %}
SET_GCODE_VARIABLE MACRO=_SET_MARQUEE VARIABLE=msg VALUE="'{msg} '"
UPDATE_DELAYED_GCODE ID=_UPDATE_MARQUEE DURATION=3
{% else %}
SET_GCODE_VARIABLE MACRO=_SET_MARQUEE VARIABLE=msg VALUE="'{msg}'"
UPDATE_DELAYED_GCODE ID=_UPDATE_MARQUEE DURATION=0
{% endif %}
[delayed_gcode _UPDATE_MARQUEE]
gcode:
{% set msg = printer["gcode_macro _SET_MARQUEE"].msg %}
SET_GCODE_VARIABLE MACRO=_SET_MARQUEE VARIABLE=msg VALUE="'{ msg[1:] + msg[0] }'"
UPDATE_DELAYED_GCODE ID=_UPDATE_MARQUEE DURATION=1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment