forked from jschuh/klipper-macros
-
Notifications
You must be signed in to change notification settings - Fork 0
/
beep.cfg
22 lines (22 loc) · 875 Bytes
/
beep.cfg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# 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 km = printer["gcode_macro _km_globals"] %}
{% set settings = printer.configfile.settings %}
{% if "output_pin beeper" in printer %}
{% set P = (params.P|default(km.beep_duration)|int, 0)|max %}
{% set S = (params.S|default(km.beep_frequency)|int, 1)|max %}
SET_PIN PIN=beeper VALUE={
settings["output_pin beeper"].scale|default(1.0) * 0.5
}{% if settings["output_pin beeper"].pwm %} 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 [output_pin beeper] config.")}
{% endif %}