Cleanup in beeper.cfg.

This commit is contained in:
Bassam Husain
2023-02-04 10:10:22 -05:00
parent 59732ccb49
commit 752c47d30b

View File

@@ -5,17 +5,8 @@ shutdown_value: 0
pwm: True pwm: True
cycle_time: 0.0005 ; Default beeper tone in kHz. 1 / 0.0005 = 2000Hz (2kHz) cycle_time: 0.0005 ; Default beeper tone in kHz. 1 / 0.0005 = 2000Hz (2kHz)
[gcode_macro M300]
gcode:
{% set S = params.S|default(1000)|int %}
{% set P = params.P|default(100)|int %}
SET_PIN PIN=beeper VALUE=0.5 CYCLE_TIME={ 1.0/S if S > 0 else 1 }
G4 P{P}
SET_PIN PIN=beeper VALUE=0
[gcode_macro BEEP] [gcode_macro BEEP]
description: "BEEP I=3 DUR=200 FREQ=2000: Beep 3 times, for 200ms each, at 2kHz frequency." description: BEEP I=3 DUR=200 FREQ=2000: Beep 3 times, for 200ms each, at 2kHz frequency.
gcode: gcode:
# Parameters # Parameters
{% set i = params.I|default(1)|int %} ; Iterations (number of times to beep). {% set i = params.I|default(1)|int %} ; Iterations (number of times to beep).
@@ -29,26 +20,35 @@ gcode:
G4 P{dur} G4 P{dur}
{% endfor %} {% endfor %}
[gcode_macro SONG_SINGLE_BEEP] # [gcode_macro M300]
gcode: # gcode:
M300 S830.61 P137 # {% set S = params.S|default(1000)|int %}
# {% set P = params.P|default(100)|int %}
[gcode_macro TOGGLE_BEEPER] # SET_PIN PIN=beeper VALUE=0.5 CYCLE_TIME={ 1.0/S if S > 0 else 1 }
description: Toggle the printer beeper on and off. # G4 P{P}
gcode: # SET_PIN PIN=beeper VALUE=0
{% set beeper_state = printer.save_variables.variables.beeper_state|lower %}
{% if printer['gcode_macro _USER_VARIABLE'].debug == 1 %} # [gcode_macro SONG_SINGLE_BEEP]
{action_respond_info('==== TOGGLE_BEEPER ====')} # gcode:
{action_respond_info("beeper_state: %s" % (beeper_state))} # M300 S830.61 P137
{action_respond_info('===============')}
{% endif %}
{% if beeper_state == "off" %} # [gcode_macro TOGGLE_BEEPER]
{action_respond_info('beeper is off, turning it on')} # description: Toggle the printer beeper on and off.
SAVE_VARIABLE VARIABLE=beeper_state VALUE='"on"' # gcode:
{% else %} # {% set beeper_state = printer.save_variables.variables.beeper_state|lower %}
{action_respond_info('beeper is on= turning it off')}
SAVE_VARIABLE VARIABLE=beeper_state VALUE='"off"' # {% if printer['gcode_macro _USER_VARIABLE'].debug == 1 %}
{% endif %} # {action_respond_info('==== TOGGLE_BEEPER ====')}
SONG_SINGLE_BEEP # {action_respond_info("beeper_state: %s" % (beeper_state))}
# {action_respond_info('===============')}
# {% endif %}
# {% if beeper_state == "off" %}
# {action_respond_info('beeper is off, turning it on')}
# SAVE_VARIABLE VARIABLE=beeper_state VALUE='"on"'
# {% else %}
# {action_respond_info('beeper is on= turning it off')}
# SAVE_VARIABLE VARIABLE=beeper_state VALUE='"off"'
# {% endif %}
# SONG_SINGLE_BEEP