Repository navigation
micropython support for Sound - #632
Conversation
|
This changes the API, right? It removes one of the "play type" options and removes the handle returns? |
|
All of the |
|
Ok, so am I correct in thinking that with this change there isn't an API to play a sound asynchronously (i.e., start it then keep going while it plays)? I feel like that behavior could be useful, as it might be nice to speak/beep some status while your robot is still going. |
|
No, that functionality is still there, to do that you use |
|
I'm still a bit concerned about the breaking change on the return type. Perhaps this is unfounded, but it feels like this might cause problems for existing consumers who do something more advanced. I think we could instead split the I think this would probably work: def _audio_command(self, command, play_type=PLAY_WAIT_FOR_COMPLETE):
if is_micropython():
if play_type == Sound.PLAY_WAIT_FOR_COMPLETE:
os.system(command)
else:
os.system('{} &'.format(command))
return None
else:
with open(os.devnull, 'w') as n:
subprocess = Popen(shlex.split(command), stdout=n)
if play_type == Sound.PLAY_WAIT_FOR_COMPLETE:
subprocess.wait()
return None
else:
return subprocessIt should be fairly straightforward to rewrite the other functions in terms of this, and that would get all the behavior we need. |
|
I think this is backwards compatible now. The only quirk is that the |
WasabiFan
left a comment
There was a problem hiding this comment.
Nice! This seems reasonable to me; I think it would make the most sense to add a note to those doc comments saying that it doesn't return the object on Micropython.
|
Will update the docstrings to mention about the return values when using python3 vs micropython and then merge this one. |
For #628
Tested micropython and python3 via