-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathM300.cfg
74 lines (66 loc) · 2.16 KB
/
M300.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
########
#
# M300.cfg
#
# Include this straight up, you don't need to change anything
# copy beeper.cfg into your local config and edit it to set the correct beeper
# pin
#
# owes a lot to the version in config/sample-macros.cfg
# todo: variable loudness, quiet for info, loud for failure alarms
[gcode_macro M300]
variable_silenced: 0
variable_loud: 200
gcode:
#{ action_respond_info("DEBUG M300") }
# 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 quiet = params.QUIET|default(0)|int %}
{% set V = params.V|default(loud)|int %}
#{ action_respond_info("V is:") }
#{ action_respond_info(V|string) }
{% if ((quiet ) > 0 ) %}
SET_GCODE_VARIABLE MACRO=M300 VARIABLE=silenced VALUE=1
{ action_respond_info("Beeper Silenced") }
{% elif (quiet) < 0 %}
SET_GCODE_VARIABLE MACRO=M300 VARIABLE=silenced VALUE=0
{ action_respond_info("Beeper Enabled") }
{% endif %}
{% if (V < 50) %}
SET_GCODE_VARIABLE MACRO=M300 VARIABLE=silenced VALUE=1
{ action_respond_info("Beeper Silenced on V < 50") }
{% elif (V > 200) %}
SET_GCODE_VARIABLE MACRO=M300 VARIABLE=loud VALUE=200
{% set V = 200|int %}
{% else %}
SET_GCODE_VARIABLE MACRO=M300 VARIABLE=loud VALUE={V}
{% endif %}
{% if printer["gcode_macro M300"].silenced < 1 %}
##{ action_respond_info("V, " + (V|float)|string + "CYCLE_TIME " + (1.0/S)|string ) } #debug
SET_PIN PIN=beeper VALUE={V|float / 255} CYCLE_TIME={ 1.0/S if S > 0 else 1 }
G4 P{P}
SET_PIN PIN=beeper VALUE=0
{% else %}
{ action_respond_info("SILENT BEEP") }
{% endif %}
[gcode_macro ALARM_BEEP]
description: Get some serious attention with M300
gcode:
#{% if printer["gcode_macro M301.1"] %}
_SOUND_ALARM
#% else %}
# M300 V 255
# G4 P 50
# M300 V 255
# G4 P 50
# M300 V 255
# G4 P 50
# M300 V 255
# G4 P 50
# M300 V 255
# G4 P 50
# M300 V 255
# G4 P 50
#{% endif %}