Skip to content

Commit

Permalink
examples/hwapi: Rename uasyncio to asyncio.
Browse files Browse the repository at this point in the history
This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
  • Loading branch information
jimmo authored and dpgeorge committed Jun 19, 2023
1 parent 9092909 commit d975bb1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
@@ -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


Expand All @@ -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):
Expand All @@ -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


Expand All @@ -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):
Expand All @@ -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))

0 comments on commit d975bb1

Please sign in to comment.