-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathv16alpha_demo.py
executable file
·82 lines (59 loc) · 1 KB
/
v16alpha_demo.py
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/python3
from v16alpha.v16alpha import V16alpha
from v16alpha.v16alpha_util import *
from time import sleep
"""
Demo program for the v16a
"""
def pingPong():
"""
"bounces" a 1 across the I/O pins
"""
rioAonly="""
Lstore 0x8000
store rint rioa
:goRight:
RIOA >> 1
IF RIOA > 1
STORE !goRight RCNT
:goLeft:
RIOA << 1
IF RIOAL < 0x80
STORE !goLeft RCNT
STORE !goRight RCNT
"""
rioAandB="""
Lstore 0x8000
store rintL riob
Lstore 0
store rint rioa
:goRightB:
RIOB >> 1
IF RIOB > 1
STORE !goRightB RCNT
store 0 riob
store 0x80 rioal
:goRightA:
RIOA >> 1
IF RIOA > 1
STORE !goRightA RCNT
:goLeftA:
RIOA << 1
IF RIOAL < 0x80
STORE !goLeftA RCNT
store 0 rioal
store 1 riob
:goLeftB:
RIOB << 1
IF RIOB < 0x80
STORE !goLeftB RCNT
STORE !goRightB RCNT
"""
p = V16alpha()
loadProgram(p,rioAandB)
while (p.err.value < 9):
p.pinset.setPinState(0,True)
sleep(0.01)
print(p.pinset, end="\r", flush=True)
if __name__ == "__main__" :
pingPong()