I made this project https://learn.adafruit.com/lightsaber-rp2040/overview but in the code , the lightsaber swing sound is blocking the code until its fully played so i want to play the sound without interrupting the code (with asyncio because Circuit Python don't support multi threading :/ ) ... Can someone help me ?
#π Need help for Multitasking in CircuitPython with asyncio
20 messages Β· Page 1 of 1 (latest)
Click here to see this code in our pastebin.
@quiet imp
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
Closes after a period of inactivity, or when you send !close.
The audiobusio module would need to support asyncio. I don't see where it does.
@novel kettle my bad i gave u a modified version... In the original code, line 140-149, u can see that the sound is blocking the code to to other things
Click here to see this code in our pastebin.
and i just want the swing sound playing to be non restrictive because it makes everything lagging when saber is movin
Your while statement on 143 is blocking and continuously updating the pixels. Could that be the problem?
it is but even if i don't update light and put nothing after, swing sound is instantly cut by the idle sound (play_wav(1, loop=True))...
Set the color once. Then while playing: pass
same problem, the swing audio block the program until its finished so when i move the saber its impossible to turn off or do hit animation
after swing what is wave1?
wav 1 is the saber sound when its on (always playing in the background)
I guess you could check for hit and button presses during the while playing loop.
and then stop the swing and break out.
Off to work. Good luck!
like that ?
Click here to see this code in our pastebin.
This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.