-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsequence_simple.py
More file actions
35 lines (26 loc) · 980 Bytes
/
Copy pathsequence_simple.py
File metadata and controls
35 lines (26 loc) · 980 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# examples/async/sequence_simple.py
#
# Demonstrates: running a sequence of moves using sequence() — no hardware needed
# API style: async for loop (sequence)
# Sync equivalent: examples/basic/sequence_simple.py
#
# sequence() steps through each move in the list in order, looping if requested.
# Each tuple is: (target_position, time_secs, steps, easing_name)
#
# CircuitPython note: asyncio.run(main()) works with adafruit_asyncio v3+.
# On older CircuitPython, use: asyncio.get_event_loop().run_until_complete(main())
import asyncio
from varspeed_async import Vspeed
vs = Vspeed(init_position=0, result="float", debug=False)
my_sequence = [
(100, 2.0, 20, "QuadEaseIn"),
(0, 2.0, 20, "QuadEaseOut"),
(50, 1.0, 10, "LinearInOut"),
]
async def main():
print("running sequence...")
async for position, running, changed in vs.sequence(my_sequence, loop_max=2):
if changed:
print(position)
print("done")
asyncio.run(main())