[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 %} # [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 SONG_SINGLE_BEEP] # gcode: # M300 S830.61 P137 # [gcode_macro TOGGLE_BEEPER] # description: Toggle the printer beeper on and off. # gcode: # {% set beeper_state = printer.save_variables.variables.beeper_state|lower %} # {% if printer['gcode_macro _USER_VARIABLE'].debug == 1 %} # {action_respond_info('==== TOGGLE_BEEPER ====')} # {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