You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -61,14 +85,38 @@ The discharge curve is roughly linear between 11.4V and 10.4V.
61
85
62
86
The power board has a piezo buzzer which can beep.
63
87
64
-
The beep function accepts 1 or 2 parameters, `duration` is compulsory and is measured in milliseconds. `note` is optional, but must be one string of `a-g` or `uc`. `frequency` is also optional, and should be an integer. One of `note` and `frequency`, must be given. If both are given, `note` is used.
88
+
The `buzz` function accepts multiple parameters, depending on what you
89
+
want to play. The first argument is the duration of the beep, in
90
+
seconds. The later arguments are either the note you want to play, or
91
+
the frequency of the buzzer (in Hertz). You have to specify which of
92
+
note or frequency you're passing using a keyword argument, your code
93
+
will fail otherwise.
94
+
95
+
Theoretically, the piezo buzzer will buzz at any provided frequency, however
96
+
humans can only hear between [20Hz and 20000Hz][pitch-range].
97
+
98
+
The `Note` enum provides notes in [scientific pitch notation][pitch-notation]
99
+
between `C6` and `C8`. You can play other tones by providing a frequency.
100
+
101
+
<divclass="info">
102
+
Calling `buzz` is non-blocking, which means it doesn't actually wait
103
+
for the piezo to stop buzzing before continuing with your code. If you
104
+
want to wait for the buzzing to stop, add a `sleep` afterwards!
105
+
If you send more than 32 beeps to the robot too quickly, your power board will crash!
106
+
</div>
65
107
66
108
~~~~~python
109
+
from sr.robot3 import Note
110
+
67
111
# Beep for 0.5s in D.
68
-
R.power.beep(500, note='d')
112
+
r.power_board.piezo.buzz(0.5, Note.D6)
69
113
70
114
# Beep for 2s at 400Hz
71
-
R.power.beep(2000, frequency=400)
115
+
r.power_board.piezo.buzz(2, 400)
72
116
~~~~~
73
117
74
118
`ValueError` is raised if the note is not recognised or the frequency is not an integer.
0 commit comments