forked from Oukki/bimatrix-controller
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.py
141 lines (115 loc) · 3.45 KB
/
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# Examples of device controller commands
import controller
import logging
if __name__ == '__main__':
print("Starting...")
device = controller.Controller('/dev/ttyUSB0', logging_level=logging.DEBUG)
print("Started.")
res = device.set_pulse_generator(True)
print(res)
battery_level = device.read_battery()
print("Battery level is: {}%".format(battery_level))
res = device.set_pulse_generator(False)
print(res)
print("Test current range")
res = device.set_current_range('high')
print(res)
res = device.set_current_range('low')
print(res)
print("Test voltage")
res = device.set_voltage(150)
print(res)
res = device.set_voltage(70)
print(res)
res = device.set_voltage(85)
print(res)
print("Test num of n-plets")
res = device.set_num_nplets(0)
print(res)
res = device.set_num_nplets(16777215)
print(res)
res = device.set_num_nplets(14500)
print(res)
print("Test time between pulses")
res = device.set_time_between(1)
print(res)
res = device.set_time_between(254)
print(res)
res = device.set_time_between(126)
print(res)
print("Test delay")
res = device.set_delay(0)
print(res)
res = device.set_delay(16777215)
print(res)
res = device.set_delay(5000)
print(res)
print("Test trigger")
res = device.trigger_pulse_generator()
print(res)
print("Sleep for 5 seconds")
#time.sleep(5)
res = device.trigger_pulse_generator()
print(res)
print("Test n-plet repetition rate")
res = device.set_repetition_rate(1)
print(res)
res = device.set_repetition_rate(400)
print(res)
print("Test pulse widths")
res = device.set_pulse_width([50, 50])
print(res)
print("Test amplitude")
res = device.set_amplitude([50, 50])
print(res)
print("Test mode")
res = device.set_mode('unipolar')
print(res)
print("Test common electrode")
res = device.set_common_electrode('anode')
print(res)
res = device.set_common_electrode('cathode')
print(res)
print("Test unipolar channels")
res = device.set_pulses_unipolar(
['800000', '400000', '200000', '100000', '080000', '040000', '020000', '010000'], value_type='hex')
print(res)
"""res = device.set_pulses_unipolar(
[
[24], [23], [22], [21], [20], [19], [18], [17], [16], [15], [14],
[13], [12], [11], [10], [9], [8], [7], [6], [5], [4], [3], [2], [1]
], value_type='list'
)"""
res = device.set_pulses_unipolar(
[
[24], [23]
]
)
print(res)
print("Change to bipolar")
res = device.set_mode('bipolar')
print(res)
print("Test bipolar")
res = device.set_pulses_bipolar(
[('200000', '400000'), ('000001', '000002'), ('004000', '008000')], value_type='hex'
)
print(res)
res = device.set_pulses_bipolar(
[([22], [23]), ([1], [2]), ([15], [16])]
)
print(res)
print("Set unipolar")
res = device.set_mode('unipolar')
print(res)
print("Test short cathode&anode")
res = device.set_common_electrode_short('cathode')
print(res)
res = device.set_common_electrode_short('anode')
print(res)
print("Test short output activity")
res = device.set_output_channel_activity('000015', 50, value_type='hex')
print(res)
res = device.set_output_channel_activity([1,3,5], 50)
print(res)
device.close_serial()
print("Quitting...")