-
Notifications
You must be signed in to change notification settings - Fork 1
/
macro_beeper.cfg
74 lines (66 loc) · 1.94 KB
/
macro_beeper.cfg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
######################################################################
# Beeper
######################################################################
# M300 : Play tone. Beeper support, as commonly found on usual LCD
# displays (i.e. RepRapDiscount 2004 Smart Controller, RepRapDiscount
# 12864 Full Graphic). This defines a custom I/O pin and a custom
# GCODE macro. Usage:
# M300 [P<ms>] [S<Hz>]
# P is the tone duration, S the tone frequency.
# The frequency won't be pitch perfect.
[gcode_macro M300]
gcode:
{% set S = params.S|default(1000)|int %} ; S sets the tone frequency
{% set P = params.P|default(100)|int %} ; P sets the tone duration
{% set L = 0.5 %} ; L varies the PWM on time, close to 0 or 1 the tone gets a bit quieter. 0.5 is a symmetric waveform
{% if S <= 0 %} ; dont divide through zero
{% set F = 1 %}
{% set L = 0 %}
{% elif S >= 10000 %} ;max frequency set to 10kHz
{% set F = 0 %}
{% else %}
{% set F = 1/S %} ;convert frequency to seconds
{% endif %}
SET_PIN PIN=beeper VALUE={L} CYCLE_TIME={F} ;Play tone
G4 P{P} ;tone duration
SET_PIN PIN=beeper VALUE=0
#---------------------------------
[gcode_macro START_BEEP]
gcode:
;Beep to indicate start of print
M300 S1864 P120
M300 S0 P60
M300 S1864 P120
M300 S0 P60
#---------------------------------
[gcode_macro END_BEEP]
gcode:
; Tune for end of print
M300 S1046 P150
M300 S1318 P150
M300 S1567 P150
M300 S2093 P150
M300 S2637 P150
M300 S3135 P400
M300 S2637 P400
M300 S1046 P150
M300 S1244 P150
M300 S1661 P150
M300 S2093 P150
M300 S2489 P150
M300 S3322 P400
M300 S2489 P400
M300 S1174 P150
M300 S1396 P150
M300 S932 P150
M300 S2349 P150
M300 S2793 P150
M300 S1864 P150
M300 S0 P400
M300 S1864 P120
M300 S0 P60
M300 S1864 P120
M300 S0 P60
M300 S1864 P120
M300 S0 P60
M300 S4186 P900 ;Congrats