summaryrefslogtreecommitdiffstatshomepage
path: root/examples/hwapi/soft_pwm2_uasyncio.py
diff options
context:
space:
mode:
authorJim Mussared <jim.mussared@gmail.com>2023-06-08 16:11:49 +1000
committerDamien George <damien@micropython.org>2023-06-19 18:36:54 +1000
commitd975bb1f2799a3a0b33ee073886354ca03e2e7f5 (patch)
treecb259a4c5b36d112702898f543c6ff8d20015a99 /examples/hwapi/soft_pwm2_uasyncio.py
parent9092909bf5e5f3347a93ea5146dd93320527956a (diff)
downloadmicropython-d975bb1f2799a3a0b33ee073886354ca03e2e7f5.tar.gz
micropython-d975bb1f2799a3a0b33ee073886354ca03e2e7f5.zip
examples/hwapi: Rename uasyncio to asyncio.
This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Diffstat (limited to 'examples/hwapi/soft_pwm2_uasyncio.py')
-rw-r--r--examples/hwapi/soft_pwm2_uasyncio.py31
1 files changed, 0 insertions, 31 deletions
diff --git a/examples/hwapi/soft_pwm2_uasyncio.py b/examples/hwapi/soft_pwm2_uasyncio.py
deleted file mode 100644
index 908ef2d8ac..0000000000
--- a/examples/hwapi/soft_pwm2_uasyncio.py
+++ /dev/null
@@ -1,31 +0,0 @@
-# Like soft_pwm_uasyncio.py, but fading 2 LEDs with different phase.
-# Also see original soft_pwm.py.
-import uasyncio
-from hwconfig import LED, LED2
-
-
-async def pwm_cycle(led, duty, cycles):
- duty_off = 20 - duty
- for i in range(cycles):
- if duty:
- led.value(1)
- await uasyncio.sleep_ms(duty)
- if duty_off:
- led.value(0)
- await uasyncio.sleep_ms(duty_off)
-
-
-async def fade_in_out(LED):
- while True:
- # Fade in
- for i in range(1, 21):
- await pwm_cycle(LED, i, 2)
- # Fade out
- for i in range(20, 0, -1):
- await pwm_cycle(LED, i, 2)
-
-
-loop = uasyncio.get_event_loop()
-loop.create_task(fade_in_out(LED))
-loop.call_later_ms(800, fade_in_out(LED2))
-loop.run_forever()