Beep repeatedly until stopped

Can someone please help me with my code? I’m trying to get the printer to beep repeatedly when it pauses so that I notice it. My idea was to have a macro that makes it beep say Repeats=600 times, and I could stop it by sending the macro with Repeats=0. I wrote this:

[gcode_macro BeepRepeatedly]
gcode:
{% set times = params.Repeats|default(600)| int %}
{% if times > 0 %}
SET_GCODE_VARIABLE MACRO=RepeatBeeping VARIABLE=repeat_beeping VALUE={times|int}
UPDATE_DELAYED_GCODE ID=RepeatBeeping
{% endif %}

[delayed_gcode RepeatBeeping]
gcode:
{% set repeat_beeping = repeat_beeping-1|int %}
M300
G4 P2000
BeepRepeatedly Repeats=repeat_beeping

I’m getting this error: !! The value ‘RepeatBeeping’ is not valid for MACRO
What am I doing wrong? Would this macro work? Is there a better way of doing this?
Thank you so much!

Please share the klippy.log in your next post as a (zipped) file.

Here it is. Thank you for looking into this.
klippy.zip (114.9 KB)

This is how I managed to get the functionality I was looking for:

[delayed_gcode beeping]
gcode:
M300 P1000
UPDATE_DELAYED_GCODE ID=beeping DURATION=5

[gcode_macro Stop_Beeping]
gcode:
UPDATE_DELAYED_GCODE ID=beeping DURATION=0

To start the beeping you send UPDATE_DELAYED_GCODE ID=beeping DURATION=1
To stop the beeping you send UPDATE_DELAYED_GCODE ID=beeping DURATION=0 or call the macro Stop_Beeping

1 Like