Adafruit ESP32-S3 Manual page 187

Tft feather
Table of Contents

Advertisement

async def blink(controls):
"""Blink animation on ring two."""
while True:
ring_two.fill((0, 0, 255))
ring_two.show()
await asyncio.sleep(controls.delay)
ring_two.fill((0, 0, 0))
ring_two.show()
await asyncio.sleep(controls.delay)
await asyncio.sleep(controls.wait)
In both functions, you must call
animations to run because you set
Notice that the controls object provides the animation direction (
, the delay between steps of the animation (
between complete animations (
In terms of the asyncio-specific parts of this code, you'll notice that both of these
functions begin with
defined as
async def
Both functions contain one or more
means "I need to wait for something; let other tasks run until I'm ready to resume."
Both include
await asyncio.sleep()
"sleep", another task can be run. When the
resume.
The
includes the following line of code twice, which utilizes the
blink()
attribute of the
AnimationsControl
await asyncio.sleep(controls.delay)
Both functions end with the following line of code which utilizes the
of the
AnimationsControl
await asyncio.sleep(controls.wait)
The next function is called
In
, first create a task. For the
main()
coroutine by calling it with the arguments desired, and then pass that coroutine
n()
to
asyncio.create_task()
©Adafruit Industries
show()
auto_write=False
controls.wait
. Every function that contains an
async def
, to indicate that it's a coroutine. 
await
. Basically, when when the code goes to
object.
object.
main()
button_task
.
create_task()
on the NeoPixel ring object to get the
in the NeoPixel ring setup.
controls.delay
).
lines. What does
is over, this coroutine will
sleep()
, instantiate the
wraps the coroutine in a task, and
controls.reverse
), and the delay
must be
await
mean?
await
await
.delay
attribute
.wait
monitor_butto
Page 187 of 263
)

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the ESP32-S3 and is the answer not in the manual?

Table of Contents

Save PDF