-
Notifications
You must be signed in to change notification settings - Fork 0
/
ext_respond.cfg
33 lines (26 loc) · 1.18 KB
/
ext_respond.cfg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
[gcode_macro RESPOND]
rename_existing: BASE_RESPOND
gcode:
{% set colors = ('primary', 'secondary', 'accent', 'info', 'success', 'error', 'warning') %}
{% if params.PREFIX is defined %}
{% set prefix = 'PREFIX=' + params.PREFIX|string %}
{% endif %}
{% if params.TYPE is defined %}
{% if params.TYPE in ('echo', 'echo_no_space', 'command', 'error') and params.TYPE != '' %}
{% set type = 'TYPE=' + params.TYPE|string %}
{% else %}
BASE_RESPOND TYPE=error MSG="RESPOND TYPE '{params.TYPE}' is invalid. Must be one of 'echo', 'command' or 'error'"
{% endif %}
{% endif %}
{% if params.MSG is defined %}
{% set msg = 'MSG="'+ params.MSG + '"'|string %}
{% endif %}
{% if params.COLOR is defined %}
{% set color = params.COLOR|lower %}
{% if color in colors %}
{% set msg = 'MSG="<span class=' + color + '--text>' + params.MSG + '</span>"'|string %}
{% else %}
BASE_RESPOND TYPE=error MSG="RESPOND COLOR '{color}' is invalid. Must be one of 'primary', 'secondary', 'accent', 'info', 'success', 'warning' or 'error'"
{% endif %}
{% endif %}
BASE_RESPOND {prefix} {type} {msg}