forked from jschuh/klipper-macros
-
Notifications
You must be signed in to change notification settings - Fork 0
/
beep.cfg
30 lines (29 loc) · 1.09 KB
/
beep.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
# Copyright (C) 2022 Justin Schuh <[email protected]>
#
# This file may be distributed under the terms of the GNU GPLv3 license.
[gcode_macro m300]
description: Emits and audible beep.
Usage: M300 [P<duration>] [S<frequency>]
gcode:
{% set settings = printer.configfile.settings %}
{% if "output_pin beeper" in printer or "pwm_cycle_time beeper" in printer %}
{% set P = (params.P|default(100)|int, 0)|max %}
{% set S = (params.S|default(1000)|int, 1)|max %}
SET_PIN PIN=beeper VALUE={% if "output_pin beeper" in settings %}1{%else%}{
settings["pwm_cycle_time beeper"].scale|default(1.0) * 0.5
} CYCLE_TIME={ 1.0 / S }{% endif %}
G4 P{P}
SET_PIN PIN=beeper VALUE=0
{% else %}
{action_respond_info(
"M300 is disabled. To enable create an [pwm_cycle_time beeper] config.")}
{% endif %}
[gcode_macro _km_beep_if_available]
description: Wraps beeper to avoid console spam
gcode:
{% if "output_pin beeper" in printer or "pwm_cycle_time beeper" in printer %}
{% for i in range(params.BEEPS|int) %}
M300 P100
G4 P200
{% endfor %}
{% endif %}