forked from whaleygeek/anyio
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtestPoint.py
89 lines (78 loc) · 1.97 KB
/
testPoint.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
83
84
85
86
87
88
#!/usr/bin/python
# Import required libraries
import zeropoint as zp
#======================================================================
# Reading single character by forcing stdin to raw mode
import sys
import tty
import termios
def readchar():
fd = sys.stdin.fileno()
old_settings = termios.tcgetattr(fd)
try:
tty.setraw(sys.stdin.fileno())
ch = sys.stdin.read(1)
finally:
termios.tcsetattr(fd, termios.TCSADRAIN, old_settings)
if ch == '0x03':
raise KeyboardInterrupt
return ch
def readkey(getchar_fn=None):
getchar = getchar_fn or readchar
c1 = getchar()
if ord(c1) != 0x1b:
return c1
c2 = getchar()
if ord(c2) != 0x5b:
return c1
c3 = getchar()
return chr(0x10 + ord(c3) - 65) # 16=Up, 17=Down, 18=Right, 19=Left arrows
# End of single character reading
#======================================================================
print ('ZeroPoint Test script')
print ('Press 0..6 to to move to position, or z to force to zero position')
print ('Press ctrl-c to exit')
zp.init(delay = 0.0011)
try:
while True:
keyp = readkey()
if keyp == '1':
zp.stepTo(100)
print ('Step to 100')
elif keyp == '2':
zp.stepTo(200)
print ('Step to 200')
elif keyp == '3':
zp.stepTo(300)
print ('Step to 300')
elif keyp == '4':
zp.stepTo(400)
print ('Step to 400')
elif keyp == '5':
zp.stepTo(500)
print ('Step to 500')
elif keyp == '6':
zp.stepTo(600)
print ('Step to 600')
elif keyp == '7':
zp.stepTo(650)
print ('Step to 700')
elif keyp == '0':
zp.stepTo(0)
print ('Step to 0')
elif keyp == 'z':
zp.stepToZero()
print ('Force to Zero')
elif keyp == 'l':
StepDir = -1
elif keyp == 'r':
StepDir = 1
elif ord(keyp) == 3:
break
else:
stepMotor = -1
print ('Stop')
except KeyboardInterrupt:
print
finally:
zp.cleanup()