Files
3dprinters/klipper/DNV-TPU-Ender3/klipper_config/klipper-macros/beep.cfg

23 lines
875 B
INI

# Copyright (C) 2022 Justin Schuh <code@justinschuh.com>
#
# 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 %}