Asyncio on CircuitPython doesn't runs two functions concurrently

37 views Asked by At

I am actually on a project that needs concurentials functions... but I don't really know (and understand) a lot about it. My program must run on a Raspberry pi pico with Circuitpython. I did some research and the most suitable library for this is Asyncio.

Here is in a nutshell my program:

async def playAudio(import 1, import 2):
   *some actions....*
   print("audio") #added this to debug
   if audio not played yet:
      playAudio()

async def lcdScreen(import 1, import 2):
    
    print("LCD") #added this to debug
    *some actions....*
    lcd.print("*something*")
    time.sleep(1)
    lcd.print("*something else*")
    time.sleep(1)

async def story(imports of both functions)
    L = await asyncio.gather(
       playAudio(imports),
       playAudio(imports),
      )
    print(l)

while True:
   *some actions....*

   asyncio.run(story(*all imports)

When I run the program, I get:

Audio
*then a while later:*
LCD

This might be a beginner problem, but I can't figure out how to make this work. I checked online and saw that I need ```await``, but again can't figure out how to apply it to this case :(

I imported Asyncio with Circup from a Windows 11

Thanks for your help !

NOTE: I tried to follow examples from Asyncio Library

0

There are 0 answers