microbit-foundation / micropython-microbit-v2

Temporary home for MicroPython for micro:bit v2 as we stablise it before pushing upstream
MIT License
42 stars 23 forks source link

microphone.current_event: first call returns None but docs don't mention the possibility of None #86

Closed microbit-matt-hillsdon closed 2 years ago

microbit-matt-hillsdon commented 2 years ago

https://microbit-micropython.readthedocs.io/en/v2-docs/microphone.html#microbit.microphone.current_event says "return: the name of the last recorded sound event, SoundEvent('loud') or SoundEvent('quiet')"

In practice it seems that the first result is None:

>>> repr(microphone.current_event())
'None'
>>> repr(microphone.current_event())
"SoundEvent('quiet')"

should the docs be updated to mention this or is it a bug in the implementation?

dpgeorge commented 2 years ago

This looks like a bug and should probably return the "quiet" event for the first call.

dpgeorge commented 2 years ago

Fixed by 69c8ddc8229bef1a6f811580b21ded83a2049166