forked from EtalumaSupport/LumaViewPro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
script_example.py
99 lines (78 loc) · 2.66 KB
/
script_example.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
89
90
91
92
93
94
95
96
97
98
99
#!/usr/bin/python3
'''
To run, you will need to install the following packages:
numpy
pyserial
pypylon
time
Pillow
You will also need to install the camera driver from Basler
'''
# Additional LumaViewPro files
import lumascope_api
import time
from PIL import Image
scope = lumascope_api.Lumascope()
# ----------------------------------------------------
# Controlling an LED
# ----------------------------------------------------
for i in range(6):
print("testing LED ", i)
scope.led_on(i, 100) # turn on LED at channel i at 100mA
time.sleep(1) # wait one second
scope.leds_off() # turn off all LEDs
# ----------------------------------------------------
# Controlling focus and XY stage
# ----------------------------------------------------
scope.xyhome() # home position of xy stage
i = 0
while scope.is_homing:
time.sleep(1) # do not send it new commands to move while its homing
print(i)
i += 1
# # ----------------------------------------------------
# # Controlling the Turret (Not Yet Functional)
# # ----------------------------------------------------
# scope.thome()
# scope.move_abs_pos('T', 90.) # move to absolute position in deg
# ----------------------------------------------------
# Controlling the Camera
# ----------------------------------------------------
scope.set_frame_size(1900,1900)
for i in range(3):
img = Image.fromarray(scope.get_image())
img.show()
# ----------------------------------------------------
# Simple Scripting Example
# ----------------------------------------------------
scope.xyhome()
i = 0
while scope.is_homing:
time.sleep(1) # do not send it new commands to move while its homing
print(i)
i += 1
# Homing needs 10 seconds. Test LEDs while homing.
for i in range(6):
print("testing LED ", i)
scope.led_on(i, 100) # turn on LED at channel i at 100mA
time.sleep(1.5)
scope.leds_off()
scope.move_absolute_position('X', 60000) # move to absolute position in um
scope.move_absolute_position('Y', 40000) # move to absolute position in um
scope.move_absolute_position('Z', 7000) # move to absolute position in um
time.sleep(2) # wait to arrive
scope.set_frame_size(1900,1900)
scope.led_on(0, 600)
time.sleep(1)
scope.get_image()
img = Image.fromarray(scope.get_image())
img.show()
scope.led_on(1, 600)
time.sleep(1)
img = Image.fromarray(scope.get_image())
img.show()
scope.led_on(2, 600)
time.sleep(1)
img = Image.fromarray(scope.get_image())
img.show()
scope.leds_off() # turn off all LEDs