-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUImicroscope.py
More file actions
111 lines (92 loc) · 3.18 KB
/
UImicroscope.py
File metadata and controls
111 lines (92 loc) · 3.18 KB
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
from audioop import mul
from guizero import App, Text, PushButton
import microscope
import serialscan
port = 'COM8' # may need to manually assign a COM port after looking in device manager
comlist = serialscan.serial_ports()
microscope.startup(port)
# microscope.homeAxis('Z')
def moveAxis(id, step):
microscope.moveAxis(id, step)
# microscope.moveAxis('Z', 15000)
def homeAxis(id):
microscope.homeAxis(id)
# microscope.homeAxis('Z')
# home button commands
def homeX():
homeAxis('X')
def homeY():
homeAxis('Y')
def homeZ():
homeAxis('Z')
def homeO():
homeAxis('O')
def homeL():
homeAxis('L')
def homeP():
homeAxis('P')
# up button commands
def upX():
moveAxis('X', 50000)
def upY():
moveAxis('Y', 35000)
def upZ():
moveAxis('Z', 15000)
def upO():
moveAxis('O', 150000)
def upL():
moveAxis('L', 1000)
def upP():
moveAxis('P', 1000)
# down button commands
def downX():
moveAxis('X', 10000)
def downY():
moveAxis('Y', 5000)
def downZ():
moveAxis('Z', 5000)
def downO():
moveAxis('O', 50000)
def downL():
moveAxis('L', 1000)
def downP():
moveAxis('P', 1000)
defmes = 'Press Button to Move'
app = App(title='Microscope Control V1', layout='grid')
def com_port_change(val):
print('Changing COM Port to ' + val)
microscope.startup(val)
# listbox = ListBox(app, items=['COM0', 'COM1'], selected=port, command=com_port_change, multiselect=False, align='right')
def com_port_function():
print("-------Re-Scanning Serial Ports---------")
comlist = serialscan.serial_ports()
app.display()
#axis identifiers
xcol = Text(app, text="x", grid=[0,0])
ycol = Text(app, text="y", grid=[1,0])
zcol = Text(app, text="z", grid=[2,0])
ocol = Text(app, text="o", grid=[0,4])
lcol = Text(app, text="l", grid=[1,4])
pcol = Text(app, text="p", grid=[2,4])
# homing buttons
buttonhx = PushButton(app, text="home x axis", grid=[0,2], command=homeX)
buttonhy = PushButton(app, text="home y axis", grid=[1,2], command=homeY)
buttonhz = PushButton(app, text="home z axis", grid=[2,2], command=homeZ)
buttonho = PushButton(app, text="home o axis", grid=[0,7], command=homeO)
buttonhl = PushButton(app, text="home l axis", grid=[1,7], command=homeL)
buttonhp = PushButton(app, text="home p axis", grid=[2,7], command=homeP)
# movement buttons
buttonupx = PushButton(app, text="up x axis", grid=[0,1], command=upX)
buttonupy = PushButton(app, text="up y axis", grid=[1,1], command=upY)
buttonupz = PushButton(app, text="up z axis", grid=[2,1], command=upZ)
buttondwnx = PushButton(app, text="down x axis", grid=[0,3], command=downX)
buttondwny = PushButton(app, text="down y axis", grid=[1,3], command=downY)
buttondwnz = PushButton(app, text="down z axis", grid=[2,3], command=downZ)
buttonupo = PushButton(app, text="up o axis", grid=[0,6], command=upO)
buttonupl = PushButton(app, text="up l axis", grid=[1,6], command=upL)
buttonupp = PushButton(app, text="up p axis", grid=[2,6], command=upP)
buttondwno = PushButton(app, text="down o axis", grid=[0,8], command=downO)
buttondwnl = PushButton(app, text="down l axis", grid=[1,8], command=downL)
buttondwnp = PushButton(app, text="down p axis", grid=[2,8], command=downP)
app.display()
microscope.closedown()