forked from Hack-a-Day/Vectorscope
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathB.py
63 lines (45 loc) · 1.4 KB
/
B.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
import math
import time
from vectorscope import Vectorscope
import vectoros
import keyboardcb
import keyleds
import asyncio
_abort=False
_xscale=1
_yscale=1
async def kminimal_example(v):
## Minimal example with keys
global _abort, _xscale, _yscale
while _abort==False:
for i in range(360):
scale=1
if _abort:
print("Get out!")
break
v.wave.constantX(int(math.cos(i * math.pi / 180 * 5*_xscale) * 10000))
v.wave.constantY(int(math.sin(i * math.pi / 180 * 5*_yscale)* 10000))
await asyncio.sleep_ms(10)
def do_abort(key):
global _abort
_abort=True
def do_xscale(key):
global _xscale
_xscale+=1
if _xscale>6:
_xscale=1
def do_yscale(key):
global _yscale
_yscale+=1
if _yscale>6:
_yscale=1
from vos_state import vos_state
async def slot_main(v):
global _abort,_continue
# So... Press D (or whatever is configured) and note the message below. Press Range to start the demo
# The demo will run until you press Menu. LEVEL/RANGE will change frequency of X and Y in steps
# Note that if you don't yield occasionaly, you don't get key scanning
# watch the keys
mykeys=keyboardcb.KeyboardCB({ keyleds.KEY_LEVEL: do_xscale, keyleds.KEY_RANGE: do_yscale, keyleds.KEY_MENU: do_abort})
await kminimal_example(v)
print("OK done")