examples/hwapi: Rename uasyncio to asyncio.
This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This commit is contained in:
parent
9092909bf5
commit
d975bb1f27
|
@ -1,6 +1,6 @@
|
|||
# Like soft_pwm_uasyncio.py, but fading 2 LEDs with different phase.
|
||||
# Like soft_pwm_asyncio.py, but fading 2 LEDs with different phase.
|
||||
# Also see original soft_pwm.py.
|
||||
import uasyncio
|
||||
import asyncio
|
||||
from hwconfig import LED, LED2
|
||||
|
||||
|
||||
|
@ -9,10 +9,10 @@ async def pwm_cycle(led, duty, cycles):
|
|||
for i in range(cycles):
|
||||
if duty:
|
||||
led.value(1)
|
||||
await uasyncio.sleep_ms(duty)
|
||||
await asyncio.sleep_ms(duty)
|
||||
if duty_off:
|
||||
led.value(0)
|
||||
await uasyncio.sleep_ms(duty_off)
|
||||
await asyncio.sleep_ms(duty_off)
|
||||
|
||||
|
||||
async def fade_in_out(LED):
|
||||
|
@ -25,7 +25,7 @@ async def fade_in_out(LED):
|
|||
await pwm_cycle(LED, i, 2)
|
||||
|
||||
|
||||
loop = uasyncio.get_event_loop()
|
||||
loop = asyncio.get_event_loop()
|
||||
loop.create_task(fade_in_out(LED))
|
||||
loop.call_later_ms(800, fade_in_out(LED2))
|
||||
loop.run_forever()
|
|
@ -1,5 +1,5 @@
|
|||
# See original soft_pwm.py for detailed comments.
|
||||
import uasyncio
|
||||
import asyncio
|
||||
from hwconfig import LED
|
||||
|
||||
|
||||
|
@ -8,10 +8,10 @@ async def pwm_cycle(led, duty, cycles):
|
|||
for i in range(cycles):
|
||||
if duty:
|
||||
led.value(1)
|
||||
await uasyncio.sleep_ms(duty)
|
||||
await asyncio.sleep_ms(duty)
|
||||
if duty_off:
|
||||
led.value(0)
|
||||
await uasyncio.sleep_ms(duty_off)
|
||||
await asyncio.sleep_ms(duty_off)
|
||||
|
||||
|
||||
async def fade_in_out(LED):
|
||||
|
@ -24,5 +24,5 @@ async def fade_in_out(LED):
|
|||
await pwm_cycle(LED, i, 2)
|
||||
|
||||
|
||||
loop = uasyncio.get_event_loop()
|
||||
loop = asyncio.get_event_loop()
|
||||
loop.run_until_complete(fade_in_out(LED))
|
Loading…
Reference in New Issue