Added beep macro.

This commit is contained in:
Bassam Husain
2023-01-29 17:46:40 -05:00
parent f371a1e60f
commit 8936d91f11
2 changed files with 22 additions and 0 deletions

21
macros/beeper.cfg Normal file
View File

@@ -0,0 +1,21 @@
[output_pin beeper]
pin: PC6
value: 0
shutdown_value: 0
pwm: True
cycle_time: 0.0005 ; Default beeper tone in kHz. 1 / 0.0005 = 2000Hz (2kHz)
[gcode_macro BEEP]
description: "BEEP I=3 DUR=200 FREQ=2000: Beep 3 times, for 200ms each, at 2kHz frequency."
gcode:
# Parameters
{% set i = params.I|default(1)|int %} ; Iterations (number of times to beep).
{% set dur = params.DUR|default(100)|int %} ; Duration/wait of each beep in ms. Default 100ms.
{% set freq = params.FREQ|default(2000)|int %} ; Frequency in Hz. Default 2kHz.
{% for iteration in range(i|int) %}
SET_PIN PIN=beeper VALUE=0.8 CYCLE_TIME={ 1.0/freq if freq > 0 else 1 }
G4 P{dur}
SET_PIN PIN=beeper VALUE=0
G4 P{dur}
{% endfor %}

View File

@@ -14,6 +14,7 @@
[include ./macros/TEST_SPEED.cfg]
[include ./macros/PARKING.cfg]
[include ./macros/MECHANICAL_GANTRY_CALIBRATION.cfg]
[include ./macros/beeper.cfg]
# Uncomment the following line if you're using an adxl345, and have it setup
# [include ./adxl-rp2040.cfg]