bbcmicrobit / micropython

Port of MicroPython for the BBC micro:bit
https://microbit-micropython.readthedocs.io
Other
595 stars 287 forks source link

music.play(pin=None) causes typeError, expecting a pin #713

Closed martinwork closed 1 year ago

martinwork commented 3 years ago

Testing with https://python.microbit.org/v/beta Editor Version: 2.2.0-beta.5; MicroPython Version: 1.0.1/2.0.0-beta.5

An error occurs if music.play specifies pin=None, either directly or through a variable.

import microbit
from microbit import *
import music

myPin=pin0

while True:
    music.play(music.JUMP_UP)
    sleep(1000)

    music.play(music.JUMP_UP,pin=myPin)
    sleep(1000)

    myPin=None
microbit-carlos commented 1 year ago

Good catch, thanks Martin! For compatibility with V2 we should to accept None as a pin value in V1 as well.

dpgeorge commented 1 year ago

Fixed by 1252f887ddc790676bf9314a136bd17650b9c36c