Skip to content

Commit f5ca4aa

Browse files
Update set_threshold doc to copy micropython doc
1 parent 7cb5277 commit f5ca4aa

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

lang/en/typeshed/stdlib/microbit/microphone.pyi

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,18 @@ def set_threshold(event: SoundEvent, value: int) -> None:
5454
5555
Example: ``microphone.set_threshold(SoundEvent.LOUD, 250)``
5656
57-
A high threshold means the event will only trigger if the sound is very loud (>= 250 in the example).
57+
The ``SoundEvent.LOUD`` event will be triggered when the sound level
58+
crosses this threshold upwards (from "quiet" to "loud"),
59+
and ``SoundEvent.QUIET`` event is triggered when crossing the threshold
60+
downwards (from "loud" to "quiet").
61+
62+
If the ``SoundEvent.LOUD`` value set is lower than ``SoundEvent.QUIET``,
63+
then "quiet" threshold will be decreased to one unit below the "loud"
64+
threshold. If the ``SoundEvent.QUIET`` value is set higher than
65+
``SoundEvent.LOUD``, then the "loud" threshold will be set one unit above.
5866
5967
:param event: A sound event, such as ``SoundEvent.LOUD`` or ``SoundEvent.QUIET``.
60-
:param value: The threshold level in the range 0-255.
68+
:param value: The threshold level in the range 0-255. Values outside this range will be clamped.
6169
"""
6270
...
6371

0 commit comments

Comments
 (0)